mirror of
https://github.com/bellingcat/auto-archiver-api.git
synced 2026-06-08 03:28:35 +03:00
14 lines
444 B
Python
14 lines
444 B
Python
import traceback
|
|
from loguru import logger
|
|
|
|
|
|
# logging configurations
|
|
logger.add("logs/api_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 = ""):
|
|
if not traceback_str: traceback_str = traceback.format_exc()
|
|
if extra: extra = f"{extra}\n"
|
|
logger.error(f"{extra}{e.__class__.__name__}: {e}\n{traceback_str}")
|