o
    vh                     @   s   d dl Z d dlZd dlmZ d dlmZmZmZ d dlm	Z	 d dl
mZ g dZG dd de jZed	d
G dd dZejZddeeef fddZdeee ef fddZdS )    N)	dataclass)DictOptionalUnion)ConfigurationError)get_and_apply)StdLogOutput	LogConfigparse_logging_configc                   @   s   e Zd Ze Ze ZdS )r   N)__name__
__module____qualname__enumautoSTDERRSTDOUT r   r   T/var/www/html/hyperkenya/venv/lib/python3.10/site-packages/pyhanko/config/logging.pyr      s    r   T)frozenc                   @   sL   e Zd ZU eeef ed< 	 eeef ed< 	 edeeef fddZ	dS )r	   leveloutputreturnc                 C   s:   t | ts	td|  }|dkrtjS |dkrtjS | S )Nz)Log output must be specified as a string.stderrstdout)
isinstancestrr   lowerr   r   r   )specspec_lr   r   r   parse_output_spec   s   
zLogConfig.parse_output_specN)
r   r   r   r   intr   __annotations__r   staticmethodr   r   r   r   r   r	      s   
 r	   r   c                 C   s`   z| | }W n t y   |d ur| Y S td| dw t|ttfs.tdt| |S )NzLogging config for 'z' does not define a log level.z#Log levels must be int or str, not )KeyErrorr   r   r    r   type)settings_dictkeydefault
level_specr   r   r   _retrieve_log_level/   s   
r)   c           	      C   s   t | ts	tdt| dtd}t| dtjtj	d}d t||i}| 
di }t |ts0td| D ]$\}}t |tsAtdt|d}t|d	tjtj	d}t||d
||< q4|S )Nz%logging config should be a dictionaryz
root-level)r'   zroot-outputz	by-modulez"logging.by-module should be a dictz+Keys in logging.by-module should be stringsr   r   )r   r   )r   dictr   r)   DEFAULT_ROOT_LOGGER_LEVELr   r	   r   r   r   getitemsr   )	log_config_specroot_logger_levelroot_logger_output
log_configlogging_by_modulemodulemodule_logging_settingsr(   output_specr   r   r   r
   ?   s<   




r
   )N)r   loggingdataclassesr   typingr   r   r   pyhanko.config.errorsr   pyhanko.pdf_utils.miscr   __all__Enumr   r	   INFOr+   r    r   r)   r
   r   r   r   r   <module>   s    