LogStream
(class from pyomo.common.log
)
- class pyomo.common.log.LogStream(level, logger)[source]
Bases:
TextIOBase
This class logs whatever gets sent to the write method. This is useful for logging solver output (a LogStream instance can be handed to TeeStream from pyomo.common.tee).
Methods
__init__
(level, logger)close
()Flush and close the IO object.
Separate the underlying buffer from the TextIOBase and return it.
fileno
()Returns underlying file descriptor if one exists.
flush
()Flush write buffers, if applicable.
isatty
()Return whether this is an 'interactive' stream.
Read at most n characters from stream.
readable
()Return whether object was opened for reading.
Read until newline or EOF.
readlines
([hint])Return a list of lines from the stream.
seek
(offset[, whence])Change the stream position to the given byte offset.
seekable
()Return whether object supports random access.
tell
()Return current stream position.
Truncate file to size bytes.
writable
()Return whether object was opened for writing.
write
(s)Write string to stream.
writelines
(lines, /)Write a list of lines to stream.
Attributes
closed
Encoding of the text stream.
The error setting of the decoder or encoder.
Line endings translated so far.
Member Documentation
- close()
Flush and close the IO object.
This method has no effect if the file is already closed.
- detach()
Separate the underlying buffer from the TextIOBase and return it.
After the underlying buffer has been detached, the TextIO is in an unusable state.
- fileno()
Returns underlying file descriptor if one exists.
OSError is raised if the IO object does not use a file descriptor.
- flush()[source]
Flush write buffers, if applicable.
This is not implemented for read-only and non-blocking streams.
- isatty()
Return whether this is an ‘interactive’ stream.
Return False if it can’t be determined.
- read()
Read at most n characters from stream.
Read from underlying buffer until we have n characters or we hit EOF. If n is negative or omitted, read until EOF.
- readable()
Return whether object was opened for reading.
If False, read() will raise OSError.
- readline()
Read until newline or EOF.
Returns an empty string if EOF is hit immediately.
- readlines(hint=-1, /)
Return a list of lines from the stream.
hint can be specified to control the number of lines read: no more lines will be read if the total size (in bytes/characters) of all lines so far exceeds hint.
- seek(offset, whence=0, /)
Change the stream position to the given byte offset.
- offset
The stream position, relative to ‘whence’.
- whence
The relative position to seek from.
The offset is interpreted relative to the position indicated by whence. Values for whence are:
os.SEEK_SET or 0 – start of stream (the default); offset should be zero or positive
os.SEEK_CUR or 1 – current stream position; offset may be negative
os.SEEK_END or 2 – end of stream; offset is usually negative
Return the new absolute position.
- seekable()
Return whether object supports random access.
If False, seek(), tell() and truncate() will raise OSError. This method may need to do a test seek().
- tell()
Return current stream position.
- truncate()
Truncate file to size bytes.
File pointer is left unchanged. Size defaults to the current IO position as reported by tell(). Returns the new size.
- writable()
Return whether object was opened for writing.
If False, write() will raise OSError.
- write(s: str) int [source]
Write string to stream. Returns the number of characters written (which is always equal to the length of the string).
- writelines(lines, /)
Write a list of lines to stream.
Line separators are not added, so it is usual for each of the lines provided to have a line separator at the end.
- encoding
Encoding of the text stream.
Subclasses should override.
- errors
The error setting of the decoder or encoder.
Subclasses should override.
- newlines
Line endings translated so far.
Only line endings translated during reading are considered.
Subclasses should override.