Skip to content

Instantly share code, notes, and snippets.

@foffer
Created July 23, 2017 20:22
Show Gist options
  • Save foffer/c4cb4ab19c805e0071be9bd2329231c4 to your computer and use it in GitHub Desktop.
Save foffer/c4cb4ab19c805e0071be9bd2329231c4 to your computer and use it in GitHub Desktop.
Wrapper on os.log
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)
}
}
@danthorpe
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment