This is bug-fix release due to overly-zealous string interpolation in the native bound logger. You can now pass anything as event again (but it really should be a string) and log % signs as long as you don't pass positional arguments.
Special Thanks
This release would not be possible without my generous sponsors! Thank you to all of you making sustainable maintenance possible! If you would like to join them, go to https://github.com/sponsors/hynek and check out the sweet perks!
Not to forget 2 more amazing humans who chose to be generous but anonymous!
Full Changlog
Changed
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
Fixed
String interpolation doesn't cause crashes in filtered log call anymore. #478
22.2.0
Highlights
This is another (too) big release, but before I go into new features, allow me to beg you to check out structlog's documentation. I've spent easily half of the time on bringing is up to date, restructuring, and adding usage recipes. Not new in this release, but did you know that the standard library chapter has flowcharts that give you as visual explanations of how the various methods work? This is usually the biggest sticking point when starting to use structlog.
Feature-wise the big thing is that structlog's internal (and extremely fast) loggers (the one created using structlog.make_filtering_bound_logger() got two new features that people have asked for forever:
String interpolation: log.info("hello %s!", "world") works now!
Async! Each logging method has an async version: await log.ainfo("hello %s!", "world") is the same thing as above, but async.
Special Thanks
This release would not be possible without my generous sponsors! Thank you to all of you making sustainable maintenance possible! If you would like to join them, go to https://github.com/sponsors/hynek and check out the sweet perks!
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
Fixed
String interpolation doesn't cause crashes in filtered log call anymore.
#478
Accessing package metadata as attributes on the structlog module is deprecated (e.g. structlog.__version__).
Please use importlib.metadata instead (for Python 3.7: the importlib-metadata PyPI package).
The structlog.types module is now deprecated in favor of the structlog.typing module.
It seems like the Python typing community is settling on this name.
Added
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
FilteringBoundLogger now also has support for asyncio-based logging.
Instead of a wrapper class like structlog.stdlib.AsyncBoundLogger, async equivalents have been added for all logging methods.
So instead of log.info("hello") you can also write await log.ainfo("hello") in async functions and methods.
This seems like the better approach and if it's liked by the community, structlog.stdlib.BoundLogger will get those methods too.
#457
Changed
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.
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Bumps structlog from 21.5.0 to 22.3.0.
Release notes
Sourced from structlog's releases.
... (truncated)
Changelog
Sourced from structlog's changelog.
... (truncated)
Commits
c597108
Prepare 22.3.0968523e
Document new string interpolation behaviorfc60f2f
Add test to ensure % can be logged w/o args2134a44
Fix interpolation in filtered log calls (#478)87cdcaf
Be more defensive about string interpolation (#475)7cf81c3
Start new development cycle4d00ebf
Prepare 22.2.05dcb24d
Fix link17cb702
Grouping255de58
Use proper Tidelif URL in creditsDependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting
@dependabot rebase
.Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)