Refine console logging

This commit is contained in:
thePR0M3TH3AN committed 2025-08-23 13:19:27 -04:00
1 parent e760bf2b25
commit e528bebae3
3 files changed
+31 -26

No files matched your search

+15
View File
@@ -1,4 +1,5 @@
import logging
from pathlib import Path
from contextlib import contextmanager
from functools import wraps
@@ -14,6 +15,20 @@ class ConsolePauseFilter(logging.Filter):
return not _console_paused
class ChecksumWarningFilter(logging.Filter):
"""Filter allowing only checksum warnings and errors to surface."""
def filter(
self, record: logging.LogRecord
) -> bool: # pragma: no cover - simple filter
if record.levelno >= logging.ERROR:
return True
return (
record.levelno == logging.WARNING
and Path(record.pathname).name == "checksum.py"
)
def pause_console_logging() -> None:
"""Temporarily pause logging to console handlers."""
global _console_paused