Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/phohenecker/stream-to-logger
A package for redirecting stdout/stderr to a file.
https://github.com/phohenecker/stream-to-logger
logging python3
Last synced: about 6 hours ago
JSON representation
A package for redirecting stdout/stderr to a file.
- Host: GitHub
- URL: https://github.com/phohenecker/stream-to-logger
- Owner: phohenecker
- License: mit
- Created: 2017-07-05T09:43:06.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-02-09T07:46:34.000Z (over 6 years ago)
- Last Synced: 2024-09-16T08:51:30.467Z (about 2 months ago)
- Topics: logging, python3
- Language: Python
- Homepage:
- Size: 21.5 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
stream-to-logger
================This package defines a [wrapper class](src/main/python/streamtologger/logger_adapter.py#L38) whose instances pretend to be streams, but forward every write to a logger. A common scenario where this is useful is when we want to redirect all of an application's output, e.g., via `print` or due to any errors that occur, to a file (in addition to the usual printing to the screen). To handle this most important use case, the package provides a [convenience function](src/main/python/streamtologger/__init__.py#L44) that redirects both `stdout` and `stderr` to a file, i.e., you don't even have to create any wrapper by yourself. Just add the following lines to your code:
```python
import streamtologger
streamtologger.redirect()
```
Have a look at the provided [example](examples/test.py) in order to try it by yourself. It really is that easy ;)Installation
------------This package can be installed from PyPI:
```
pip install streamtologger
```