add logger API variants that take an error (#12)

motivation: easily log errors w/o converting them to string first

changes:
* add another set of logger APIs that take in an error object
* add tests and refactor testing assertions
* add autoclosure tests to make sure its resoved on when log level is appropriate
This commit is contained in:
tomer doron authored and Johannes Weiss committed 2019-01-08 20:41:03 +00:00
1 parent 5527732754
commit 19d987b6d5
9 files changed
+224 -142

No files matched your search

@@ -21,8 +21,8 @@ internal final class SimpleLogger {
self.formatter = formatter
}
public func log(level: Logging.Level, message: String, printer: (String) -> Void) {
printer("[\(self.label)] \(self.formatter.string(from: Date()))\(self.prettyMetadata.map { " \($0)" } ?? "") \(level): \(message)")
public func log(level: Logging.Level, message: String, error: Error?, printer: (String) -> Void) {
printer("[\(self.label)] \(self.formatter.string(from: Date()))\(self.prettyMetadata.map { " \($0)" } ?? "") \(level): \(message)\(error.map { " \($0)" } ?? "")")
}
public var logLevel: Logging.Level? {