mirror of
https://github.com/9P9/Discord-QR-Token-Logger.git
synced 2025-06-14 14:55:17 +00:00
Delete logger.py
This commit is contained in:
parent
a55b74b0d4
commit
79df7f3f79
@ -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
|
|
Loading…
x
Reference in New Issue
Block a user