mirror of
https://github.com/apple/swift-log
synced 2026-11-24 03:47:49 +00:00
### Motivation: The two deprecated `LogHandler` defaults forward to each other: the source-carrying `log(level:message:metadata:source:file:function:line:)` default calls `log(event:)`, whose default calls the source-carrying method, and the SwiftLog 1.0 `log(level:message:metadata:file:function:line:)` default calls the source-carrying method. A handler that implements only `log(event:)`, as the protocol documentation asks, therefore recurses until the stack overflows whenever anything calls the 1.0 method on it. Handlers written against SwiftLog 1.0 that wrap another handler and forward through the 1.0 method reach this path. Differs from #248, where the handler implemented no log method at all. ### Modifications: The 1.0 default builds a `LogEvent` and calls `log(event:)` directly. The source is still the module derived from `file`, as before. Two tests in `CompatibilityTest`: the 1.0 method reaching an event-only handler (SIGSEGV at `main` before the change) and reaching a source-only handler. ### Result: A `LogHandler` implementing only `log(event:)` can be called through every deprecated entry point. No source-breaking change; both deprecated defaults remain. Verified on Linux with Swift 6.1.2: `swift test -Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable` (166 tests) and `swift-format lint --strict` on the changed files. Found by an automated audit loop (Claude); patch and description reviewed by me. --------- Co-authored-by: Vladimir Kukushkin <kukushechkin@apple.com>