Your IP : 216.73.216.213


Current Path : /opt/alt/python27/lib/python2.7/site-packages/py/_log/
Upload File :
Current File : //opt/alt/python27/lib/python2.7/site-packages/py/_log/log.pyc

�
%q�]c@s7dZddlZddlZdefd��YZdefd��YZddd��YZd	�Ze�Zd
�Z	d�Z
d�Zd
efd��YZdefd��YZ
d�Zd�Zddd��YZxUdj�D]GZdeZy#eeeeejje��Wq�ek
r.q�Xq�WdS(s�
basic logging functionality based on a producer/consumer scheme.

XXX implement this API: (maybe put it into slogger.py?)

        log = Logger(
                    info=py.log.STDOUT,
                    debug=py.log.STDOUT,
                    command=None)
        log.info("hello", "world")
        log.command("hello", "world")

        log = Logger(info=Logger(something=...),
                     debug=py.log.STDOUT,
                     command=None)
i����NtMessagecBs,eZd�Zd�Zd�Zd�ZRS(cCs||_||_dS(N(tkeywordstargs(tselfRR((s</opt/alt/python27/lib/python2.7/site-packages/py/_log/log.pyt__init__s	cCsdjtt|j��S(Nt (tjointmaptstrR(R((s</opt/alt/python27/lib/python2.7/site-packages/py/_log/log.pytcontentscCsddj|j�S(Ns[%s] t:(RR(R((s</opt/alt/python27/lib/python2.7/site-packages/py/_log/log.pytprefixscCs|j�|j�S(N(RR	(R((s</opt/alt/python27/lib/python2.7/site-packages/py/_log/log.pyt__str__s(t__name__t
__module__RR	RR(((s</opt/alt/python27/lib/python2.7/site-packages/py/_log/log.pyRs			tProducercBsAeZdZeZiZdd�Zd�Zd�Zd�Z	RS(s� (deprecated) Log producer API which sends messages to be logged
        to a 'consumer' object, which then prints them to stdout,
        stderr, files, etc. Used extensively by PyPy-1.1.
    cKsOt|d�r$t|j��}n||_|dkrBt}n||_dS(Ntsplit(thasattrttupleRt	_keywordstNonetdefault_keywordmappert_keywordmapper(RRt
keywordmappertkw((s</opt/alt/python27/lib/python2.7/site-packages/py/_log/log.pyR+s		cCsddj|j�S(Ns<py.log.Producer %s>R
(RR(R((s</opt/alt/python27/lib/python2.7/site-packages/py/_log/log.pyt__repr__3scCsHd|krt|��n|j|j|f�}t|||�|S(Nt_(tAttributeErrort	__class__Rtsetattr(Rtnametproducer((s</opt/alt/python27/lib/python2.7/site-packages/py/_log/log.pyt__getattr__6s
cGsA|jj|j�}|dk	r=||j|j|��ndS(s0 write a message to the appropriate consumer(s) N(RtgetconsumerRRR(RRtfunc((s</opt/alt/python27/lib/python2.7/site-packages/py/_log/log.pyt__call__=sN(
R
Rt__doc__Rtkeywords2consumerRRRR R#(((s</opt/alt/python27/lib/python2.7/site-packages/py/_log/log.pyR"s		t
KeywordMappercBs5eZd�Zd�Zd�Zd�Zd�ZRS(cCs
i|_dS(N(R%(R((s</opt/alt/python27/lib/python2.7/site-packages/py/_log/log.pyRDscCs
|jj�S(N(R%tcopy(R((s</opt/alt/python27/lib/python2.7/site-packages/py/_log/log.pytgetstateGscCs!|jj�|jj|�dS(N(R%tcleartupdate(Rtstate((s</opt/alt/python27/lib/python2.7/site-packages/py/_log/log.pytsetstateIs
cCs`xJtt|�dd�D]0}y|j|| SWqtk
rHqqXqW|jjdt�S(s return a consumer matching the given keywords.

            tries to find the most suitable consumer by walking, starting from
            the back, the list of keywords, the first consumer matching a
            keyword is returned (falling back to py.log.default)
        ii����tdefault(trangetlenR%tKeyErrortgettdefault_consumer(RRti((s</opt/alt/python27/lib/python2.7/site-packages/py/_log/log.pyR!Ms
cCs�t|t�r-ttd|j���}n@t|d�rH|j}n%t|t�smtd|f��n|dk	r�t	j
j|�r�t|d�s�td|f��nt|�}n||j
|<dS(s' set a consumer for a set of keywords. Rskey %r is not a string or tupletwrites(%r should be None, callable or file-likeN(t
isinstanceRRtfilterRRRRt	TypeErrortpytbuiltintcallabletFileR%(RRtconsumer((s</opt/alt/python27/lib/python2.7/site-packages/py/_log/log.pytsetconsumer[s(R
RRR(R,R!R=(((s</opt/alt/python27/lib/python2.7/site-packages/py/_log/log.pyR&Cs
				cCstjjt|�d�dS(sD the default consumer, prints the message to stdout (using 'print') s
N(tsyststderrR4R(tmsg((s</opt/alt/python27/lib/python2.7/site-packages/py/_log/log.pyR2kscCstj||�dS(N(RR=(RR<((s</opt/alt/python27/lib/python2.7/site-packages/py/_log/log.pyR=qscCstj|�dS(N(RR,(R+((s</opt/alt/python27/lib/python2.7/site-packages/py/_log/log.pyR,tscCs
tj�S(N(RR((((s</opt/alt/python27/lib/python2.7/site-packages/py/_log/log.pyR(vsR;cBs eZdZd�Zd�ZRS(s, log consumer wrapping a file(-like) object cCs"t|d�st�||_dS(NR4(RtAssertionErrort_file(Rtf((s</opt/alt/python27/lib/python2.7/site-packages/py/_log/log.pyRscCs@|jjt|�d�t|jd�r<|jj�ndS(s write a message to the log s
tflushN(RBR4RRRD(RR@((s</opt/alt/python27/lib/python2.7/site-packages/py/_log/log.pyR#�s(R
RR$RR#(((s</opt/alt/python27/lib/python2.7/site-packages/py/_log/log.pyR;}s	tPathcBs2eZdZeeed�Zd�Zd�ZRS(s. log consumer that opens and writes to a Path cCs8||_t|�|_||_|s4|j�ndS(N(t_appendRt	_filenamet
_bufferingt	_openfile(Rtfilenametappendtdelayed_createt	buffering((s</opt/alt/python27/lib/python2.7/site-packages/py/_log/log.pyR�s
		cCs4|jrdpd}t|j|�}||_dS(Ntatw(RFtopenRGRB(RtmodeRC((s</opt/alt/python27/lib/python2.7/site-packages/py/_log/log.pyRI�scCsSt|d�s|j�n|jjt|�d�|jsO|jj�ndS(s write a message to the log RBs
N(RRIRBR4RRHRD(RR@((s</opt/alt/python27/lib/python2.7/site-packages/py/_log/log.pyR#�s

	(R
RR$tFalseRRIR#(((s</opt/alt/python27/lib/python2.7/site-packages/py/_log/log.pyRE�s
	cCstjjt|�d�dS(s$ consumer that writes to sys.stdout s
N(R>tstdoutR4R(R@((s</opt/alt/python27/lib/python2.7/site-packages/py/_log/log.pytSTDOUT�scCstjjt|�d�dS(s$ consumer that writes to sys.stderr s
N(R>R?R4R(R@((s</opt/alt/python27/lib/python2.7/site-packages/py/_log/log.pytSTDERR�stSyslogcBs#eZdZdd�Zd�ZRS(s+ consumer that writes to the syslog daemon cCs%|dkr|j}n||_dS(N(RtLOG_INFOtpriority(RRX((s</opt/alt/python27/lib/python2.7/site-packages/py/_log/log.pyR�scCs#tjjj|jt|��dS(s write a message to the log N(R8tstdtsyslogRXR(RR@((s</opt/alt/python27/lib/python2.7/site-packages/py/_log/log.pyR#�sN(R
RR$RRR#(((s</opt/alt/python27/lib/python2.7/site-packages/py/_log/log.pyRV�ss.EMERG ALERT CRIT ERR WARNING NOTICE INFO DEBUGtLOG_(((R$R8R>tobjectRRR&R2RR=R,R(R;RERTRURVRt_prioRtgetattrRYRZR(((s</opt/alt/python27/lib/python2.7/site-packages/py/_log/log.pyt<module>s(!(					
		
#