Created
July 23, 2017 20:22
-
-
Save foffer/c4cb4ab19c805e0071be9bd2329231c4 to your computer and use it in GitHub Desktop.
Wrapper on os.log
This file contains 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.log | |
struct Logger { | |
private let logger: OSLog | |
enum LogCategory:String { | |
case uploads | |
case downloads | |
case realm | |
case auth | |
case general | |
} | |
init(_ category: LogCategory) { | |
logger = OSLog(subsystem: BUNDLE_IDENTIFIER, category: category.rawValue) | |
} | |
func info(_ msg:StaticString, _ args:CVarArg) { | |
os_log(msg, log: logger, type: .info, args) | |
} | |
func error(_ msg: StaticString, _ args:CVarArg) { | |
os_log(msg, log: logger, type: .error, args) | |
} | |
func debug(_ msg: StaticString, _ args: CVarArg) { | |
os_log(msg, log: logger, type: .debug, args) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Okay - nice, well you can use this internally inside of ProcedureKit by setting it as the custom logging function. See the docs here which are a little bit out-of-date, but all still relevant.
Then you don't need to inject your own
Logger
types into your procedures manually.