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.2.0.tar.gz (8.4 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.2.0-py2.py3-none-any.whl (6.7 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

File hashes

Hashes for sprockets.logging-1.2.0.tar.gz
Algorithm Hash digest
SHA256 f8db1efee25d3cf4994ad09f28bca2e7ab0b19d8fe29b83a265c0f45bdf86a51
MD5 18672a1b8e0976e2a76a4252f453bedd
BLAKE2b-256 8a397b30130ecff7ffbe7b88f3971b11127fb4f8fad948d33ebc03303c57bb45

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sprockets.logging-1.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 3d2d8341581d0384f4f1689ebbff76378bca9bbfe7b5142527801d5800b8c937
MD5 66ba0a09ef5e2d12131c402ee70d7d72
BLAKE2b-256 59a2405a5ac10e5ce3b86641c087c784a6f62803eb8d243ba75be9138f72ff89

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