feat: Add logging and error handling enhancements
- Introduced new logging modules for action tracking, error logging, and performance tracking to improve observability. - Added functions for retrieving debug and error log paths in `path_config.py`. - Updated various components to utilize the new logging system, enhancing error handling and performance diagnostics. - Implemented a GUI component for viewing error logs, improving user experience in monitoring application issues. - Cleaned up unnecessary blank lines and improved code readability across multiple files.
This commit is contained in:
1 parent
bdf9312bc9
commit
efe6e2252f
48 files changed
+2165
-320
No files matched your search
@@ -0,0 +1,30 @@
|
||||
"""操作追踪装饰器:自动记录函数耗时与操作信息"""
|
||||
from __future__ import annotations
|
||||
|
||||
import time
|
||||
from functools import wraps
|
||||
|
||||
from .performance_tracker import PerformanceTracker
|
||||
from .action_logger import ActionLogger
|
||||
_perf = PerformanceTracker()
|
||||
_logger = ActionLogger()
|
||||
|
||||
def track_action(name: str = ""):
|
||||
def decorator(func):
|
||||
@wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
timer = _perf.start_timer(name or func.__name__)
|
||||
t0 = time.time()
|
||||
try:
|
||||
result = func(*args, **kwargs)
|
||||
return result
|
||||
finally:
|
||||
elapsed = _perf.end_timer(timer)
|
||||
elapsed = elapsed if elapsed is not None else time.time() - t0
|
||||
_logger.log_step(name or func.__name__, elapsed=elapsed)
|
||||
return wrapper
|
||||
return decorator
|
||||
|
||||
__all__ = ["track_action"]
|
||||
|
||||
|
||||
Reference in new issue
Block a user