From 8171248a6a95f7b3edb83379e8a82506e68f6832 Mon Sep 17 00:00:00 2001 From: Chris Lenk Date: Wed, 21 Feb 2024 10:06:41 -0500 Subject: [PATCH] Tweak log styles Use Rich's default log format, but change warning to yellow to differentiate it more from error. --- server.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/server.py b/server.py index 3c4da4ecd..17dece38e 100644 --- a/server.py +++ b/server.py @@ -2,7 +2,9 @@ import asyncio import logging import os +from rich.console import Console from rich.logging import RichHandler +from rich.theme import Theme import sys import warnings import subprocess @@ -36,16 +38,17 @@ def setup_logger(level=logging.DEBUG): - format = "%(asctime)s - %(levelname)-5s (%(filename)s:%(lineno)s %(funcName)s) %(message)s" + format = "%(message)s" datefmt = "%Y-%m-%d %H:%M:%S" if no_color(): logging.basicConfig(level=level, format=format, datefmt=datefmt) else: + console = Console(theme=Theme({"logging.level.warning": "yellow"})) logging.basicConfig( level=level, format=format, datefmt=datefmt, - handlers=[RichHandler(rich_tracebacks=True, markup=True, show_time=False)] + handlers=[RichHandler(rich_tracebacks=True, markup=True, console=console)] ) for logger_name in logging.root.manager.loggerDict.keys():