resource impl
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
#logging_handlers/DatabaseLogHandler.py
|
||||
|
||||
import logging
|
||||
import traceback
|
||||
from db import get_db
|
||||
from db.models.Log import Log
|
||||
from contexts.RequestContext import RequestContext
|
||||
class DatabaseLogHandler(logging.Handler):
|
||||
def __init__(self, application="backend"):
|
||||
super().__init__()
|
||||
@@ -18,5 +18,6 @@ class DatabaseLogHandler(logging.Handler):
|
||||
with get_db() as db:
|
||||
db.add(log_entry)
|
||||
db.commit()
|
||||
RequestContext.set_error_id(log_entry.id)
|
||||
except Exception:
|
||||
print(f"Failed to log to database: {traceback.format_exc()}")
|
||||
print(f"failed to log")
|
||||
Reference in New Issue
Block a user