Files
douyi_guaji_main/douyin/logging/action_tracker.py
T
Your Name 0b5f150691 Refactor and clean up code across multiple scripts
- Removed trailing whitespace and ensured files end with a single newline in cleanup_unused_files.py.
- Added fix_trailing_whitespace.py to batch remove trailing whitespace from Python files.
- Updated install_dependencies.py to improve dependency installation prompts.
- Cleaned up pick_coords.py by removing unnecessary whitespace and improving code readability.
- Enhanced region_selector.py by disabling specific pylint checks for better compatibility with third-party libraries.
- Improved WPS流程图生成工具.py by cleaning up whitespace and enhancing readability.
- Updated __init__.py in typings to remove unnecessary lines.
- Modified app.js to adjust default configuration values and clean up unused code.
2026-01-02 23:57:03 +08:00

29 lines
890 B
Python

"""操作追踪装饰器:自动记录函数耗时与操作信息"""
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"]