Streams
provide.foundation.streams
¶
TODO: Add module docstring.
Functions¶
close_log_streams
¶
Close file log streams and reset to stderr.
Source code in provide/foundation/streams/file.py
configure_file_logging
¶
Configure file logging if a path is provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_file_path
|
str | None
|
Path to log file, or None to disable file logging |
required |
Source code in provide/foundation/streams/file.py
ensure_stderr_default
¶
Ensure the log stream defaults to stderr if it's stdout.
Source code in provide/foundation/streams/core.py
flush_log_streams
¶
Flush all log streams.
Source code in provide/foundation/streams/file.py
get_console_stream
¶
get_log_stream
¶
Get the current log stream.
Note: High complexity is intentional for robust stream handling across test/prod.
Source code in provide/foundation/streams/core.py
is_tty
¶
reset_streams
¶
Reset all stream state (for testing).
Source code in provide/foundation/streams/file.py
set_log_stream_for_testing
¶
Set the log stream for testing purposes.
This function not only sets the stream but also reconfigures structlog if it's already configured to ensure logs actually go to the test stream.
Source code in provide/foundation/streams/core.py
supports_color
¶
Check if the current stream supports color output.
Source code in provide/foundation/streams/console.py
write_to_console
¶
Write a message to the console stream.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
Message to write |
required |
stream
|
TextIO | None
|
Optional specific stream to write to, defaults to current console stream |
None
|
log_fallback
|
bool
|
Whether to log when falling back to stderr |
True
|