@brunowernimont
Let's connect together

Embrace the new Swift Logging framework

March 16, 2021

Xcode Swift logging logger

Since iOS 14, Apple released a new logging framework that replace the not so old os_log framework introduced with iOS 10.

Create a convenient extension.

Logger+extensions.swift

import os.log

extension Logger {
    static var ui = Logger(subsystem: "be.brunowernimont.aucast", category: "ui")
}

Send log

import os.log

Logger.ui.logger.debug("\(region.identifier, privacy: .public) enter \(enter)")

Strings are considered as private by default and won’t be visible if your device isn’t plugged, to protect the user privacy.

Different logging types

There are many different logging types that you can use:

  • trace
  • debug
  • info
  • notice
  • warning
  • error
  • critical