Adds OSMMON_LOG_LEVEL env var to config log level
[osm/MON.git] / osm_mon / plugins / OpenStack / Aodh / notifier.py
index 377404a..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__), '..', '..', '..', '..', '..')))
@@ -72,11 +75,11 @@ class NotifierHandler(BaseHTTPRequestHandler):
             post_data = post_data.decode()
         except AttributeError:
             pass
-        log.info("This alarm was triggered: %s", json.dumps(post_data))
+        log.info("This alarm was triggered: %s", post_data)
 
         # Send alarm notification to message bus
         try:
-            self.notify_alarm(json.dumps(post_data))
+            self.notify_alarm(json.loads(post_data))
         except Exception:
             log.exception("Error notifying alarm")
 
@@ -107,7 +110,7 @@ class NotifierHandler(BaseHTTPRequestHandler):
             sev=values['severity'],
             date=a_date,
             state=values['current'])
-        producer.notify_alarm(
+        producer.publish_alarm_response(
             'notify_alarm', resp_message)
         log.info("Sent alarm notification: %s", resp_message)