paper-dynasty-card-creation/exceptions.py

13 lines
432 B
Python

import logging
from typing import Literal
def log_exception(e: Exception, msg: str = '', level: Literal['debug', 'error', 'info', 'warn'] = 'error'):
if level == 'debug':
logging.debug(msg, stack_info=True)
elif level == 'error':
logging.error(msg, stack_info=True)
elif level == 'info':
logging.info(msg, stack_info=True)
else:
logging.warning(msg, stack_info=True)
raise e(msg)