6.28.2.4 SocketHandler

The SocketHandler class sends logging output to a network socket. The base class uses a TCP socket.

class SocketHandler( host, port)
Returns a new instance of the SocketHandler class intended to communicate with a remote machine whose address is given by host and port.

close( )
Closes the socket.

handleError( )

emit( )
Pickles the record's attribute dictionary and writes it to the socket in binary format. If there is an error with the socket, silently drops the packet. If the connection was previously lost, re-establishes the connection. To unpickle the record at the receiving end into a LogRecord, use the makeLogRecord function.

handleError( )
Handles an error which has occurred during emit(). The most likely cause is a lost connection. Closes the socket so that we can retry on the next event.

makeSocket( )
This is a factory method which allows subclasses to define the precise type of socket they want. The default implementation creates a TCP socket (socket.SOCK_STREAM).

makePickle( record)
Pickles the record's attribute dictionary in binary format with a length prefix, and returns it ready for transmission across the socket.

send( packet)
Send a pickled string packet to the socket. This function allows for partial sends which can happen when the network is busy.

See About this document... for information on suggesting changes.