Issue #7086: Added TCP support to SysLogHandler and tidied up some anachronisms in the code.
diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst
index bdd6809..9dc98fb 100644
--- a/Doc/library/logging.rst
+++ b/Doc/library/logging.rst
@@ -763,11 +763,13 @@
Does basic configuration for the logging system by creating a
:class:`StreamHandler` with a default :class:`Formatter` and adding it to the
- root logger. The function does nothing if any handlers have been defined for
- the root logger. The functions :func:`debug`, :func:`info`, :func:`warning`,
+ root logger. The functions :func:`debug`, :func:`info`, :func:`warning`,
:func:`error` and :func:`critical` will call :func:`basicConfig` automatically
if no handlers are defined for the root logger.
+ This function does nothing if the root logger already has handlers
+ configured for it.
+
The following keyword arguments are supported.
+--------------+---------------------------------------------+
@@ -1957,16 +1959,22 @@
supports sending logging messages to a remote or local Unix syslog.
-.. class:: SysLogHandler(address=('localhost', SYSLOG_UDP_PORT), facility=LOG_USER)
+.. class:: SysLogHandler(address=('localhost', SYSLOG_UDP_PORT), facility=LOG_USER, socktype=socket.SOCK_DGRAM)
Returns a new instance of the :class:`SysLogHandler` class intended to
communicate with a remote Unix machine whose address is given by *address* in
the form of a ``(host, port)`` tuple. If *address* is not specified,
- ``('localhost', 514)`` is used. The address is used to open a UDP socket. An
+ ``('localhost', 514)`` is used. The address is used to open a socket. An
alternative to providing a ``(host, port)`` tuple is providing an address as a
string, for example "/dev/log". In this case, a Unix domain socket is used to
send the message to the syslog. If *facility* is not specified,
- :const:`LOG_USER` is used.
+ :const:`LOG_USER` is used. The type of socket opened depends on the
+ *socktype* argument, which defaults to :const:`socket.SOCK_DGRAM` and thus
+ opens a UDP socket. To open a TCP socket (for use with the newer syslog
+ daemons such as rsyslog), specify a value of :const:`socket.SOCK_STREAM`.
+
+ .. versionchanged:: 3.2
+ *socktype* was added.
.. method:: close()