Ignore syslog settings if /dev/log is not present
When journald crashes, the /dev/log socket is not present and rootwrap calls fail with an unclear error message. Ignore syslog configuration, log a warning and proceed in those cases. Change-Id: I4152593696ad63a977f127da3b00934feb14b069 Closes-Bug: #1730949
This commit is contained in:
parent
0ff2675f7e
commit
574dede5ef
@ -99,10 +99,17 @@ class RootwrapConfig(object):
|
|||||||
|
|
||||||
|
|
||||||
def setup_syslog(execname, facility, level):
|
def setup_syslog(execname, facility, level):
|
||||||
rootwrap_logger = logging.getLogger()
|
try:
|
||||||
rootwrap_logger.setLevel(level)
|
|
||||||
handler = logging.handlers.SysLogHandler(address='/dev/log',
|
handler = logging.handlers.SysLogHandler(address='/dev/log',
|
||||||
facility=facility)
|
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.setFormatter(logging.Formatter(
|
handler.setFormatter(logging.Formatter(
|
||||||
os.path.basename(execname) + ': %(message)s'))
|
os.path.basename(execname) + ': %(message)s'))
|
||||||
rootwrap_logger.addHandler(handler)
|
rootwrap_logger.addHandler(handler)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user