[Python-checkins] python/dist/src/Lib/logging __init__.py,1.8,1.9 handlers.py,1.5,1.6

nnorwitz@users.sourceforge.net nnorwitz@users.sourceforge.net
Tue, 22 Apr 2003 20:49:45 -0700


Update of /cvsroot/python/python/dist/src/Lib/logging
In directory sc8-pr-cvs1:/tmp/cvs-serv32209/Lib/logging

Modified Files:
	__init__.py handlers.py 
Log Message:
SF patch #725904, Minor changes to logging from module author (Vinay Sajip)
 - upgrade to version 0.4.8


Index: __init__.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/logging/__init__.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** __init__.py	2 Mar 2003 20:47:28 -0000	1.8
--- __init__.py	23 Apr 2003 03:49:43 -0000	1.9
***************
*** 36,53 ****
  
  __author__  = "Vinay Sajip <vinay_sajip@red-dove.com>"
! __status__  = "alpha"
  __version__ = "0.4.8"
! __date__    = "16 February 2003"
  
  #---------------------------------------------------------------------------
  #   Miscellaneous module data
  #---------------------------------------------------------------------------
- 
- #
- # _verinfo is used for when behaviour needs to be adjusted to the version
- # of Python
- #
- 
- _verinfo = getattr(sys, "version_info", None)
  
  #
--- 36,46 ----
  
  __author__  = "Vinay Sajip <vinay_sajip@red-dove.com>"
! __status__  = "beta"
  __version__ = "0.4.8"
! __date__    = "22 April 2003"
  
  #---------------------------------------------------------------------------
  #   Miscellaneous module data
  #---------------------------------------------------------------------------
  
  #

Index: handlers.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/logging/handlers.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** handlers.py	18 Feb 2003 14:20:07 -0000	1.5
--- handlers.py	23 Apr 2003 03:49:43 -0000	1.6
***************
*** 27,31 ****
  """
  
! import sys, logging, socket, types, os, string, cPickle, struct
  
  from SocketServer import ThreadingTCPServer, StreamRequestHandler
--- 27,31 ----
  """
  
! import sys, logging, socket, types, os, string, cPickle, struct, time
  
  from SocketServer import ThreadingTCPServer, StreamRequestHandler
***************
*** 146,151 ****
          network is busy.
          """
!         v = logging._verinfo
!         if v and (v[0] >= 2) and (v[1] >= 2):
              self.sock.sendall(s)
          else:
--- 146,150 ----
          network is busy.
          """
!         if hasattr(self.sock, "sendall"):
              self.sock.sendall(s)
          else:
***************
*** 449,452 ****
--- 448,466 ----
          return self.subject
  
+     weekdayname = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
+ 
+     monthname = [None,
+                  'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
+                  'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
+ 
+     def date_time(self):
+         """Return the current date and time formatted for a MIME header."""
+         year, month, day, hh, mm, ss, wd, y, z = time.gmtime(time.time())
+         s = "%s, %02d %3s %4d %02d:%02d:%02d GMT" % (
+                 self.weekdayname[wd],
+                 day, self.monthname[month], year,
+                 hh, mm, ss)
+         return s
+ 
      def emit(self, record):
          """
***************
*** 462,470 ****
              smtp = smtplib.SMTP(self.mailhost, port)
              msg = self.format(record)
!             msg = "From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n%s" % (
                              self.fromaddr,
                              string.join(self.toaddrs, ","),
!                             self.getSubject(record), msg
!                             )
              smtp.sendmail(self.fromaddr, self.toaddrs, msg)
              smtp.quit()
--- 476,484 ----
              smtp = smtplib.SMTP(self.mailhost, port)
              msg = self.format(record)
!             msg = "From: %s\r\nTo: %s\r\nSubject: %s\r\nDate: %s\r\n\r\n%s" % (
                              self.fromaddr,
                              string.join(self.toaddrs, ","),
!                             self.getSubject(record),
!                             self.date_time(), msg)
              smtp.sendmail(self.fromaddr, self.toaddrs, msg)
              smtp.quit()
***************
*** 588,591 ****
--- 602,613 ----
          self.method = method
  
+     def mapLogRecord(self, record):
+         """
+         Default implementation of mapping the log record into a dict
+         that is send as the CGI data. Overwrite in your class.
+         Contributed by Franz  Glasner.
+         """
+         return record.__dict__
+ 
      def emit(self, record):
          """
***************
*** 598,602 ****
              h = httplib.HTTP(self.host)
              url = self.url
!             data = urllib.urlencode(record.__dict__)
              if self.method == "GET":
                  if (string.find(url, '?') >= 0):
--- 620,624 ----
              h = httplib.HTTP(self.host)
              url = self.url
!             data = urllib.urlencode(self.mapLogRecord(record))
              if self.method == "GET":
                  if (string.find(url, '?') >= 0):