AlkantarClanX12

Your IP : 18.117.94.77


Current Path : /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�idx�payloadrrrr�
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.)�enabledrrr�make_bufferLsr2cOs||d<t||�S)Nr
)r )r
r/r0rrr�record_breadcrumbRsr3c
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
r�ctxrrrr 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�logging�getLevelName�lower)rZ
formatted_msg)r/r0rr%�msgrrrqsz)_record_log_breadcrumb.<locals>.processor)r)�special_logging_handlers�special_logger_handlers�getr9r )r%rr=r/r0�handlerr'rr)r/r0rr%r=r�_record_log_breadcrumbes
rBc		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)rr=z
level, msg)r=z%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, )�offsetr9r/�fwdr�exec�factoryT)�
isinstancerZim_func�getattrrr:�_srcfile�os�path�normpath�currentframe�__code__�co_filename�eval�compile�co_firstlinenor+�join�__dict__rB�__doc__�AssertionErrorr,rC)	�methr�funcr/rG�codeZlogging_srcfile�ns�new_funcrrr�_wrap_logging_method�s>
r_c	Csttj}tjtjtjtjtjtjtjtjd�}x2t	|�D]&\}}t
t||�|�}ttj||�q6Wt
tjj
�tj_
dS)N)�debug�info�warning�warn�errorr&�critical�fatal)r:�Logger�DEBUG�INFO�WARNING�WARN�ERROR�CRITICAL�FATALrr_rK�setattr�log)�cls�methods�method_namerr^rrr�
_patch_logger�s
rtcCs
t�dS)zXInstalls the logging hook if it was not installed yet.  Otherwise
    does nothing.
    N)rtrrrr�install_logging_hook�srucs�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%rr=r/r0)�allow_levelrrrA�szignore_logger.<locals>.handlerN)�register_special_log_handler)�name_or_loggerrvrAr)rvr�
ignore_logger�srycCs"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)rJrr9r?)rx�callbackr9rrrrw�s
rwcCst�|�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)rzrrr�register_logging_handler
sr{cs�fdd�}|S)Ncst|�}|t�<|S)N)r�hooked_libraries)�f)r9rr�	decoratorszlibraryhook.<locals>.decoratorr)r9r~r)r9r�libraryhooksr�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�httpr�)�url�method�status_code�reason)r
r
r)r r�r�r�r�)�response)�requestrr�_record_request(s
z5_hook_requests.<locals>.send.<locals>._record_request)r$)rr�r/r0r�Zresp)�	real_send)r�r�send'sz_hook_requests.<locals>.sendz(requests.packages.urllib3.connectionpool)rv)Zrequests.sessionsr��ImportErrorr�ryr:rj)r�r�r)r�r�_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��httpsr�z:%s�)r�r�r)�
startswithr8)rZreal_url)�default_port�hostr��port�statusr�rrrNs
z7_install_httplib.<locals>.putrequest.<locals>.processorr�r�)r
r
r)�_raven_status_dictr�r�r�r )rr�r�r/r0r)�real_putrequest)r�r�r�r�r�r�r�
putrequestHs
z$_install_httplib.<locals>.putrequestcsD�|f|�|�}t|dd�}|dk	r@d|kr@|j|d<|j|d<|S)Nr�r�r�)rKr�r�)rr/r0r'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)r|�keysr@�RuntimeError)�	libraries�libr[rrr�hook_librariesls

r�)T)NNNNNNN)N)N)'�
__future__rrMrr:�typesrZraven.utils.compatrrrrZraven.utilsrr>r?�	getLoggerr%r�objectrr.r2r3r rBr_rtruryrwr{r|rr�r�r�Z
raven.contextr	rrrr�<module>s:

*

&
F


	 .