summaryrefslogtreecommitdiffstats
path: root/Lib/logging
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2003-01-26 16:15:24 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2003-01-26 16:15:24 (GMT)
commitf4cdb474b6bdd234aa1833b7a60dbdc954ccb030 (patch)
tree496fc65e3feaff636cbb87e5d85792ff80f43525 /Lib/logging
parentcc4c50c0ed1f57cbcaa1247c6653cad35d17bc27 (diff)
downloadcpython-f4cdb474b6bdd234aa1833b7a60dbdc954ccb030.zip
cpython-f4cdb474b6bdd234aa1833b7a60dbdc954ccb030.tar.gz
cpython-f4cdb474b6bdd234aa1833b7a60dbdc954ccb030.tar.bz2
amk pointed out that syslog may use UDP or TCP sockets.
Update to try UDP, if that fails, try TCP.
Diffstat (limited to 'Lib/logging')
-rw-r--r--Lib/logging/handlers.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py
index 38711f8..bb3fe70 100644
--- a/Lib/logging/handlers.py
+++ b/Lib/logging/handlers.py
@@ -349,7 +349,13 @@ class SysLogHandler(logging.Handler):
self.facility = facility
if type(address) == types.StringType:
self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
- self.socket.connect(address)
+ # syslog may require either DGRAM or STREAM sockets
+ try:
+ self.socket.connect(address)
+ except socket.error:
+ self.socket.close()
+ self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
+ self.socket.connect(address)
self.unixsocket = 1
else:
self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)