LoggingProxy
Forward file object to :class:logging.Logger instance.
Attributes
| Attribute | Type | Description |
|---|---|---|
| mode | string = w | The file mode used for the proxy, defaulting to 'w' for write access. |
| name | string | The name of the file-like object, which defaults to None. |
| closed | boolean = false | A boolean flag indicating whether the proxy is closed; when true, no further write requests are forwarded to the logger. |
| loglevel | int or str = logging.ERROR | Log level to use when logging messages. |
Constructor
Signature
def LoggingProxy(
logger: logging.Logger,
loglevel: int or str = None
)
Parameters
| Name | Type | Description |
|---|---|---|
| logger | logging.Logger | The logger instance to which messages will be forwarded. |
| loglevel | int or str = None | The 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
| Name | Type | Description |
|---|---|---|
| data | str | The string content or byte data to be logged as a message. |
Returns
| Type | Description |
|---|---|
int | The 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
| Name | Type | Description |
|---|---|---|
| sequence | iterable | A 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
| Type | Description |
|---|---|
bool | Always returns False as the logging proxy is not a terminal. |