mirror of
https://github.com/bellingcat/auto-archiver-api.git
synced 2026-06-11 04:58:33 +03:00
24 lines
575 B
Python
24 lines
575 B
Python
import traceback
|
|
|
|
from auto_archiver.utils.custom_logger import logger
|
|
|
|
|
|
# logging configurations
|
|
logger.add(
|
|
"logs/all_logs.log", retention="30 days", format="{extra[serialized]}"
|
|
)
|
|
logger.add(
|
|
"logs/all_error_logs.log",
|
|
retention="120 days",
|
|
level="ERROR",
|
|
format="{extra[serialized]}",
|
|
)
|
|
|
|
|
|
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}")
|