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

Uploaded Python 2Python 3

File details

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

File metadata

File hashes

Hashes for sprockets.logging-1.2.1.tar.gz
Algorithm Hash digest
SHA256 cd3844f20ecfbb88639721f80caacda6162d45a8af248bc66c4de2d1729c19f7
MD5 b44afce0f058242e30f91b62e96e9cfa
BLAKE2b-256 6379043aa28abb11b3c42dbc668cbe4945c5bd0d61e8d877d4ed40b3a081fc99

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sprockets.logging-1.2.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1d15afdbf2bc3b5cb16b7bd56a7965dd4a7760f8e5b6185b7cef721e9ef1a9ec
MD5 7f6395f0cac5c3730b6e972b00df542c
BLAKE2b-256 859dbcc1000cdaa2296df72bd3dc6be0252b42836444d899ba8c18ff59856ce6

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