File: //opt/alt/python37/lib/python3.7/site-packages/loguru/__pycache__/_handler.cpython-37.pyc
B
�P�eZ1 � @ s� d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlmZ ddlm Z ddl
mZ dd� Zd d
� Z
dd� ZG d
d� de�ZG dd� d�ZdS )� N)�contextmanager)�Thread� )� Colorizer)�create_handler_lockc C s t �| �}||�|�fS )N)r �prepare_format�colorize)�format_�
ansi_level�colored� r �@/opt/alt/python37/lib/python3.7/site-packages/loguru/_handler.py�prepare_colored_format
s
r c C s t �| �}|�� S )N)r r �strip)r r r r r
�prepare_stripped_format s
r c C s t jdd�| �S )N�@ )�maxsize)� functools� lru_cache)�functionr r r
�memoize s r c @ s e Zd ZdZdS )�Message)�recordN)�__name__�
__module__�__qualname__� __slots__r r r r
r s r c @ s� e Zd Zdd� Zdd� Zedd� �Zdd� Zd d
� Zdd� Z d
d� Z
dd� Zedd� �Z
edd� �Zdd� Zdd� Zdd� ZdS )�Handlerc C s� || _ || _|| _|| _|| _|| _|| _|| _| | _|
| _ || _
|| _|
| _|| _
d | _i | _d | _d| _t� | _t�� | _d | _d | _d | _d | _d | _d | _| jr�| jr�tt�| _q�tt�| _n.| jr�x&| j
D ]}| � |� q�W n| j�!� | _| j�r�| j d k�r(t"�#� | _t"�$� | _t"�%� | _n$| j �#� | _| j �$� | _| j �%� | _t� | _t&�'� | _t(| j)dd| j d�| _| j�*� d S )NFTzloguru-writer-%d)�target�daemon�name)+�_name�_sink�_levelno�
_formatter�_is_formatter_dynamic�_filter� _colorize�
_serialize�_enqueueZ_multiprocessing_context�_error_interceptor�_exception_formatter�_id�_levels_ansi_codes�_decolorized_format�_precolorized_formats�_memoize_dynamic_format�_stoppedr �_lock� threading�local�_lock_acquired�_queue�_queue_lock�_confirmation_event�_confirmation_lock�_owner_process_pid�_threadr r r �
update_formatr �multiprocessing�SimpleQueue�Event�Lock�os�getpidr �_queued_writer�start)�selfZsinkr �levelno� formatterZis_formatter_dynamic�filter_r � serialize�enqueueZmultiprocessing_contextZerror_interceptorZexception_formatterZid_Zlevels_ansi_codes�
level_namer r r
�__init__ s^
zHandler.__init__c C s d| j | j| jf S )Nz(id=%d, level=%d, sink=%s))r, r# r! )rE r r r
�__repr__k s zHandler.__repr__c c sJ t | jdd�rtd��d| j_z| j� dV W dQ R X W dd| j_X dS )zNAcquire the lock, but fail fast if its already acquired by the current thread.�acquiredFa
Could not acquire internal lock because it was already in use (deadlock avoided). This likely happened because the logger was re-used inside a sink, a signal handler or a '__del__' method. This is not permitted because the logger and its handlers are not re-entrant.TN)�getattrr5 �RuntimeErrorrN r2 )rE r r r
�_protected_lockn s zHandler._protected_lockc C s� �yX| j |d jkrd S | jd k r0| �|�s0d S | jr@| �|�}|�� }|d sZd|d<