a
    2b                     @   s`   d Z ddlZddlZddlZddlZddlZddlZddlmZ ddl	m
Z
 G dd de
ZdS )z&A mixin for adding a debug log file.

    N)Unicode)Configurablec                   @   s(   e Zd ZeddddZejdd ZdS )DebugLogFileMixin Tz"Path to use for the debug log file)Zconfighelpc              
   c   s  | j }tj|r tj|d}|s@tjddd\}}t| | j}|j	D ]}|
| j qL|
d tj|dddd	}| j| j| jd
}|| |
d || z
d V  W n tyR } zt \}}}	t|j||	}
|
D ]}| j| qt|trtd|  td t|
d   td| | d W Y d }~nHd }~0 0 || |   |  zt!| W n t"y   Y n0 || d S )Nzjupyterlab-debug.logzjupyterlab-debug-z.log)prefixsuffixDEBUGwutf8T)Zdelay)ZfmtZdatefmtz1An error occurred. See the log file for details: zAn error occurred.zSee the log file for details:    )#debug_log_pathospathisdirjointempfileZmkstempcloseloghandlersZsetLevelZ	log_levelloggingZFileHandlerZ_log_formatter_clsZ
log_formatZlog_datefmtZsetFormatterZ
addHandler	Exceptionsysexc_info	tracebackformat_exception	__class__debug
isinstance
SystemExitprintstripexitZremoveHandlerflushremoveFileNotFoundError)selfZlog_pathZhandler   hZ_debug_handlerZ_log_formatterex_exc_tracebackmsgline r.   2lib/python3.9/site-packages/jupyterlab/debuglog.pydebug_logging   sN    








 
zDebugLogFileMixin.debug_loggingN)__name__
__module____qualname__r   r   
contextlibcontextmanagerr0   r.   r.   r.   r/   r      s   r   )__doc__r4   r   r   r   r   r   Z	traitletsr   Ztraitlets.configr   r   r.   r.   r.   r/   <module>   s   