Skip to content

[Feature]: Improve the logging configuration #618

@PawelPlesniak

Description

@PawelPlesniak

Description

When using the python scripts in this repo, there were some conflicts in the way that logging is handled. daqconf currently uses a basicConfig implementation as

logging.basicConfig(
level="NOTSET", format=FORMAT, datefmt="[%X]", handlers=[RichHandler()]
)

This assigns a set of handlers to the root logger instance. When other python tools make use of tools defined here, this can cause issues with logging. An example is in DUNE-DAQ/drunc#741, where in commit DUNE-DAQ/drunc@190fec5 we had to strip out all the handlers associated with the root logger. Can we correct this so the daqconf logging uses the daqpytools handlers, which are already configured to use a "pseudo-root" logger? In drunc, we instantiate this "pseudo-root" logger using function setup_root_logger here, which creates a logging instance called drunc, which we block from having any handlers. All subsequent instances of loggers inherit from this "pseudo" root logger, and prevents cross-repository bugged logging.

Potential impact radius

Zero

Reason for change

When working on DUNE-DAQ/drunc#741, it was found that the daqconf loggers contaminate the output of drunc when spawning multiple instances of a session on the same host. I will be pushing for this to be globally true.

Suggested implementations

The generally suggested practice is to setup a "pseudo-root" logger using function setup_root_logger, and inheriting all handlers from it on a per-application basis using function get_daq_logger from daqpytools.

In drunc, this is implemented here:
https://github.com/DUNE-DAQ/drunc/blob/d8785100d77fc61844db23d566fb6abb55538748/src/drunc/utils/utils.py#L36-L61

Testing suggestions

This is a refactor, and should not require changes to the code output. This will, however, allow for easy application of the RichHandler formattted in the way that drunc has it.

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions