[~!] Separate console and file

This commit is contained in:
Maxim Khomutov 2025-03-19 16:58:30 +03:00
parent 2e4e254cb8
commit 554e13807d

View File

@ -48,14 +48,14 @@ def zip_logs():
"Some files are locked...\nProgram cannot works in multiplies instances.")
sys.exit(1)
def setup(debug=False, low_debug=False):
def setup(console_debug=False, file_debug=False, file_low_debug=False):
logger.remove()
fmt = "<green>{elapsed} -- {time:YYYY-MM-DD HH:mm:ss.SSS}</green> | <level>{level:<8}</level> | {extra[module]:^12} | {extra[prefix]:<12} | {message}"
logger.add(sys.stdout, level="DEBUG" if debug else "INFO", format=fmt, backtrace=True, diagnose=True)
logger.add(sys.stdout, level="DEBUG" if console_debug else "INFO", format=fmt, backtrace=True, diagnose=True)
logger.add(log_file, level="INFO", format=fmt, backtrace=False, diagnose=False, rotation="25 MB")
if debug:
if file_debug:
logger.add(log_dir / "debug.log", level="DEBUG", format=fmt, rotation="10 MB")
if low_debug:
if file_low_debug:
logger.add(log_dir / "low_debug.log", level="DEBUG", rotation="10 MB")
sys.excepthook = handle_exception
threading.excepthook = handle_thread_exception