LoggingService.swift 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. //
  2. // LoggingService.swift
  3. // LoopKit
  4. //
  5. // Created by Darin Krauss on 6/17/19.
  6. // Copyright © 2019 LoopKit Authors. All rights reserved.
  7. //
  8. import os.log
  9. public protocol Logging {
  10. /// Log a message for the specific subsystem, category, type, and optional arguments. Modeled after OSLog, but
  11. /// captures all of the necessary data in one function call per message. Note that like OSLog, the message may
  12. /// contain "%{public}" and "%{private}" string substitution qualifiers that should be observed based upon the
  13. /// OSLog rules. That is, scalar values are considered public by default, while strings and objects are considered
  14. /// private by default. The explicitly specified qualifiers override these defaults.
  15. ///
  16. /// - Parameters:
  17. /// - message: The message to log with optional string substitution. Note that like OSLog, it make contain "%{public}"
  18. /// and "%{private}" string substitution qualifiers that should be observed based upon the OSLog rules.
  19. /// - subsystem: The subsystem logging the message. Typical the reverse dot notation identifier of the framework.
  20. /// - category: The category for the message. Typically the class or extension name.
  21. /// - type: The type of the message. One of OSLogType.
  22. /// - args: Optional arguments to be substituted into the string.
  23. func log(_ message: StaticString, subsystem: String, category: String, type: OSLogType, _ args: [CVarArg])
  24. }
  25. public protocol LoggingService: Logging, Service {}
  26. public class SharedLogging {
  27. /// A shared, global instance of Logging.
  28. public static var instance: Logging?
  29. }