diff --git a/anta/logger.py b/anta/logger.py index ed6e05475..2cbb81c81 100644 --- a/anta/logger.py +++ b/anta/logger.py @@ -88,6 +88,10 @@ def setup_logging(level: LogLevel = Log.INFO, file: Path | None = None) -> None: def _get_file_handler(logger_instance: logging.Logger, file: Path) -> logging.FileHandler | None: """Return the FileHandler if present.""" + for handler in logger_instance.handlers: + if isinstance(handler, logging.FileHandler): + print(handler.baseFilename) # noqa: T201 + return ( next((handler for handler in logger_instance.handlers if isinstance(handler, logging.FileHandler) and handler.baseFilename == str(file)), None) if logger_instance.hasHandlers()