Make practical Python logging easy (and developers happy!)
Project description
happy-python-logging
Make practical Python logging easy.
Table of Contents
Installation
pip install happy-python-logging
Usage
For library developers
getLoggerForLibrary()
happy_python_logging.getLoggerForLibrary()
-import logging
+from happy_python_logging import getLoggerForLibrary
-logger = logging.getLogger(__name__)
-logger.addHandler(logging.NullHandler())
+logger = getLoggerForLibrary(__name__)
See example for detail.
OrFilter
happy_python_logging.lib.filters.OrFilter
import logging
from happy_python_logging.lib.filters import OrFilter
root_logger = logging.getLogger()
root_logger.setLevel(logging.DEBUG)
stream_handler = logging.StreamHandler()
stream_handler.addFilter(OrFilter("libA", "libB"))
root_logger.addHandler(stream_handler)
DEBUG | libA:libA_awesome:8 - awesome
DEBUG | libB:libB_fabulous:12 - fabulous
You can combine OrFilter with logging.Filter using the | operator:
OrFilter("libA", "libB") | logging.Filter("app.important")
# reverse order also supported
CLI: happy-python-logging run (experimental)
Run any Python script with quick library-level logging — RUST_LOG style:
$ happy-python-logging run example_script.py --log-config httpx=debug
Multiple loggers can be set at once, comma-separated:
$ happy-python-logging run example_script.py --log-config httpx=debug,urllib3=info
The same spec can be supplied via the PYTHON_LOG environment variable:
$ PYTHON_LOG=httpx=debug happy-python-logging run example_script.py
A bare level (e.g. --log-config debug) sets the root logger.
The StreamHandler (stderr) and Formatter are fixed — the goal is to get
library logs onto the console with one flag.
License
happy-python-logging is distributed under the terms of the MIT license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file happy_python_logging-0.0.9.tar.gz.
File metadata
- Download URL: happy_python_logging-0.0.9.tar.gz
- Upload date:
- Size: 17.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
44df863de4b0769eb5d143d3f998253eaf8e67c630d2d1791ae891a2e19ab437
|
|
| MD5 |
96e6d2b3e8e81014c6402d964fcdce35
|
|
| BLAKE2b-256 |
105c98322336a69345272d7bc5ec8b49a237bbd97ce507d23bff95120dc84d40
|
Provenance
The following attestation bundles were made for happy_python_logging-0.0.9.tar.gz:
Publisher:
publish.yml on ftnext/happy-python-logging
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
happy_python_logging-0.0.9.tar.gz -
Subject digest:
44df863de4b0769eb5d143d3f998253eaf8e67c630d2d1791ae891a2e19ab437 - Sigstore transparency entry: 1508724308
- Sigstore integration time:
-
Permalink:
ftnext/happy-python-logging@4529359afe36b1f7d121e9298aff7d8dfc40fd8b -
Branch / Tag:
refs/tags/0.0.9 - Owner: https://github.com/ftnext
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4529359afe36b1f7d121e9298aff7d8dfc40fd8b -
Trigger Event:
release
-
Statement type:
File details
Details for the file happy_python_logging-0.0.9-py3-none-any.whl.
File metadata
- Download URL: happy_python_logging-0.0.9-py3-none-any.whl
- Upload date:
- Size: 13.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae56a47171fdb8bc9892007f8a685be5ea0ebd78e447905aa98ff21abad7b9dd
|
|
| MD5 |
9d0f26e8dc8865c379da2daa7513835b
|
|
| BLAKE2b-256 |
418dd540c5b1337793a8f08f8bdf3f5d2a00d4b13c6598b713acacfbc0fb5c88
|
Provenance
The following attestation bundles were made for happy_python_logging-0.0.9-py3-none-any.whl:
Publisher:
publish.yml on ftnext/happy-python-logging
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
happy_python_logging-0.0.9-py3-none-any.whl -
Subject digest:
ae56a47171fdb8bc9892007f8a685be5ea0ebd78e447905aa98ff21abad7b9dd - Sigstore transparency entry: 1508724816
- Sigstore integration time:
-
Permalink:
ftnext/happy-python-logging@4529359afe36b1f7d121e9298aff7d8dfc40fd8b -
Branch / Tag:
refs/tags/0.0.9 - Owner: https://github.com/ftnext
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4529359afe36b1f7d121e9298aff7d8dfc40fd8b -
Trigger Event:
release
-
Statement type: