mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2026-11-03 19:34:45 +00:00
Refine console logging
This commit is contained in:
1 parent
e760bf2b25
commit
e528bebae3
3 files changed
+31
-26
No files matched your search
@@ -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
|
||||
|
||||
Reference in new issue
Block a user