apple / apple/swift-log

Introduce #dsoHandle and args in addition to #file, #function and #line

Open
#72 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
4k
Forks
344
Avg merge
1d 15h
Merged PRs (30d)
4

Description

Hello,

This is more like a pitch, not an issue at all, and it’s probably too late. However, I’d like to have a custom handler for `os_log`, something like this works fine for debugging purposes, even though it’s using private API:

```swift
import os
import _SwiftOSOverlayShims

...

func log(
level: Logger.Level, message: Logger.Message, metadata: Logger.Metadata?,
file: String, function: String, line: UInt, dso: UnsafeRawPointer, args: CVarArg...)
{
let ra = _swift_os_log_return_address()
message.withUTF8Buffer { (buf: UnsafeBufferPointer) in
buf.baseAddress?.withMemoryRebound(to: CChar.self, capacity: buf.count) { str in
withVaList(args) { valist in
_swift_os_log(dso, ra, self.log_from_label(), self.type_from_level(level), message, valist)
}
}
}
}
```

Unfortunately, the current `log` signature misses `#dsoHandle` and `args`, using `#file`, `#function` and `#line` instead. What do you think about adding two more arguments to the `log` function? Or maybe you have some alternative suggestion?

Thanks in advance!

Contributor guide

Open the contributing guide

Research direction

Start with the current log function signature in swift-log and compare it with the proposed os_log bridge using #dsoHandle and args. Review the API implications and alternatives described in the issue; done means a maintainer-approved direction for changing the logging API, with its scope and acceptance criteria decided.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
observability-sre
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.