Skip to main content

Don’t fight with logging …

Coverage Status PyPI Version PyPI License PyPI latest


Easy logging configuration based on environment variables.

Features:

  • Set logging level using environment variable LOG_LEVEL (defaults to INFO)

  • Set which loggers to enable using environment variable LOGGERS (defaults to ‘’, everything)

  • Always output to stdout

  • Optional JSON formatter

  • Completely disable logging setting LOG_LEVEL=DISABLED

Requirements:

  • Python 3.10+

Install:

pip install belogging

Examples:

Simple applications:

# my_script.py

import belogging
belogging.load()
# ^^ this call is optional, only useful for customization
# For example, to enable JSON output: belogging.load(json=True)

# belogging.getLogger is just a sugar to logging.getLogger, you can
# use logging.getLogger as usual (and recommended).
logger = belogging.getLogger('foobar')
logger.debug('test 1')
logger.info('test 2')

Executing:

# selecting LOG_LEVEL
$ LOG_LEVEL=DEBUG python my_script.py
# level=DEBUG message=test 1
# level=INFO message=test 2

# selecting LOGGERS
$ LOGGERS=foobar python my_script.py
# Both messages

# Both
$ LOGGERS=foobar LOG_LEVEL=INFO my_script.py
# only level=INFO message=test 2

Applications should call `belogging.load()` upon initialization. The first `__init__.py` would be a good candidate, but anything before any call to `logging` module will be fine.

Django:

In your projects `settings.py`:

import belogging
# Disable django logging setup
LOGGING_CONFIG = None
belogging.load()

Inside your code, just use `logging.getLogger()` as usual.

$ export LOG_LEVEL=WARNING
$ ./manage.py runserver
# It will output only logging messages with severity > WARNING

Logging follows a hierarchy, so you easily select or skip some logging messages:

$ export LOGGERS=my_app.critical_a,my_app.critical_c,my_lib
$ ./my-app.py
# "my_app.critical_b messages" will be skipped
# all messages from my_lib will show up

Metadata

Release files for belogging 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for belogging 0.2.0
File Size Uploaded Provenance Actions
belogging-0.2.0.tar.gz 27.3 kB Without provenance Details for belogging-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for belogging 0.2.0
File Interpreter ABI Platform Actions
belogging-0.2.0-py3-none-any.whl Python 3 none any Details for belogging-0.2.0-py3-none-any.whl

Total release size: 34.0 kB

Release files / belogging-0.2.0.tar.gz

Download URL belogging-0.2.0.tar.gz
Size 27.3 kB
Tags Source
SHA-256 checksum
How to use checksums
fe28c51eef09e62acfd2139f8d249853198022c027e36b958f6bb59ac3da8987
BLAKE2b-256 checksum
How to use checksums
4d64e0a91b7d8a9fafcdf795b7c1e909e4e2d3839d253aed5da69fb0eda64f01
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.10

Release files / belogging-0.2.0-py3-none-any.whl

Download URL belogging-0.2.0-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fb9aeb583274d9354ed646ae7c6e82c4a206470021c895382849c3a34ae78610
BLAKE2b-256 checksum
How to use checksums
631688dbc386ea75fb33ec0d46d3c84f23c1a6884a159876cb29361d148cf66d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.10

Security for belogging 0.2.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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page