From: Benjamin Diaz Date: Tue, 9 Oct 2018 17:01:54 +0000 (-0300) Subject: Adds OSMMON_LOG_LEVEL env var to config log level X-Git-Tag: v5.0.0~33 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F64%2F6664%2F1;p=osm%2FMON.git Adds OSMMON_LOG_LEVEL env var to config log level Signed-off-by: Benjamin Diaz --- diff --git a/docker/Dockerfile b/docker/Dockerfile index 26845d8..e736b50 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -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 diff --git a/osm_mon/core/message_bus/common_consumer.py b/osm_mon/core/message_bus/common_consumer.py index df3133d..b3ac8ae 100755 --- a/osm_mon/core/message_bus/common_consumer.py +++ b/osm_mon/core/message_bus/common_consumer.py @@ -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__) diff --git a/osm_mon/core/settings.py b/osm_mon/core/settings.py index d27f0ca..166018c 100644 --- a/osm_mon/core/settings.py +++ b/osm_mon/core/settings.py @@ -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} diff --git a/osm_mon/plugins/OpenStack/Aodh/notifier.py b/osm_mon/plugins/OpenStack/Aodh/notifier.py index 1de3284..c43f238 100644 --- a/osm_mon/plugins/OpenStack/Aodh/notifier.py +++ b/osm_mon/plugins/OpenStack/Aodh/notifier.py @@ -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__), '..', '..', '..', '..', '..')))