Skip to main content

A set of classes and functions that extend the log package.

Project description

uc_logging

A set of classes and functions that extend the log package.

It is part of the Unicon project.

https://unicon.10k.me

Usage:

Install
pip install --user uc-logging
and use
import uc_logging

Functions:

Classes:

Formatter(default=logging.BASIC_FORMAT, formats=None)

Multi formatter. Adds the ability to format log messages based on their level.

Formats is a dict where key is a level and value it's a format.

UnbufferedStreamHandler(stream)

Unbuffered stream handler.

When multiprocessing queue is used (for example), standard output may stuck. Common flushing not working. Using -u option not guaranteed (it helps). So write directly.

Example:

import logging
import uc_logging

format_standard_a = "%(asctime)s [%(levelname)s] - %(message)s"
format_standard_d = "%(asctime)s [%(levelname)s] %(filename)s:%(lineno)d - %(message)s"

logger = logging.getLogger("formatter_test")
logger.handlers.clear()
logger.setLevel(logging.DEBUG)
# Set multi formatter
formatter = uc_logging.Formatter(default=format_standard_a, formats={logging.DEBUG: format_standard_d})
handler = logging.StreamHandler()
handler.setFormatter(formatter)
logger.addHandler(handler)

logger.info("TEST FORMATTER.")
logger.debug("TEST FORMATTER.")

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

uc_logging-0.0.2.tar.gz (2.8 kB view hashes)

Uploaded Source

Built Distribution

uc_logging-0.0.2-py3-none-any.whl (15.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page