U
    ¯ªhS  ã                   @   s"   d dl Z d dlZG dd„ dƒZdS )é    Nc                   @   s,   e Zd Zdd„ Zdd„ Zd	ddœdd„ZdS )
ÚErrorInterceptorc                 C   s   || _ || _d S ©N)Ú_should_catchÚ_handler_id)ÚselfÚshould_catchZ
handler_id© r   ú=/tmp/pip-unpacked-wheel-j9z6yzd1/loguru/_error_interceptor.pyÚ__init__   s    zErrorInterceptor.__init__c                 C   s   | j S r   )r   )r   r   r   r	   r   
   s    zErrorInterceptor.should_catchN)Ú	exceptionc                C   sÌ   t js
d S |d kr"t  ¡ \}}}nt|ƒ||j  }}}z†zlt j d| j ¡ zt|ƒ}W n tk
rr   d}Y nX t j d| ¡ t	 
|||d t j¡ t j d¡ W n tk
rº   Y nX W 5 ~~~X d S )Nz,--- Logging error in Loguru Handler #%d ---
z/!\ Unprintable record /!\zRecord was: %s
z--- End of logging error ---
)ÚsysÚstderrÚexc_infoÚtypeÚ__traceback__Úwriter   ÚstrÚ	ExceptionÚ	tracebackÚprint_exceptionÚOSError)r   Úrecordr   Útype_ÚvalueZ
traceback_Zrecord_reprr   r   r	   Úprint   s"    

zErrorInterceptor.print)N)Ú__name__Ú
__module__Ú__qualname__r
   r   r   r   r   r   r	   r      s   r   )r   r   r   r   r   r   r	   Ú<module>   s   