log: Add throw()

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2025-01-28 10:17:27 +01:00
commit d5e268a03b

View file

@ -175,6 +175,13 @@ def slog(prio: int, *args, only_printable: bool=False, **kwargs) -> None: # expo
for file in files: for file in files:
print(msg, file=file) print(msg, file=file)
def throw(*args, prio=ERR, caller=None, **kwargs) -> None:
if caller is None:
caller = get_caller_pos(1)
msg = ' '.join([str(arg) for arg in args])
slog(prio, msg, caller=caller)
raise Exception(msg)
def parse_log_prio_str(prio: str) -> int: # export def parse_log_prio_str(prio: str) -> int: # export
try: try:
r = int(prio) r = int(prio)