Release v0.4.1 (What’s new?).
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.
structlog targets Python 2.6, 2.7, 3.2, 3.3, and PyPy with no additional dependencies for core functionality.
If you need any help, visit us on #structlog on Freenode!
structlog makes structured logging with incremental context building and arbitrary formatting as easy as:
>>> from structlog import get_logger >>> log = get_logger() >>> 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'
Since structlog avoids monkey-patching and events are fully free-form, you can start using it today!
structlog can be used immediately with any existing logger. However it comes with special wrappers for the Python standard library and Twisted that are optimized for their respective underlying loggers and contain less magic.