mirror of
https://github.com/apple/swift-log
synced 2026-11-24 03:47:49 +00:00
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:
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? {
|
||||
|
||||
Reference in new issue
Block a user