Skip to main content

Structured Logging for Python

Project description

https://travis-ci.org/hynek/structlog.svg?branch=master https://codecov.io/github/hynek/structlog/coverage.svg?branch=master https://www.irccloud.com/invite-svg?channel=%23structlog&hostname=irc.freenode.net&port=6697&ssl=1

structlog makes structured logging in Python easy by augmenting your existing logger. It allows you to split your log entries up into key/value pairs and build them incrementally without annoying boilerplate code.

>>> from structlog import get_logger
>>> log = get_logger()
>>> log.info("key_value_logging", out_of_the_box=True, effort=0)
out_of_the_box=True effort=0 event='key_value_logging'
>>> log = log.bind(user='anonymous', some_key=23)
>>> log = log.bind(user='hynek', another_key=42)
>>> log.info('user.logged_in', happy=True)
some_key=23 user='hynek' another_key=42 happy=True event='user.logged_in'

It’s dual-licensed under Apache License, version 2 and MIT, available from PyPI, the source code can be found on GitHub, the documentation at http://www.structlog.org/.

structlog targets Python 2.6, 2.7, 3.3 and newer, and PyPy.

If you need any help, visit us on #structlog on Freenode!

Release Information

16.0.0 (2016-01-28)

Changes:

  • structlog.processors.ExceptionPrettyPrinter and structlog.processors.format_exc_info now support passing of Exceptions on Python 3.

  • Clean up the context when exiting structlog.threadlocal.tmp_bind in case of exceptions. [64]

  • Be more more lenient about missing __name__s. [62]

  • Add structlog.dev.ConsoleRenderer that renders the event dictionary aligned and with colors.

  • Use six for compatibility.

  • Add structlog.processors.UnicodeDecoder that will decode all byte string values in an event dictionary to Unicode.

  • Add serializer parameter to structlog.processors.JSONRenderer which allows for using different (possibly faster) JSON encoders than the standard library.

Full changelog.

Authors

structlog is written and maintained by Hynek Schlawack. It’s inspired by previous work done by Jean-Paul Calderone and David Reid.

The development is kindly supported by Variomedia AG.

A full list of contributors can be found on GitHub’s overview. Some of them disapprove of the addition of thread local context data. :)

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

structlog-16.0.0.tar.gz (154.0 kB view hashes)

Uploaded Source

Built Distribution

structlog-16.0.0-py2.py3-none-any.whl (29.7 kB view hashes)

Uploaded Python 2 Python 3

Supported by

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