Created
June 9, 2020 13:36
-
-
Save KaQuMiQ/245b01bbf8fef0354e2afe08e64fdce9 to your computer and use it in GitHub Desktop.
Easy diagnostics for apple platforms
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| internal enum Diagnostics { | |
| internal static let logger: OSLog = OSLog(subsystem: "com.company", category: "diagnostics") | |
| @inline(__always) | |
| internal static func log(_ type: OSLogType = .debug, _ message: StaticString) { | |
| os_log(type, log: logger, message) | |
| } | |
| internal enum Signpost { | |
| @inline(__always) | |
| private static let logger: OSLog = OSLog(subsystem: "com.company", category: .pointsOfInterest) | |
| @inline(__always) | |
| internal static func begin(_ name: StaticString = #file, context: String = #function, id signpostID: OSSignpostID = OSSignpostID(log: logger)) -> () -> Void { | |
| os_signpost(.begin, log: logger, name: name, signpostID: signpostID, "%s", context) | |
| return { os_signpost(.end, log: logger, name: name, signpostID: signpostID, "%s", context) } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment