aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEugeni Dodonov <eugeni@mandriva.org>2009-02-05 21:22:03 +0000
committerEugeni Dodonov <eugeni@mandriva.org>2009-02-05 21:22:03 +0000
commit1c15c696a048aee1632917e76d336ccc3e1030a8 (patch)
tree602cf2663a0936f5c2c31d640bbc63cd22e65062 /src
parent99d20f31a6a94c982e071e55867fda020097c9a9 (diff)
downloadmsec-1c15c696a048aee1632917e76d336ccc3e1030a8.tar
msec-1c15c696a048aee1632917e76d336ccc3e1030a8.tar.gz
msec-1c15c696a048aee1632917e76d336ccc3e1030a8.tar.bz2
msec-1c15c696a048aee1632917e76d336ccc3e1030a8.tar.xz
msec-1c15c696a048aee1632917e76d336ccc3e1030a8.zip
Falling back to interactive logging if other loggers are not available
Diffstat (limited to 'src')
-rwxr-xr-xsrc/msec/libmsec.py24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/msec/libmsec.py b/src/msec/libmsec.py
index 6d26b87..6786519 100755
--- a/src/msec/libmsec.py
+++ b/src/msec/libmsec.py
@@ -199,17 +199,25 @@ class Log:
# syslog
if log_syslog:
- self.syslog_h = SysLogHandler(facility=log_facility, address=syslog_address)
- formatter = logging.Formatter('%(name)s: %(levelname)s: %(message)s')
- self.syslog_h.setFormatter(formatter)
- self.logger.addHandler(self.syslog_h)
+ try:
+ self.syslog_h = SysLogHandler(facility=log_facility, address=syslog_address)
+ formatter = logging.Formatter('%(name)s: %(levelname)s: %(message)s')
+ self.syslog_h.setFormatter(formatter)
+ self.logger.addHandler(self.syslog_h)
+ except:
+ print >>sys.stderr, "Logging to syslog not available: %s" % (sys.exc_value[1])
+ interactive = True
# log to file
if log_file:
- self.file_h = logging.FileHandler(self.log_path)
- formatter = logging.Formatter('%(asctime)s %(levelname)s: %(message)s')
- self.file_h.setFormatter(formatter)
- self.logger.addHandler(self.file_h)
+ try:
+ self.file_h = logging.FileHandler(self.log_path)
+ formatter = logging.Formatter('%(asctime)s %(levelname)s: %(message)s')
+ self.file_h.setFormatter(formatter)
+ self.logger.addHandler(self.file_h)
+ except:
+ print >>sys.stderr, "Logging to '%s' not available: %s" % (self.log_path, sys.exc_value[1])
+ interactive = True
# interactive logging
if interactive: