Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib/python3.5/site-packages/raven/handlers/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib/python3.5/site-packages/raven/handlers/__pycache__/logbook.cpython-35.pyc



��Y��@s�dZddlmZddlmZddlZddlZddlZddlmZddl	m
Z
ddlmZGdd	�d	ej
�ZdS)
z�
raven.handlers.logbook
~~~~~~~~~~~~~~~~~~~~~~

:copyright: (c) 2010-2012 by the Sentry Team, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
�)�absolute_import)�print_functionN)�string_types)�Client)�	to_stringcs:eZdZ�fdd�Zdd�Zdd�Z�S)�
SentryHandlercs�t|�dkr�|d}t|t�rO|jdt�d||�|_n7t|t�rj||_ntd|jj|f��g}n7y|jd�|_Wnt	k
r�t
d��YnXtt|�j
||�dS)N�rZ
client_clsZdsnzSThe first argument to %s must be either a Client instance or a DSN, got %r instead.�clientz3Expected keyword argument for SentryHandler: client)�len�
isinstancer�poprr	�
ValueError�	__class__�__name__�KeyError�	TypeError�superr�__init__)�self�args�kwargs�arg)r��G/opt/alt/python35/lib/python3.5/site-packages/raven/handlers/logbook.pyrs
$	
	
zSentryHandler.__init__cCs�yI|jjd�r;tt|j|��dtj�dS|j|�SWn�tk
r�|j	j
rh�tddtj�tt|j�dtj�tttj
���y|j	j�Wntk
r�YnXYnXdS)N�
sentry.errors�raven�filez>Top level Sentry exception caught - failed creating log record)rr)�channel�
startswith�printr�format�sys�stderr�_emit�	Exceptionr	Zraise_send_errors�msg�	traceback�
format_excZcaptureException)r�recordrrr�emit*s"

zSentryHandler.emitc
Cs8dtj|j�j�d|ji}d}d|jd|jd|j|�i}d|jkrt|jd|d<|j	dks�|j	r�t
|j	�r�|jj|�}|j
|j|��d	}|j	|d
<d|jd|jd
|jd|jd|ji}|j
|j�|jj|d|d||�S)N�level�loggerzraven.events.Message�message�params�	formattedZtagsTzraven.events.Exception�exc_info�lineno�filename�function�process�process_name�data�extra)�logbookZget_level_namer*�lowerrr%rr rr/�allr	Zget_handler�update�capturer0r1�	func_namer3r4r6)rr(r5Z
event_typeZhandler_kwargs�handlerr6rrrr#>s.		'
				zSentryHandler._emit)r�
__module__�__qualname__rr)r#rr)rrrsr)�__doc__�
__future__rrr7r!r&Zraven.utils.compatrZ
raven.baserZraven.utils.encodingr�Handlerrrrrr�<module>s