mirror of
https://github.com/apple/swift-log
synced 2026-11-22 03:40:39 +00:00
This proposal adds task-local logger storage so that metadata can accumulate across async call stacks without threading a `Logger` through every function signature. ### Motivation: Metadata propagation requires threading a logger through every layer. Every function on the path from request ingress to the bottom of the call stack has to accept, mutate, and forward a `Logger`. Libraries must choose between polluting their public API with a `logger:` parameter and losing all the caller's context. There is no third option today. ### Modifications: - New API surface for reading and modifying the `@TaskLocal` `Logger` instance added. - Best practices on how to correctly propagate logger into libraries updated with `Logger.current` API. ### Result: Users can now automatically propagate accumulated metadata into libraries without explicitly passing loggers through the API boundaries. --------- Co-authored-by: Franz Busch <privat@franz-busch.de>