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

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

Open
SakuraPuare opened this issue Dec 7, 2024 · 1 comment

Comments

@SakuraPuare
Copy link

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

@SergeyPirogov
Copy link
Owner

Open a PR pls

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

No branches or pull requests

2 participants