d22556d04e89703da67d754e70253949a58d7b09
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.
SwiftLog OSLog
A OSLog ([unified logging][unfied-logging]) backend implementation for SwiftLog (swift-log).
It maps the label parameter of [SwiftLog (swift-log) to the subsystem and
category parameter of OSLog. It even allows the use of the bundle
identifier - if any as a value for the subsystem parameter.
Installation
To use this library in your project, add it to the package dependencies:
.package(url: "https://github.com/astzweig/swift-log-oslog", from: "1.0.0")
and add it as a dependency on the specific target:
.target(
name: "YourTarget",
dependencies: [
.product(name: "LoggingOSLog", package: "swift-log-oslog")
]
)
Basic Usage
// Import the logging API and this backend implementation
import Logging
#if canImport(Darwin)
import LoggingOSLog
#endif
// Later, in your application initialization code
func init() {
// ...
#if canImport(Darwin)
LoggingSystem.bootstrap(LoggingOSLog.init)
#endif
// Start creating loggers
let loggers: [String: Logger] = [
"main": Logger(label: "com.example.yourapp.Main"),
"mail": Logger(label: "com.example.yourapp.Mail System"),
]
}
Languages
Swift
100%