aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--cgitize/utils.py13
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,