diff options
| author | Egor Tensin <egor@tensin.name> | 2026-06-23 14:52:58 +0200 |
|---|---|---|
| committer | Egor Tensin <egor@tensin.name> | 2026-06-23 14:54:25 +0200 |
| commit | 05044361ec94a24dc370196e5234b0292cfefe96 (patch) | |
| tree | be7532f6493b8ec1fbe0c3bee854f0419b5b400b | |
| parent | Merge pull request #29 from egor-tensin/dependabot/github_actions/actions/che... (diff) | |
| download | cgitize-8.0.1.tar.gz cgitize-8.0.1.zip | |
shorter level names in logsv8.0.1
| -rw-r--r-- | cgitize/utils.py | 13 |
1 files 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, |
