allows possibility to set the driver used in syslog for unix sockets

This changes allows a use to set the driver used to send the data over a
unix socket. 'dgram' for a dgram driver or 'stream' for a stream driver.
'stream' is the default. The change is documented in the settings
documentation.

fix #671
This commit is contained in:
benoitc 2013-12-27 13:43:48 +01:00
parent a3e7b68119
commit 24bfae8508
2 changed files with 19 additions and 2 deletions

View File

@ -1062,7 +1062,15 @@ class SyslogTo(Setting):
default = "udp://localhost:514"
desc = """\
Address to send syslog messages
Address to send syslog messages.
Adress are a string of the form:
- 'unix://PATH#TYPE' : for unix domain socket. TYPE can be 'stream'
for the stream driver or 'dgram' for the dgram driver. 'stream' is
the default.
- 'udp://HOST:PORT' : for UDP sockets
- 'tcp://HOST:PORT' : for TCP sockets
"""

View File

@ -105,7 +105,16 @@ class SafeAtoms(dict):
def parse_syslog_address(addr):
if addr.startswith("unix://"):
return (socket.SOCK_STREAM, addr.split("unix://")[1])
sock_type = socket.SOCK_STREAM
# are we using a different socket type?
parts = addr.split("#", 1)
if len(parts) == 2:
addr = parts[0]
if part[1] == "dgram":
sock_type = socket.SOCK_DGRAM
return (sock_type, addr.split("unix://")[1])
if addr.startswith("udp://"):
addr = addr.split("udp://")[1]