Coverage for src/utils/trace_logging.py: 0%

14 statements  

« prev     ^ index     » next       coverage.py v7.8.2, created at 2025-06-03 19:06 +0000

1import logging 

2import time 

3 

4from dash import ctx 

5 

6from src.configuration import config 

7 

8 

9def measure_duration(func): 

10 def wrapper(*args, **kwargs): 

11 start_time = time.time() 

12 result = func(*args, **kwargs) 

13 end_time = time.time() 

14 duration = end_time - start_time 

15 

16 if config.trace: 

17 # Log the duration 

18 logging.info(f"Function '{func.__name__}' took {duration:.4f}" 

19 f" seconds to execute. tigger: '{ctx.triggered_id}'") 

20 

21 return result 

22 

23 return wrapper