I’m trying to determine the state of the Logging packages on Swift in general, and in particular on Apple platforms.
As far as I understand, on non-Apple platform, the default logging package would be Apple’s
swift-log. It has customisable loggers and works well.
This is where things get weird.
My latest (but dated) news on the subject was that on these platforms, logging should be done using Apple’s unified logging, namely
In theory there is nothing stopping us from using
swift-log in an Apple project with an
os_log logger. However, the
swift-log repo tells us we should not do that otherwise we lose performance, and we cannot use the special
public modifiers on the string formatting (GitHub - apple/swift-log: A Logging API for Swift).
Question 1: Is this still true?
All of this was a while ago.
Apparently now on latest SDKs for Apple platforms there is a
Logger struct readily available. I guess (and doc says so) we should use this.
Logger supports privacy level in string interpolation, which makes it somewhat incompatible with
Question 2: Are there any other differences between the
Logger from Apple and the one in
Question 3: How are we supposed to log properly on cross-platform projects?
Because of the privacy-level stuff from Apple’s
Logger, I guess we cannot cheat in any way to have a
Logger working with both systems. We have to commit to one logger, and because
swift-log works everywhere we should use that one and forget about privacy-levels, at least while they have not been implemented in