INNER CODE UNIT · Python

_setup_logging

mindee/doctr · doctr/cli/main.py:58

def _setup_logging(quiet: bool = False) -> None:
    """Configure the logging of the `doctr` package for the CLI

    Only the library logger is configured, so that the CLI output stays free of the third-party
    logs the root logger would otherwise pick up.

    Args:
        quiet: whether only errors should be logged
    """
    doctr_logger = logging.getLogger("doctr")

    # `main` can be called several times in the same process, so the previous handler is replaced
    for handler in list(doctr_logger.handlers):
        if handler.name == _CLI_HANDLER_NAME:
            doctr_logger.removeHandler(handler)

    handler = logging.StreamHandler()
    handler.set_name(_CLI_HANDLER_NAME)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…