Skip to content

Commit

Permalink
vlog: Don't fail syslog initialization in chroot.
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Thomas Graf <[email protected]>
  • Loading branch information
shettyg committed Jan 29, 2015
1 parent 491c2ea commit 7905aae
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions python/ovs/vlog.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,19 @@ def add_syslog_handler(facility=None):
if (not facility or facility == syslog_facility) and syslog_handler:
return

if facility:
syslog_facility = facility

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

syslog_handler = logging.handlers.SysLogHandler(address="/dev/log",
facility=syslog_facility)
logger.addHandler(syslog_handler)
Expand Down

0 comments on commit 7905aae

Please sign in to comment.