summaryrefslogtreecommitdiffstats
path: root/src/lib/Logging.py
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2006-02-28 16:39:59 +0000
committerNarayan Desai <desai@mcs.anl.gov>2006-02-28 16:39:59 +0000
commit0c4bb9314b84e6a798fe9c33767d5cf456462a47 (patch)
tree46e56ebb2ae0ff490daecd8845fbd89295ef6550 /src/lib/Logging.py
parentbd4dec23c72dda97a9522b2ac95e8e657b73105f (diff)
downloadbcfg2-0c4bb9314b84e6a798fe9c33767d5cf456462a47.tar.gz
bcfg2-0c4bb9314b84e6a798fe9c33767d5cf456462a47.tar.bz2
bcfg2-0c4bb9314b84e6a798fe9c33767d5cf456462a47.zip
Reconnect syslog handler when the syslog daemon is restarted
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@1777 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Logging.py')
-rw-r--r--src/lib/Logging.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/lib/Logging.py b/src/lib/Logging.py
index 60f5e98df..b744698cc 100644
--- a/src/lib/Logging.py
+++ b/src/lib/Logging.py
@@ -1,7 +1,7 @@
'''Bcfg2 logging support'''
__revision__ = '$Revision$'
-import copy, fcntl, logging, logging.handlers, lxml.etree, math, struct, sys, termios, types
+import copy, fcntl, logging, logging.handlers, lxml.etree, math, socket, struct, sys, termios, types
def print_attributes(attrib):
''' Add the attributes for an element'''
@@ -102,13 +102,21 @@ class FragmentingSysLogHandler(logging.handlers.SysLogHandler):
newrec = copy.deepcopy(record)
newrec.msg = msgdata[start:start+250]
newrec.exc_info = error
- logging.handlers.SysLogHandler.emit(self, newrec)
+ try:
+ self.socket.send(self.format(newrec))
+ except:
+ self.socket.connect(self.address)
+ continue
# only send the traceback once
error = None
start += 250
else:
- logging.handlers.SysLogHandler.emit(self, newrec)
-
+ try:
+ self.socket.send(self.format(newrec))
+ except socket.error:
+ self.socket.connect(self.address)
+ self.socket.send(self.format(newrec))
+
def setup_logging(procname, to_console=True, to_syslog=True, syslog_facility='local0', level=0):
'''setup logging for bcfg2 software'''
if hasattr(logging, 'already_setup'):