feat: allow disabling color output

This commit is contained in:
Matthias
2024-12-29 10:39:31 +01:00
parent 3e5ab8549f
commit 59f3d88c58
2 changed files with 6 additions and 3 deletions

View File

@@ -22,7 +22,7 @@ LOGFORMAT = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
bufferHandler = FTBufferingHandler(1000)
bufferHandler.setFormatter(Formatter(LOGFORMAT))
error_console = Console(stderr=True)
error_console = Console(stderr=True, color_system=None)
def get_existing_handlers(handlertype):
@@ -60,6 +60,9 @@ def setup_logging(config: Config) -> None:
# Log level
verbosity = config["verbosity"]
logging.root.addHandler(bufferHandler)
if config.get("print_colorized", True):
logger.info("Enabling colorized output")
error_console._color_system = "auto"
logfile = config.get("logfile")

View File

@@ -16,9 +16,9 @@ class FtRichHandler(Handler):
# Format log message
log_time = Text(
datetime.fromtimestamp(record.created).strftime("%Y-%m-%d %H:%M:%S,%f")[:-3],
style="gray46",
style="gray78",
)
name = Text(record.name)
name = Text(record.name, style="violet")
log_level = Text(record.levelname, style=f"logging.level.{record.levelname.lower()}")
gray_sep = Text(" - ", style="gray46")