Skip to content

[Feature Request] Remove unnecessary Logger type check to support third-party loggers #688

@SakuraPuare

Description

@SakuraPuare

Currently in the set_logger() function, there is a type check that requires the logger to be an instance of logging.Logger. However, this restriction prevents the use of third-party logging libraries that don't inherit from logging.Logger but provide compatible logging interfaces.

def set_logger(logger):
    """
    Set the global logger.

    Parameters
    ----------
    logger : logging.Logger
        The custom logger to use.

    Returns None
    """

    # Check if the logger is a valid logger
    if not isinstance(logger, logging.Logger):
        raise ValueError("The logger must be an instance of logging.Logger")

    # Bind the logger input to the global logger
    global __logger
    __logger = logger

For example, popular logging libraries like loguru cannot be used with the current implementation, even though they provide all the necessary logging methods.

https://loguru.readthedocs.io/en/stable/api.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions