Skip to main content

🪵 logging518

PyPI version PyPI - Downloads Test Matrix

Use your pyproject.toml (or any other TOML file) to configure Python's native logging module

Usage

You can use logging518.config.fileConfig the same way you would use logging.config.fileConfig but instead of passing a ConfigParser-form file, you can pass in a TOML-form file.

import logging
import logging518.config  # instead of logging.config

logging518.config.fileConfig("pyproject.toml")
logger = logging.get_logger("project")

logger.info("Hello, log!")

Configure

logging518.config.fileConfig simply deserializes the TOML file you pass in (using tomli/tomlib) and passes the contents to logging.config.dictConfig.

logging518.config.fileConfig uses the tool table in your TOML file to look up the configuration. All logging config should be defined under tool.logging in the tool table.

[tool.logging]
version = 1
disable_existing_loggers = true

[tool.logging.loggers.project]
level = "WARNING"

[tool.logging.loggers.project.foo_module]
level = "DEBUG"

This config would be the same as:

import logging.config

LOGGING_CONFIG = {
    "version": 1,
    "disable_existing_loggers": True,
    "loggers": {
        "project": {
            "level": "WARNING"
        },
        "project.foo_module": {
            "level": "DEBUG"
        }
    }
}

logging.config.dictConfig(LOGGING_CONFIG)

More examples can be found in the 👩‍🍳 Cookbook

Metadata

Release files for logging518 1.0.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 logging518 1.0.0
File Size Uploaded
logging518-1.0.0.tar.gz 3.4 kB Details

Built distribution (wheel)

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

Total release size: 7.1 kB

Release files / logging518-1.0.0.tar.gz

Download URL logging518-1.0.0.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
df349043647e394962ab6eaaa11c07d60496ac0efe4992d7a54b8f8e05b6d698
BLAKE2b-256 checksum
How to use checksums
05346e14021eba6af71a5c0977f1ba83cb64042f1f4943d3887474ab82fa9b5b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.8.13 Linux/5.16.20-051620-generic

Release files / logging518-1.0.0-py3-none-any.whl

Download URL logging518-1.0.0-py3-none-any.whl
Size 3.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
048956ee2f5bf3c24f00a8d3f0c567b3836fb79529d6ddb2fa726cefef961be1
BLAKE2b-256 checksum
How to use checksums
27c32323d183d22f58fd402437bf8c7e7149699e7a57082746598b50d5ccc41d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.8.13 Linux/5.16.20-051620-generic

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.2.2

2 release files

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