Skip to main content

Making logs nicer since 2015!

Project description

Making logs nicer since 2015!

Version Downloads Travis CodeCov ReadTheDocs

Installation

sprockets.logging is available on the Python Package Index and can be installed via pip or easy_install:

pip install sprockets.logging

Documentation

https://sprocketslogging.readthedocs.org

Requirements

  • No external requirements

Example

This examples demonstrates the most basic usage of sprockets.logging

import logging
import sys

import sprockets.logging


formatter = logging.Formatter('%(levelname)s %(message)s {%(context)s}')
handler = logging.StreamHandler(sys.stdout)
handler.setFormatter(formatter)
handler.addFilter(sprockets.logging.ContextFilter(properties=['context']))
logging.Logger.root.addHandler(handler)
logging.Logger.root.setLevel(logging.DEBUG)

# Outputs: INFO Hi there {None}
logging.info('Hi there')

# Outputs: INFO No KeyError {bah}
logging.info('No KeyError', extra={'context': 'bah'})

# Outputs: INFO Now with context! {foo}
adapted = logging.LoggerAdapter(logging.Logger.root, extra={'context': 'foo'})
adapted.info('Now with context!')

Source

sprockets.logging source is available on Github at https://github.com/sprockets/sprockets.logging

License

sprockets.logging is released under the 3-Clause BSD license.

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

sprockets.logging-1.3.0.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sprockets.logging-1.3.0-py2.py3-none-any.whl (7.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file sprockets.logging-1.3.0.tar.gz.

File metadata

File hashes

Hashes for sprockets.logging-1.3.0.tar.gz
Algorithm Hash digest
SHA256 68f54de266e79fc74c4eba5aff8a745ddf6a69a3892ad78f62175008acf9e0f3
MD5 9c0b81470bd6797e2b334624da5aa0de
BLAKE2b-256 e88b1faeba3198540352039a268bc8ed3d0fbd7c4ef879ed528b96458a876a78

See more details on using hashes here.

File details

Details for the file sprockets.logging-1.3.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for sprockets.logging-1.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 bff7e583e3133a223e9d17534048d7e12da8f1997a268a9fcd2ac70686beb893
MD5 108d622de372b772fbba3f11521f8018
BLAKE2b-256 fade2fe639f0cb95a910ee4f3212c8496426a151b38ee1c9954e959ce3bf853a

See more details on using hashes here.

Supported by

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