mirror of
https://github.com/python/cpython.git
synced 2025-10-03 13:45:29 +00:00
amk pointed out that syslog may use UDP or TCP sockets.
Update to try UDP, if that fails, try TCP.
This commit is contained in:
parent
cc4c50c0ed
commit
f4cdb474b6
1 changed files with 7 additions and 1 deletions
|
@ -349,6 +349,12 @@ class SysLogHandler(logging.Handler):
|
||||||
self.facility = facility
|
self.facility = facility
|
||||||
if type(address) == types.StringType:
|
if type(address) == types.StringType:
|
||||||
self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
|
self.socket = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
|
||||||
|
# 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.socket.connect(address)
|
||||||
self.unixsocket = 1
|
self.unixsocket = 1
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue