Skip to main content

Make practical Python logging easy (and developers happy!)

Project description

happy-python-logging

Make practical Python logging easy.

PyPI - Version PyPI - Python Version


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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

happy_python_logging-0.0.10.tar.gz (19.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

happy_python_logging-0.0.10-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file happy_python_logging-0.0.10.tar.gz.

File metadata

  • Download URL: happy_python_logging-0.0.10.tar.gz
  • Upload date:
  • Size: 19.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for happy_python_logging-0.0.10.tar.gz
Algorithm Hash digest
SHA256 e01e3451637b86090940ca0934531bc515c8f15c6005a029c0b84991ad873f8f
MD5 37ceb0183559737860926d2ffd83f64e
BLAKE2b-256 9d45af7f48217f2d541619f29eaaa384e20a9b3edbd92a9c9172ade11b885893

See more details on using hashes here.

Provenance

The following attestation bundles were made for happy_python_logging-0.0.10.tar.gz:

Publisher: publish.yml on ftnext/happy-python-logging

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file happy_python_logging-0.0.10-py3-none-any.whl.

File metadata

File hashes

Hashes for happy_python_logging-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 91d3deb0ddaec5fcca1d46eb57e4a99cc66fdf95c192c14e5804c42444ccfcf6
MD5 764ca643da5acdf726041f0fdd7cff70
BLAKE2b-256 8deccc08b43fe30420b44ef9588e1efc4f69af439a92c5cb19c23fedd7de56e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for happy_python_logging-0.0.10-py3-none-any.whl:

Publisher: publish.yml on ftnext/happy-python-logging

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page