Skip to content

Commit

Permalink
test: More windows
Browse files Browse the repository at this point in the history
  • Loading branch information
gmuloc committed Jan 3, 2025
1 parent b9883a3 commit bf50279
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions anta/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def setup_logging(level: LogLevel = Log.INFO, file: Path | None = None) -> None:
# Add RichHandler for stdout if not already present
_maybe_add_rich_handler(loglevel, root)

# Add FileHandler if file is provided and same FileHandler is not already present
# Add FileHandler if file is provided and same File Handler is not already present
if file and not _get_file_handler(root, file):
file_handler = logging.FileHandler(file)
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
Expand All @@ -88,9 +88,12 @@ 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."""
# ruff: noqa: T201
for handler in logger_instance.handlers:
if isinstance(handler, logging.FileHandler):
print(handler.baseFilename) # noqa: T201
print(handler.baseFilename)
print(Path(handler.baseFilename))
print(file)

return (
next((handler for handler in logger_instance.handlers if isinstance(handler, logging.FileHandler) and handler.baseFilename == str(file)), None)
Expand Down

0 comments on commit bf50279

Please sign in to comment.