ok

Mini Shell

Direktori : /opt/alt/python37/lib/python3.7/site-packages/raven/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/raven/__pycache__/breadcrumbs.cpython-37.pyc

B

��Y-�@s*ddlmZddlZddlZddlZddlmZddlmZm	Z	m
Z
mZddlm
Z
gZiZe�d�Zdd�ZGd	d
�d
e�ZGdd�de�Zd,dd�Zdd�Zd-dd�Zdd�Zd.dd�Zdd�Ze
dd��Zd/dd�Zdd�Zd d!�ZiZ d"d#�Z!e!d$�d%d&��Z"e!d'�d(d)��Z#d*d+�Z$ddl%Z&dS)0�)�absolute_importN)�FunctionType)�	iteritems�get_code�	text_type�string_types)�once�ravencCsP|d|dkoN|d|dkoN|d|dkoN|d|dkoN|d|dkS)N�type�level�message�category�data�)�a�brr�B/opt/alt/python37/lib/python3.7/site-packages/raven/breadcrumbs.py�event_payload_considered_equals
rc@s0eZdZddd�Zddd�Zdd�Zd	d
�ZdS)
�BreadcrumbBuffer�dcCsg|_||_dS)N)�buffer�limit)�selfrrrr�__init__szBreadcrumbBuffer.__init__Nc	CsZ|s|s|std��|dkr$t��}|j�|p0d|||||d�|f�|jd|j�=dS)Nz6You must pass either `message`, `data`, or `processor`�default)r
�	timestamprrr
r)�
ValueError�timer�appendr)rrrrr
rr
�	processorrrr�record#szBreadcrumbBuffer.recordcCs|jdd�=dS)N)r)rrrr�clear4szBreadcrumbBuffer.clearc	Cs�g}x�t|j�D]v\}\}}|dk	rby||�Wn"tk
rRt�d�d}YnX|df|j|<|dk	r|r|t|d|�s|�|�qW|S)Nz&Failed to process breadcrumbs. Ignored���)�	enumerater�	Exception�logger�	exceptionrr)r�rv�idxZpayloadrrrr�
get_buffer7s

zBreadcrumbBuffer.get_buffer)r)NNNNNNN)�__name__�
__module__�__qualname__rr r!r)rrrrrs


rc@seZdZdd�ZdS)�BlackholeBreadcrumbBuffercOsdS)Nr)r�args�kwargsrrrr Hsz BlackholeBreadcrumbBuffer.recordN)r*r+r,r rrrrr-Gsr-TcCs|r
t�St�S)N)rr-)Zenabledrrr�make_bufferLsr0cOs||d<t||�S)Nr
)r )r
r.r/rrr�record_breadcrumbRsr1c
Cs@|dkrt��}x*tj��D]}|j�|||||||�qWdS)z�Records a breadcrumb for all active clients.  This is what integration
    code should use rather than invoking the `captureBreadcrumb` method
    on a specific client.
    N)rr	�contextZget_active_contextsZbreadcrumbsr )rrrr
rr
rZctxrrrr Xs
r cstx$tD]}|������}|rdSqWt��j�}|dk	rR|������}|rRdS�����fdd�}t|d�dS)Ncsb�}yt��}�r��}Wntk
r0YnX��dd�|�|�jt������d��dS)N�exc_info)rr
rr)rr$�pop�update�name�loggingZgetLevelName�lower)rZ
formatted_msg)r.r/rr%�msgrrrqsz)_record_log_breadcrumb.<locals>.processor)r)�special_logging_handlers�special_logger_handlers�getr6r )r%rr9r.r/�handlerr'rr)r.r/rr%r9r�_record_log_breadcrumbes
r>c		Cs�t|t�s|j}n|}t|dd�r&dS|dkr8d}d}nd}d|}t|�}tj}|dkrltj�	tj
jj�}i}t
tdd|jd	|jd
�|�||d�|d�tj|�|d
|t�}|j|_|jt|�jks�t�|j|jk|j|jkd|_|S)N�__patched_for_raven__F)rr9z
level, msg)r9z%d, msga%(offset)sif 1:
    def factory(original, record_crumb):
        def %(name)s(self, %(args)s, *args, **kwargs):
            record_crumb(self, %(fwd)s, *args, **kwargs)
            return original(self, %(args)s, *args, **kwargs)
        return %(name)s
    
