swift-log and osLog differences

Hey

In my opinion osLog ( or Logging ) is an Apple Logging framework which provides logging facilities.

And swift-log is Swift OpenSource framework which provides logging facitilies.

And on Apple platforms Apple frameworks ( osLog ) are more conveinent and performant than Swift OpenSource frameworks.

Am I right?

So, a difference between these two frameworks is that swift-log provides an open source logging analogue for Swift.

Answered by DTS Engineer in 859866022

The Apple system log API — the thing you get when you import os.log — is what I recommend if you’re developing software exclusively for Apple platforms. I have a lot of info about it in Your Friend the System Log.

SwiftLog — the open source package available here — makes a lot of sense if you’re developing open source Swift packages that run on a wide range of platforms. It has a bunch of back ends, including one that logs to the Apple system log. That back end is less than ideal because at its core it has code like this:

os_log("%{public}@", …, formedMessage as NSString)

This is problematic for two reasons:

  • It logs everything as public, which is often not the right option for client devices.
  • It logs everything as a string, which defeats the optimisations done by the system log. If you’d like to learn more about that, see this post.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

The Apple system log API — the thing you get when you import os.log — is what I recommend if you’re developing software exclusively for Apple platforms. I have a lot of info about it in Your Friend the System Log.

SwiftLog — the open source package available here — makes a lot of sense if you’re developing open source Swift packages that run on a wide range of platforms. It has a bunch of back ends, including one that logs to the Apple system log. That back end is less than ideal because at its core it has code like this:

os_log("%{public}@", …, formedMessage as NSString)

This is problematic for two reasons:

  • It logs everything as public, which is often not the right option for client devices.
  • It logs everything as a string, which defeats the optimisations done by the system log. If you’d like to learn more about that, see this post.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

swift-log and osLog differences
 
 
Q