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>
Improve readability by extracting separate types to their own files
### Motivation:
`Logger.swift` is >2000 LoC, which makes it hard to navigate both for
contributors and users of `swift-log`. Widely different concepts, such
as concrete `LogHandler` implementations, are mixed with core types such
as `Logger.Level`. Extracting separate types should make it easier to
find what you are looking for.
Closes#441
### Modifications:
* Extract all (not `Logger`-namespaced) types from `Logging.swift` to
separate files.
* Rename `Logging.swift` to `Logger.swift`, as this is the only
remaining top-level type.
* Change `LoggingSystem.factory` from `fileprivate` to `internal` to be
accessible from `Logger.swift`.
### Result:
Each (non-private) top-level type lives in a separate file, named after
the type.
---------
Co-authored-by: Vladimir Kukushkin <kukushechkin@mac.com>