You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

logging518

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

logging518

Configure Python's native logging module using pyproject.toml

1.0.0
pipPyPI
Maintainers
1

🪵 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

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts