Files
swift-log/Sources/ExampleUsage/ConfigExample.swift
T
David Hart 2474d61a80 Multiple proposal improvements to the API (#41)
* Move `Logging.make` to a `Logger` initializer.
* Remove all factory initializers in example and test code.
2019-02-18 20:27:59 +01:00

22 lines
730 B
Swift

//
// THIS IS NOT PART OF THE PITCH, JUST AN EXAMPLE HOW A LOGGER USAGE LOOKS LIKE
//
import ExampleImplementation
import Foundation
import Logging
enum ConfigExample {
static func main() {
// boostrap with our config based sample implementations
let config = Config(defaultLogLevel: .info)
Logging.bootstrap({ ConfigLogHandler(label: $0, config: config) })
// run the example
let logger = Logger(label: "com.example.TestApp")
logger.trace("hello world?")
// changes the config in runtime, real implemnetations will use config files instead of in-memory config
config.set(key: "com.example.TestApp", value: .trace)
logger.trace("hello world!")
}
}