Skip to main content

Advanced logging features.

Project description

starlog

Python logging library to improve python's standard logger capabilities.

Features:

  • Status log handler
  • Multiprocess log handler

Full Documentation

Examples

Status Logger

A log handler that examines every log and does some statistics on it. It generates a log message in regular intervals.

# minimalistic sample configuration for status logging
# The 'status' handler aggregates all log messages occurring at the 'root'
# logger. Every 5 seconds a status log line is sent by 'starlog.status' to
# its handler 'status_stdout'
[loggers]
keys = root, starlog.status

[handlers]
keys = status, status_stdout

[formatters]
keys = status

[logger_root]
level = NOTSET
handlers = status

[logger_starlog.status]
handlers = status_stdout
qualname = starlog.status

[handler_status]
class = starlog.StatusHandler
args = ()

[handler_status_stdout]
class = StreamHandler
args = (sys.stdout, )
formatter = status

[formatter_status]
format = %(asctime)s log messages: %(ERROR)d ERROR, %(WARNING)d WARNING %(INFO)d INFO
datefmt = %Y-%m-%d %H:%M:%S

Example usage:

import logging

logging.config.fileConfig('logging.conf', disable_existing_loggers=False)

logging.info('Lorem ipsum dolor sit amet, consetetur sadipscing elitr, ')
logging.info('sed diam nonumy eirmod tempor invidunt ut labore et dolore ')
logging.info('magna aliquyam')

And the final output will look like:

2019-03-05 23:53:31 log messages: 0 ERROR, 0 WARNING 3 INFO

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

starlog-1.0.0a4.tar.gz (11.3 kB view hashes)

Uploaded Source

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