Skip to content

logging should not be configured #980

@pmeier

Description

@pmeier

Disclaimer: I'm reviewing the autoemulate package as part of this JOSS review. This issue is based on version v1.1.1.


Quoting the official Python documentation:

It is strongly advised that you do not add any handlers other than NullHandler to your library’s loggers. This is because the configuration of handlers is the prerogative of the application developer who uses your library. The application developer knows their target audience and what handlers are most appropriate for their application: if you add handlers ‘under the hood’, you might well interfere with their ability to carry out unit tests and deliver logs which suit their requirements.

Yet

def configure_logging(log_to_file=False, level: str = "INFO"):
"""
Configure the logging system.
Parameters
----------
log_to_file: bool or string, optional
If True, logs will be written to a file.
If a string, logs will be written to the specified file.
verbose: str, optional
The verbosity level. Can be "critical", "error", "warning",
"info", or "debug". Defaults to "info".
"""
logger = logging.getLogger("autoemulate")
logger.handlers = [] # Clear existing handlers

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions