Adds OSMMON_LOG_LEVEL env var to config log level 64/6664/1
authorBenjamin Diaz <bdiaz@whitestack.com>
Tue, 9 Oct 2018 17:01:54 +0000 (14:01 -0300)
committerBenjamin Diaz <bdiaz@whitestack.com>
Tue, 9 Oct 2018 17:01:54 +0000 (14:01 -0300)
Signed-off-by: Benjamin Diaz <bdiaz@whitestack.com>
docker/Dockerfile
osm_mon/core/message_bus/common_consumer.py
osm_mon/core/settings.py
osm_mon/plugins/OpenStack/Aodh/notifier.py

index 26845d8..e736b50 100644 (file)
@@ -42,6 +42,7 @@ ENV DATABASE sqlite:///mon_sqlite.db
 ENV OS_NOTIFIER_URI localhost:8662
 ENV OS_DEFAULT_GRANULARITY 300
 ENV REQUEST_TIMEOUT 10
+ENV OSMMON_LOG_LEVEL INFO
 
 EXPOSE 8662
 
index df3133d..b3ac8ae 100755 (executable)
@@ -40,10 +40,12 @@ from osm_mon.plugins.OpenStack.Aodh import alarming
 from osm_mon.plugins.OpenStack.Gnocchi import metrics
 from osm_mon.plugins.vRealiseOps import plugin_receiver
 
+cfg = Config.instance()
+
 logging.basicConfig(stream=sys.stdout,
-                    format='%(asctime)s %(message)s',
+                    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
                     datefmt='%m/%d/%Y %I:%M:%S %p',
-                    level=logging.INFO)
+                    level=logging.getLevelName(cfg.OSMMON_LOG_LEVEL))
 log = logging.getLogger(__name__)
 
 
index d27f0ca..166018c 100644 (file)
@@ -65,6 +65,7 @@ class Config(object):
         CfgParam('OS_NOTIFIER_URI', "http://localhost:8662", six.text_type),
         CfgParam('OS_DEFAULT_GRANULARITY', "300", six.text_type),
         CfgParam('REQUEST_TIMEOUT', 10, int),
+        CfgParam('OSMMON_LOG_LEVEL', "INFO", six.text_type),
     ]
 
     _config_dict = {cfg.key: cfg for cfg in _configuration}
index 1de3284..c43f238 100644 (file)
@@ -32,11 +32,14 @@ from six.moves.BaseHTTPServer import BaseHTTPRequestHandler
 from six.moves.BaseHTTPServer import HTTPServer
 
 # Initialise a logger for alarm notifier
+from osm_mon.core.settings import Config
+
+cfg = Config.instance()
 
 logging.basicConfig(stream=sys.stdout,
-                    format='%(asctime)s %(message)s',
+                    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
                     datefmt='%m/%d/%Y %I:%M:%S %p',
-                    level=logging.INFO)
+                    level=logging.getLevelName(cfg.OSMMON_LOG_LEVEL))
 log = logging.getLogger(__name__)
 
 sys.path.append(os.path.abspath(os.path.join(os.path.realpath(__file__), '..', '..', '..', '..', '..')))