diff options
Diffstat (limited to 'Lib/logging')
-rw-r--r-- | Lib/logging/__init__.py | 15 | ||||
-rw-r--r-- | Lib/logging/handlers.py | 25 |
2 files changed, 25 insertions, 15 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index 9d6aa92..3bd0c6d 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -36,8 +36,8 @@ except ImportError: __author__ = "Vinay Sajip <vinay_sajip@red-dove.com>" __status__ = "beta" -__version__ = "0.4.8" -__date__ = "22 April 2003" +__version__ = "0.4.8.1" +__date__ = "26 June 2003" #--------------------------------------------------------------------------- # Miscellaneous module data @@ -233,6 +233,17 @@ class LogRecord: msg = msg % self.args return msg +def makeLogRecord(dict): + """ + Make a LogRecord whose attributes are defined by the specified dictionary, + This function is useful for converting a logging event received over + a socket connection (which is sent as a dictionary) into a LogRecord + instance. + """ + rv = LogRecord(None, None, "", 0, "", (), None) + rv.__dict__.update(dict) + return rv + #--------------------------------------------------------------------------- # Formatter classes and functions #--------------------------------------------------------------------------- diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py index 4a597a1..7ed1135 100644 --- a/Lib/logging/handlers.py +++ b/Lib/logging/handlers.py @@ -111,8 +111,12 @@ class SocketHandler(logging.Handler): A handler class which writes logging records, in pickle format, to a streaming socket. The socket is kept open across logging calls. If the peer resets it, an attempt is made to reconnect on the next call. - Note that the very simple wire protocol used means that packet sizes - are expected to be encodable within 16 bits (i.e. < 32767 bytes). + The pickle which is sent is that of the LogRecord's attribute dictionary + (__dict__), so that the receiver does not need to have the logging module + installed in order to process the logging event. + + To unpickle the record at the receiving end into a LogRecord, use the + makeLogRecord function. """ def __init__(self, host, port): @@ -208,9 +212,12 @@ class SocketHandler(logging.Handler): class DatagramHandler(SocketHandler): """ A handler class which writes logging records, in pickle format, to - a datagram socket. Note that the very simple wire protocol used means - that packet sizes are expected to be encodable within 16 bits - (i.e. < 32767 bytes). + a datagram socket. The pickle which is sent is that of the LogRecord's + attribute dictionary (__dict__), so that the receiver does not need to + have the logging module installed in order to process the logging event. + + To unpickle the record at the receiving end into a LogRecord, use the + makeLogRecord function. """ def __init__(self, host, port): @@ -236,14 +243,6 @@ class DatagramHandler(SocketHandler): when the network is busy - UDP does not guarantee delivery and can deliver packets out of sequence. """ - #old code - #sentsofar = 0 - #left = len(s) - #addr = (self.host, self.port) - #while left > 0: - # sent = self.sock.sendto(s[sentsofar:], addr) - # sentsofar = sentsofar + sent - # left = left - sent self.sock.sendto(s, (self.host, self.port)) class SysLogHandler(logging.Handler): |