�
�z, )�offsetr6r.�fwdr�exec�factoryT)�
isinstancerZim_func�getattrrr7Z_srcfile�os�path�normpathZcurrentframe�__code__�co_filename�eval�compile�co_firstlinenor*�join�__dict__r>�__doc__�AssertionErrorr+r?)	Zmethr�funcr.rC�codeZlogging_srcfile�ns�new_funcrrr�_wrap_logging_method�s>
rXc	Csttj}tjtjtjtjtjtjtjtjd�}x2t	|�D]&\}}t
t||�|�}ttj||�q6Wt
tjj
�tj_
dS)N)�debug�infoZwarning�warn�errorr&ZcriticalZfatal)r7ZLogger�DEBUG�INFO�WARNINGZWARNZERRORZCRITICALZFATALrrXrG�setattr�log)�cls�methodsZmethod_namerrWrrr�
_patch_logger�s
rdcCs
t�dS)zXInstalls the logging hook if it was not installed yet.  Otherwise
    does nothing.
    N)rdrrrr�install_logging_hook�srecs�fdd�}t||�dS)z�Ignores a logger for the regular breadcrumb code.  This is useful
    for framework integration code where some log messages should be
    specially handled.
    cs�dk	r|�krdSdS)NFTr)r%rr9r.r/)�allow_levelrrr=�szignore_logger.<locals>.handlerN)�register_special_log_handler)�name_or_loggerrfr=r)rfr�
ignore_logger�sricCs"t|t�r|}n|j}|t|<dS)aRegisters a callback for log handling.  The callback is invoked
    with give arguments: `logger`, `level`, `msg`, `args` and `kwargs`
    which are the values passed to the logging system.  If the callback
    returns `True` the default handling is disabled.
    N)rFrr6r;)rh�callbackr6rrrrg�s
rgcCst�|�dS)aRegisters a callback for log handling.  The callback is invoked
    with give arguments: `logger`, `level`, `msg`, `args` and `kwargs`
    which are the values passed to the logging system.  If the callback
    returns `True` the default handling is disabled.
    N)r:r)rjrrr�register_logging_handler
srkcs�fdd�}|S)Ncst|�}|t�<|S)N)r�hooked_libraries)�f)r6rr�	decoratorszlibraryhook.<locals>.decoratorr)r6rnr)r6r�libraryhooksro�requestscsPyddlm}Wntk
r$dSX|j��fdd�}||_tdtjd�dS)Nr)�SessioncsN�fdd�}y�|�f|�|�}Wntk
r@|d��Yn
X||�|S)Ncs4tdd�j�j|r|jpd|r$|jp&dd�d�dS)N�httprp)�url�method�status_code�reason)r
r
r)r rsrtrurv)Zresponse)�requestrr�_record_request(s
z5_hook_requests.<locals>.send.<locals>._record_request)r$)rrwr.r/rxZresp)�	real_send)rwr�send'sz_hook_requests.<locals>.sendz(requests.packages.urllib3.connectionpool)rf)Zrequests.sessionsrq�ImportErrorrzrir7r_)rqrzr)ryr�_hook_requestssr|�httplibcsfyddlm}Wn tk
r0ddlm}YnX|j�|j��fdd�}�fdd�}||_||_dS)Nr)�HTTPConnectioncsTi|_�|j�|j�|j�������fdd�}tdd|d��|��f|�|�S)NcsZ�}|�d�s:d�dkrdpd���kr0d�p2d�f}|�d�|d	<|d	���|S)
N)zhttp://zhttps://z%s://%s%s%si�Zhttpsrrz:%s�)rsrtr)�
startswithr5)rZreal_url)�default_port�hostrt�port�statusrsrrrNs
z7_install_httplib.<locals>.putrequest.<locals>.processorrrrp)r
r
r)�_raven_status_dictr�r�r�r )rrtrsr.r/r)�real_putrequest)r�r�rtr�r�rsr�
putrequestHs
z$_install_httplib.<locals>.putrequestcsD�|f|�|�}t|dd�}|dk	r@d|kr@|j|d<|j|d<|S)Nr�rurv)rGr�rv)rr.r/r'r�)�real_getresponserr�getresponse`s

z%_install_httplib.<locals>.getresponse)r}r~r{Zhttp.clientr�r�)r~r�r�r)r�r�r�_install_httplib>sr�cCsF|dkrt��}x0|D](}t�|�}|dkr8td|��|�qWdS)NzUnknown library %r for hooking)rl�keysr<�RuntimeError)Z	libraries�librTrrr�hook_librariesls

r�)T)NNNNNNN)N)N)'Z
__future__rrHrr7�typesrZraven.utils.compatrrrrZraven.utilsrr:r;Z	getLoggerr%r�objectrr-r0r1r r>rXrdrerirgrkrlror|r�r�Z
raven.contextr	rrrr�<module>s:

*

&
F


	 .

Zerion Mini Shell 1.0