³ò
OÉcIc           @   s¼   d  Z  d d k Z d d k Z d d k Z d d k Z d d k Z d d k Z d d k Z d d k Z d e	 f d „  ƒ  YZ
 d d	 d „  ƒ  YZ e ƒ  Z d d
 d „  ƒ  YZ e i e ƒ d S(   sI   Manage logging, displaying and recording messages with required verbosityiÿÿÿÿNt   LoggerErrorc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s5   /var/lib/python-support/python2.5/rdiff_backup/log.pyR       s    t   Loggerc           B   s¶   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d d d „ Z g  d „ Z d d d „ Z RS(   s%   All functions which deal with loggingc         C   s/   d  |  _ d  |  _ d |  _ |  _ d  |  _ d  S(   Ni   (   t   Nonet   log_file_opent   log_file_localt	   verbosityt   term_verbosityt   termverbset(   t   self(    (    s5   /var/lib/python-support/python2.5/rdiff_backup/log.pyt   __init__   s    		c         C   sX   y t  | ƒ |  _ Wn$ t j
 o t i d | ƒ n X|  i p |  i |  _ n d S(   s,   Set verbosity levels.  Takes a number strings2   Verbosity must be a number, received '%s' instead.N(   t   intR   t
   ValueErrort   Logt
   FatalErrorR	   R   (   R
   t   verbosity_string(    (    s5   /var/lib/python-support/python2.5/rdiff_backup/log.pyt   setverbosity%   s     	
 c         C   sG   y t  | ƒ |  _ Wn$ t j
 o t i d | ƒ n Xd |  _ d S(   s1   Set verbosity to terminal.  Takes a number strings;   Terminal verbosity must be a number, received '%s' instead.i   N(   R   R   R   R   R   R	   (   R
   t   termverb_string(    (    s5   /var/lib/python-support/python2.5/rdiff_backup/log.pyt   setterm_verbosity-   s     	c         C   sV   |  i  p t ‚ | i i i i | ƒ x' t i D] } | i i i | i ƒ q2 Wd S(   s‰   Inform all connections of an open logfile.

		rpath.conn will write to the file, and the others will pass
		write commands off to it.

		N(	   R   t   AssertionErrort   connt   logR   t   open_logfile_localt   Globalst   connectionst   open_logfile_allconn(   R
   t   rpathR   (    (    s5   /var/lib/python-support/python2.5/rdiff_backup/log.pyt   open_logfile5   s
    
 c         C   s   d |  _  | |  _ d S(   s1   Run on all connections to signal log file is openi   N(   R   t   log_file_conn(   R
   R   (    (    s5   /var/lib/python-support/python2.5/rdiff_backup/log.pyR   A   s    	c         C   s}   | i  t i j p t ‚ y | i d ƒ |  _ Wn4 t t f j
 o" } t d | i	 | f ƒ ‚ n Xd |  _
 | |  _ d S(   s;   Open logfile locally - should only be run on one connectiont   as   Unable to open logfile %s: %si   N(   R   R   t   local_connectionR   t   opent   logfpt   OSErrort   IOErrorR    t   pathR   t   logrp(   R
   R   t   e(    (    s5   /var/lib/python-support/python2.5/rdiff_backup/log.pyR   F   s     	c         C   sI   |  i  o; x! t i D] } | i i i ƒ  q W|  i i i i ƒ  n d S(   s(   Close logfile and inform all connectionsN(   R   R   R   R   R   t   close_logfile_allconnR   t   close_logfile_local(   R
   R   (    (    s5   /var/lib/python-support/python2.5/rdiff_backup/log.pyt   close_logfileP   s
    

 c         C   s   d |  _ d S(   s   Run on every connectionN(   R   R   (   R
   (    (    s5   /var/lib/python-support/python2.5/rdiff_backup/log.pyR'   W   s    c         C   s?   |  i  t i j p t ‚ |  i i ƒ  p t ‚ d |  _ d S(   s)   Run by logging connection - close logfileN(   R   R   R   R   R!   t   closeR   R   (   R
   (    (    s5   /var/lib/python-support/python2.5/rdiff_backup/log.pyR(   [   s    c         C   sC   | d j  o | d Sn' d t  i t  i t  i  ƒ  ƒ ƒ | f Sd S(   s4   Format the message, possibly adding date informationi	   s   
s   %s  %s
N(   t   timet   asctimet	   localtime(   R
   t   messageR   (    (    s5   /var/lib/python-support/python2.5/rdiff_backup/log.pyt   formata   s     c         C   sÇ   | |  i  j o | |  i j o d Sn t | ƒ t i j p t | ƒ t i j p* t | ƒ t i j p t ‚ | ƒ  } n | |  i  j o |  i | ƒ n | |  i j o |  i	 | | ƒ n d S(   s  Log message that has verbosity importance

		message can be a string, which is logged as-is, or a function,
		which is then called and should return the string to be
		logged.  We do it this way in case producing the string would
		take a significant amount of CPU.
		
		N(
   R   R   t   typet   typest
   StringTypet   UnicodeTypet   FunctionTypeR   t   log_to_filet   log_to_term(   R
   R.   R   (    (    s5   /var/lib/python-support/python2.5/rdiff_backup/log.pyt   __call__g   s    	  c         C   sb   |  i  oT |  i o0 |  i i |  i | |  i ƒ ƒ |  i i ƒ  q^ |  i i i	 i
 | ƒ n d S(   s.   Write the message to the log file, if possibleN(   R   R   R!   t   writeR/   R   t   flushR   R   R   R5   (   R
   R.   (    (    s5   /var/lib/python-support/python2.5/rdiff_backup/log.pyR5   |   s
    

c         C   sM   | d j p
 t  i o t i } n
 t i } | i |  i | |  i ƒ ƒ d S(   s   Write message to stdout/stderri   N(   R   t   servert   syst   stderrt   stdoutR8   R/   R   (   R
   R.   R   t   termfp(    (    s5   /var/lib/python-support/python2.5/rdiff_backup/log.pyR6   „   s     	c         C   sˆ   |  i  d j  o d Sn t | ƒ t i j o t | ƒ } n t | ƒ } t i o
 d } n d } |  i d | | | | f d ƒ d S(   s  Log some data on the connection

		The main worry with this function is that something in here
		will create more network traffic, which will spiral to
		infinite regress.  So, for instance, logging must only be done
		to the terminal, because otherwise the log file may be remote.

		i	   Nt   Servert   Clients   %s %s (%d): %s(	   R   R0   R1   R2   t   reprt   strR   R:   R6   (   R
   t	   directiont   resultt   req_numt   result_reprt   conn_str(    (    s5   /var/lib/python-support/python2.5/rdiff_backup/log.pyR   Š   s    	  
 
	i    i   c         C   s]   | d j p | d j p t  ‚ | o
 d } n d } |  i | | d ƒ t i | ƒ d S(   s   Log a fatal error and exiti    i   t    s   Fatal Error: N(   R   R6   R;   t   exit(   R
   R.   t   no_fatal_messaget   errlevelt   prefix_string(    (    s5   /var/lib/python-support/python2.5/rdiff_backup/log.pyR   ›   s    ! 
c         C   si   t  i ƒ  \ } } } d | | d i t i | ƒ ƒ f } | o$ | d d i t t | ƒ ƒ 7} n | S(   sA   Return string version of current exception plus what's in arglists'   Exception '%s' raised of class '%s':
%sRH   s   __Arguments:
s   
(   R;   t   exc_infot   joint	   tracebackt	   format_tbt   mapRB   (   R
   t   arglistR0   t   valuet   tbt   s(    (    s5   /var/lib/python-support/python2.5/rdiff_backup/log.pyt   exception_to_string¥   s    "$i   c         C   s§   | d j p t  ‚ | d j p | d j o |  i o |  i } n" |  i } | |  i j o d Sn |  i ƒ  } y | | | ƒ Wn t j
 o d GH| GHn Xd S(   sÊ   Log an exception and traceback

		If only_terminal is None, log normally.  If it is 1, then only
		log to disk if log file is local (self.log_file_open = 1).  If
		it is 2, don't log to disk at all.

		i    i   i   Ns&   IOError while trying to log exception!(   i    i   i   (   R   R   R7   R6   R   RV   R#   (   R
   t   only_terminalR   t   logging_funct   exception_string(    (    s5   /var/lib/python-support/python2.5/rdiff_backup/log.pyt	   exception®   s    	 (   R   R   t   __doc__R   R   R   R   R   R   R)   R'   R(   R/   R7   R5   R6   R   R   RV   RZ   (    (    (    s5   /var/lib/python-support/python2.5/rdiff_backup/log.pyR      s$   						
								
	t   ErrorLogc           B   sV   e  Z d  Z d	 Z d d „ Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z RS(
   s[  Log each recoverable error in error_log file

	There are three types of recoverable errors:  ListError, which
	happens trying to list a directory or stat a file, UpdateError,
	which happen when trying to update a changed file, and
	SpecialFileError, which happen when a special file cannot be
	created.  See the error policy file for more info.

	i   c         C   sŸ   t  i p t  i i i i | | ƒ Sn |  i p
 t d ‚ t  i p t ‚ t  i i	 d | f ƒ } | o t
 i | ƒ |  _ n | i d d d ƒ|  _ d S(   s'   Open the error log, prepare for writings   log already opens   error_log.%s.datat   wbt   compressi    N(   R   t   isbackup_writert   backup_writerR   R\   R    t   _log_fileobjR   t   rbdirt   appendR   t	   MaybeGzip(   t   clst   time_stringR^   t   base_rp(    (    s5   /var/lib/python-support/python2.5/rdiff_backup/log.pyR    Ô   s    
 c         C   s=   t  i p t  i o |  i d j	 Sn t  i i i i ƒ  Sd S(   s,   True if the error log file is currently openN(   R   R_   R`   Ra   R   R   R\   t   isopen(   Re   (    (    s5   /var/lib/python-support/python2.5/rdiff_backup/log.pyRh   à   s    c         C   s—   t  i p  t  i i i i | | | ƒ Sn |  i | | | ƒ } t | d ƒ t  i o | d 7} n  t	 i
 d d | ƒ } | d 7} |  i i | ƒ d S(   s6   Add line to log file indicating error exc with file rpi   t    s   
t    N(   R   R_   R`   R   R\   R8   t   get_log_stringR   t   null_separatort   ret   subRa   (   Re   t
   error_typet   rpt   excRU   (    (    s5   /var/lib/python-support/python2.5/rdiff_backup/log.pyR8   æ   s    

 
c         C   sY   y | i  ƒ  SWnD t j
 o8 t | ƒ t i j o d i | ƒ SqU t | ƒ Sn Xd S(   s=   Return filename for logging.  rp is a rpath, string, or tuplet   /N(   t   get_indexpatht   AttributeErrorR0   R1   t	   TupleTypeRN   RB   (   Re   t   obj(    (    s5   /var/lib/python-support/python2.5/rdiff_backup/log.pyRs   ó   s      c         C   s   t  i o0 t  i o& t  i i i i | | t | ƒ ƒ Sn |  i ƒ  o |  i | | | ƒ n t	 |  i
 | | | ƒ d ƒ d S(   s9   Call cls.write(...) if error log open, only log otherwisei   N(   R   R_   R`   R   R\   t   write_if_openRB   Rh   R8   R   Rk   (   Re   Ro   Rp   Rq   (    (    s5   /var/lib/python-support/python2.5/rdiff_backup/log.pyRw   ú   s     c         C   sU   | d j p( | d j p | d j p t  d | ‚ d | |  i | ƒ t | ƒ f S(   s%   Return log string to put in error logt	   ListErrort   UpdateErrort   SpecialFileErrors   Unknown type s   %s %s %s(   R   Rs   RB   (   Re   Ro   Rp   Rq   (    (    s5   /var/lib/python-support/python2.5/rdiff_backup/log.pyRk     s    c         C   sF   t  i p t  i i i i ƒ  Sn |  i i ƒ  p t ‚ d |  _ d S(   s   Close the error log fileN(	   R   R_   R`   R   R\   R*   Ra   R   R   (   Re   (    (    s5   /var/lib/python-support/python2.5/rdiff_backup/log.pyR*     s    
N(   R   R   R[   R   Ra   R    Rh   R8   Rs   Rw   Rk   R*   (    (    (    s5   /var/lib/python-support/python2.5/rdiff_backup/log.pyR\   É   s   						(    (    (   R[   R+   R;   RO   R1   R   R   t   staticRm   t	   ExceptionR    R   R   R\   t	   MakeClass(    (    (    s5   /var/lib/python-support/python2.5/rdiff_backup/log.pys   <module>   s   <$ª	F