mirror of https://gitlab.com/pamhyr/pamhyr2
SQL: Minor change.
parent
7f8e8d5a9f
commit
2af9b0018c
30
src/tools.py
30
src/tools.py
|
|
@ -67,6 +67,16 @@ def logger_color_reset():
|
||||||
return f"{Style.RESET_ALL}"
|
return f"{Style.RESET_ALL}"
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
def logger_exception(exception):
|
||||||
|
logger.error(
|
||||||
|
f"[{Fore.RED}ERROR{Style.RESET_ALL}] " +
|
||||||
|
f"{Fore.RED}{e}{Style.RESET_ALL}"
|
||||||
|
)
|
||||||
|
logger.debug(
|
||||||
|
f"{Fore.BLUE}{e}{Style.RESET_ALL}\n" +
|
||||||
|
f"{Fore.RED}{traceback.format_exc()}{Style.RESET_ALL}"
|
||||||
|
)
|
||||||
|
|
||||||
##########
|
##########
|
||||||
# TIMERS #
|
# TIMERS #
|
||||||
##########
|
##########
|
||||||
|
|
@ -135,12 +145,20 @@ def timer(func):
|
||||||
try:
|
try:
|
||||||
value = func(*args, **kwargs)
|
value = func(*args, **kwargs)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.debug(f"[{Fore.RED}ERROR{Style.RESET_ALL}]" +
|
logger.error(
|
||||||
|
f"[{Fore.RED}ERROR{Style.RESET_ALL}] " +
|
||||||
|
f"{Fore.RED}{e}{Style.RESET_ALL}"
|
||||||
|
)
|
||||||
|
logger.debug(
|
||||||
f"[{func.__module__}.{Fore.GREEN}" +
|
f"[{func.__module__}.{Fore.GREEN}" +
|
||||||
f"{func.__qualname__}" +
|
f"{func.__qualname__}" +
|
||||||
f"{Style.RESET_ALL}]: " +
|
f"{Style.RESET_ALL}]: " +
|
||||||
f"{Fore.RED}{e}{Style.RESET_ALL}")
|
f"{Fore.RED}{e}{Style.RESET_ALL}"
|
||||||
traceback.print_exc()
|
)
|
||||||
|
logger.debug(
|
||||||
|
f"{Fore.BLUE}{e}{Style.RESET_ALL}\n" +
|
||||||
|
f"{Fore.RED}{traceback.format_exc()}{Style.RESET_ALL}"
|
||||||
|
)
|
||||||
|
|
||||||
end_time = time.perf_counter()
|
end_time = time.perf_counter()
|
||||||
run_time = end_time - start_time
|
run_time = end_time - start_time
|
||||||
|
|
@ -329,11 +347,7 @@ class SQL(object):
|
||||||
|
|
||||||
value = self._fetch(res, fetch_one)
|
value = self._fetch(res, fetch_one)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(
|
logger_exception(e)
|
||||||
f"[{Fore.RED}ERROR{Style.RESET_ALL}] " +
|
|
||||||
f"{Fore.RED}{e}{Style.RESET_ALL}"
|
|
||||||
)
|
|
||||||
traceback.print_exc()
|
|
||||||
finally:
|
finally:
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue