diff --git a/Example/WSLoggerExample/Logger.swift b/Example/WSLoggerExample/Logger.swift index ec0e096..0ff3bd2 100644 --- a/Example/WSLoggerExample/Logger.swift +++ b/Example/WSLoggerExample/Logger.swift @@ -60,3 +60,8 @@ func logEntryIf(condition: Bool, message: String, level: LogLevel, className: St } logEntry(message, level: level, className: className, fileName: fileName, line: line, function: function) } + +func logError(error: ErrorType, className: String = "", fileName: NSString = #file, line: Int = #line, function: String = #function) { + let e = error as NSError + logEntry(e.localizedDescription, level: .Error, customAttributes: ["Code": e.code, "Domain": e.domain], className: className, fileName: fileName, line: line, function: function) +} diff --git a/Example/WSLoggerExample/ViewController.swift b/Example/WSLoggerExample/ViewController.swift index 12d73d8..546c54f 100644 --- a/Example/WSLoggerExample/ViewController.swift +++ b/Example/WSLoggerExample/ViewController.swift @@ -16,6 +16,7 @@ class ViewController: UIViewController, Loggable { logEntry(NSUUID().UUIDString, message: "App has started", level: .Info) logEntryIf(true, message: "App is not ready", level: .Warning) logEntryIf(false, message: "App is ready", level: .Warning) + logError(NSError.init(domain: "co.whitesmith.WSLoggerExample", code: 100, userInfo: [NSLocalizedDescriptionKey: "App is not running"])) } class func register() {