All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog and this project adheres to Calendar Versioning.
The first number of the version is the year. The second number is incremented with each release, starting at 1 for each year. The third number is for emergencies when we need to start branches for older releases.
You can find our backwards-compatibility policy here.
- Python 3.8 and 3.9 support.
- Support for better-exceptions is deprecated and will be removed within a year. Use our Rich integration or copy-paste the one line of code you need. #802
structlog.dev.ConsoleRendererdoes not warn anymore when theexceptionkey has a rendered value despite having a fancy formatter configured. #790
25.5.0 - 2025-10-27
structlog.dev.ConsoleRenderer()'s pad_event argument has been renamed to pad_event_to to differentiate it from the boolean pad_level argument. pad_event is now deprecated.
-
Added
structlog.dev.ConsoleRenderer.get_active()that returns the currently activestructlog.dev.ConsoleRenderer(). #749 -
structlog.dev.ConsoleRenderer()now supports setting theexception_formatterattribute.You can now disable the pretty-printing of exceptions by setting it to
structlog.dev.plain_traceback:cr = structlog.dev.ConsoleRenderer.get_active() cr.exception_formatter = structlog.dev.plain_traceback
Same goes for sort_keys, columns, colors, force_colors, level_styles, pad_event_to, event_key, timestamp_key, and repr_native_str.
-
Added
structlog.dev.ConsoleRenderer.get_default_column_styles()for reuse the default column styles. #741 -
structlog.testing.capture_logs()now optionally accepts processors to apply before capture. #728 -
structlog.dev.RichTracebackFormatternow exposes the upstream code_width parameter. Default width is nowNonefor full terminal width. Full terminal width is now handled by Rich itself, bringing support for reflow andCOLUMNenvironment variable. Passing-1for width is now deprecated and automatically replaced byNone. #717 -
Native loggers now allow the passing of a dictionary for dictionary-based interpolation
log.info("hello %(name)s!", {"name": "world"}). #748 -
On Python 3.11+,
structlog.processors.CallsiteParameterAddernow supportsCallsiteParameter.QUAL_NAMEthat adds the qualified name of the callsite, including scope and class names. This is only available for structlog-originated events since the standard library has no equivalent. -
structlog.stdlib.LoggerFactorynow supports the stacklevel parameter. #763
structlog.dev.rich_traceback()now throws a more helpful error when Rich is missing. #735
-
structlog.processors.MaybeTimeStampernow respects the key argument when determining whether to overwrite the timestamp field. #747 -
structlog.tracebacks.extract()no longer raises aRecursionErrorwhen the cause chain of an exception contains itself. #739 -
Default config now respects
FORCE_COLORon Windows. #758
25.4.0 - 2025-06-02
-
Support for Python 3.14 and Python 3.13.4.
Python 3.14 has an backwards-incompatible change to
logging.Logger.isEnabledFor()(it now always returns False if a log entry is in flight) that has been backported to 3.13.4 (expected on 2025-06-03). It mainly affectsstructlog.stdlib.filter_by_level(). #723 -
structlog.tracebacksnow handles exception groups.structlog.tracebacks.Stackhas two new fields,is_group: boolandexceptions: list[Trace]. This works similarly to what Rich v14.0.0 does. #720
structlog.processors.ExceptionPrettyPrinternow respects the exception_formatter arguments instead of always using the default formatter. #724
25.3.0 - 2025-04-25
structlog.processors.TimeStampernow again uses timestamps using UTC for custom format strings whenutc=True. #713
25.2.0 - 2025-03-11
structlog.tracebacks.Stacknow includes anexc_notesfield reflecting the notes attached to the exception. #684
-
structlog.stdlib.BoundLogger's binding-related methods now also returnSelf. #694 -
structlog.processors.TimeStampernow produces internally timezone-awaredatetimeobjects. Default output hasn't changed, but you can now use%zin your fmt string. #709
- Expose
structlog.dev.RichTracebackFormatterfor imports. #699 - Expose
structlog.processors.LogfmtRendererfor imports. #701
25.1.0 - 2025-01-16
-
Add
structlog.stdlib.render_to_log_args_and_kwargsprocessor. Same asstructlog.stdlib.render_to_log_kwargs, but also allows to pass positional arguments tologging. With it, you do not need to addstructlog.stdlib.PositionalArgumentsFormatterprocessor to format positional arguments from structlog loggers. #668 -
Native loggers now have
is_enabled_for()andget_effective_level()methods that mirror the behavior of the standard library'slogging.Logger.isEnabledFor()andlogging.Logger.getEffectiveLevel(). #689
-
structlog.typing.BindableLoggerprotocol now returnsSelfinstead ofBindableLogger. This adds a dependency on typing-extensions for Pythons older than 3.11. #642 #659 -
structlog.dev.ConsoleRendererwill quote string value with special characters. #647 -
structlog.stdlib.recreate_defaults()now also addsstructlog.stdlib.PositionalArgumentsFormatter. In default native mode, this is done by the loggers at the edge. -
structlog.make_filtering_bound_logger()now also accepts a string for min_level.
-
Fix handling calls to
{logger}.exception()outside of exception blocks. Depending on the structlog configuration, this either resulted in an event dict keyexception: "MISSING"or lead to an error. Now, an invalid or missingexc_infowill just be ignored. This means, that calling{logger}.exception()outside of an exception block is basically the same as calling{logger}.error(). #634 #680 -
Instantiating
structlog.dev.ConsoleRendererdoes not mutate the passed styles dict anymore. #669 -
The native
FilteringBoundLogger.fatal()method now maps to the critical level, as it does in the standard library. Note that the level is discouraged to use there, so we recommend to stick toerror()orcritical(). #677 -
structlog.tracebacks.ExceptionDictTransformernow actually acceptsNoneforlocals_max_lengthandlocals_max_string. #675
24.4.0 - 2024-07-17
No code changes since 24.3.0
24.3.0 - 2024-07-17
-
Restore feature parity between
structlog.traceback.ExceptionDictTransformerand Rich's traceback extractor:- When displaying locals, use Rich for formatting if it is available.
- When displaying locals, call
repr()on strings, too (improves handling ofSecretStrimplementations). - Add
locals_max_lengthconfig option - Add
locals_hide_sunderconfig option - Add
locals_hide_dunderconfig option - Add
suppressconfig option
structlog.testing.capture_logs()now maps theexceptionlog level toerror(as it's elsewhere). #628
24.2.0 - 2024-05-27
-
It is now possible to disable log level-padding in
structlog.dev.LogLevelColumnFormatterandstructlog.dev.ConsoleRenderer. #599 -
The
structlog.processors.CallsiteParameterAddercan now be pickled. #603 -
structlog.processors.CallsiteParameterAddernow also works withstructlog.stdlib.BoundLogger's non-standard async methods (ainfo(), and so forth) #618
-
structlog.processors.LogfmtRenderernow escapes newlines. #592 -
structlog.processors.LogfmtRenderernow escapes backslashes and double quotes. #594 -
structlog.processors.CallsiteParameterAdderhas been optimized to be about 2x faster. #606
structlog.stdlib.render_to_log_kwargsnow correctly passes stacklevel as a kwarg to stdlib logging. #619
24.1.0 - 2024-01-08
-
The lazy logger proxy returned by
structlog.get_logger()now returns its initial values when asked for context. When asked for context before binding for the first time, it returned an empty dictionary in 23.3.0. -
The displayed level name when using
structlog.stdlib.BoundLogger.exception()is"error"instead of"exception". Fixes regression in 23.3.0. #584 -
Don't ignore the
widthargument ofRichTracebackFormatter. #587
23.3.0 - 2023-12-29
-
The colorful development logger is now even more configurable! Choose freely your colors and the order of the key-value pairs! Implement your own formatters for certain keys!
Implementing the output on top of the new columns API has changed the default very slightly, but shouldn't be noticeable. #577
-
Async log methods (those starting with an
a) now also support the collection of callsite information usingstructlog.processors.CallsiteParameterAdder. #565
structlog.stdlib.recreate_defaults()now also addsstructlog.stdlib.add_logger_nameto the processors. Check out the updated screenshot!
-
The return value from
get_logger()(aBoundLoggerLazyProxy) now passesisinstance-checks againststructlog.typing.BindableLoggeron Python 3.12. #561 -
structlog.threadlocal.tmp_bind()now also works withBoundLoggerLazyProxy(in other words: before anything is bound to a bound logger). -
stdlib:
ProcessorFormattercan now be told to not render the log record message usinggetMessageand juststr(record.msg)instead. #550 -
stdlib:
structlog.stdlib.BoundLogger.exception()'s handling ofLogRecord.exc_infois now set consistent withlogging. #571 #572
23.2.0 - 2023-10-09
- Support for Python 3.7.
-
Official support for Python 3.12. #515
-
structlog.processors.MaybeTimeStamperthat only adds a timestamp if there isn't one already. #81 -
structlog.dev.ConsoleRenderernow supports renamed timestamp keys using the timestamp_key parameter. #541 -
structlog.dev.RichTracebackFormatterthat allows to configure the traceback formatting. #542
FilteringBoundLogger.exception()andFilteringBoundLogger.aexception()now support positional argument formatting like the rest of the methods. #531structlog.processors.format_exc_info()andstructlog.dev.ConsoleRendererdo not crash anymore when told to format a non-existent exception. #533
23.1.0 - 2023-04-06
-
structlog.stdlib.BoundLoggernow has, analogously to our native logger, a full set of async log methods prefixed with ana:await log.ainfo("event!")#502 -
The default configuration now respects the presence of
FORCE_COLOR(regardless of its value, unless an empty string). This disables all heuristics whether it makes sense to use colors. #503 -
The default configuration now respects the presence of
NO_COLOR(regardless of its value, unless an empty string). This disables all heuristics whether it makes sense to use colors and overridesFORCE_COLOR. #504
-
ConsoleRenderer now reuses the
_figure_out_exc_infoto process theexc_infoargument likeExceptionRendererdoes. This prevents crashes if the actual Exception is passed for the exc_info argument instead of a tuple orTrue. #482 -
FilteringBoundLogger.aexception()now extracts the exception info usingsys.exc_info()before passing control to the asyncio executor (where original exception info is no longer available). #488
22.3.0 - 2022-11-24
- String interpolation in
FilteringBoundLogger(used by default) is now only attempted if positional arguments are passed. This prevents crashes if something different than a string is passed for the event argument. #475
- String interpolation doesn't cause crashes in filtered log call anymore. #478
22.2.0 - 2022-11-19
- Accessing package metadata as attributes on the structlog module is deprecated (for example,
structlog.__version__). Please useimportlib.metadatainstead (for Python 3.7: the importlib-metadata PyPI package). - The
structlog.typesmodule is now deprecated in favor of thestructlog.typingmodule. It seems like the Python typing community is settling on this name.
-
FilteringBoundLogger(used by default) now allows for string interpolation using positional arguments:>>> log.info("Hello %s! The answer is %d.", "World", 42, x=1) 2022-10-07 10:04.31 [info ] Hello World! The answer is 42. x=1
-
FilteringBoundLoggernow also has support for asyncio-based logging. Instead of a wrapper class likestructlog.stdlib.AsyncBoundLogger, async equivalents have been added for all logging methods. So instead oflog.info("hello")you can also writeawait log.ainfo("hello")in async functions and methods.This seems like the better approach and if it's liked by the community,
structlog.stdlib.BoundLoggerwill get those methods too. #457
- The documentation has been heavily overhauled. Have a look if you haven't lately! Especially the graphs in the standard library chapter have proven valuable to many.
- The build backend has been switched to Hatch.
- The timestamps in the default configuration now use the correct separator (
:) for seconds.
22.1.0 - 2022-07-20
- Python 3.6 is not supported anymore.
- Pickling is now only possible with protocol version 3 and newer.
-
The entire
structlog.threadlocalmodule is deprecated. Please use the primitives fromstructlog.contextvarsinstead.If you're using the modern APIs (
bind_threadlocal()/merge_threadlocal()) it's enough to replace them 1:1 with theircontextvarscounterparts. The old approach aroundwrap_dict()has been discouraged for a while.Currently there are no concrete plans to remove the module, but no patches against it will be accepted from now on. #409
structlog.processors.StackInfoRenderernow has an additional_ignores parameter that allows you to filter out your own logging layer. #396- Added
structlog.WriteLogger, a faster – but more low-level – alternative tostructlog.PrintLogger. It works the wayPrintLoggerused to work in previous versions. #403 #404 structlog.make_filtering_bound_logger()-returned loggers now also have alog()method to match thestructlog.stdlib.BoundLoggersignature closer. #413- Added structured logging of tracebacks via the
structlog.tracebacksmodule, and most notably thestructlog.tracebacks.ExceptionDictTransformerwhich can be used with the newstructlog.processors.ExceptionRendererto render JSON tracebacks. #407 structlog.stdlib.recreate_defaults(log_level=logging.NOTSET)that recreates structlog's defaults on top of standard library'slogging. It optionally also configuresloggingto log to standard out at the passed log level. #428structlog.processors.EventRenamerallows you to rename the hitherto hard-coded event dict keyeventto something else. Optionally, you can rename another key toeventat the same time, too. So addingEventRenamer(to="msg", replace_by="_event")to your processor pipeline will rename the standardeventkey tomsgand then rename the_eventkey toevent. This allows you to use theeventkey in your own log files and to have consistent log message keys across languages.structlog.dev.ConsoleRenderer(event_key="event")now allows to customize the name of the key that is used for the log message.
structlog.make_filtering_bound_logger()now returns a method with the same signature for all log levels, whether they are active or not. This ensures that invalid calls to inactive log levels are caught immediately and don't explode once the log level changes. #401structlog.PrintLogger– that is used by default – now usesprint()for printing, making it a better citizen for interactive terminal applications. #399structlog.testing.capture_logsnow works for already initialized bound loggers. #408structlog.processors.format_exc_info()is no longer a function, but an instance ofstructlog.processors.ExceptionRenderer. Its behavior has not changed. #407- The default configuration now includes the
structlog.contextvars.merge_contextvarsprocessor. That means you can usestructlog.contextvarsfeatures without configuring structlog.
- Overloaded the
bind,unbind,try_unbindandnewmethods in theFilteringBoundLoggerProtocol. This makes it easier to use objects of typeFilteringBoundLoggerin a typed context. #392 - Monkeypatched
sys.stdouts are now handled more gracefully byConsoleRenderer(that's used by default). #404 structlog.stdlib.render_to_log_kwargs()now correctly handles the presence ofexc_info,stack_info, andstackLevelin the event dictionary. They are transformed into proper keyword arguments instead of putting them into theextradictionary. #424, #427
21.5.0 - 2021-12-16
- Added the
structlog.processors.LogfmtRendererprocessor to render log lines using the logfmt format. #376 - Added the
structlog.stdlib.ExtraAdderprocessor that adds extra attributes oflogging.LogRecordobjects to the event dictionary. This processor can be used for adding data passed in theextraparameter of theloggingmodule's log methods to the event dictionary. #209, #377 - Added the
structlog.processor.CallsiteParameterAdderprocessor that adds parameters of the callsite that an event dictionary originated from to the event dictionary. This processor can be used to enrich events dictionaries with information such as the function name, line number and filename that an event dictionary originated from. #380
21.4.0 - 2021-11-25
- Added the
structlog.threadlocal.bound_threadlocalandstructlog.contextvars.bound_contextvarsdecorator/context managers to temporarily bind key-value pairs to a thread-local and context-local context. #371
- Fixed import when running in optimized mode (
PYTHONOPTIMIZE=2orpython -OO) . #373
21.3.0 - 2021-11-20
structlog.dev.ConsoleRenderernow hassort_keysboolean parameter that allows to disable the sorting of keys on output. #358
- structlog switched its packaging to flit. Users shouldn't notice a difference, but (re-)packagers might.
structlog.stdlib.AsyncBoundLoggernow determines the running loop when logging, not on instantiation. That has a minor performance impact, but makes it more robust when loops change (for example,aiohttp.web.run_app()), or you want to usesync_blbefore a loop has started.
-
structlog.processors.TimeStampernow works well with FreezeGun even when it gets applied before the loggers are configured. #364 -
structlog.stdlib.ProcessorFormatternow has a processors argument that allows to define a processor chain to run over all log entries.Before running the chain, two additional keys are added to the event dictionary:
_recordand_from_structlog. With them it's possible to extract information fromlogging.LogRecords and differentiate between structlog andlogginglog entries while processing them.The old processor (singular) parameter is now deprecated, but no plans exist to remove it. #365
21.2.0 - 2021-10-12
-
structlog.threadlocal.get_threadlocal()andstructlog.contextvars.get_contextvars()can now be used to get a copy of the current thread-local/context-local context that has been bound usingstructlog.threadlocal.bind_threadlocal()andstructlog.contextvars.bind_contextvars(). #331, #337 -
structlog.threadlocal.get_merged_threadlocal(bl)andstructlog.contextvars.get_merged_contextvars(bl)do the same, but also merge the context from a bound logger bl. Same pull requests as previous change. -
structlog.contextvars.bind_contextvars()now returns a mapping of keys tocontextvars.Tokens, allowing you to reset values using the newstructlog.contextvars.reset_contextvars(). #339 -
Exception rendering in
structlog.dev.ConsoleLoggeris now configurable using theexception_formattersetting. If either the Rich or the better-exceptions package is present, structlog will use them for pretty-printing tracebacks. Rich takes precedence over better-exceptions if both are present.This only works if
format_exc_infois absent in the processor chain. #330, #349 -
The final processor can now return a
bytearray(additionally tostrandbytes). #344
-
To implement pretty exceptions (see Changes below),
structlog.dev.ConsoleRenderernow formats exceptions itself.Make sure to remove
format_exc_infofrom your processor chain if you configure structlog manually. This change is not really breaking, because the old use-case will keep working as before. However if you passpretty_exceptions=True(which is the default if eitherrichorbetter-exceptionsis installed), a warning will be raised and the exception will be rendered without prettification. -
All use of Colorama on non-Windows systems has been excised. Thus, colors are now enabled by default in
structlog.dev.ConsoleRendereron non-Windows systems. You can keep using Colorama to customize colors, of course. #345
- structlog is now importable if
sys.stdoutisNone(for example, when running usingpythonw). #313
21.1.0 - 2021-02-18
structlog.dev.ConsoleRendererwill now look for alogger_namekey if nologgerkey is set. #295
structlog.threadlocal.wrap_dict()now has a correct type annotation. #290- Fix isolation in
structlog.contextvars. #302 - The default configuration and loggers are pickleable again. #301
20.2.0 - 2020-12-31
- 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
- Accessing the
_contextattribute of a bound logger is now deprecated. Please use the newstructlog.get_context().
-
structlog has now type hints for all of its APIs! Since structlog is highly dynamic and configurable, this led to a few concessions like a specialized
structlog.stdlib.get_logger()whose only difference tostructlog.get_logger()is that it has the correct type hints.We consider them provisional for the time being – that means the backwards-compatibility does not apply to them in its full strength until we feel we got it right. Please feel free to provide feedback! #223, #282
-
Added
structlog.make_filtering_loggerthat can be used likeconfigure(wrapper_class=make_filtering_bound_logger(logging.INFO)). It creates a highly optimized bound logger whose inactive methods only consist of areturn None. This is now also the default logger. -
As a complement,
structlog.stdlib.add_log_level()can now additionally be imported asstructlog.processors.add_log_levelsince it just adds the method name to the event dict. -
Added
structlog.BytesLoggerto avoid unnecessary encoding round trips. Concretely this is useful with orjson which returns bytes. #271 -
The final processor now also may return bytes that are passed untouched to the wrapped logger.
-
structlog.get_context()allows you to retrieve the original context of a bound logger. #266, -
Added
structlog.testing.CapturingLoggerfor more unit testing goodness. -
Added
structlog.stdlib.AsyncBoundLoggerthat executes logging calls in a thread executor and therefore doesn't block. #245
-
The default bound logger (
wrapper_class) if you don't configure structlog has changed. It's mostly compatible with the old one but a few uncommon methods likelog,failure, orerrdon't exist anymore.You can regain the old behavior by using
structlog.configure(wrapper_class=structlog.BoundLogger).Please note that due to the various interactions between settings, it's possible that you encounter even more errors. We strongly urge you to always configure all possible settings since the default configuration is not covered by our backwards-compatibility policy.
-
structlog.processors.add_log_level()is now part of the default configuration. -
structlog.stdlib.ProcessorFormatterno longer uses exceptions for control flow, allowingforeign_pre_chainprocessors to usesys.exc_info()to access the real exception.
structlog.PrintLoggernow supportscopy.deepcopy(). #268
20.1.0 - 2020-01-28
- 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.
- Added a new module
structlog.contextvarsthat allows to have a global but context-local structlog context the same way as withstructlog.threadlocalsince 19.2.0. #201, #236 - Added a new module
structlog.testingfor first class testing support. The first entry is the context managercapture_logs()that allows to make assertions about structured log calls. #14, #234 - Added
structlog.threadlocal.unbind_threadlocal(). #239
- The logger created by
structlog.get_logger()is not detected as an abstract method anymore, when attached to an abstract base class. #229 - Colorama isn't initialized lazily on Windows anymore because it breaks rendering. #232, #242
19.2.0 - 2019-10-16
-
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 structlog will break under 3.4 anytime soon, but we don't test it anymore.
- Full Python 3.8 support for
structlog.stdlib. - Added more pass-through properties to
structlog.stdlib.BoundLogger. To makes it easier to use it as a drop-in replacement forlogging.Logger. #198 - Added new processor
structlog.dev.set_exc_info()that will setexc_info=Trueif the method's name isexceptionandexc_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,structlog.get_logger().exception("hi")in anexceptblock would not print the exception without passingexc_info=Trueto it explicitly. #130, #173, #200, #204 - Added a new thread-local API that allows binding values to a thread-local context explicitly without affecting the default behavior of
bind(). #222, #225 - Added pass_foreign_args argument to
structlog.stdlib.ProcessorFormatter. It allows to pass a foreign log record's args attribute to the event dictionary under thepositional_argskey. #228
structlog.stdlib.ProcessorFormatternow takes a logger object as an optional keyword argument. This makesProcessorFormatterwork properly withstuctlog.stdlib.filter_by_level(). #219structlog.dev.ConsoleRenderernow callsstr()on the event value. #221
-
structlog.dev.ConsoleRenderernow uses no colors by default, if Colorama is not available. #215 -
structlog.dev.ConsoleRenderernow initializes Colorama lazily, to prevent accidental side-effects just by importing structlog. #210 -
A best effort has been made to make as much of structlog pickleable 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.processor.TimeStamper,structlog.BoundLogger,structlog.PrintLoggerandstructlog.dev.ConsoleRendererhave been made pickleable. Please report if you need any another class fixed. #126
19.1.0 - 2019-02-02
structlog.ReturnLoggerandstructlog.PrintLoggernow have afatal()log method. #181
- As announced in 18.1.0,
pip install -e .[dev]now installs all development dependencies. Sorry for the inconveniences this undoubtedly will cause! - structlog now tolerates passing through
dicts to stdlib logging. #187, #188, #189
- Under certain (rather unclear) circumstances, the frame extraction could throw an
SystemError: error return without exception set. A workaround has been added. #174
18.2.0 - 2018-09-05
- Added
structlog.stdlib.add_log_level_number()processor that adds the level number to the event dictionary. Can be used to simplify log filtering. #151 structlog.processors.JSONRenderernow allows for overwriting the default argument of its serializer. #77, #163- Added
try_unbind()that works likeunbind()but doesn't raise aKeyErrorif one of the keys is missing. #171
18.1.0 - 2018-01-27
-
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 structlog in your normal dependencies and additionally a
structlog[dev]for development (pipwill report an error).
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 forConsoleRenderer.get_default_level_styles()for usage. #139- Added
structlog.is_configured()to check whether or not structlog has been configured. - Added
structlog.get_config()to introspect current configuration.
- Empty strings are valid events now. #110
structlog.stdlib.BoundLogger.exception()now uses theexc_infoargument if it has been passed instead of setting it unconditionally toTrue. #149- Default configuration now uses plain
dicts on Python 3.6+ and PyPy since they are ordered by default.
- Do not encapsulate Twisted failures twice with newer versions of Twisted. #144
17.2.0 - 2017-05-15
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 beFalsetherefore it's the default. #109
structlog.stdlib.add_logger_name()now works instructlog.stdlib.ProcessorFormatter'sforeign_pre_chain. #112- Clear log record args in
structlog.stdlib.ProcessorFormatterafter rendering. This fix is for you if you tried to use it and gotTypeError: not all arguments converted during string formattingexceptions. #116, #117
17.1.0 - 2017-04-24
The main features of this release are massive improvements in standard library's logging integration.
Have a look at the updated standard library chapter on how to use them!
Special thanks go to Fabian Büchler, Gilbert Gilb's, Iva Kaneva, insolite, and sky-code, that made them possible.
- Added
structlog.stdlib.render_to_log_kwargs(). This allows you to uselogging-based formatters to take care of rendering your entries. #98 - Added
structlog.stdlib.ProcessorFormatterwhich does the opposite: This allows you to run structlog processors on arbitrarylogging.LogRecords. #79, #105 - Added repr_native_str to
structlog.processors.KeyValueRendererandstructlog.dev.ConsoleRenderer. This allows for human-readable non-ASCII output on Python 2 (repr()on Python 2 behaves likeascii()on Python 3 in that regard). As per compatibility policy, it's on (original behavior) inKeyValueRendererand off (human-friendly behavior) inConsoleRenderer. #94 - Added colors argument to
structlog.dev.ConsoleRendererand made it the default renderer. #78
- 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 backwards-compatibility policy that explicitly excludes default settings. - UNIX epoch timestamps from
structlog.processors.TimeStamperare more precise now. - Positional arguments are now removed even if they are empty. #82
- Fixed bug with Python 3 and
structlog.stdlib.BoundLogger.log(). Error log level was not reproducible and was logged as exception one time out of two. #92
16.1.0 - 2016-05-24
-
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.
- Added a
drop_missingargument toKeyValueRenderer. Ifkey_orderis used and a key is missing a value, it's not rendered at all instead of being rendered asNone. #67
- 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
16.0.0 - 2016-01-28
- Added
structlog.dev.ConsoleRendererthat renders the event dictionary aligned and with colors. - Added
structlog.processors.UnicodeDecoderthat will decode all byte string values in an event dictionary to Unicode. - Added
serializerparameter tostructlog.processors.JSONRendererwhich allows for using different (possibly faster) JSON encoders than the standard library.
structlog.processors.ExceptionPrettyPrinterandstructlog.processors.format_exc_infonow support passing of Exceptions on Python 3.- six is now used for compatibility.
- The context is now cleaned up when exiting
structlog.threadlocal.tmp_bindin case of exceptions. #64 - Be more more lenient about missing
__name__s. #62
15.3.0 - 2015-09-25
- Officially support Python 3.5.
- Added
structlog.ReturnLogger.failureandstructlog.PrintLogger.failureas preparation for the new Twisted logging system.
- Tolerate frames without a
__name__, better. #58
15.2.0 - 2015-06-10
- Added option to specify target key in
structlog.processors.TimeStamperprocessor. #51
- 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.
- Better support of
logging.Logger.exceptionwithin structlog. #52
- Prevent Twisted's
log.errfrom quoting strings rendered bystructlog.twisted.JSONRenderer.
15.1.0 - 2015-02-24
- Tolerate frames without a
__name__when guessing callsite names.
15.0.0 - 2015-01-23
- Added
structlog.stdlib.add_log_levelandstructlog.stdlib.add_logger_nameprocessors. #44 - Added
structlog.stdlib.BoundLogger.log. #42 - Added
structlog.stdlib.BoundLogger.exception. #22
- Pass positional arguments to stdlib wrapped loggers that use string formatting. #19
- structlog is now dually licensed under the Apache License, Version 2 and the MIT license. Therefore it is now legal to use structlog with GPLv2-licensed projects. #28
0.4.2 - 2014-07-26
- 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
- Test Twisted-related code on Python 3 (with some caveats).
- 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.from structlog import *works now (but you still shouldn't use it).
0.4.1 - 2013-12-19
- Don't cache proxied methods in
structlog.threadlocal._ThreadLocalDictWrapper. This doesn't affect regular users.
- Various doc fixes.
0.4.0 - 2013-11-10
- Added
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 - Add
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 (for example, function names, line numbers) extraction for wrapped stdlib loggers. #5
0.3.2 - 2013-09-27
- Fix stdlib's name guessing.
0.3.1 - 2013-09-26
- Added forgotten
structlog.processors.TimeStamperto API documentation.
0.3.0 - 2013-09-23
- 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.stdlib.BoundLogger. structlog.ReturnLoggernow allows arbitrary positional and keyword arguments.- Add Twisted-specific BoundLogger that has an explicit API instead of intercepting unknown method calls.
See
structlog.twisted.BoundLogger. - Allow logger proxies that are returned by
structlog.get_loggerandstructlog.wrap_loggerto cache the BoundLogger they assemble according to configuration on first use. See the chapter on performance and thecache_logger_on_first_useargument ofstructlog.configureandstructlog.wrap_logger. - 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
structlog.BoundLoggerBase.
0.2.0 - 2013-09-17
- Add
key_orderoption tostructlog.processors.KeyValueRendererfor more predictable log entries with anydictclass. - Enhance Twisted support by offering JSONification of non-structlog log entries.
- Allow for custom serialization in
structlog.twisted.JSONRendererwithout abusing__repr__.
- Promote to stable, thus henceforth a strict backwards-compatibility policy is put into effect.
structlog.PrintLoggernow uses proper I/O routines and is thus viable not only for examples but also for production.
0.1.0 - 2013-09-16
Initial release.