-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Description
Here's an issue about two related problems:
Logger configuration
Several people have asked on slack about logger configuration, with the number 1 question being how to enable debug logging.
For the moment the answer is something like using Logging; global_logger(SimpleLogger(STDERR, Logging.Debug)), but this is pretty unsatisfactory:
- It's verbose and unfriendly
- When
ConsoleLoggeror something like it is merged (see ConsoleLogger for more fully featured log printing #25370), they'll be baking in the use ofSimpleLoggerrather than configuring the current logger.
We need a simple way to configure the current logger. Ideally to support a few basic desires:
- Easily enable debug logging
- Log level filtering in general
- Per-module log level filtering as would by typical in logging systems like python's.
Because stdlib Logging currently has no opinion about the internal structure of a Logger, I think we just need a neat way of applying some configuration options to either the current, global or (task) local logger. Perhaps just configure_logging(logger::AbstractLogger; kwargs) with configure_logging(:global; ...) applying to the global logger, configure_logging(::Task; ...) applying to a task local logger, and configure_logging(; ...) = configure_logging(current_logger(); ...)?
Logger installation
The current with_logger interface for installing a task-local logger doesn't allow us to install or remove a task local logger permanently. To do that, one needs to dig into the internals which is clearly nasty. To fix this global_logger probably needs a companion which applies to tasks. Or perhaps we unify things to have Logging.logger!(context, logger) set the logger for context to logger:
Logging.logger!(:global, logger) # set global logger
Logging.logger!(some_task, logger) # set task local loggerSimilarly, Logging.logger(context) would get the logger installed for context.