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.
This commit is contained in:
parent
ffc946184e
commit
ff2f43ae68
@ -73,8 +73,7 @@ def setupLogging(cfg=None):
|
|||||||
|
|
||||||
# See if any of them actually load...
|
# See if any of them actually load...
|
||||||
am_tried = 0
|
am_tried = 0
|
||||||
am_worked = 0
|
for log_cfg in enumerate(log_cfgs):
|
||||||
for i, log_cfg in enumerate(log_cfgs):
|
|
||||||
try:
|
try:
|
||||||
am_tried += 1
|
am_tried += 1
|
||||||
# Assume its just a string if not a filename
|
# Assume its just a string if not a filename
|
||||||
@ -84,19 +83,22 @@ def setupLogging(cfg=None):
|
|||||||
log_cfg = StringIO(log_cfg)
|
log_cfg = StringIO(log_cfg)
|
||||||
# Attempt to load its config
|
# Attempt to load its config
|
||||||
logging.config.fileConfig(log_cfg)
|
logging.config.fileConfig(log_cfg)
|
||||||
am_worked += 1
|
return
|
||||||
except Exception as e:
|
except Exception:
|
||||||
sys.stderr.write(("WARN: Setup of logging config %s"
|
# we do not write any logs of this here, because the default
|
||||||
" failed due to: %s\n") % (i + 1, e))
|
# 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)
|
# If it didn't work, at least setup a basic logger (if desired)
|
||||||
basic_enabled = cfg.get('log_basic', True)
|
basic_enabled = cfg.get('log_basic', True)
|
||||||
if not am_worked:
|
|
||||||
sys.stderr.write(("WARN: no logging configured!"
|
sys.stderr.write(("WARN: no logging configured!"
|
||||||
" (tried %s configs)\n") % (am_tried))
|
" (tried %s configs)\n") % (am_tried))
|
||||||
if basic_enabled:
|
if basic_enabled:
|
||||||
sys.stderr.write("Setting up basic logging...\n")
|
sys.stderr.write("Setting up basic logging...\n")
|
||||||
setupBasicLogging()
|
setupBasicLogging()
|
||||||
|
|
||||||
|
|
||||||
def getLogger(name='cloudinit'):
|
def getLogger(name='cloudinit'):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user