mirror of
https://github.com/apple/swift-log
synced 2026-11-24 03:47:49 +00:00
* naming proposal motivation: intuitive APIs changes: * Logger is the main API users interact with * Logging is the factory from which users get instances of Logger, via Logging.for(identifer) * LogHandler is what logging libraries implement, this is not exposed to users as its boxed in Logger * replace Logging (aka LoggerFactory) factory property with bootstrap(factory) function * rename main module to Logging since its not server only * converge examples into an Examples module open questions: * Logging.make or Logging.for * is Logging.for(object: Any.Type) a good idea? is there a better way to get the FQN for an object?
25 lines
769 B
Swift
25 lines
769 B
Swift
import Foundation
|
|
import Logging
|
|
|
|
// this model just uses one global logger. This is similar to what IBM's Logger API uses today (except that the one
|
|
// global thing has static methods.
|
|
let logger = Logging.make("com.example.TestApp.OneGlobalLoggerExample")
|
|
|
|
enum OneGlobalLoggerExample {
|
|
static func main() {
|
|
for _ in 0 ..< 10 {
|
|
// NOTE: we can't change the log level per client because we only have one global logger
|
|
self.spawnFreshClient(uuid: UUID())
|
|
}
|
|
}
|
|
|
|
static func spawnFreshClient(uuid _: UUID) {
|
|
logger.info("we're up and running")
|
|
self.randomFunction()
|
|
}
|
|
|
|
static func randomFunction() {
|
|
logger.debug("just to say hi, here the log level / UUID do not get propagated")
|
|
}
|
|
}
|