[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mailman-cvs
Subject:    [Mailman-checkins] CVS: mailman/Mailman/Handlers SMTPDirect.py,2.3,2.4
From:       Barry Warsaw <bwarsaw () users ! sourceforge ! net>
Date:       2001-06-27 18:08:42
[Download RAW message or body]

Update of /cvsroot/mailman/mailman/Mailman/Handlers
In directory usw-pr-cvs1:/tmp/cvs-serv879/Mailman/Handlers

Modified Files:
	SMTPDirect.py 
Log Message:
process(): Add support for configurable log files.  Four new variables
have been added:

SMTP_LOG_EVERY_MESSAGE
SMTP_LOG_SUCCESS
SMTP_LOG_REFUSED
SMTP_LOG_EACH_FAILURE

The usage and format of these variables are described in
Defaults.py.in.



Index: SMTPDirect.py
===================================================================
RCS file: /cvsroot/mailman/mailman/Mailman/Handlers/SMTPDirect.py,v
retrieving revision 2.3
retrieving revision 2.4
diff -C2 -r2.3 -r2.4
*** SMTPDirect.py	2001/05/22 21:06:47	2.3
--- SMTPDirect.py	2001/06/27 18:08:40	2.4
***************
*** 34,37 ****
--- 34,38 ----
  from Mailman import Errors
  from Mailman.Logging.Syslog import syslog
+ from Mailman.SafeDict import MsgSafeDict
  
  threading = None
***************
*** 72,89 ****
      # Log the successful post
      t1 = time.time()
!     syslog('smtp', 'smtp for %d recips, completed in %.3f seconds' %
!            (len(recips), (t1-t0)))
  
      if refused:
!         # Always log failures
!         syslog('post', 'post to %s from %s, size=%d, %d failures' %
!                (mlist.internal_name(), msg.get_sender(), len(msgtext),
!                 len(refused)))
      elif msgdata.get('tolist'):
          # Log the successful post, but only if it really was a post to the
          # mailing list.  Don't log sends to the -owner, or -admin addrs.
!         # -request addrs should never get here.
!         syslog('post', 'post to %s from %s, size=%d, success' %
!                (mlist.internal_name(), msg.get_sender(), len(msgtext)))
  
      # Process any failed deliveries.
--- 73,106 ----
      # Log the successful post
      t1 = time.time()
!     d = MsgSafeDict(msg, {'time'    : t1-t0,
!                           'size'    : len(msgtext),
!                           '#recips' : len(recips),
!                           '#refused': len(refused),
!                           'listname': mlist.internal_name(),
!                           'sender'  : msg.get_sender(),
!                           })
! 
!     # We have to use the copy() method because extended call syntax requires a
!     # concrete dictionary object; it does not allow a generic mapping.  It's
!     # still worthwhile doing the interpolation in syslog() because it'll catch
!     # any catastrophic exceptions due to bogus format strings.
!     if mm_cfg.SMTP_LOG_EVERY_MESSAGE:
!         syslog(mm_cfg.SMTP_LOG_EVERY_MESSAGE[0],
!                mm_cfg.SMTP_LOG_EVERY_MESSAGE[1], **d.copy())
  
      if refused:
!         if mm_cfg.SMTP_LOG_REFUSED:
!             syslog(mm_cfg.SMTP_LOG_REFUSED[0],
!                    mm_cfg.SMTP_LOG_REFUSED[1], **d.copy())
! 
      elif msgdata.get('tolist'):
          # Log the successful post, but only if it really was a post to the
          # mailing list.  Don't log sends to the -owner, or -admin addrs.
!         # -request addrs should never get here.  BAW: it may be useful to log
!         # the other messages, but in that case, we should probably have a
!         # separate configuration variable to control that.
!         if mm_cfg.SMTP_LOG_SUCCESS:
!             syslog(mm_cfg.SMTP_LOG_SUCCESS[0],
!                    mm_cfg.SMTP_LOG_SUCCESS[1], **d.copy())
  
      # Process any failed deliveries.
***************
*** 107,111 ****
              # future delivery.  TBD: this could generate lots of log entries!
              tempfailures.append(recip)
!         syslog('smtp-failure', '%d %s (%s)' % (code, recip, smtpmsg))
      # Return the results
      if tempfailures or permfailures:
--- 124,133 ----
              # future delivery.  TBD: this could generate lots of log entries!
              tempfailures.append(recip)
!         if mm_cfg.SMTP_LOG_EACH_FAILURE:
!             d.update({'recipient': recip,
!                       'failcode' : code,
!                       'failmsg'  : smtpmsg})
!             syslog(mm_cfg.SMTP_LOG_EACH_FAILURE[0],
!                    mm_cfg.SMTP_LOG_EACH_FAILURE[1], **d.copy())
      # Return the results
      if tempfailures or permfailures:
***************
*** 204,210 ****
              refused = conn.sendmail(envsender, recips, msgtext)
          finally:
- ##            t1 = time.time()
- ##            syslog('smtp', 'smtp for %d recips, completed in %.3f seconds' %
- ##                   (len(recips), (t1-t0)))
              conn.quit()
      except smtplib.SMTPRecipientsRefused, e:
--- 226,229 ----
***************
*** 213,217 ****
      # SMTPException.  In that case, nothing got delivered
      except (socket.error, smtplib.SMTPException), e:
!         syslog('smtp', 'All recipients refused: %s' % e)
          # If the exception had an associated error code, use it, otherwise,
          # fake it with a non-triggering exception code
--- 232,237 ----
      # SMTPException.  In that case, nothing got delivered
      except (socket.error, smtplib.SMTPException), e:
!         # BAW: should this be configurable?
!         syslog('smtp', 'All recipients refused: %s', e)
          # If the exception had an associated error code, use it, otherwise,
          # fake it with a non-triggering exception code


_______________________________________________
Mailman-checkins mailing list
Mailman-checkins@python.org
http://mail.python.org/mailman/listinfo/mailman-checkins

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic