Open
Description
As a maintainer of a package using swift-log, we want to make an implementation such that if the logging system hasn't been bootstrapped by package clients, then our loggers will use some specific log handler (an OS handler implementation in our case).
I think the API itself would be a bit simple on the Logger
s itself, but can foresee ambiguity issues with the trailing closure. I admit I'm also unsure about the performance of making the bootstrap checks, but ultra-fast performance isn't a large concern within our package.
struct Logger {
init(label: String, ifNotBootstrappedFactory: (String) -> any LogHandler)
}
Or, if the LoggingSystem
somehow exposed its own, but newly separate and optional, factory
instance we would be able to check within the existing local factory
inits, just an idea.
let logger = Logger(label: "mylogger") { label in
if let bootstrapped = LoggingSystem.factory {
return bootstrapped(label)
} else {
return MyLogHandler(label)
}
}
Metadata
Metadata
Assignees
Labels
No labels