Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// for example, for debugging messages in `ViewController.swift`
#if DEBUG
private let log = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "ViewController")
#else
private let log = OSLog.disabled
#endif
// and then:
//
// 1. Use `.debug` log for debugging messages, only shown if configuration is set to show debugging messages
// (and it's a memory-only log, by default).
//
// 2. Use `%{public}@" for strings that should be logged, but omit the `{public}` if not.
func foo(message: String) {
os_log(.debug, log: log, "%{public}@ message: %@", #function, message)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.