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:
T. R. Bernstein
2026-05-04 01:27:57 +02:00
committed by GitHub
2 changed files with 9 additions and 2 deletions

View File

@@ -6,8 +6,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-log",
"state" : {
"revision" : "bbd81b6725ae874c69e9b8c8804d462356b55523",
"version" : "1.10.1"
"revision" : "5073617dac96330a486245e4c0179cb0a6fd2256",
"version" : "1.12.0"
}
}
],

View File

@@ -84,6 +84,13 @@ public struct LoggingOSLog: LogHandler {
let message = messageParts.compactMap { $0 }.joined(separator: "")
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.