Stream capture

Context manager to capture streams stdout/stderr

Intuitive interface. Use within with block

multiprocessing.pool.Pool workers have to capture both streams and logging output

logging_strict.tech_niques.stream_capture.__all__: tuple[str] = ("CaptureOutput",)

This modules exports

class logging_strict.tech_niques.stream_capture.CaptureOutput

Context manager to capture both sys.stdout and sys.stderr streams

__slots__: tuple[str, str, str, str] = ("_stdout_output", "_stderr_output", "_stdout", "_stderr")

Reduce class memory footprint

__enter__()

PEP 343 with statement Context manager. For capturing - sys.stdout - sys.stderr

contextlib has similiar functionality, but this is as one context manager instead of two

Returns:

class instance stores sys.stdout and sys.stderr initial state

Return type:

logging_strict.tech_niques.stream_capture.CaptureOutput

See also

PEP 20 Rule #1 Beautiful is better than ugly

__exit__(*args)

Context Manager teardown. Restores sys.stdout and sys.stderr previous state

Parameters:
property stderr

Getter of captured stderr

Returns:

Captured stderr

Return type:

str

property stdout

Getter of captured stdout

Returns:

Captured stdout

Return type:

str