Support new LogEvent interface
SwiftLog introduced the LogEvent LogHandler API with commit 1f38a59. This commit implements that new interface.
This was contributed by FelixSFD on GitHub.
See: 1f38a59922
This commit is contained in:
@@ -6,8 +6,8 @@
|
|||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
"location" : "https://github.com/apple/swift-log",
|
"location" : "https://github.com/apple/swift-log",
|
||||||
"state" : {
|
"state" : {
|
||||||
"revision" : "bbd81b6725ae874c69e9b8c8804d462356b55523",
|
"revision" : "5073617dac96330a486245e4c0179cb0a6fd2256",
|
||||||
"version" : "1.10.1"
|
"version" : "1.12.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -84,6 +84,13 @@ public struct LoggingOSLog: LogHandler {
|
|||||||
let message = messageParts.compactMap { $0 }.joined(separator: " → ")
|
let message = messageParts.compactMap { $0 }.joined(separator: " → ")
|
||||||
self.oslogger.log(level: OSLogType.from(loggerLevel: level), "\(message, privacy: .public)")
|
self.oslogger.log(level: OSLogType.from(loggerLevel: level), "\(message, privacy: .public)")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
This function is called by [SwiftLog](https://github.com/apple/swift-log).
|
||||||
|
*/
|
||||||
|
public func log(event: LogEvent) {
|
||||||
|
self.log(level: event.level, message: event.message, metadata: event.metadata, source: event.source, file: event.file, function: event.function, line: event.line)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Use subscripts on struct instances, to add metadata for all future log messages.
|
Use subscripts on struct instances, to add metadata for all future log messages.
|
||||||
|
|||||||
Reference in New Issue
Block a user