Skip to content

Instantly share code, notes, and snippets.

@KaQuMiQ
Created June 9, 2020 13:36
Show Gist options
  • Select an option

  • Save KaQuMiQ/245b01bbf8fef0354e2afe08e64fdce9 to your computer and use it in GitHub Desktop.

Select an option

Save KaQuMiQ/245b01bbf8fef0354e2afe08e64fdce9 to your computer and use it in GitHub Desktop.
Easy diagnostics for apple platforms
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