Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. // for example, for debugging messages in `ViewController.swift`
  2.  
  3. #if DEBUG
  4. private let log = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "ViewController")
  5. #else
  6. private let log = OSLog.disabled
  7. #endif
  8.  
  9. // and then:
  10. //
  11. // 1. Use `.debug` log for debugging messages, only shown if configuration is set to show debugging messages
  12. // (and it's a memory-only log, by default).
  13. //
  14. // 2. Use `%{public}@" for strings that should be logged, but omit the `{public}` if not.
  15.  
  16. func foo(message: String) {
  17. os_log(.debug, log: log, "%{public}@ message: %@", #function, message)
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement