vlog: Don't fail syslog initialization in chroot.
authorGurucharan Shetty <gshetty@nicira.com>
Wed, 28 Jan 2015 21:12:11 +0000 (13:12 -0800)
committerGurucharan Shetty <gshetty@nicira.com>
Thu, 29 Jan 2015 19:00:35 +0000 (11:00 -0800)
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>
python/ovs/vlog.py

index 5690924..107f18c 100644 (file)
@@ -292,12 +292,19 @@ class Vlog:
         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)