You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.2 KiB
48 lines
1.2 KiB
6 years ago
|
// Copyright © 2015 Abhishek Banthia
|
||
|
|
||
|
import Cocoa
|
||
4 years ago
|
import os
|
||
6 years ago
|
import os.log
|
||
6 years ago
|
import os.signpost
|
||
6 years ago
|
|
||
4 years ago
|
public class Logger: NSObject {
|
||
4 years ago
|
let logObjc = OSLog(subsystem: "com.abhishek.Clocker", category: "app")
|
||
|
|
||
4 years ago
|
public class func log(object annotations: [String: Any]?, for event: NSString) {
|
||
4 years ago
|
if #available(OSX 10.14, *) {
|
||
4 years ago
|
os_log(.default, "[%@] - [%@]", event, annotations ?? [:])
|
||
|
}
|
||
|
}
|
||
|
|
||
4 years ago
|
public class func info(_ message: String) {
|
||
4 years ago
|
if #available(OSX 10.14, *) {
|
||
4 years ago
|
os_log(.info, "%@", message)
|
||
4 years ago
|
}
|
||
4 years ago
|
}
|
||
6 years ago
|
}
|
||
6 years ago
|
|
||
|
@available(OSX 10.14, *)
|
||
4 years ago
|
public class PerfLogger: NSObject {
|
||
6 years ago
|
static var panelLog = OSLog(subsystem: "com.abhishek.Clocker",
|
||
|
category: "Open Panel")
|
||
|
static let signpostID = OSSignpostID(log: panelLog)
|
||
6 years ago
|
|
||
4 years ago
|
public class func disable() {
|
||
6 years ago
|
panelLog = .disabled
|
||
|
}
|
||
6 years ago
|
|
||
4 years ago
|
public class func startMarker(_ name: StaticString) {
|
||
6 years ago
|
os_signpost(.begin,
|
||
|
log: panelLog,
|
||
|
name: name,
|
||
|
signpostID: signpostID)
|
||
6 years ago
|
}
|
||
|
|
||
4 years ago
|
public class func endMarker(_ name: StaticString) {
|
||
6 years ago
|
os_signpost(.end,
|
||
|
log: panelLog,
|
||
|
name: name,
|
||
|
signpostID: signpostID)
|
||
6 years ago
|
}
|
||
|
}
|