Summary
swift-log allows callers to pass explicit file, function, and line into Logger APIs, but OSLog / unified logging ignores these as call-site metadata when used via an OSLog-backed LogHandler. This creates a mismatch between swift-log's abstraction (which can carry a “logical call site”) and what unified logging actually exposes in tools like Xcode and Console.
I’d like to request that this gap be addressed, either by:
- defining a way for an OSLog-backed handler to use the logical call site as true call-site metadata, or
- coordinating with the unified logging team to introduce the necessary OS feature/API,
- and then surfacing that capability in
swift-log as appropriate.
Current behavior
-
Logger.log and the convenience methods accept file, function, and line parameters (defaulting to #fileID, #function, #line) and pass them through to the configured LogHandler. This makes it possible for many backends (stdout, custom sinks, etc.) to treat those as the “logical call site.” [web:6][web:23]
-
For a backend that uses OSLog/unified logging, the OS determines the call site from the actual frame where os_log / OSLog.Logger is invoked. There is no public API to override that with the file/line values provided to swift-log; those values can only be encoded as payload/metadata. [web:34][web:36]
-
As a result, in Xcode / Console:
- Logs are attributed to the internal logging frame (often inside a library or backend), not to the original caller that invoked
Logger.
- “Jump to source” and other tooling cannot point to the logical origin that
swift-log already knows about.
Use case
A typical flow:
- User code emits a domain event and logs it via
Logger, optionally passing custom file/function/line to describe the logical origin.
- The event/log travels through multiple layers and third-party libraries that I do not control.
- A logging/analytics layer at the bottom uses an OSLog-based
LogHandler to write into unified logging.
- In Xcode/Console, I would like to see the event attributed to the logical call site in my module, not to the internal logging code in a dependency.
swift-log already gives me a way to represent that logical call site (the parameters), but unified logging currently does not let an OSLog backend treat those as the real call-site metadata.
Why this seems like a mismatch
- From a
swift-log perspective, the API clearly models call-site information as data that can be passed around and potentially used by backends.
- From a unified logging perspective, the call site is effectively fixed to the physical
os_log / OSLog.Logger call frame, and cannot be influenced by higher-level abstractions such as swift-log.
- This means that the most capable and recommended logging backend on Apple platforms (unified logging) cannot fully leverage the call-site information that
swift-log is already designed to carry.
Requested feature / questions
I understand that swift-log itself cannot modify unified logging behavior, but given that this is an Apple-owned package that is meant to integrate well with Apple platforms, I’d like to ask:
-
Would you consider it in scope for swift-log to support an OSLog-based backend that can preserve or set the logical call site, provided unified logging exposes an appropriate API?
-
If this requires new OS / compiler support (e.g. a way for OSLog to accept an explicit logical call site separate from the physical frame), is this something the swift-log maintainers could raise or coordinate with the relevant Apple internal teams?
Motivation
- Align the capabilities of
swift-log (carrying call-site info as data) with the capabilities of the primary Apple logging backend (OSLog).
- Make it possible for developers to build layered architectures (events flowing through multiple modules/libraries) while still having unified logging tooling point back to the logical origin in their own code.
- Provide a clearer and more powerful story for using
swift-log as the abstraction layer on top of unified logging on Apple platforms.
I realize that fulfilling this request likely requires work outside this repository, but having this mismatch documented and tracked here would help clarify expectations and potentially guide future integration between swift-log and unified logging.
Summary
swift-logallows callers to pass explicitfile,function, andlineintoLoggerAPIs, but OSLog / unified logging ignores these as call-site metadata when used via an OSLog-backedLogHandler. This creates a mismatch betweenswift-log's abstraction (which can carry a “logical call site”) and what unified logging actually exposes in tools like Xcode and Console.I’d like to request that this gap be addressed, either by:
swift-logas appropriate.Current behavior
Logger.logand the convenience methods acceptfile,function, andlineparameters (defaulting to#fileID,#function,#line) and pass them through to the configuredLogHandler. This makes it possible for many backends (stdout, custom sinks, etc.) to treat those as the “logical call site.” [web:6][web:23]For a backend that uses OSLog/unified logging, the OS determines the call site from the actual frame where
os_log/OSLog.Loggeris invoked. There is no public API to override that with thefile/linevalues provided toswift-log; those values can only be encoded as payload/metadata. [web:34][web:36]As a result, in Xcode / Console:
Logger.swift-logalready knows about.Use case
A typical flow:
Logger, optionally passing customfile/function/lineto describe the logical origin.LogHandlerto write into unified logging.swift-logalready gives me a way to represent that logical call site (the parameters), but unified logging currently does not let an OSLog backend treat those as the real call-site metadata.Why this seems like a mismatch
swift-logperspective, the API clearly models call-site information as data that can be passed around and potentially used by backends.os_log/OSLog.Loggercall frame, and cannot be influenced by higher-level abstractions such asswift-log.swift-logis already designed to carry.Requested feature / questions
I understand that
swift-logitself cannot modify unified logging behavior, but given that this is an Apple-owned package that is meant to integrate well with Apple platforms, I’d like to ask:Would you consider it in scope for
swift-logto support an OSLog-based backend that can preserve or set the logical call site, provided unified logging exposes an appropriate API?If this requires new OS / compiler support (e.g. a way for OSLog to accept an explicit logical call site separate from the physical frame), is this something the
swift-logmaintainers could raise or coordinate with the relevant Apple internal teams?Motivation
swift-log(carrying call-site info as data) with the capabilities of the primary Apple logging backend (OSLog).swift-logas the abstraction layer on top of unified logging on Apple platforms.I realize that fulfilling this request likely requires work outside this repository, but having this mismatch documented and tracked here would help clarify expectations and potentially guide future integration between
swift-logand unified logging.