From c3179fb681e4f8645d4dbbe30de1f5b6098dba86 Mon Sep 17 00:00:00 2001 From: hygienic-books Date: Tue, 5 Jul 2022 19:55:08 +0200 Subject: [PATCH] refactor(debug): Cosmetics --- update-firewall-source.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/update-firewall-source.py b/update-firewall-source.py index 5465da3..ee1406d 100644 --- a/update-firewall-source.py +++ b/update-firewall-source.py @@ -1,6 +1,6 @@ # Exit with various exit codes import sys -# Path manipulation +# Path and env manipulation import os # Manipulate style and content of logs import logging @@ -76,18 +76,17 @@ class CONST(object): CFG_MANDATORY = [section_cfg["key"] for section_cfg in CFG_KNOWN_SECTION if section_cfg["is_mandatory"]] +is_systemd = any([systemd_env_var in os.environ for systemd_env_var in ["SYSTEMD_EXEC_PID", "INVOCATION_ID"]]) logging.basicConfig( # Default for all modules is NOTSET so log everything level="NOTSET", format=CONST.LOG_FORMAT, datefmt="[%X]", handlers=[RichHandler( - show_time=False if any([systemd_env_var in os.environ for systemd_env_var in [ - "SYSTEMD_EXEC_PID", - "INVOCATION_ID"]]) else True, - rich_tracebacks=True, - show_path=False, - show_level=False + show_time=False if is_systemd else True, + show_path=False if is_systemd else True, + show_level=False if is_systemd else True, + rich_tracebacks=True )] ) log = logging.getLogger("rich")