
    ,g                      >   d Z ddlZddlZ ej                  d      Zej
                  s;ej                  ej                         ej                   ej                                 ej                  d      Z
 G d dej                        Zej                  dd       Zy)	a(  Logging setup.

The rest of the code gets the logger through this module rather than
``logging.getLogger`` to make sure that it is configured.

Logging levels are used for specific purposes:

- errors are used in ``LOGGER`` for unreachable or unusable external resources,
  including unreachable stylesheets, unreachables images and unreadable images;
- warnings are used in ``LOGGER`` for unknown or bad HTML/CSS syntaxes,
  unreachable local fonts and various non-fatal problems;
- infos are used in ``PROCESS_LOGGER`` to advertise rendering steps.

    N
weasyprintweasyprint.progressc                       e Zd ZdZd Zy)CallbackHandlerz:A logging handler that calls a function for every message.c                 P    t         j                  j                  |        || _        y )N)loggingHandler__init__emit)selfcallbacks     i/home/viktor/gitlab-persoonlijk/factuur-applicatie/venv/lib/python3.12/site-packages/weasyprint/logger.pyr
   zCallbackHandler.__init__   s      &	    N)__name__
__module____qualname____doc__r
    r   r   r   r      s
    Dr   r   c              #     K   t         j                  t        j                  |       } g fd}| j                  }| j                  }g | _        | j                  t        |             | j                  t         j                         	  || _        | j                  |       y# || _        | j                  |       w xY ww)z;Return a context manager that captures all logged messages.Nc                     | j                   dk(  ry | j                  k  ry j                  | j                  j	                          d| j                                 y )Nr   z: )namelevelnoappend	levelnameupper
getMessage)recordlevelmessagess    r   r   zcapture_logs.<locals>.emit*   sS    ;;//>>E!6++1134Bv7H7H7J6KLMr   )	r   INFO	getLoggerhandlersr   
addHandlerr   setLevelDEBUG)loggerr   r   previous_handlersprevious_levelr   s    `   @r   capture_logsr)   "   s      }v&FHN \\NFO
od+,
OOGMM"(+' ,'s   BCB* C*CC)r   N)r   
contextlibr   r!   LOGGERr"   r$   WARNINGr#   NullHandlerPROGRESS_LOGGERr	   r   contextmanagerr)   r   r   r   <module>r0      s     			<	(
OOGOO$
)g))+,#'##$9:goo  ( (r   