Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging configuration and installation #25404

Open
c42f opened this issue Jan 5, 2018 · 2 comments
Open

Logging configuration and installation #25404

c42f opened this issue Jan 5, 2018 · 2 comments
Labels
logging The logging framework

Comments

@c42f
Copy link
Member

c42f commented Jan 5, 2018

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:

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 logger

Similarly, Logging.logger(context) would get the logger installed for context.

@c42f
Copy link
Member Author

c42f commented Jan 5, 2018

This was quickly becoming a slack FAQ, so to mention a few people who have asked or might care about this - @quinnj @tshort @iamed2 @rofinn @StefanKarpinski

@c42f c42f added the logging The logging framework label Jan 5, 2018
@rofinn
Copy link
Contributor

rofinn commented Jan 5, 2018

I haven't been following the 0.7 changes changes that much, but the API in Memento would be setlevel!(getlogger(), "debug") (there's also Memento.config("debug")). In this case, the getlogger() returns the current root/global logger and then we're just mutating that logger reference.

I'm not sure I follow the Task logger situation. I would have assumed that a Task could access a logger via some kind of getlogger(...) interface or via an appropriately managed constant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
logging The logging framework
Projects
None yet
Development

No branches or pull requests

2 participants