2
0
mirror of https://github.com/openvswitch/ovs synced 2025-10-25 15:07:05 +00:00

vlog: Don't fail syslog initialization in chroot.

When OVS unit tests are run inside chroot environment,
there is no syslog infrastructure available. In a
situation like that, don't fail or log additional messages
to syslog by increasing the severity level of syslog very high
(log messages would continue to be logged to console and file).

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Thomas Graf <tgraf@noironetworks.com>
This commit is contained in:
Gurucharan Shetty
2015-01-28 13:12:11 -08:00
parent 491c2ea323
commit 7905aae3fc

View File

@@ -292,12 +292,19 @@ class Vlog:
if (not facility or facility == syslog_facility) and syslog_handler:
return
logger = logging.getLogger('syslog')
# If there is no infrastructure to support python syslog, increase
# the logging severity level to avoid repeated errors.
if not os.path.isfile("/dev/log"):
logger.setLevel(logging.CRITICAL)
return
if syslog_handler:
logger.removeHandler(syslog_handler)
if facility:
syslog_facility = facility
logger = logging.getLogger('syslog')
if syslog_handler:
logger.removeHandler(syslog_handler)
syslog_handler = logging.handlers.SysLogHandler(address="/dev/log",
facility=syslog_facility)
logger.addHandler(syslog_handler)