diff options
author | Scott Moser <smoser@ubuntu.com> | 2015-08-02 16:50:47 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2015-08-02 16:50:47 -0400 |
commit | 89c5936c7c1fb6d172cd0eee9c5f9aa2cd5e2053 (patch) | |
tree | 09512d6fa1c5ae42ed3adc6d9bbe1811f1cadad5 /cloudinit/reporting/handlers.py | |
parent | 07b452e166b5d2ff34d5558b1dbba42ab0f1f23c (diff) | |
download | vyos-cloud-init-89c5936c7c1fb6d172cd0eee9c5f9aa2cd5e2053.tar.gz vyos-cloud-init-89c5936c7c1fb6d172cd0eee9c5f9aa2cd5e2053.zip |
sync with 2.0 trunk on reporting
Diffstat (limited to 'cloudinit/reporting/handlers.py')
-rw-r--r-- | cloudinit/reporting/handlers.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/cloudinit/reporting/handlers.py b/cloudinit/reporting/handlers.py new file mode 100644 index 00000000..be323f53 --- /dev/null +++ b/cloudinit/reporting/handlers.py @@ -0,0 +1,25 @@ +import abc +import logging + +from cloudinit.registry import DictRegistry + + +class ReportingHandler(object): + + @abc.abstractmethod + def publish_event(self, event): + raise NotImplementedError + + +class LogHandler(ReportingHandler): + """Publishes events to the cloud-init log at the ``INFO`` log 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()) + + +available_handlers = DictRegistry() +available_handlers.register_item('log', LogHandler) |