diff --git a/cnn_classification_service/config.py b/cnn_classification_service/config.py index 154393f..12ffae3 100644 --- a/cnn_classification_service/config.py +++ b/cnn_classification_service/config.py @@ -1,4 +1,6 @@ import os +import sys +import logging class Config: @@ -13,3 +15,9 @@ class Config: RELEASE_ID = os.environ.get('RELEASE_ID', 'test') RELEASEMODE = os.environ.get('RELEASEMODE', 'dev') + + LOG_LEVEL = logging.DEBUG if ( + '--debug' in sys.argv + ) or ( + os.environ.get('DEBUG', '0').lower() in ['yes', 'true', '1'] + ) else logging.INFO diff --git a/cnn_classification_service/main.py b/cnn_classification_service/main.py index 8acb2df..001c7ea 100644 --- a/cnn_classification_service/main.py +++ b/cnn_classification_service/main.py @@ -37,7 +37,7 @@ def main(): logging.basicConfig( stream=sys.stdout, format="%(asctime)s - %(name)s [%(levelname)s]: %(message)s", - level=logging.DEBUG if '--debug' in sys.argv else logging.INFO + level=Config.LOG_LEVEL ) if Config.SENTRY_DSN: