Created
December 28, 2020 00:19
-
-
Save jxq0/185112cb77781715968af4d0fe5bbe09 to your computer and use it in GitHub Desktop.
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
class FMLog: NSObject { | |
let myOsLog = OSLog(subsystem: "com.jiaxq.fotomete", category: "") | |
func debug( | |
_ msg: String, _ args: CVarArg..., file: String = #file, line: Int = #line | |
) { | |
let logMsg = String(format: msg, arguments: args) | |
log(logMsg, type: .debug, file: file, line: line) | |
} | |
func info( | |
_ msg: String, _ args: CVarArg..., file: String = #file, line: Int = #line | |
) { | |
let logMsg = String(format: msg, arguments: args) | |
log(logMsg, type: .info, file: file, line: line) | |
} | |
func error( | |
_ msg: String, _ args: CVarArg..., file: String = #file, line: Int = #line | |
) { | |
let logMsg = String(format: msg, arguments: args) | |
log(logMsg, type: .error, file: file, line: line) | |
} | |
func fault( | |
_ msg: String, _ args: CVarArg..., file: String = #file, line: Int = #line | |
) { | |
let logMsg = String(format: msg, arguments: args) | |
log(logMsg, type: .fault, file: file, line: line) | |
} | |
func log(_ msg: String, type: OSLogType, file: String, line: Int) { | |
os_log( | |
"%s:%d %s", log: myOsLog, type: type, | |
(file as NSString).lastPathComponent, line, msg) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment