Better logging

This commit is contained in:
Dylan
2023-08-01 14:07:42 +01:00
parent cac3026f2b
commit 53128fef58
2 changed files with 16 additions and 7 deletions

View File

@ -1,5 +1,7 @@
IS_DEBUG = False
from flask import request
from io import StringIO
import traceback
def generic(message):
invocation_id = None
try:
@ -33,4 +35,10 @@ def warn(message):
def debug(message):
if IS_DEBUG:
message = str(message)
generic(f" > [ D ] {message}")
generic(f" > [ D ] {message}")
def get_exception_traceback_str(exc: Exception) -> str:
# Ref: https://stackoverflow.com/a/76584117/
file = StringIO()
traceback.print_exception(exc, file=file)
return file.getvalue().rstrip()