summaryrefslogtreecommitdiffstats
path: root/openstack/common/notifier/log_notifier.py
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-06-26 18:59:20 +0000
committerGerrit Code Review <review@openstack.org>2012-06-26 18:59:20 +0000
commit71cddc514ac194e2332817673ef76c099dc158cc (patch)
treec231d2029ec471c8200c8c5ca3eba81ea888922c /openstack/common/notifier/log_notifier.py
parent5a93e1d790422ddf21c223ec77b0355e6b790021 (diff)
parent16916b6129f075e54c1ead915d5131f6d34218ed (diff)
Merge "Add common logging and notification."
Diffstat (limited to 'openstack/common/notifier/log_notifier.py')
-rw-r--r--openstack/common/notifier/log_notifier.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/openstack/common/notifier/log_notifier.py b/openstack/common/notifier/log_notifier.py
new file mode 100644
index 0000000..594fd3e
--- /dev/null
+++ b/openstack/common/notifier/log_notifier.py
@@ -0,0 +1,34 @@
+# Copyright 2011 OpenStack LLC.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+import json
+
+from openstack.common import cfg
+from openstack.common import log as logging
+
+
+CONF = cfg.CONF
+
+
+def notify(_context, message):
+ """Notifies the recipient of the desired event given the model.
+ Log notifications using openstack's default logging system"""
+
+ priority = message.get('priority',
+ CONF.default_notification_level)
+ priority = priority.lower()
+ logger = logging.getLogger(
+ 'openstack.common.notification.%s' % message['event_type'])
+ getattr(logger, priority)(json.dumps(message))