Skip to main content

convenient python stdlib logging configuration

Project description

logconf

Build Status Latest version on PyPI Licence

Setting up logging in Python is verbose and error prone. This library aims to fix that, without replacing the standard library logging entirely.

import logging
from logconf import global_logconf

with global_logconf() as logger:
    # simple example:
    logger.log_to_console_if_interactive(level=logging.DEBUG)
    if os.getenv('LOG_DEST'):  # can be "stdout" or "stderr"
        logger.log_to_file(os.getenv('LOG_DEST'), level=os.getenv('LOG_LEVEL'))

    # more fine-grained control:
    logger.log_json_to_file('/var/log/myapp.jsonlog', level=logging.WARNING)
    logger.log_json_to_file('/var/log/myapp_debug.jsonlog', level=logging.DEBUG)

    # configure sub-loggers:
    with logger.logger('urllib3') as sublogger:
        sublogger.level = logging.WARNING
    with logger.logger('myapp.security') as sublogger:
        sublogger.log_to_file('/var/log/myapp.security.log', level=logging.INFO)

Project details


Download files

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

Files for logconf, version 0.2.1
Filename, size File type Python version Upload date Hashes
Filename, size logconf-0.2.1-py3-none-any.whl (10.4 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size logconf-0.2.1.tar.gz (4.6 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page