From a9022c0a1ba071246da54ddb5af5fd95f8f38220 Mon Sep 17 00:00:00 2001 From: kaeeraa Date: Mon, 21 Oct 2024 18:45:09 +0300 Subject: [PATCH] instances.log: add code, that i need to rework --- instances/log.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/instances/log.py b/instances/log.py index 65028a1..d7b7e41 100644 --- a/instances/log.py +++ b/instances/log.py @@ -32,14 +32,22 @@ logger.level("ERROR", color="", icon="💔") logger.level("CRITICAL", color="", icon="💔") +if any(arg in ["-V", "--verbose"] for arg in argv): + logLevel = "DEBUG" +elif any(arg in ["-VV", "--vomit"] for arg in argv): + logLevel = "TRACE" +else: + logLevel = "INFO" + # Add a file handler with specific configurations logger.add( + # Generate a unique log filename ({time}_xxxxxxxx.log) sink=f"logs/{datetime.now().strftime('%Y-%m-%d')}_{randbytes(n=4).hex()}.log", format="{time:HH:mm:ss:SSS} | " "{level} | " "{name}:{function}:{line} - " "{message}", - level=("TRACE" if any(arg in ["-V", "--verbose"] for arg in argv) else "DEBUG"), # Set level based on verbosity + level=logLevel, # Set level based on verbosity serialize=True, # Enable log serialization colorize=False, # Disable colorization in file logs rotation="10 MB", # Rotate logs after reaching 10 MB @@ -55,5 +63,5 @@ "{level.icon} | " "{name}:{function}:{line} - " "{message}", - level=("TRACE" if any(arg in ["-V", "--verbose"] for arg in argv) else "DEBUG"), # Set level based on verbosity + level=logLevel, # Set level based on verbosity )