Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 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)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement