Skip to content

Commit 0eb2f90

Browse files
committed
pythongh-98307: Add docstring and documentation for SysLogHandler.createSocket
1 parent 7b48d02 commit 0eb2f90

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

Doc/library/logging.handlers.rst

+7
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,13 @@ supports sending logging messages to a remote or local Unix syslog.
650650

651651
Closes the socket to the remote host.
652652

653+
.. method:: createSocket()
654+
655+
Tries to create a socket and, if it's not a datagram socket, connect it
656+
to the other end. This method is called during handler initialization,
657+
but it's not regarded as an error if the other end isn't listening at
658+
this point - the method will be called again when emitting an event, if
659+
there is no socket at that point.
653660

654661
.. method:: emit(record)
655662

Lib/logging/handlers.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -891,14 +891,21 @@ def _connect_unixsocket(self, address):
891891
raise
892892

893893
def createSocket(self):
894+
"""
895+
Try to create a socket and, if it's not a datagram socket, connect it
896+
to the other end. This method is called during handler initialization,
897+
but it's not regarded as an error if the other end isn't listening at
898+
this point - the method will be called again when emitting an event, if
899+
there is no socket at that point.
900+
"""
894901
address = self.address
895902
socktype = self.socktype
896903

897904
if isinstance(address, str):
898905
self.unixsocket = True
899906
# Syslog server may be unavailable during handler initialisation.
900907
# C's openlog() function also ignores connection errors.
901-
# Moreover, we ignore these errors while logging, so it not worse
908+
# Moreover, we ignore these errors while logging, so it's not worse
902909
# to ignore it also here.
903910
try:
904911
self._connect_unixsocket(address)

0 commit comments

Comments
 (0)