mirror of
https://github.com/jlengrand/bugsink.git
synced 2026-03-10 08:01:17 +00:00
14 lines
244 B
Python
14 lines
244 B
Python
import time
|
|
|
|
from contextlib import contextmanager
|
|
|
|
|
|
@contextmanager
|
|
def time_to_logger(logger, msg):
|
|
t0 = time.time()
|
|
try:
|
|
yield
|
|
finally:
|
|
took = (time.time() - t0) * 1000
|
|
logger.info(f"{took:6.2f}ms {msg}")
|