Skip to content

Commit f06b569

Browse files
authored
bpo-37331: Clarify format of socket handler messages in the documentation. (GH-14234)
1 parent 0150001 commit f06b569

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

Doc/library/logging.handlers.rst

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,12 @@ sends logging output to a network socket. The base class uses a TCP socket.
488488
.. method:: makePickle(record)
489489

490490
Pickles the record's attribute dictionary in binary format with a length
491-
prefix, and returns it ready for transmission across the socket.
491+
prefix, and returns it ready for transmission across the socket. The
492+
details of this operation are equivalent to::
493+
494+
data = pickle.dumps(record_attr_dict, 1)
495+
datalen = struct.pack('>L', len(data))
496+
return datalen + data
492497

493498
Note that pickles aren't completely secure. If you are concerned about
494499
security, you may want to override this method to implement a more secure
@@ -499,8 +504,12 @@ sends logging output to a network socket. The base class uses a TCP socket.
499504

500505
.. method:: send(packet)
501506

502-
Send a pickled string *packet* to the socket. This function allows for
503-
partial sends which can happen when the network is busy.
507+
Send a pickled byte-string *packet* to the socket. The format of the sent
508+
byte-string is as described in the documentation for
509+
:meth:`~SocketHandler.makePickle`.
510+
511+
This function allows for partial sends, which can happen when the network
512+
is busy.
504513

505514

506515
.. method:: createSocket()
@@ -561,7 +570,8 @@ over UDP sockets.
561570

562571
.. method:: send(s)
563572

564-
Send a pickled string to a socket.
573+
Send a pickled byte-string to a socket. The format of the sent byte-string
574+
is as described in the documentation for :meth:`SocketHandler.makePickle`.
565575

566576

567577
.. _syslog-handler:

0 commit comments

Comments
 (0)