mirror of
https://github.com/bellingcat/auto-archiver-api.git
synced 2026-06-10 20:48:34 +03:00
* Update pyproject.toml * add pre-commit * Create .pre-commit-config.yaml * Comment out ruff * Update .pre-commit-config.yaml * General formatting * Create format-and-fail.yml * Update ci.yml * Add pre-commit to dev dependencies * Update pyproject.toml
15 lines
441 B
Python
15 lines
441 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}")
|