Configuring log level
dscoppelletti opened this issue · 5 comments
I am using Swift-Log initialized by LoggingSystem.bootstrap(StreamLogHandler.standardError)
, but on log messages with log level >= info
are shown on the console window of XCode 12.0.1.
How can I configure the log level of the log messages shown on the console?
Thanks.
OK, I figure out:
LoggingSystem.bootstrap { label in
var handler = StreamLogHandler.standardError(label: label)
handler.logLevel = Logger.Level.debug
return handler
}
I would prefer some configuration feature, for example by label
, but that's it.
Hi @dscoppelletti,
LoggingSystem.bootstrap(StreamLogHandler.standardError), but on log messages with log level >= info are shown on the console window of XCode 12.0.1.
Oh, but that's configurable on the logger you're using, see:
// LoggingSystem.bootstrap(StreamLogHandler.standardError)
var logger = Logger(label: "...")
logger.logLevel = .debug
logger.debug("hello")
this should print this message 👍
I would prefer some configuration feature, for example by label, but that's it.
sorry to disappoint but we really only intend swift-log to be the absolute bare minimum package -- that it even ships any log handlers is already pushing it.
As such, we will not be including any "proper log handler" features such as per label configurations or similar.
We hope for the community to step up and implement these features in separate packages shipping more specialized LogHandler
implementations.
This falls in the same category as #162 where we unanimously agreed that more features must be kept out of the handlers we shipped and we must encourage more LogHandlers to be implemented.
This of it this way:
- this package is ONLY the API
- the fact that it ships any log handlers is sadly a historic artifact that we can't remove for now
- any "proper" features should be pushed into LogHandler libraries as much as possible -- we really need to build up an ecosystem or at least a few really good log handlers.
Please report back if this solves your issue and we can close the ticket?
Yeah, it's fair.
Cool, thanks for reporting/asking!