tee-output
raw JSON → 0.4.16 verified Fri May 01 auth: no python
A utility to tee standard output/standard error from the current process into a logfile while preserving terminal semantics (e.g., breakpoint() works). Current version 0.4.16. Stable release cadence.
pip install tee-output Common errors
error AttributeError: module 'tee_output' has no attribute 'TeeOutput' ↓
cause Incorrect import or misspelled class name.
fix
Use
from tee_output import TeeOutput. error TypeError: 'TeeOutput' object is not callable ↓
cause Forgetting to instantiate the class.
fix
Instantiate:
tee = TeeOutput('log.txt') then call tee.start(). error OSError: [Errno 22] Invalid argument ↓
cause File path is a directory or invalid filename.
fix
Provide a valid file path, e.g.,
TeeOutput('output.log'). Warnings
gotcha Call `start()` before output is generated; otherwise output before start is not captured. ↓
fix Ensure `tee.start()` is called at the very beginning of the script, before any print or logging.
gotcha Do not forget to call `stop()` to restore original stdout/stderr; otherwise residual buffering may occur. ↓
fix Always call `tee.stop()` after teeing is done, or use it as a context manager.
deprecated The `add_logging_level` function is deprecated in favor of standard logging.setLevel. ↓
fix Use `logging.getLogger().setLevel(logging.TRACE)` or define custom level via `logging.addLevelName()`.
Imports
- TeeOutput
from tee_output import TeeOutput - add_logging_level
from tee_output import add_logging_level
Quickstart
import logging
from tee_output import TeeOutput
logging.basicConfig(stream=open('app.log', 'w'), level=logging.INFO)
tee = TeeOutput('app.log')
tee.start()
print('Hello, tee!')
logging.info('This goes to both console and file.')
tee.stop()