Delete logger.py

This commit is contained in:
mouadessalim 2023-02-10 23:41:10 +01:00 committed by GitHub
parent a55b74b0d4
commit 79df7f3f79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,34 +0,0 @@
import logging
from functools import wraps
from typing import Any
logging.basicConfig(filename='qrg.log', filemode='w',
format="[%(filename)s:%(lineno)s - %(funcName)20s() ] %(message)s")
def log_unknown_exceptions(log_lvl: int) -> Any:
"""Logs unknown exceptions that occur in a function to a log file.
"""
def decorate(func):
@wraps(func)
def wrapper(*args, **kwargs) -> Any:
try:
result = func(*args, **kwargs)
return result
except Exception as e:
if log_lvl == logging.DEBUG:
logging.debug(e)
elif log_lvl == logging.INFO:
logging.info(e)
elif log_lvl == logging.WARNING:
logging.warning(e)
elif log_lvl == logging.ERROR:
logging.error(e)
elif log_lvl == logging.CRITICAL:
logging.critical(e)
else:
raise ValueError(
'Invalid log level provided for log_unknown_exceptions decorator.')
return None
return wrapper
return decorate