mirror of
https://github.com/bellingcat/auto-archiver-api.git
synced 2026-06-08 03:28:35 +03:00
fixes logic of error logging
This commit is contained in:
@@ -5,15 +5,14 @@ from fastapi import Request
|
||||
|
||||
# logging configurations
|
||||
logger.add("logs/api_logs.log", retention="30 days", rotation="3 days")
|
||||
error_logger = logger.add("logs/error_logs.log", retention="30 days")
|
||||
logger.add("logs/error_logs.log", retention="30 days", level="ERROR")
|
||||
|
||||
|
||||
def log_error(e: Exception, traceback_str: str = None, extra:str = ""):
|
||||
# EXCEPTION_COUNTER.labels(type(e).__name__).inc()
|
||||
if not traceback_str: traceback_str = traceback.format_exc()
|
||||
if extra: extra = f"{extra}\n"
|
||||
logger.error(f"{extra}{e.__class__.__name__}: {e}")
|
||||
error_logger.error(f"{extra}{e.__class__.__name__}: {e}\n{traceback_str}")
|
||||
logger.error(f"{extra}{e.__class__.__name__}: {e}\n{traceback_str}")
|
||||
|
||||
async def logging_middleware(request: Request, call_next):
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user