From edfc96451513143e1a64b5cbceaf647db1eed194 Mon Sep 17 00:00:00 2001 From: Yuman Hordijk Date: Tue, 30 Jan 2024 12:14:07 +0100 Subject: [PATCH] Added the caller_level argument for some of the logging functions. --- src/tcutility/log.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/tcutility/log.py b/src/tcutility/log.py index 07a7e343..66ef7178 100644 --- a/src/tcutility/log.py +++ b/src/tcutility/log.py @@ -306,39 +306,39 @@ def boxed(message: str, title: Union[str, None] = None, message_align: str = "le log(s, level=level) -def debug(message: str, level: int = 10): +def debug(message: str, level: int = 10, caller_level: int = 2): """ Print a debug message. """ - log(f"[DEBUG]({caller_name(2)}): " + message, level=level) + log(f"[DEBUG]({caller_name(caller_level)}): " + message, level=level) -def info(message: str, level: int = 20): +def info(message: str, level: int = 20, caller_level: int = 2): """ Print an informative message. """ - log(f"[INFO]({caller_name(2)}): " + message, level=level) + log(f"[INFO]({caller_name(caller_level)}): " + message, level=level) -def warn(message: str, level: int = 30): +def warn(message: str, level: int = 30, caller_level: int = 2): """ Print a warning message. """ - log(f"[WARNING]({caller_name(2)}): " + message, level=level) + log(f"[WARNING]({caller_name(caller_level)}): " + message, level=level) -def error(message: str, level: int = 40): +def error(message: str, level: int = 40, caller_level: int = 2): """ Print an error message. """ - log(f"[ERROR]({caller_name(2)}): " + message, level=level) + log(f"[ERROR]({caller_name(caller_level)}): " + message, level=level) -def critical(message: str, level: int = 50): +def critical(message: str, level: int = 50, caller_level: int = 2): """ Print a critical message. """ - log(f"[CRITICAL]({caller_name(2)}): " + message, level=level) + log(f"[CRITICAL]({caller_name(caller_level)}): " + message, level=level) def caller_name(level: int = 1) -> str: