diff options
author | Eugeni Dodonov <eugeni@mandriva.org> | 2009-02-05 21:22:03 +0000 |
---|---|---|
committer | Eugeni Dodonov <eugeni@mandriva.org> | 2009-02-05 21:22:03 +0000 |
commit | 1c15c696a048aee1632917e76d336ccc3e1030a8 (patch) | |
tree | 602cf2663a0936f5c2c31d640bbc63cd22e65062 /src | |
parent | 99d20f31a6a94c982e071e55867fda020097c9a9 (diff) | |
download | msec-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-x | src/msec/libmsec.py | 24 |
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: |