tools: Add new file.
parent
99ff7c5fed
commit
ad865e2829
|
|
@ -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
|
||||||
Loading…
Reference in New Issue