TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/alex-ber/AlexBerUtils/llms.txt
Use this file to discover all available pages before exploring further.
stdlogging module provides a StreamToLogger adapter class and an initStream convenience function for redirecting any stream-like object (typically sys.stderr or sys.stdout) to a Python logging.Logger.
Capturing
stdout can be fragile. Use with care and test thoroughly in your environment.StreamToLogger
Adapter class that wraps a stream-like object and forwards each written line to alogging.Logger.
It is recommended to use
initStream() rather than instantiating StreamToLogger directly.__init__
Standard Python
Logger or any logger-compatible object. Cannot be None.The original stream being wrapped (e.g.
sys.stderr, sys.stdout). Cannot be None. Used by flush() to delegate flush calls.Log level for emitted messages. Accepts an
int constant (e.g. logging.DEBUG) or a level-name string (e.g. 'INFO'). Defaults to logging.DEBUG. The alias logger_level is also accepted.write(lines)
Writes one or more lines to the logger. Each non-empty line is logged individually at the configured level.
String content to log. Empty strings are silently ignored.
flush()
Delegates flush() to the underlying stream. Keeps the adapter compatible with the stream protocol.
initStream
Preferred API. Wraps a stream withStreamToLogger (or a custom adapter) and redirects it to a logger.
Logger to route stream output to. If not supplied,
logging.getLogger('stderr') is used.Log level for emitted messages. Accepts an
int constant or a level-name string. Defaults to logging.ERROR.Zero-argument callable that returns the stream to wrap. If not supplied, defaults to
lambda: sys.stderr.One-argument callable that installs the wrapped adapter in place of the original stream. If not supplied, defaults to
lambda s: setattr(sys, 'stderr', s).Adapter class to instantiate. Can be a class or a fully-qualified dotted string resolved via
importer. Defaults to StreamToLogger.None.