Skip to main content

structlog: Structured Logging for Python

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. :)

Metadata

Release files for structlog 16.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for structlog 16.0.0
File Size Uploaded
structlog-16.0.0.tar.gz 154.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for structlog 16.0.0
File Interpreter ABI Platform
structlog-16.0.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 183.8 kB

Release files / structlog-16.0.0.tar.gz

Download URL structlog-16.0.0.tar.gz
Size 154.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ba305858ee5dcd4518d79ee99907565bcd2ccd3f1cfba9679105078d13e566d0
BLAKE2b-256 checksum
How to use checksums
6e8e7be23d5ef287113264b93676ab67f895f28b5f795d91a9a45ba3f4daeeab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / structlog-16.0.0-py2.py3-none-any.whl

Download URL structlog-16.0.0-py2.py3-none-any.whl
Size 29.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
bed91b277972d3cf9090403e0cb3c84f2a38ae890357165892d60e1b0240be84
BLAKE2b-256 checksum
How to use checksums
353c258e5d3fda2605feae1f384970b20fd3d94d9dd2df216791623438716168
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

25.5.0

2 release files

25.3.0

2 release files

25.2.0

2 release files

25.1.0

2 release files

24.4.0

2 release files

24.3.0

2 release files

24.2.0

2 release files

23.3.0

2 release files

22.3.0

2 release files

22.2.0

2 release files

22.1.0

2 release files

21.5.0

2 release files

21.4.0

2 release files

21.3.0

2 release files

21.2.0

2 release files

21.1.0

2 release files

20.2.0

2 release files

20.1.0

2 release files

19.2.0

2 release files

18.1.0

2 release files

17.2.0

2 release files

17.1.0

2 release files

16.1.0

2 release files

This release

16.0.0 This release

2 release files

15.3.0

2 release files

15.2.0

2 release files

15.1.0

2 release files

15.0.0

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page