mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
[3.11] gh-98307: Add docstring and documentation for SysLogHandler.cr… (GH-98325)
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
This commit is contained in:
parent
e26c526fd4
commit
f64e26c04e
3 changed files with 21 additions and 1 deletions
|
@ -650,6 +650,17 @@ supports sending logging messages to a remote or local Unix syslog.
|
||||||
|
|
||||||
Closes the socket to the remote host.
|
Closes the socket to the remote host.
|
||||||
|
|
||||||
|
.. method:: createSocket()
|
||||||
|
|
||||||
|
Tries to create a socket and, if it's not a datagram socket, connect it
|
||||||
|
to the other end. This method is called during handler initialization,
|
||||||
|
but it's not regarded as an error if the other end isn't listening at
|
||||||
|
this point - the method will be called again when emitting an event, if
|
||||||
|
but it's not regarded as an error if the other end isn't listening yet
|
||||||
|
--- the method will be called again when emitting an event,
|
||||||
|
if there is no socket at that point.
|
||||||
|
|
||||||
|
.. versionadded:: 3.11
|
||||||
|
|
||||||
.. method:: emit(record)
|
.. method:: emit(record)
|
||||||
|
|
||||||
|
|
|
@ -891,6 +891,13 @@ class SysLogHandler(logging.Handler):
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def createSocket(self):
|
def createSocket(self):
|
||||||
|
"""
|
||||||
|
Try to create a socket and, if it's not a datagram socket, connect it
|
||||||
|
to the other end. This method is called during handler initialization,
|
||||||
|
but it's not regarded as an error if the other end isn't listening yet
|
||||||
|
--- the method will be called again when emitting an event,
|
||||||
|
if there is no socket at that point.
|
||||||
|
"""
|
||||||
address = self.address
|
address = self.address
|
||||||
socktype = self.socktype
|
socktype = self.socktype
|
||||||
|
|
||||||
|
@ -898,7 +905,7 @@ class SysLogHandler(logging.Handler):
|
||||||
self.unixsocket = True
|
self.unixsocket = True
|
||||||
# Syslog server may be unavailable during handler initialisation.
|
# Syslog server may be unavailable during handler initialisation.
|
||||||
# C's openlog() function also ignores connection errors.
|
# C's openlog() function also ignores connection errors.
|
||||||
# Moreover, we ignore these errors while logging, so it not worse
|
# Moreover, we ignore these errors while logging, so it's not worse
|
||||||
# to ignore it also here.
|
# to ignore it also here.
|
||||||
try:
|
try:
|
||||||
self._connect_unixsocket(address)
|
self._connect_unixsocket(address)
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
A :meth:`~logging.handlers.SysLogHandler.createSocket` method was added to
|
||||||
|
:class:`~logging.handlers.SysLogHandler`.
|
Loading…
Add table
Add a link
Reference in a new issue