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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 2 Python 3

File details

Details for the file structlog-16.0.0.tar.gz.

File metadata

  • Download URL: structlog-16.0.0.tar.gz
  • Upload date:
  • Size: 154.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for structlog-16.0.0.tar.gz
Algorithm Hash digest
SHA256 ba305858ee5dcd4518d79ee99907565bcd2ccd3f1cfba9679105078d13e566d0
MD5 59ac00a23b966c6d63ad85c26f454ea9
BLAKE2b-256 6e8e7be23d5ef287113264b93676ab67f895f28b5f795d91a9a45ba3f4daeeab

See more details on using hashes here.

File details

Details for the file structlog-16.0.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for structlog-16.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 bed91b277972d3cf9090403e0cb3c84f2a38ae890357165892d60e1b0240be84
MD5 e76718f24ad671b1255f1489ee230990
BLAKE2b-256 353c258e5d3fda2605feae1f384970b20fd3d94d9dd2df216791623438716168

See more details on using hashes here.

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