summaryrefslogtreecommitdiff
path: root/cloudinit/log.py
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2012-07-09 22:06:51 -0400
committerScott Moser <smoser@ubuntu.com>2012-07-09 22:06:51 -0400
commit4b8d66b68ffc9a5cfa8fa8d129f9eed55f6ac1a7 (patch)
treea5f498d6da5403d9174c031f24bbdec4f2f80f88 /cloudinit/log.py
parentac84c966bdf6fb007b3c29f4cabb1f8fe5236579 (diff)
downloadvyos-cloud-init-4b8d66b68ffc9a5cfa8fa8d129f9eed55f6ac1a7.tar.gz
vyos-cloud-init-4b8d66b68ffc9a5cfa8fa8d129f9eed55f6ac1a7.zip
do not warn to stderr if one of the logging configs works.
In 0.6.3, if one of the logging configs succeeded, then it was just used. If it failed, it failed silently. This behavior was expected, and desired. As the code was here, we tried each log_cfg in the list anyway (possibly using the last rather than the first) and writing a messgae including 'WARN' to stderr on failure of the log.
Diffstat (limited to 'cloudinit/log.py')
-rw-r--r--cloudinit/log.py26
1 files changed, 14 insertions, 12 deletions
diff --git a/cloudinit/log.py b/cloudinit/log.py
index fc1428a2..76a2c5e0 100644
--- a/cloudinit/log.py
+++ b/cloudinit/log.py
@@ -73,8 +73,7 @@ def setupLogging(cfg=None):
# See if any of them actually load...
am_tried = 0
- am_worked = 0
- for i, log_cfg in enumerate(log_cfgs):
+ for log_cfg in enumerate(log_cfgs):
try:
am_tried += 1
# Assume its just a string if not a filename
@@ -84,19 +83,22 @@ def setupLogging(cfg=None):
log_cfg = StringIO(log_cfg)
# Attempt to load its config
logging.config.fileConfig(log_cfg)
- am_worked += 1
- except Exception as e:
- sys.stderr.write(("WARN: Setup of logging config %s"
- " failed due to: %s\n") % (i + 1, e))
+ return
+ except Exception:
+ # we do not write any logs of this here, because the default
+ # configuration includes an attempt at using /dev/log, followed
+ # up by writing to a file. /dev/log will not exist in very early
+ # boot, so an exception on that is expected.
+ pass
# If it didn't work, at least setup a basic logger (if desired)
basic_enabled = cfg.get('log_basic', True)
- if not am_worked:
- sys.stderr.write(("WARN: no logging configured!"
- " (tried %s configs)\n") % (am_tried))
- if basic_enabled:
- sys.stderr.write("Setting up basic logging...\n")
- setupBasicLogging()
+
+ sys.stderr.write(("WARN: no logging configured!"
+ " (tried %s configs)\n") % (am_tried))
+ if basic_enabled:
+ sys.stderr.write("Setting up basic logging...\n")
+ setupBasicLogging()
def getLogger(name='cloudinit'):