3 # User Vinay Sajip <vinay_sajip@yahoo.co.uk>
4 # Date 1366621660 -3600
5 # Node ID d037847137866e850abc5b8e4136ca60404dcfcb
6 # Parent 9df9931fae96ab5f1cd2e516f065dccb9c061c18
7 Issue #17795: Reverted backwards-incompatible change in SysLogHandler with Unix domain sockets.
9 diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py
10 --- a/Lib/logging/handlers.py
11 +++ b/Lib/logging/handlers.py
13 -# Copyright 2001-2012 by Vinay Sajip. All Rights Reserved.
14 +# Copyright 2001-2013 by Vinay Sajip. All Rights Reserved.
16 # Permission to use, copy, modify, and distribute this software and its
17 # documentation for any purpose and without fee is hereby granted,
19 Additional handlers for the logging package for Python. The core package is
20 based on PEP 282 and comments thereto in comp.lang.python.
22 -Copyright (C) 2001-2012 Vinay Sajip. All Rights Reserved.
23 +Copyright (C) 2001-2013 Vinay Sajip. All Rights Reserved.
25 To use, simply 'import logging.handlers' and log away!
27 @@ -767,7 +767,7 @@ class SysLogHandler(logging.Handler):
30 def __init__(self, address=('localhost', SYSLOG_UDP_PORT),
31 - facility=LOG_USER, socktype=socket.SOCK_DGRAM):
32 + facility=LOG_USER, socktype=None):
36 @@ -786,18 +786,37 @@ class SysLogHandler(logging.Handler):
37 self._connect_unixsocket(address)
39 self.unixsocket = False
40 + if socktype is None:
41 + socktype = socket.SOCK_DGRAM
42 self.socket = socket.socket(socket.AF_INET, socktype)
43 if socktype == socket.SOCK_STREAM:
44 self.socket.connect(address)
45 + self.socktype = socktype
48 def _connect_unixsocket(self, address):
49 - self.socket = socket.socket(socket.AF_UNIX, self.socktype)
50 + use_socktype = self.socktype
51 + if use_socktype is None:
52 + use_socktype = socket.SOCK_DGRAM
53 + self.socket = socket.socket(socket.AF_UNIX, use_socktype)
55 self.socket.connect(address)
56 + # it worked, so set self.socktype to the used type
57 + self.socktype = use_socktype
61 + if self.socktype is not None:
62 + # user didn't specify falling back, so fail
64 + use_socktype = socket.SOCK_STREAM
65 + self.socket = socket.socket(socket.AF_UNIX, use_socktype)
67 + self.socket.connect(address)
68 + # it worked, so set self.socktype to the used type
69 + self.socktype = use_socktype
70 + except socket.error:
74 def encodePriority(self, facility, priority):
76 diff --git a/Misc/NEWS b/Misc/NEWS
83 +- Issue #17795: Reverted backwards-incompatible change in SysLogHandler with
84 + Unix domain sockets.
86 - Issue #17625: In IDLE, close the replace dialog after it is used.