From 05044361ec94a24dc370196e5234b0292cfefe96 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Tue, 23 Jun 2026 14:52:58 +0200 Subject: shorter level names in logs --- cgitize/utils.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cgitize/utils.py b/cgitize/utils.py index 7a9596f..9ec8dd3 100644 --- a/cgitize/utils.py +++ b/cgitize/utils.py @@ -14,12 +14,21 @@ from urllib.parse import quote, urlsplit, urlunsplit @contextmanager def setup_logging(verbose=False): + level_names = { + logging.DEBUG: 'DBG', + logging.INFO: 'INFO', + logging.WARNING: 'WARN', + logging.ERROR: 'ERR', + logging.CRITICAL: 'CRIT', + } + for lvl, name in level_names.items(): + logging.addLevelName(lvl, name) + level = logging.DEBUG if verbose else logging.INFO logging.basicConfig( level=level, datefmt='%Y-%m-%d %H:%M:%S%z', - # The 8 below is for "CRITICAL" - format='%(asctime)s | %(levelname)8s | %(message)s', + format='%(asctime)s | %(levelname)4s | %(message)s', # Log to stdout, because that's where subprocess's output goes (so that # they don't get interleaved). stream=sys.stdout, -- cgit v1.3