Skip to main content

LoggingProxy

Forward file object to :class:logging.Logger instance.

Attributes

AttributeTypeDescription
modestring = wThe file mode used for the proxy, defaulting to 'w' for write access.
namestringThe name of the file-like object, which defaults to None.
closedboolean = falseA boolean flag indicating whether the proxy is closed; when true, no further write requests are forwarded to the logger.
loglevelint or str = logging.ERRORLog level to use when logging messages.

Constructor

Signature

def LoggingProxy(
logger: logging.Logger,
loglevel: int or str = None
)

Parameters

NameTypeDescription
loggerlogging.LoggerThe logger instance to which messages will be forwarded.
loglevelint or str = NoneThe log level to use for messages; defaults to the logger's level or the class default if not provided.

Methods


write()

@classmethod
def write(
data: str
) - > int

Write message to logging object.

Parameters

NameTypeDescription
datastrThe string content or byte data to be logged as a message.

Returns

TypeDescription
intThe number of characters successfully written to the log or stderr.

writelines()

@classmethod
def writelines(
sequence: iterable
)

Write list of strings to file. The sequence can be any iterable object producing strings. This is equivalent to calling :meth:write for each string.

Parameters

NameTypeDescription
sequenceiterableA collection of strings to be processed and logged individually.

flush()

@classmethod
def flush()

Ignores flush requests because this object is not buffered.


close()

@classmethod
def close()

Closes the proxy so that no further write requests are forwarded to the logging object.


isatty()

@classmethod
def isatty() - > bool

Here for file support.

Returns

TypeDescription
boolAlways returns False as the logging proxy is not a terminal.