tools: Add new file.

This commit is contained in:
parouby committed 2025-03-19 15:30:56 +01:00
1 parent 99ff7c5fed
commit ad865e2829
1 file changed
+45
+45
View File
@@ -0,0 +1,45 @@
import os
import time
import logging
import traceback
from datetime import datetime, timedelta
from pathlib import Path
from functools import wraps
###########
# LOGGING #
###########
logger = logging.getLogger("acoused")
#########
# WRAPS #
#########
def trace(func):
@wraps(func)
def wrapper(*args, **kwargs):
t = time.time()
head = f"[TRACE]"
logger.debug(
f"{head} Call {func.__module__}." +
f"{func.__qualname__}({args}, {kwargs})"
)
value = func(*args, **kwargs)
t1 = time.time()
logger.debug(
f"{head} Return {func.__module__}." +
f"{func.__qualname__}: {value}"
)
logger.debug(
f"{head}[TIME] {func.__module__}." +
f"{func.__qualname__}: {t1-t} sec"
)
return value
return wrapper