diff options
author | Scott Moser <smoser@ubuntu.com> | 2015-08-07 14:44:00 -0500 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2015-08-07 14:44:00 -0500 |
commit | 95bfe5d5150e2bf0a26dd1b97578c4fd04152365 (patch) | |
tree | 44a6a76e23f390cc125442da8a5acb74ad062343 /cloudinit | |
parent | 71c8fedcd581d8c4aa937d270f5bbd2e5af99e26 (diff) | |
download | vyos-cloud-init-95bfe5d5150e2bf0a26dd1b97578c4fd04152365.tar.gz vyos-cloud-init-95bfe5d5150e2bf0a26dd1b97578c4fd04152365.zip |
add doc, remove some debug / print statements.
Diffstat (limited to 'cloudinit')
-rw-r--r-- | cloudinit/reporting/__init__.py | 1 | ||||
-rw-r--r-- | cloudinit/reporting/handlers.py | 16 |
2 files changed, 14 insertions, 3 deletions
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): |