structlog_config.factory#
Classes#
Defers resolution of sys.stdout/stderr to write time. |
|
Binary version of LazyStream for BytesLoggerFactory. |
Functions#
|
Return the reserved stream name for PYTHON_LOG_PATH, if one was requested. |
|
Build the default structlog logger factory for the current environment. |
Module Contents#
- class structlog_config.factory.LazyStream(name: str)[source]#
Defers resolution of sys.stdout/stderr to write time.
This is critical when tests redirect sys.stdout per-phase (pytest’s capture resets sys.stdout between fixture-setup and test-call phases), so we must not capture the stream at configure time.
- class structlog_config.factory.LazyBuffer(name: str)[source]#
Binary version of LazyStream for BytesLoggerFactory.
- structlog_config.factory.python_log_stream_name(python_log_path: str | None) Literal['stderr', 'stdout'] | None[source]#
Return the reserved stream name for PYTHON_LOG_PATH, if one was requested.
The values stdout and stderr are treated as symbolic stream destinations rather than literal filesystem paths so env-based routing can reuse the same lazy stream handling as explicit logger factories.
- structlog_config.factory.get_logger_factory(json_logger: bool)[source]#
Build the default structlog logger factory for the current environment.
PYTHON_LOG_PATH can target either a real file path or the reserved stream names stdout and stderr. JSON mode requires bytes output, while console mode requires text output.