DoubleStreamHandler
A StreamHandler wrapper that outputs messages to different streams based on logLevel
Logging to the console is a nice feature to have, and Python's StreamHandler is of great help. However, it can only output to one stream at a time, and by default it's stderr.
This goes well with the default settings (level=WARNING), but it isn't good when you decide to output INFO messages as well.
This package prevents you from outputting non-error messages to stderr as well as from having to juggle with your output streams.
Usage
import logging
from double_stream_handler import DoubleStreamHandler
# create logger
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
# create the handler
ch = DoubleStreamHandler()
# you can customize the logger by providing different streams and level, from which
# the stderr output will start
from io import StringIO
custom_out, custom_err = (StringIO(), StringIO())
ch = DoubleStreamHandler(err_level=25, streams=(custom_out, custom_err))
# set handler's level and add it to the logger
ch.setLevel(logging.INFO)
logger.addHandler(ch)
logger.debug("This is not printed")
logger.info("This is printed to stdout")
logger.error("This is printed to stderr")
Install
Requirements: Python 3.6 or higher
This package is hosted on PyPI, so you can install it with your package manager of choice
# for Pip
pip install double-stream-handler
# for Pipenv
pipenv install double-stream-handler
# for Poetry
poetry add double-stream-handler
# for Poetry
conda install double-stream-handler
Licence
BSD-3-Clause © 2021, Nikita Karamov
Metadata
Release files for double-stream-handler 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| double-stream-handler-1.0.0.tar.gz | 3.9 kB | Without provenance | Details for double-stream-handler-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| double_stream_handler-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for double_stream_handler-1.0.0-py3-none-any.whl |
Total release size: 7.8 kB
Release files / double-stream-handler-1.0.0.tar.gz
| Download URL | double-stream-handler-1.0.0.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
93c3c8c096296caddb90c2bee0eabfcbea63dbc0fbaf30894554b36443703ce7
|
|
BLAKE2b-256 checksum How to use checksums |
0c7b07f715572e9bfe5ddbf9928e1774688b1cd18b817bb6e4f97ab8e12f1d3f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.6 CPython/3.9.5 Linux/5.4.0-1047-azure
|
Release files / double_stream_handler-1.0.0-py3-none-any.whl
| Download URL | double_stream_handler-1.0.0-py3-none-any.whl |
|---|---|
| Size | 3.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
37dad2bc3bd62a3cc13c7a110efda35344bbbce3a97c945d3b58fe708753fb81
|
|
BLAKE2b-256 checksum How to use checksums |
43c53dbd1affc2533ad69766d8430a2ffae481a8ee2bb3a42b2103604f0c5935
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.6 CPython/3.9.5 Linux/5.4.0-1047-azure
|
Security for double-stream-handler 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.