From 3eda9831a4df9b3aa1d84c013a3e1d8c7f39f861 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Fri, 26 Aug 2011 16:46:16 -0700 Subject: [PATCH] ovs-monitor-ipsec: Don't abort if syslog is not available. If /dev/log doesn't exist or cannot be contacted, ovs-monitor-ipsec would abort with an exception. This allows it to start up and run. It's pretty common for a chroot used for testing not to have a syslogd instance set up and running, so this limitation caused testing problems. Reported-by: Simon Horman Tested-by: Simon Horman --- debian/ovs-monitor-ipsec | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/debian/ovs-monitor-ipsec b/debian/ovs-monitor-ipsec index 0a97c88d..a9af8eca 100755 --- a/debian/ovs-monitor-ipsec +++ b/debian/ovs-monitor-ipsec @@ -29,6 +29,7 @@ import getopt import glob import logging, logging.handlers import os +import socket import subprocess import sys @@ -38,16 +39,18 @@ import ovs.util import ovs.daemon import ovs.db.idl - -# By default log messages as DAEMON into syslog s_log = logging.getLogger("ovs-monitor-ipsec") -l_handler = logging.handlers.SysLogHandler( - "/dev/log", - facility=logging.handlers.SysLogHandler.LOG_DAEMON) -l_formatter = logging.Formatter('%(filename)s: %(levelname)s: %(message)s') -l_handler.setFormatter(l_formatter) -s_log.addHandler(l_handler) - +try: + # By default log messages as DAEMON into syslog + l_handler = logging.handlers.SysLogHandler( + "/dev/log", + facility=logging.handlers.SysLogHandler.LOG_DAEMON) + l_formatter = logging.Formatter('%(filename)s: %(levelname)s: %(message)s') + l_handler.setFormatter(l_formatter) + s_log.addHandler(l_handler) +except socket.error, e: + logging.basicConfig() + s_log.warn("failed to connect to syslog (%s)" % e) setkey = "/usr/sbin/setkey" -- 2.30.2