summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/cloud-init1
-rw-r--r--cloudinit/reporting/__init__.py1
-rw-r--r--cloudinit/reporting/handlers.py16
-rw-r--r--doc/examples/cloud-config-reporting.txt17
4 files changed, 31 insertions, 4 deletions
diff --git a/bin/cloud-init b/bin/cloud-init
index 86780408..1f64461e 100755
--- a/bin/cloud-init
+++ b/bin/cloud-init
@@ -648,7 +648,6 @@ def main():
"running single module %s" % args.name)
report_on = args.report
- reporting.update_configuration({'print': {'type': 'print'}})
args.reporter = reporting.ReportEventStack(
rname, rdesc, reporting_enabled=report_on)
with args.reporter:
diff --git a/cloudinit/reporting/__init__.py b/cloudinit/reporting/__init__.py
index a3b8332f..e23fab32 100644
--- a/cloudinit/reporting/__init__.py
+++ b/cloudinit/reporting/__init__.py
@@ -18,7 +18,6 @@ START_EVENT_TYPE = 'start'
DEFAULT_CONFIG = {
'logging': {'type': 'log'},
- 'print': {'type': 'print'},
}
diff --git a/cloudinit/reporting/handlers.py b/cloudinit/reporting/handlers.py
index 9cf8bd2b..1343311f 100644
--- a/cloudinit/reporting/handlers.py
+++ b/cloudinit/reporting/handlers.py
@@ -28,17 +28,29 @@ class ReportingHandler(object):
class LogHandler(ReportingHandler):
"""Publishes events to the cloud-init log at the ``INFO`` log level."""
+ def __init__(self, level="DEBUG"):
+ super(LogHandler, self).__init__()
+ if isinstance(level, int):
+ pass
+ else:
+ input_level = level
+ try:
+ level = gettattr(logging, level.upper())
+ except:
+ LOG.warn("invalid level '%s', using WARN", input_level)
+ level = logging.WARN
+ self.level = level
+
def publish_event(self, event):
"""Publish an event to the ``INFO`` log level."""
logger = logging.getLogger(
'.'.join(['cloudinit', 'reporting', event.event_type, event.name]))
- logger.info(event.as_string())
+ logger.log(self.level, event.as_string())
class PrintHandler(ReportingHandler):
def publish_event(self, event):
"""Publish an event to the ``INFO`` log level."""
- print(event.as_string())
class WebHookHandler(ReportingHandler):
diff --git a/doc/examples/cloud-config-reporting.txt b/doc/examples/cloud-config-reporting.txt
new file mode 100644
index 00000000..ee00078f
--- /dev/null
+++ b/doc/examples/cloud-config-reporting.txt
@@ -0,0 +1,17 @@
+#cloud-config
+##
+## The following sets up 2 reporting end points.
+## A 'webhook' and a 'log' type.
+## It also disables the built in default 'log'
+reporting:
+ smtest:
+ type: webhook
+ endpoint: "http://myhost:8000/"
+ consumer_key: "ckey_foo"
+ consumer_secret: "csecret_foo"
+ token_key: "tkey_foo"
+ token_secret: "tkey_foo"
+ smlogger:
+ type: log
+ level: WARN
+ log: null