ó
Cü½cc           @   sB   d  d l  Z  d  d l Z d  d l m Z d e f d „  ƒ  YZ d S(   iÿÿÿÿN(   t   Loggert   StampedLoggerc           B   s>   e  Z d  Z d d d d d „ Z d „  Z d „  Z d „  Z RS(   sF  Record messages in log files, including date stamp and optional label.

    If manual_reprime is on (off by default), then timestamp prefix will
    included only on first .write() and on any write immediately following a
    call to the .reprime() method.  This is useful for when StampedLogger is
    substituting for sys.stderr, where you'd like to see the grouping of
    multiple writes under a single timestamp (and there is often is one group,
    for uncaught exceptions where a script is bombing).

    In any case, the identifying prefix will only follow writes that start on
    a new line.

    Nofail (by default) says to fallback to sys.stderr if write fails to
    category file.  A message is emitted, but the IOError is caught.
    Initialize with nofail=0 if you want to handle the error in your code,
    instead.

    i    i   c         C   s>   | |  _  | |  _ d |  _ d |  _ t j |  | | | ƒ d S(   s„   If specified, optional label is included after timestamp.
        Other options are passed to the Logger class initializer.
        i   N(   t   _StampedLogger__labelt   _StampedLogger__manual_reprimet   _StampedLogger__primedt   _StampedLogger__bolR    t   __init__(   t   selft   categoryt   labelt   manual_reprimet   nofailt	   immediate(    (    s<   /export/web/mailman/mailman/Mailman/Logging/StampedLogger.pyR   +   s
    				c         C   s   d |  _  d S(   s4   Reset so timestamp will be included with next write.i   N(   R   (   R   (    (    s<   /export/web/mailman/mailman/Mailman/Logging/StampedLogger.pyt   reprime6   s    c         C   sæ   |  j  s d } n‹ |  j s% |  j rR t j d t j t j ƒ  ƒ ƒ } d |  _ n d } |  j d  k rz d t j	 ƒ  } n d |  j t j	 ƒ  f } | | } t
 j |  d | | f ƒ | rÙ | d d k rÙ d	 |  _  n	 d |  _  d  S(
   Nt    s   %b %d %H:%M:%S %Y i    s   (%d)s   %s(%d):s   %s %siÿÿÿÿs   
i   (   R   R   R   t   timet   strftimet	   localtimeR   t   Nonet   ost   getpidR    t   write(   R   t   msgt   prefixt   stampR	   (    (    s<   /export/web/mailman/mailman/Mailman/Logging/StampedLogger.pyR   :   s    			
c         C   st   d } xg | D]_ } | r/ |  j  | ƒ d } q | r\ | d d k r\ t j  |  d | ƒ q t j  |  | ƒ q Wd  S(   Ni   i    t    s   	s   
(   R   s   	s   
(   R   R    (   R   t   linest   firstt   l(    (    s<   /export/web/mailman/mailman/Mailman/Logging/StampedLogger.pyt
   writelinesO   s    	N(   t   __name__t
   __module__t   __doc__R   R   R   R   R   (    (    (    s<   /export/web/mailman/mailman/Mailman/Logging/StampedLogger.pyR      s   	
		(   R   R   t   Mailman.Logging.LoggerR    R   (    (    (    s<   /export/web/mailman/mailman/Mailman/Logging/StampedLogger.pyt   <module>   s   