Streams
provide.foundation.utils.streams
¶
TODO: Add module docstring.
Functions¶
get_foundation_log_stream
¶
Get the appropriate stream for Foundation internal logging.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output_setting
|
str
|
One of "stderr", "stdout", or "main" |
required |
Returns:
| Type | Description |
|---|---|
TextIO
|
A writable text stream based on the output setting |
Notes
- "stderr": Returns sys.stderr (default, RPC-safe)
- "stdout": Returns sys.stdout
- "main": Returns the main logger stream from _PROVIDE_LOG_STREAM
- Invalid values default to sys.stderr with warning
Source code in provide/foundation/utils/streams.py
get_safe_stderr
¶
Get a safe stderr stream, falling back to StringIO if stderr is not available.
This is used during initialization when sys.stderr might not be available (e.g., in some embedded Python environments or during testing).
Returns:
| Type | Description |
|---|---|
TextIO
|
A writable text stream, either sys.stderr or io.StringIO() |