Versions are year-based with a strict backward compatibility policy. The third digit is only for regressions.
Python 2.7 and 3.5 aren’t supported anymore. The package meta data should ensure that you keep getting 20.1.0 on those versions. #244
_contextattribute of a bound logger is now deprecated. Please use the new
This is the last version to support Python 2.7 (including PyPy) and 3.5. All following versions will only support Python 3.6 or later.
The logger created by
structlog.get_logger()is not detected as an abstract method anymore, when attached to an abstract base class. #229
Python 3.4 is not supported anymore. It has been unsupported by the Python core team for a while now and its PyPI downloads are negligible.
It’s very unlikely that
structlogwill break under 3.4 anytime soon, but we don’t test it anymore.
Full Python 3.8 support for
Added more pass-through properties to
structlog.stdlib.BoundLogger. To makes it easier to use it as a drop-in replacement for
structlog.stdlib.ProcessorFormatternow takes a logger object as an optional keyword argument. This makes
ProcessorFormatterwork properly with
structlog.dev.ConsoleRenderernow uses no colors by default, if
coloramais not available. #215
coloramalazily, to prevent accidental side-effects just by importing
Added new processor
structlog.dev.set_exc_info()that will set
exc_info=Trueif the method’s name is
exc_infoisn’t set at all. This is only necessary when the standard library integration is not used. It fixes the problem that in the default configuration,
exceptblock would not print the exception without passing
exc_info=Trueto it explicitly. #130, #173, #200, #204
A best effort has been made to make as much of
structlogpickleable as possible to make it friendlier with
multiprocessingand similar libraries. Some classes can only be pickled on Python 3 or using the dill library though and that is very unlikely to change.
So far, the configuration proxy,
structlog.dev.ConsoleRendererhave been made pickelable. Please report if you need any another class fixed. #126
structlog.stdlib.ProcessorFormatter. It allows to pass a foreign log record’s
argsattribute to the event dictionary under the
str()on the event value. #221
As announced in 18.1.0,
pip install -e .[dev]now installs all development dependencies. Sorry for the inconveniences this undoubtedly will cause!
structlog.PrintLoggernow have a
fatal()log method. #181
Under certain (rather unclear) circumstances, the frame extraction could throw an
SystemError: error return without exception set. A workaround has been added. #174
structlog.stdlib.add_log_level_number()processor that adds the level number to the event dictionary. Can be used to simplify log filtering. #151
try_unbind()that works like
unbind()but doesn’t raise a
KeyErrorif one of the keys is missing. #171
The meaning of the
structlog[dev]installation target will change from “colorful output” to “dependencies to develop
structlog” in 19.1.0.
The main reason behind this decision is that it’s impossible to have a
structlogin your normal dependencies and additionally a
structlog[dev]for development (
pipwill report an error).
Empty strings are valid events now. #110
Do not encapsulate Twisted failures twice with newer versions of Twisted. #144
structlog.dev.ConsoleRenderernow accepts a force_colors argument to output colored logs even if the destination is not a tty. Use this option if your logs are stored in files that are intended to be streamed to the console.
structlog.dev.ConsoleRenderernow accepts a level_styles argument for overriding the colors for individual levels, as well as to add new levels. See the docs for
ConsoleRenderer.get_default_level_styles()for usage. #139
structlog.stdlib.BoundLogger.exception()now uses the
exc_infoargument if it has been passed instead of setting it unconditionally to
Default configuration now uses plain
dicts on Python 3.6+ and PyPy since they are ordered by default.
structlog.is_configured()to check whether or not
structloghas been configured.
structlog.get_config()to introspect current configuration.
structlog.stdlib.ProcessorFormatternow accepts keep_exc_info and keep_stack_info arguments to control what to do with this information on log records. Most likely you want them both to be
Falsetherefore it’s the default. #109
structlog.stdlib.add_logger_name()now works in
Clear log record args in
structlog.stdlib.ProcessorFormatterafter rendering. This fix is for you if you tried to use it and got
TypeError: not all arguments converted during string formattingexceptions. #116, #117
The main features of this release are massive improvements in standard library’s
Have a look at the updated standard library chapter on how to use them!
Special thanks go to
that made them possible.
The default renderer now is
structlog.dev.ConsoleRendererif you don’t configure
structlog. Colors are used if available and human-friendly timestamps are prepended. This is in line with our backward compatibility policy that explicitly excludes default settings.
structlog.stdlib.render_to_log_kwargs(). This allows you to use
logging-based formatters to take care of rendering your entries. #98
UNIX epoch timestamps from
structlog.processors.TimeStamperare more precise now.
Added repr_native_str to
structlog.dev.ConsoleRenderer. This allows for human-readable non-ASCII output on Python 2 (
repr()on Python 2 behaves like
ascii()on Python 3 in that regard). As per compatibility policy, it’s on (original behavior) in
KeyValueRendererand off (humand-friendly behavior) in
Added colors argument to
structlog.dev.ConsoleRendererand made it the default renderer. #78
Fixed bug with Python 3 and
structlog.stdlib.BoundLogger.log(). Error log level was not reproductible and was logged as exception one time out of two. #92
Positional arguments are now removed even if they are empty. #82
Python 3.3 and 2.6 aren’t supported anymore. They may work by chance but any effort to keep them working has ceased.
The last Python 2.6 release was on October 29, 2013 and isn’t supported by the CPython core team anymore. Major Python packages like Django and Twisted dropped Python 2.6 a while ago already.
Python 3.3 never had a significant user base and wasn’t part of any distribution’s LTS release.
key_orderis used and a key is missing a value, it’s not rendered at all instead of being rendered as
Exceptions without a
__traceback__are now also rendered on Python 3.
Don’t cache loggers in lazy proxies returned from
get_logger(). This lead to in-place mutation of them if used before configuration which in turn lead to the problem that configuration was applied only partially to them later. #72
structlog.processors.format_exc_infonow support passing of Exceptions on Python 3.
Clean up the context when exiting
structlog.threadlocal.tmp_bindin case of exceptions. #64
Be more more lenient about missing
structlog.dev.ConsoleRendererthat renders the event dictionary aligned and with colors.
Use six for compatibility.
structlog.processors.UnicodeDecoderthat will decode all byte string values in an event dictionary to Unicode.
structlog.processors.JSONRendererwhich allows for using different (possibly faster) JSON encoders than the standard library.
Allow empty lists of processors. This is a valid use case since #26 has been merged. Before, supplying an empty list resulted in the defaults being used.
log.errfrom quoting strings rendered by
Better support of
Add option to specify target key in
Pass positional arguments to stdlib wrapped loggers that use string formatting. #19
Fixed a memory leak in greenlet code that emulates thread locals. It shouldn’t matter in practice unless you use multiple wrapped dicts within one program that is rather unlikely. #8
structlog.PrintLoggernow is thread-safe.
Test Twisted-related code on Python 3 (with some caveats).
Drop support for Python 3.2. There is no justification to add complexity for a Python version that nobody uses. If you are one of the 0.350% that use Python 3.2, please stick to the 0.4 branch; critical bugs will still be fixed.
Officially support Python 3.4.
Allow final processor to return a dictionary. See the adapting chapter. #26
from structlog import *works now (but you still shouldn’t use it).
Don’t cache proxied methods in
structlog.threadlocal._ThreadLocalDictWrapper. This doesn’t affect regular users.
Various doc fixes.
structlog.processors.StackInfoRendererfor adding stack information to log entries without involving exceptions. Also added it to default processor chain. #6
Allow optional positional arguments for
structlog.get_loggerthat are passed to logger factories. The standard library factory uses this for explicit logger naming. #12
structlog.processors.ExceptionPrettyPrinterfor development and testing when multiline log entries aren’t just acceptable but even helpful.
Allow the standard library name guesser to ignore certain frame names. This is useful together with frameworks.
Add meta data (e.g. function names, line numbers) extraction for wrapped stdlib loggers. #5
Greatly enhanced and polished the documentation and added a new theme based on Write The Docs, requests, and Flask.
Add Python Standard Library-specific BoundLogger that has an explicit API instead of intercepting unknown method calls. See
structlog.ReturnLoggernow allows arbitrary positional and keyword arguments.
Add Twisted-specific BoundLogger that has an explicit API instead of intercepting unknown method calls. See
Allow logger proxies that are returned by
structlog.wrap_loggerto cache the BoundLogger they assemble according to configuration on first use. See the chapter on performance and the
Extract a common base class for loggers that does nothing except keeping the context state. This makes writing custom loggers much easier and more straight-forward. See
Promote to stable, thus henceforth a strict backward compatibility policy is put into effect.
structlog.processors.KeyValueRendererfor more predictable log entries with any
structlog.PrintLoggernow uses proper I/O routines and is thus viable not only for examples but also for production.
Enhance Twisted support by offering JSONification of non-structlog log entries.
Allow for custom serialization in