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.9.tar.gz (17.2 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.9-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

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

Hashes for happy_python_logging-0.0.9.tar.gz
Algorithm Hash digest
SHA256 44df863de4b0769eb5d143d3f998253eaf8e67c630d2d1791ae891a2e19ab437
MD5 96e6d2b3e8e81014c6402d964fcdce35
BLAKE2b-256 105c98322336a69345272d7bc5ec8b49a237bbd97ce507d23bff95120dc84d40

See more details on using hashes here.

Provenance

The following attestation bundles were made for happy_python_logging-0.0.9.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.9-py3-none-any.whl.

File metadata

File hashes

Hashes for happy_python_logging-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 ae56a47171fdb8bc9892007f8a685be5ea0ebd78e447905aa98ff21abad7b9dd
MD5 9d0f26e8dc8865c379da2daa7513835b
BLAKE2b-256 418dd540c5b1337793a8f08f8bdf3f5d2a00d4b13c6598b713acacfbc0fb5c88

See more details on using hashes here.

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

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