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.1.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.1-py2.py3-none-any.whl (7.1 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

File hashes

Hashes for sprockets.logging-1.3.1.tar.gz
Algorithm Hash digest
SHA256 a778949aa5c7e57ccea8fa318eeee1f9e5eaff92c71739f7d54149d30023843a
MD5 29fdd94e4b0ecade98821925a5731527
BLAKE2b-256 ef050080d5a906fc5eba2bc030335290218b7ae6c8acc97ca7bb9130c08afa4b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sprockets.logging-1.3.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 de394e880b01e9d7f53b2cea0ddff7a5e1828cb0198bb78b5fe7746d01531736
MD5 2a1098c5cfdfaca93f82413b07a7141f
BLAKE2b-256 4cb5e6767a4987a3375837c85ce2634e899d079f2c900d097297080f43c7f1fb

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