Metadata shall be machine readable (see SwiftLog/Structured Logging) and the previous metadata serialization erased the nesting structure. The JSON output ensures that the metadata can be quickly analyzed by either a copy and paste into a JSON editor or a small CLI pipeline. See https://swiftpackageindex.com/apple/swift-log/1.10.1/documentation/logging/002-structuredlogging for more information on metadata.
29 lines
715 B
Swift
29 lines
715 B
Swift
import Testing
|
|
import Logging
|
|
import LoggingOSLog
|
|
|
|
@Test func isConstructable() {
|
|
let _ = LoggingOSLog(subsystem: "de.astzweig.app", category: "Image Processing")
|
|
}
|
|
|
|
@Test func canAddAsLoggingBackend() {
|
|
LoggingSystem.bootstrap(LoggingOSLog.init)
|
|
}
|
|
|
|
@Test func canLogMessage() {
|
|
let logger = Logging.Logger(label: "de.astzweig.loggingoslog.Test")
|
|
logger.info("Test message")
|
|
}
|
|
|
|
@Test func canLogMessageWithMetadata() {
|
|
let logger = Logging.Logger(label: "de.astzweig.loggingoslog.Test")
|
|
logger.info("Test message", metadata: [
|
|
"request.id": "20140801",
|
|
"request.dirname": "\"Impossible\"",
|
|
"request.authorization": [
|
|
"bearer": "empty"
|
|
],
|
|
"request.values": ["1", "rootID", ["key": "value"]]
|
|
])
|
|
}
|