Merge "Ignore syslog settings if /dev/log is not present"

This commit is contained in:
Zuul 2017-12-09 18:20:54 +00:00 committed by Gerrit Code Review
commit a73ed854d3
1 changed files with 9 additions and 2 deletions

View File

@ -99,10 +99,17 @@ class RootwrapConfig(object):
def setup_syslog(execname, facility, level):
try:
handler = logging.handlers.SysLogHandler(address='/dev/log',
facility=facility)
except IOError:
logging.warning("Unable to setup syslog, maybe /dev/log socket needs "
"to be restarted. Ignoring syslog configuration "
"options.")
return
rootwrap_logger = logging.getLogger()
rootwrap_logger.setLevel(level)
handler = logging.handlers.SysLogHandler(address='/dev/log',
facility=facility)
handler.setFormatter(logging.Formatter(
os.path.basename(execname) + ': %(message)s'))
rootwrap_logger.addHandler(handler)