You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
896 B
34 lines
896 B
# ============================================================
|
|
# File: scraper/logger_decorators.py
|
|
# Purpose: Function-call logging decorator
|
|
# ============================================================
|
|
|
|
from functools import wraps
|
|
from scraper.logger import log_debug
|
|
|
|
|
|
def logcall(func):
|
|
"""
|
|
Decorator: log function name + arguments every time it's called.
|
|
Usage: @logcall above any function.
|
|
"""
|
|
|
|
@wraps(func)
|
|
def wrapper(*args, **kwargs):
|
|
# Naam van de functie
|
|
name = func.__qualname__
|
|
|
|
# Eerste logregel vóór uitvoering
|
|
# log_debug(f"[CALL] {name} args={args} kwargs={kwargs}")
|
|
log_debug(f"[CALL] {name} args={args}")
|
|
# log_debug(f"[CALL] {name}")
|
|
|
|
result = func(*args, **kwargs)
|
|
|
|
# Log ná uitvoering
|
|
# log_debug(f"[RETURN] {name} → {result}")
|
|
|
|
return result
|
|
|
|
return wrapper
|