o
    e                     @  sT   d Z ddlmZ ddlZddlmZ ddlmZ G dd dejZG dd	 d	Z	dS )
zLogging support classes.    )annotationsN)suppress)tqdmc                   @  s   e Zd ZdZdd ZdS )PageNumberFilterz>Insert PDF page number that emitted log message to log record.c                 C  s:   t |dd }t|tr|dd|_dS |d u rd|_dS )NpagenoZ5d  T)getattr
isinstanceintr   )selfrecordr    r   AD:\Projects\ConvertPro\env\Lib\site-packages\ocrmypdf/_logging.pyfilter   s   
zPageNumberFilter.filterN)__name__
__module____qualname____doc__r   r   r   r   r   r      s    r   c                   @  s(   e Zd ZdZdd Zdd Zdd ZdS )	TqdmConsolea  Wrapper to log messages in a way that is compatible with tqdm progress bar

    This routes log messages through tqdm so that it can print them above the
    progress bar, and then refresh the progress bar, rather than overwriting
    it which looks messy.
    c                 C  s
   || _ d S N)file)r   r   r   r   r   __init__"   s   
zTqdmConsole.__init__c                 C  s   t j| d| jd d S )N
)endr   )r   writerstripr   )r   msgr   r   r   r   %   s   zTqdmConsole.writec                 C  s8   t t | j  W d    d S 1 sw   Y  d S r   )r   AttributeErrorr   flush)r   r   r   r   r   )   s   
"zTqdmConsole.flushN)r   r   r   r   r   r   r   r   r   r   r   r      s
    r   )
r   
__future__r   logging
contextlibr   r   Filterr   r   r   r   r   r   <module>   s   