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.1.0.tar.gz (8.2 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.1.0-py2.py3-none-any.whl (6.4 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

File hashes

Hashes for sprockets.logging-1.1.0.tar.gz
Algorithm Hash digest
SHA256 61b2b105eec4ad80c006cc345c06efc2b5489ee4903b036db3d9888e2c263801
MD5 eaf536e3e4239b3d7796b60cdd76ab55
BLAKE2b-256 6e4786575df94085b8d737e3e47375c6175258dbaea85e839881d63fabc3c095

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sprockets.logging-1.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 27e5b4f2714f0985a0c9b3ff2c81095446fe7ca76065d9191d8227d3f1f71efd
MD5 5c04791eb3ec53037a8b7cef1f532c34
BLAKE2b-256 68399ad3042a4e9e79a20d719fa3810df718eca4fc331e004682fa3fc574caf3

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