Skip to main content

This package provides a standard logging handler which writes log records to DbgLog.

Project description

This package provides a standard logging handler which writes log records to DbgLog.

You are not probably interested in this library unless you are working for Seznam.cz.

A spadl.DbgLogHandler class implemented in this package allows you to use and write code that uses the standard Python logging and at the same time utilize DbgLog.

Installation

SPADL can be installed using PIP (or easy_install from PYPI):

$ pip install spadl

Alternatively you can download and extract tarball and install the package manually:

$ python setup.py install

Placing the package somewhere on the PYTHONPATH should also work.

Example usage

DbgLog distinguish severities of log records with same level. Message can be logged for example as D4 (important debug) or E1 (minor error). So the spadl.DbgLogHandler maps logger names to these severities.

There is spadl.configure function defined which simplifies logging configuration. So the basic usage can be similar to:

import spadl
spadl.configure({
    # Log records from the 'app' logger and its children will
    # be logged using the highest severity (D4, I4, W4, E4, F4).
    'app': 4,
    # But log records from the 'app.request' (and its children)
    # will be logged using a lower severity (D3, I3, W3, E3, F3).
    'app.request': 3,
    # Another severity for another loggers.
    'rpc': 2,
    # Log records from the 'db.sql' logger will be ignored.
    'db.sql': 0,
    # Specification of the default severity. If was not present here then
    # the default behaviour would be to ignore records from unknown loggers.
    '': 1,
})

# Now use logging normally.
logging.info('This will be recorded by DbgLog.')

Alternatively you can configure logging using the logging.config package. A relevant section in a configuration file for the logging.config.fileConfig function can be similar to:

[handler_dbglog]
class=spadl.DbgLogHandler
level=NOTSET
args=({'app': 4,
       'app.request': 3,
       'rpc': 2,
       '': 1},)

See (and run) example.py for the working example.

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

spadl-0.1.tar.gz (6.6 kB view details)

Uploaded Source

File details

Details for the file spadl-0.1.tar.gz.

File metadata

  • Download URL: spadl-0.1.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for spadl-0.1.tar.gz
Algorithm Hash digest
SHA256 96623c761baaf22bf7064388509f977a30e8d675df2f718a1b601a68b6f521df
MD5 e7b1f11b40243eafb84a9cc48d115146
BLAKE2b-256 d16ce8df4834b402d472dcce1ebce88d242db7810300db1e71e5c2aaad51248f

See more details on using hashes here.

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