
    Wwg                         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e j                        Z ed	
       G d d             Zej                   Zddeeef   fdZdeee   ef   fdZy)    N)	dataclass)DictOptionalUnion)ConfigurationError)get_and_apply)StdLogOutput	LogConfigparse_logging_configc                   P    e Zd Z ej                         Z ej                         Zy)r	   N)__name__
__module____qualname__enumautoSTDERRSTDOUT     M/var/www/horilla/myenv/lib/python3.12/site-packages/pyhanko/config/logging.pyr	   r	      s    TYY[FTYY[Fr   r	   T)frozenc                   Z    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       Z	y)r
   leveloutputreturnc                     t        | t              st        d      | j                         }|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_ls     r   parse_output_speczLogConfig.parse_output_spec   sV    $$$;  X&&&x&&&Kr   N)
r   r   r   r   intr    __annotations__r	   staticmethodr$   r   r   r   r
   r
      sQ    c? ,#$$ 5s):#;  r   r
   r   c                     	 | |   }t        |t        t        f      st        dt        |             |S # t         $ r ||cY S t        d| d      w xY w)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_specs       r   _retrieve_log_levelr/   /   s|    
"3'
 j3*- 1$z2B1CD
 	
   
N "3%'EF
 	

s   6 AAc                     t        | t              st        d      t        | dt              }t        | dt        j                  t        j                        }d t        ||      i}| j                  di       }t        |t              st        d      |j                         D ]g  \  }}t        |t              st        d      t        |d      }t        |d	t        j                  t        j                        }t        ||
      ||<   i |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_specs	            r   r   r   ?   s   ot, !HII+/H '####	 	i)+=>2J (++K<'. !EFF+<+B+B+D M''&#&$=  ))@'J
##'' ''	
 'ZL
6M r   )N)r   loggingdataclassesr   typingr   r   r   pyhanko.config.errorsr   pyhanko.pdf_utils.miscr   __all__Enumr	   r
   INFOr2   r%   r    r/   r   r   r   r   <module>rE      s      ! ( ( 4 0
?499 
 $  4 $LL U38_  %T(3-2J-K %r   