apple / swift-log

A Logging API for Swift
https://apple.github.io/swift-log/
Apache License 2.0
3.48k stars 285 forks source link

make Logger Sendable #216

Closed weissi closed 2 years ago

weissi commented 2 years ago

Logger should be Sendable because that's required almost everywhere now :).

ktoso commented 2 years ago

Yeap sounds good -- can you send in a pr?

weissi commented 2 years ago

It's complicated. Logger obvs needs a ref to the LogHandler and LogHandler is the public protocol. So we'd need to require LogHandler to be Sendable which is SemVer major...

So want me to make it @unchecked Sendable? That kinda feels not right either. Said that I think the API docs require thread-safetey so we could do that 😬 . WDYT?

Joannis commented 2 years ago

I don't think that @unchecked Sendable is a good solution here, and I strongly believe that a semver major that requires your log handlers to be Sendable is a good move.

ffried commented 2 years ago

With Swift 5.6, LogHandler could inherit from Sendable and be annotated with @preconcurrency. This would spit out a warning on LogHandler implementations that don't fulfill the Sendable requirements.

tomerd commented 2 years ago

for visibility: https://github.com/apple/swift-log/pull/218

tomerd commented 2 years ago

resolved via https://github.com/apple/swift-log/pull/218