Skip to content

Logging configuration and installation #25404

@c42f

Description

@c42f

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    loggingThe logging framework

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions