mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2026-11-06 12:52:04 +00:00
refactor: restrict console logging and pause during UI
This commit is contained in:
1 parent
fde09bd1a0
commit
7b0344739f
4 files changed
+60
-9
No files matched your search
@@ -1,4 +1,6 @@
|
||||
import logging
|
||||
from contextlib import contextmanager
|
||||
from functools import wraps
|
||||
|
||||
_console_paused = False
|
||||
|
||||
@@ -22,3 +24,24 @@ def resume_console_logging() -> None:
|
||||
"""Resume logging to console handlers."""
|
||||
global _console_paused
|
||||
_console_paused = False
|
||||
|
||||
|
||||
@contextmanager
|
||||
def console_logging_paused() -> None:
|
||||
"""Context manager to pause console logging within a block."""
|
||||
pause_console_logging()
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
resume_console_logging()
|
||||
|
||||
|
||||
def pause_logging_for_ui(func):
|
||||
"""Decorator to pause console logging while ``func`` executes."""
|
||||
|
||||
@wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
with console_logging_paused():
|
||||
return func(*args, **kwargs)
|
||||
|
||||
return wrapper
|
||||
Reference in new issue
Block a user