From 2ae5f64aa2e72b66ff37ad3c62a6dd8091864985 Mon Sep 17 00:00:00 2001 From: Richard Hitier Date: Thu, 26 Oct 2023 14:59:12 +0200 Subject: [PATCH] Change the logging level based on env var DEBUG --- web/run.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/web/run.py b/web/run.py index 8edfa4a..92f9046 100755 --- a/web/run.py +++ b/web/run.py @@ -65,22 +65,25 @@ CME_DATE_FMT = "%Y-%m-%dT%H:%MZ" # Are we on the SSA instance for ESA? SSA = environ.get('SSA') == 'true' -DEBUG = environ.get('DEBUG') == 'true' -# SSA = True +DEBUG = environ.get('DEBUG') in ['true', 'True', 1, '1'] # LOGGING ##################################################################### LOG_FILE = get_path('run.log') hp_logger = logging.getLogger("HelioPropa") -if DEBUG: - hp_logger.setLevel(logging.DEBUG) -else: - hp_logger.setLevel(logging.ERROR) +hp_logger.setLevel(logging.DEBUG) + logHandler = logging.FileHandler(LOG_FILE) logHandler.setFormatter(logging.Formatter( "%(asctime)s - %(levelname)s - %(message)s" )) + +# set file messages depending on env var setting +if DEBUG: + logHandler.setLevel(logging.DEBUG) +else: + logHandler.setLevel(logging.ERROR) hp_logger.addHandler(logHandler) # HARDCODED CONFIGURATION ##################################################### -- libgit2 0.21.2