structlog v21.2.0 Release Notes
Release Date: 2021-10-12 // over 2 years ago-
Backward-incompatible changes:
- ๐ To implement pretty exceptions (see Changes below),
structlog.dev.ConsoleRenderer
now formats exceptions itself.
Make sure to remove
format_exc_info
from your processor chain if you configurestructlog
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 eitherrich
orbetter-exceptions
is installed), a warning will be raised and the exception will be renderered without prettyfication.๐ Deprecations: ^
none
๐ Changes: ^
structlog
is now importable ifsys.stdout
isNone
(e.g. when running usingpythonw
).#313 <https://github.com/hynek/structlog/issues/313>
_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 <https://github.com/hynek/structlog/pull/331>
_#337 <https://github.com/hynek/structlog/pull/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.Token
\s, allowing you to reset values using the newstructlog.contextvars.reset_contextvars()
.#339 <https://github.com/hynek/structlog/pull/339>
_- ๐ง Exception rendering in
structlog.dev.ConsoleLogger
is now configurable using theexception_formatter
setting. If either therich <https://github.com/willmcgugan/rich>
_ or thebetter-exceptions <https://github.com/qix-/better-exceptions>
_ package is present,structlog
will use them for pretty-printing tracebacks.rich
takes precedence overbetter-exceptions
if both are present.
This only works if
format_exc_info
is absent in the processor chain.#330 <https://github.com/hynek/structlog/pull/330>
_#349 <https://github.com/hynek/structlog/pull/349>
_- ๐ All use of
colorama
on non-Windows systems has been excised. Thus, colors are now enabled by default instructlog.dev.ConsoleRenderer
on non-Windows systems. You can keep usingcolorama
to customize colors, of course.#345 <https://github.com/hynek/structlog/pull/345>
_ - The final processor can now return a
bytearray
(additionally tostr
andbytes
).#344 <https://github.com/hynek/structlog/issues/344>
_
- ๐ To implement pretty exceptions (see Changes below),