Skip to content

Commit

Permalink
Merge pull request #99 from TheoChem-VU/96-add-caller_level-as-argume…
Browse files Browse the repository at this point in the history
…nt-for-logging-functions

Added the caller_level argument for some of the logging functions.
  • Loading branch information
YHordijk authored Jan 30, 2024
2 parents 1f738a5 + edfc964 commit ae5522b
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/tcutility/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit ae5522b

Please sign in to comment.