From afb5f8da541f97a9fc5c023cac7dc55b5b81dd06 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Thu, 17 Jun 2010 11:29:34 -0400 Subject: add initial logging support This logging infrastructure in cloudinit: - uses python logging - allows user supplied config of logging.config.fileConfig format to be supplied in /etc/cloud/cloud.cfg or in cloud_config by user data. - by default, tries to use syslog, if that is not available, writes directly to /var/log/cloud-init.log (syslog will not be available yet when cloud-init runs) - when using syslog, the doc/21-cloudinit.conf file provides a rsyslogd file to be placed in /etc/rsyslog.d/ that will file [CLOUDINIT] messages to /var/log/cloud-init.log --- cloud-init-run-module.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'cloud-init-run-module.py') diff --git a/cloud-init-run-module.py b/cloud-init-run-module.py index f7299f46..4ec79ff9 100755 --- a/cloud-init-run-module.py +++ b/cloud-init-run-module.py @@ -19,6 +19,7 @@ import sys import cloudinit +import logging def Usage(out = sys.stdout): out.write("Usage: cloud-init-run-module freq sem-name mod-name [args]\n") @@ -33,6 +34,9 @@ def main(): (freq,semname,modname)=sys.argv[1:4] run_args=sys.argv[4:] + cloudinit.logging_set_from_cfg_file() + log = logging.getLogger() + log.info("cloud-init-run-module %s" % sys.argv[1:]) cloud = cloudinit.CloudInit() try: cloud.get_data_source() -- cgit v1.2.3