
    	h              	      h   d Z ddlmZ ddlZddlZddlZddlZddlZddlmZ ddl	m
Z
mZmZmZmZ ddlmZ ddlmZ dd	lmZmZ dd
lmZmZmZ ddlmZ ddlmZ ddlmZ ddl	mZm Z m!Z!m"Z"m#Z# g dZ$ej%        dd8dZ& e'            Z( G d dej)                  Z* G d de          Z+d9dZ, G d d          Z- G d  d!          Z. G d" d#          Z/d:d*Z0d:d+Z1d:d,Z2 ej3        d-dd.dd/d0d          j4        5                                Z6 G d1 d2          Z7d;d5Z8 G d6 d7ej9                  Z:dS )<z
Processors and helpers specific to the :mod:`logging` module from the `Python
standard library <https://docs.python.org/>`_.

See also :doc:`structlog's standard library support <standard-library>`.
    )annotationsN)partial)AnyCallable
CollectionIterableSequence   )_config)BoundLoggerBase)_find_first_app_frame_and_name_format_stack)_LEVEL_TO_NAME_NAME_TO_LEVELadd_log_level)merge_contextvars)	DropEvent)StackInfoRenderer)Context	EventDictExcInfo	ProcessorWrappedLogger)add_log_level_numberr   add_logger_name
ExtraAdderBoundLoggerfilter_by_level
get_loggerLoggerFactoryPositionalArgumentsFormatterProcessorFormatterrecreate_defaultsrender_to_log_kwargs)	log_levelr%   
int | NonereturnNonec                <   | #ddi}t          j        d	dt          j        | d| t	          j                     t	          j        t          t          t                      t          j
        d         t          j
        d         gt          t                                 dS )
ak  
    Recreate defaults on top of standard library's logging.

    The output looks the same, but goes through `logging`.

    As with vanilla defaults, the backwards-compatibility guarantees don't
    apply to the settings applied here.

    Arguments:

        log_level:
            If `None`, don't configure standard library logging **at all**.

            Otherwise configure it to log to `sys.stdout` at *log_level*
            (``logging.NOTSET`` being the default).

            If you need more control over `logging`, pass `None` here and
            configure it yourself.

    .. versionadded:: 22.1.0
    NforceT%(message)s)formatstreamlevel)
processorswrapper_classlogger_factory )loggingbasicConfigsysstdoutr   reset_defaults	configurer   r   r   _BUILTIN_DEFAULT_PROCESSORSr   r    )r%   kws     ]/var/www/html/web-builder-api.evdpl.com/venv/lib/python3.11/site-packages/structlog/stdlib.pyr#   r#   1   s    , t_ 	
 :	
 	
 		
 	
 	
 /3/3
 "$
 
 
 
 
 
    c                      e Zd ZdZ	 ddd
ZdS )_FixedFindCallerLoggerzi
    Change the behavior of `logging.Logger.findCaller` to cope with
    *structlog*'s extra frames.
    Fr
   
stack_infobool
stacklevelintr'    tuple[str, int, str, str | None]c                    t          dg          \  }}|rt          |          nd}|j        j        |j        |j        j        |fS )z
        Finds the first caller frame outside of structlog so that the caller
        info is populated for wrapping stdlib.

        This logger gets set as the default one when using LoggerFactory.
        r5   N)r   r   f_codeco_filenamef_linenoco_name)selfrA   rC   fnamesinfos         r=   
findCallerz!_FixedFindCallerLogger.findCallerh   sI     1)==4$.8a   Dx#QZ1A5HHr>   N)Fr
   )rA   rB   rC   rD   r'   rE   )__name__
__module____qualname____doc__rO   r4   r>   r=   r@   r@   b   sC          ;<I I I I I I Ir>   r@   c                      e Zd ZU dZded<   dN fdZdO fd
ZdO fdZdN fdZdPdQdZ	dPdQdZ
dPdQdZeZdPdQdZdPdQdZ	 dPdQdZ	 dPdRdZeZ	 dPdS fdZedTd            ZedUd             ZedVd!            ZedWd#            ZedVd$            ZedUd%            ZdXd'Z	 dYdZd+Z	 	 d[d\d6Zd]d8Zd^d;Zd^d<ZdWd=Z d]d>Z!dUd?Z"d_d@Z#d`dBZ$dadFZ%dbdGZ&dbdHZ'dbdIZ(dbdJZ)dbdKZ*e*Z+dbdLZ,dcdMZ- xZ.S )dr   a'  
    Python Standard Library version of `structlog.BoundLogger`.

    Works exactly like the generic one except that it takes advantage of
    knowing the logging methods in advance.

    Use it like::

        structlog.configure(
            wrapper_class=structlog.stdlib.BoundLogger,
        )

    It also contains a bunch of properties that pass-through to the wrapped
    `logging.Logger` which should make it work as a drop-in replacement.

    .. versionadded:: 23.1.0
       Async variants `alog()`, `adebug()`, `ainfo()`, and so forth.
    logging.Logger_logger
new_valuesr   r'   c                6     t                      j        di |S )zS
        Return a new logger with *new_values* added to the existing ones.
        r4   )superbindrK   rW   	__class__s     r=   rZ   zBoundLogger.bind   s!     uww|))j)))r>   keysstrc                0     t                      j        | S )z
        Return a new logger with *keys* removed from the context.

        Raises:

            KeyError: If the key is not part of the context.
        )rY   unbindrK   r]   r\   s     r=   r`   zBoundLogger.unbind   s     uww~t$$r>   c                0     t                      j        | S )zs
        Like :meth:`unbind`, but best effort: missing keys are ignored.

        .. versionadded:: 18.2.0
        )rY   
try_unbindra   s     r=   rc   zBoundLogger.try_unbind   s     "uww!4((r>   c                6     t                      j        di |S )z
        Clear context and binds *initial_values* using `bind`.

        Only necessary with dict implementations that keep global state like
        those wrapped by `structlog.threadlocal.wrap_dict` when threads
        are re-used.
        r4   )rY   newr[   s     r=   re   zBoundLogger.new   s!     uww{((Z(((r>   Nevent
str | Noneargsr<   c                &     | j         d|g|R i |S )zP
        Process event and call `logging.Logger.debug` with the result.
        debug_proxy_to_loggerrK   rf   rh   r<   s       r=   rj   zBoundLogger.debug   )     %t$WeAdAAAbAAAr>   c                &     | j         d|g|R i |S )zO
        Process event and call `logging.Logger.info` with the result.
        infork   rm   s       r=   rp   zBoundLogger.info   s)     %t$VU@T@@@R@@@r>   c                &     | j         d|g|R i |S )zR
        Process event and call `logging.Logger.warning` with the result.
        warningrk   rm   s       r=   rr   zBoundLogger.warning   s)     %t$YCCCCCCCr>   c                &     | j         d|g|R i |S )zP
        Process event and call `logging.Logger.error` with the result.
        errorrk   rm   s       r=   rt   zBoundLogger.error   rn   r>   c                &     | j         d|g|R i |S )zS
        Process event and call `logging.Logger.critical` with the result.
        criticalrk   rm   s       r=   rv   zBoundLogger.critical   s)     %t$ZDDDDDDDr>   c                P    |                     dd            | j        |g|R i |S )z~
        Process event and call `logging.Logger.error` with the result,
        after setting ``exc_info`` to `True`.
        exc_infoT)
setdefaultrt   rm   s       r=   	exceptionzBoundLogger.exception   s:     	j$'''tz%-$---"---r>   r.   rD   c                <     | j         t          |         |g|R i |S )zg
        Process *event* and call the appropriate logging method depending on
        *level*.
        )rl   r   rK   r.   rf   rh   r<   s        r=   logzBoundLogger.log   s.     %t$^E%:EODOOOBOOOr>   method_name
event_argsevent_kwc                J    |r||d<    t                      j        |fd|i|S )a  
        Propagate a method call to the wrapped logger.

        This is the same as the superclass implementation, except that
        it also preserves positional arguments in the ``event_dict`` so
        that the stdlib's support for format strings can be used.
        positional_argsrf   )rY   rl   )rK   r~   rf   r   r   r\   s        r=   rl   zBoundLogger._proxy_to_logger   s<      	5*4H&''uww'MM5MHMMMr>   c                    | j         j        S )z5
        Returns :attr:`logging.Logger.name`
        )rV   rM   rK   s    r=   rM   zBoundLogger.name   s    
 |  r>   c                    | j         j        S )z6
        Returns :attr:`logging.Logger.level`
        )rV   r.   r   s    r=   r.   zBoundLogger.level  s    
 |!!r>   c                    | j         j        S )z7
        Returns :attr:`logging.Logger.parent`
        )rV   parentr   s    r=   r   zBoundLogger.parent
  s    
 |""r>   rB   c                    | j         j        S )z:
        Returns :attr:`logging.Logger.propagate`
        )rV   	propagater   s    r=   r   zBoundLogger.propagate  s    
 |%%r>   c                    | j         j        S )z9
        Returns :attr:`logging.Logger.handlers`
        )rV   handlersr   s    r=   r   zBoundLogger.handlers      
 |$$r>   c                    | j         j        S )z9
        Returns :attr:`logging.Logger.disabled`
        )rV   disabledr   s    r=   r   zBoundLogger.disabled  r   r>   r(   c                :    | j                             |           dS )zR
        Calls :meth:`logging.Logger.setLevel` with unmodified arguments.
        N)rV   setLevelrK   r.   s     r=   r   zBoundLogger.setLevel&  s      	e$$$$$r>   FrA   rE   c                8    | j                             |          S )zT
        Calls :meth:`logging.Logger.findCaller` with unmodified arguments.
        )rA   )rV   rO   )rK   rA   s     r=   rO   zBoundLogger.findCaller,  s     |&&*&===r>   rM   fnlnomsgtuple[Any, ...]rx   r   funcextralogging.LogRecordc
                H    | j                             |||||||||		  	        S )zT
        Calls :meth:`logging.Logger.makeRecord` with unmodified arguments.
        )r   r   )rV   
makeRecord)
rK   rM   r.   r   r   r   rh   rx   r   r   s
             r=   r   zBoundLogger.makeRecord4  s6     |&&%S#tXD ' 
 
 	
r>   recordc                :    | j                             |           dS )zP
        Calls :meth:`logging.Logger.handle` with unmodified arguments.
        N)rV   handlerK   r   s     r=   r   zBoundLogger.handleG  s      	F#####r>   hdlrlogging.Handlerc                :    | j                             |           dS )zT
        Calls :meth:`logging.Logger.addHandler` with unmodified arguments.
        N)rV   
addHandlerrK   r   s     r=   r   zBoundLogger.addHandlerM  s      	%%%%%r>   c                :    | j                             |           dS )zW
        Calls :meth:`logging.Logger.removeHandler` with unmodified arguments.
        N)rV   removeHandlerr   s     r=   r   zBoundLogger.removeHandlerS  s      	""4(((((r>   c                4    | j                                         S )zw
        Calls :meth:`logging.Logger.hasHandlers` with unmodified arguments.

        Exists only in Python 3.
        )rV   hasHandlersr   s    r=   r   zBoundLogger.hasHandlersY  s     |'')))r>   c                :    | j                             |           dS )zV
        Calls :meth:`logging.Logger.callHandlers` with unmodified arguments.
        N)rV   callHandlersr   s     r=   r   zBoundLogger.callHandlersa  s      	!!&)))))r>   c                4    | j                                         S )zc
        Calls :meth:`logging.Logger.getEffectiveLevel` with unmodified
        arguments.
        )rV   getEffectiveLevelr   s    r=   r   zBoundLogger.getEffectiveLevelg  s    
 |--///r>   c                6    | j                             |          S )zV
        Calls :meth:`logging.Logger.isEnabledFor` with unmodified arguments.
        )rV   isEnabledForr   s     r=   r   zBoundLogger.isEnabledForn  s     |((///r>   suffixc                6    | j                             |          S )zR
        Calls :meth:`logging.Logger.getChild` with unmodified arguments.
        )rV   getChild)rK   r   s     r=   r   zBoundLogger.getChildt  s     |$$V,,,r>   methCallable[..., Any]dict[str, Any]c                   K   t          j                    t          j                                        dfd           d{V  dS )S
        Merge contextvars and log using the sync logger in a thread pool.
        Nc                 :                          fd          S )Nc                      g R i S Nr4   rh   rf   r<   r   s   r=   <lambda>zABoundLogger._dispatch_to_sync.<locals>.<lambda>.<locals>.<lambda>  !    DD$<$<$<$<$<$< r>   runrh   ctxrf   r<   r   s   r=   r   z/BoundLogger._dispatch_to_sync.<locals>.<lambda>  &    CGG<<<<<<<== r>   )contextvarscopy_contextasyncioget_running_looprun_in_executorrK   r   rf   rh   r<   r   s    ````@r=   _dispatch_to_synczBoundLogger._dispatch_to_sync{  s       &((&((88========
 
 	
 	
 	
 	
 	
 	
 	
 	
 	
r>   c                P   K   |                      | j        |||           d{V  dS )zq
        Log using `debug()`, but asynchronously in a separate thread.

        .. versionadded:: 23.1.0
        N)r   rj   rm   s       r=   adebugzBoundLogger.adebug  <       $$TZbAAAAAAAAAAAr>   c                P   K   |                      | j        |||           d{V  dS )zp
        Log using `info()`, but asynchronously in a separate thread.

        .. versionadded:: 23.1.0
        N)r   rp   rm   s       r=   ainfozBoundLogger.ainfo  s<       $$TYtR@@@@@@@@@@@r>   c                P   K   |                      | j        |||           d{V  dS )zs
        Log using `warning()`, but asynchronously in a separate thread.

        .. versionadded:: 23.1.0
        N)r   rr   rm   s       r=   awarningzBoundLogger.awarning  s<       $$T\5$CCCCCCCCCCCr>   c                P   K   |                      | j        |||           d{V  dS )zq
        Log using `error()`, but asynchronously in a separate thread.

        .. versionadded:: 23.1.0
        N)r   rt   rm   s       r=   aerrorzBoundLogger.aerror  r   r>   c                P   K   |                      | j        |||           d{V  dS )zt
        Log using `critical()`, but asynchronously in a separate thread.

        .. versionadded:: 23.1.0
        N)r   rv   rm   s       r=   	acriticalzBoundLogger.acritical  s<       $$T]E4DDDDDDDDDDDr>   c                   K   |                     dd          du r+|                     d          t          j                    |d<   |                     | j        |||           d{V  dS )zu
        Log using `exception()`, but asynchronously in a separate thread.

        .. versionadded:: 23.1.0
        rx   Trz   N)getr7   rx   r   rz   rm   s       r=   
aexceptionzBoundLogger.aexception  su       66*d##t++{0C0C0K \^^BzN$$T^UD"EEEEEEEEEEEr>   c                l   K   |                      t          | j        |          |||           d{V  dS )zo
        Log using `log()`, but asynchronously in a separate thread.

        .. versionadded:: 23.1.0
        N)r   r   r}   r|   s        r=   alogzBoundLogger.alog  sF       $$WTXu%=%=udBOOOOOOOOOOOr>   )rW   r   r'   r   )r]   r^   r'   r   r   )rf   rg   rh   r   r<   r   r'   r   )
r.   rD   rf   rg   rh   r   r<   r   r'   r   )
r~   r^   rf   rg   r   r^   r   r   r'   r   )r'   r^   )r'   rD   )r'   r   )r'   rB   )r.   rD   r'   r(   )F)rA   rB   r'   rE   )NN)rM   r^   r.   rD   r   r^   r   rD   r   r^   rh   r   rx   r   r   rg   r   r   r'   r   )r   r   r'   r(   )r   r   r'   r(   )r.   rD   r'   rB   )r   r^   r'   rU   
r   r   rf   r^   rh   r   r<   r   r'   r(   rf   r^   rh   r   r<   r   r'   r(   
r.   r   rf   r^   rh   r   r<   r   r'   r(   )/rP   rQ   rR   rS   __annotations__rZ   r`   rc   re   rj   rp   rr   warnrt   rv   rz   r}   fatalrl   propertyrM   r.   r   r   r   r   r   rO   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   afatalr   r   __classcell__r\   s   @r=   r   r   x   s?         & * * * * * *% % % % % %) ) ) ) ) )) ) ) ) ) )B B B B BA A A A AD D D D D DB B B B BE E E E E #'	. 	. 	. 	. 	. /3P P P P P E
 !N N N N N N N, ! ! ! X! " " " X" # # # X# & & & X& % % % X% % % % X%% % % % "'> > > > >"  
 
 
 
 
&$ $ $ $& & & &) ) ) )* * * ** * * *0 0 0 00 0 0 0- - - -
 
 
 
"B B B BA A A AD D D DB B B BE E E E FF F F FP P P P P P P Pr>   r   rh   r   initial_valuesc                 $    t          j        | i |S )a/  
    Only calls `structlog.get_logger`, but has the correct type hints.

    .. warning::

       Does **not** check whether -- or ensure that -- you've configured
       *structlog* for standard library :mod:`logging`!

       See :doc:`standard-library` for details.

    .. versionadded:: 20.2.0
    )r   r   )rh   r   s     r=   r   r     s     t6~666r>   c                      e Zd ZU dZdZded<   ded<   dZeZdddd,dZ	e
d-d            Zd.dZd.dZd/dZd/dZd0d#Zd1d$Zd1d%Zd1d&ZeZd1d'Zd1d(ZeZd1d)Zd2d+ZdS )3AsyncBoundLoggera`  
    Wraps a `BoundLogger` & exposes its logging methods as ``async`` versions.

    Instead of blocking the program, they are run asynchronously in a thread
    pool executor.

    This means more computational overhead per log call. But it also means that
    the processor chain (e.g. JSON serialization) and I/O won't block your
    whole application.

    Only available for Python 3.7 and later.

    .. versionadded:: 20.2.0
    .. versionchanged:: 20.2.0 fix _dispatch_to_sync contextvars usage
    .. deprecated:: 23.1.0
       Use the regular `BoundLogger` with its a-prefixed methods instead.
    )sync_bl_loopr   r   r   _contextN)_sync_blr   loggerrU   r1   Iterable[Processor]contextr   r   r   c                   |r|| _         || _        d S |                     |||          | _         t          j                    | _        d S )N)r   r1   r   )r   r   _bound_logger_factoryr   r   )rK   r   r1   r   r   r   s         r=   __init__zAsyncBoundLogger.__init__  sX      	#DLDJF11j' 2 
 
 -//


r>   r'   c                    | j         j        S r   )r   r   r   s    r=   r   zAsyncBoundLogger._context  s    |$$r>   rW   c           
     T    t          d di  | j        j        di || j                  S Nr4   )r   r1   r   r   r   )r   r   rZ   r   rK   rW   s     r=   rZ   zAsyncBoundLogger.bind  sA     &T\&4444*	
 	
 	
 		
r>   c           
     T    t          d di  | j        j        di || j                  S r   )r   r   re   r   r   s     r=   re   zAsyncBoundLogger.new'  s?    %T\%33
33*
 
 
 	
r>   r]   r^   c                N    t          d di  | j        j        | | j                  S r   )r   r   r`   r   rK   r]   s     r=   r`   zAsyncBoundLogger.unbind1  s6    (T\($/*
 
 
 	
r>   c                N    t          d di  | j        j        | | j                  S r   )r   r   rc   r   r   s     r=   rc   zAsyncBoundLogger.try_unbind;  s6    ,T\,d3*
 
 
 	
r>   r   r   rf   rh   r   r<   r   r(   c                   K   t          j                    t          j                                        | j        fd           d{V  dS )r   c                 :                          fd          S )Nc                      g R i S r   r4   r   s   r=   r   zFAsyncBoundLogger._dispatch_to_sync.<locals>.<lambda>.<locals>.<lambda>S  r   r>   r   r   s   r=   r   z4AsyncBoundLogger._dispatch_to_sync.<locals>.<lambda>S  r   r>   N)r   r   r   r   r   	_executorr   s    ````@r=   r   z"AsyncBoundLogger._dispatch_to_syncE  s       &((&((88N========
 
 	
 	
 	
 	
 	
 	
 	
 	
 	
r>   c                Z   K   |                      | j        j        |||           d {V  d S r   )r   r   rj   rm   s       r=   rj   zAsyncBoundLogger.debugV  =      $$T\%7bIIIIIIIIIIIr>   c                Z   K   |                      | j        j        |||           d {V  d S r   )r   r   rp   rm   s       r=   rp   zAsyncBoundLogger.infoY  s=      $$T\%6tRHHHHHHHHHHHr>   c                Z   K   |                      | j        j        |||           d {V  d S r   )r   r   rr   rm   s       r=   rr   zAsyncBoundLogger.warning\  s=      $$T\%95$KKKKKKKKKKKr>   c                Z   K   |                      | j        j        |||           d {V  d S r   )r   r   rt   rm   s       r=   rt   zAsyncBoundLogger.errora  r   r>   c                Z   K   |                      | j        j        |||           d {V  d S r   )r   r   rv   rm   s       r=   rv   zAsyncBoundLogger.criticald  s=      $$T\%:E4LLLLLLLLLLLr>   c                   K   |                     dd           }|(|                    d          t          j                    }||d<   |                     | j        j        |||           d {V  d S )Nrx   rz   )popr   r7   rx   r   r   rz   )rK   rf   rh   r<   eis        r=   rz   zAsyncBoundLogger.exceptioni  s|       VVJ%%:"&&--5B:$$T\%;UD"MMMMMMMMMMMr>   r.   c                v   K   |                      t          | j        j        |          |||           d {V  d S r   )r   r   r   r}   r|   s        r=   r}   zAsyncBoundLogger.logt  s^      $$DL$e,,eT2
 
 	
 	
 	
 	
 	
 	
 	
 	
 	
r>   )
r   rU   r1   r   r   r   r   r   r   r   )r'   r   )rW   r   r'   r   )r]   r^   r'   r   r   r   r   )rP   rQ   rR   rS   	__slots__r   r   r   r   r   r   r   rZ   re   r`   rc   r   rj   rp   rr   r   rt   rv   r   rz   r}   r4   r>   r=   r   r     s         $ %I  I' 0 0 0 0 0 02 % % % X%

 

 

 


 
 
 

 
 
 

 
 
 

 
 
 
"J J J JI I I IL L L L DJ J J JM M M M E	N 	N 	N 	N
 
 
 
 
 
r>   r   c                  $    e Zd ZdZdddZdd
ZdS )r    a  
    Build a standard library logger when an *instance* is called.

    Sets a custom logger using :func:`logging.setLoggerClass` so variables in
    log format are expanded properly.

    >>> from structlog import configure
    >>> from structlog.stdlib import LoggerFactory
    >>> configure(logger_factory=LoggerFactory())

    Arguments:

        ignore_frame_names:
            When guessing the name of a logger, skip frames whose names *start*
            with one of these.  For example, in pyramid applications you'll
            want to set it to ``["venusian", "pyramid.config"]``. This argument
            is called *additional_ignores* in other APIs throughout
            *structlog*.
    Nignore_frame_nameslist[str] | Nonec                F    || _         t          j        t                     d S r   )_ignorer5   setLoggerClassr@   )rK   r	  s     r=   r   zLoggerFactory.__init__  s!    )566666r>   rh   r   r'   rU   c                    |rt          j        |d                   S t          | j                  \  }}t          j        |          S )aM  
        Deduce the caller's module name and create a stdlib logger.

        If an optional argument is passed, it will be used as the logger name
        instead of guesswork.  This optional argument would be passed from the
        :func:`structlog.get_logger` call.  For example
        ``structlog.get_logger("foo")`` would cause this method to be called
        with ``"foo"`` as its first positional argument.

        .. versionchanged:: 0.4.0
            Added support for optional positional arguments.  Using the first
            one for naming the constructed logger.
        r   )r5   	getLoggerr   r  )rK   rh   _rM   s       r=   __call__zLoggerFactory.__call__  sG      	.$T!W--- 1>>4 &&&r>   r   )r	  r
  )rh   r   r'   rU   rP   rQ   rR   rS   r   r  r4   r>   r=   r    r    z  sK         (7 7 7 7 7' ' ' ' ' 'r>   r    c                  $    e Zd ZdZdddZddZdS )r!   aN  
    Apply stdlib-like string formatting to the ``event`` key.

    If the ``positional_args`` key in the event dict is set, it must
    contain a tuple that is used for formatting (using the ``%s`` string
    formatting operator) of the value from the ``event`` key.  This works
    in the same way as the stdlib handles arguments to the various log
    methods: if the tuple contains only a single `dict` argument it is
    used for keyword placeholders in the ``event`` string, otherwise it
    will be used for positional placeholders.

    ``positional_args`` is populated by `structlog.stdlib.BoundLogger` or
    can be set manually.

    The *remove_positional_args* flag can be set to `False` to keep the
    ``positional_args`` key in the event dict; by default it will be
    removed from the event dict after formatting a message.
    Tremove_positional_argsrB   r'   r(   c                    || _         d S r   )r  )rK   r  s     r=   r   z%PositionalArgumentsFormatter.__init__  s    &<###r>   r  r   __r^   
event_dictr   c                    |                     d          }|rNt          |          dk    r+t          |d         t                    r|d         r|d         }|dxx         |z  cc<   | j        r||d= |S )Nr   r
   r   rf   )r   len
isinstancedictr  )rK   r  r  r  rh   s        r=   r  z%PositionalArgumentsFormatter.__call__  s     ~~/00  	(4yyA~~*T!Wd";";~Q~Aww4'& 	.4+;,-r>   N)T)r  rB   r'   r(   r  r   r  r^   r  r   r'   r   r  r4   r>   r=   r!   r!     sK         &= = = = =     r>   r!   r   rU   r~   r^   r  r   c                T    |                      t          |                   r|S t          )aA  
    Check whether logging is configured to accept messages from this log level.

    Should be the first processor if stdlib's filtering by level is used so
    possibly expensive processors like exception formatters are avoided in the
    first place.

    >>> import logging
    >>> from structlog.stdlib import filter_by_level
    >>> logging.basicConfig(level=logging.WARN)
    >>> logger = logging.getLogger()
    >>> filter_by_level(logger, 'warn', {})
    {}
    >>> filter_by_level(logger, 'debug', {})
    Traceback (most recent call last):
    ...
    DropEvent
    )r   r   r   r   r~   r  s      r=   r   r     s*    * >+677 
Or>   c                &    t           |         |d<   |S )a  
    Add the log level number to the event dict.

    Log level numbers map to the log level names. The Python stdlib uses them
    for filtering logic. This adds the same numbers so users can leverage
    similar filtering. Compare::

       level in ("warning", "error", "critical")
       level_number >= 30

    The mapping of names to numbers is in
    ``structlog.stdlib._log_levels._NAME_TO_LEVEL``.

    .. versionadded:: 18.2.0
    level_number)r   r  s      r=   r   r     s    $ "0!<J~r>   c                ^    |                     d          }|| j        |d<   n
|j        |d<   |S )z0
    Add the logger name to the event dict.
    _recordNr   )r   rM   )r   r~   r  r   s       r=   r   r   	  s;     ^^I&&F~%{
8%{
8r>   rM   pathnamer   r4   c                  X    e Zd ZdZdZdddZddZedd            Zedd            Z	dS )r   a  
    Add extra attributes of `logging.LogRecord` objects to the event
    dictionary.

    This processor can be used for adding data passed in the ``extra``
    parameter of the `logging` module's log methods to the event dictionary.

    Arguments:

        allow:
            An optional collection of attributes that, if present in
            `logging.LogRecord` objects, will be copied to event dictionaries.

            If ``allow`` is None all attributes of `logging.LogRecord` objects
            that do not exist on a standard `logging.LogRecord` object will be
            copied to event dictionaries.

    .. versionadded:: 21.5.0
    )_copierNallowCollection[str] | Noner'   r(   c                l    |  |#t          j        | j        g |          | _        d S | j        | _        d S r   )	functoolsr   _copy_allowedr%  	_copy_all)rK   r&  s     r=   r   zExtraAdder.__init__3  s<    D %,T-?5JJDLLL>DLLLr>   r   rU   rM   r^   r  r   c                `    |                     d          }||                     ||           |S )Nr"  )r   r%  )rK   r   rM   r  r   s        r=   r  zExtraAdder.__call__=  s5     ,6>>)+D+DLLV,,,r>   r   r   c                `    |j                                         D ]\  }}|t          vr|||<   d S r   )__dict__items_LOG_RECORD_KEYS)clsr  r   keyvalues        r=   r+  zExtraAdder._copy_allE  sE     !///11 	( 	(JC***"'
3	( 	(r>   Collection[str]c                B    |D ]}||j         v r|j         |         ||<   d S r   )r.  )r1  r&  r  r   r2  s        r=   r*  zExtraAdder._copy_allowedM  s;      	7 	7Cfo%%"(/#"6
3	7 	7r>   r   )r&  r'  r'   r(   )r   rU   rM   r^   r  r   r'   r   )r  r   r   r   r'   r(   )r&  r4  r  r   r   r   r'   r(   )
rP   rQ   rR   rS   r  r   r  classmethodr+  r*  r4   r>   r=   r   r     s         ( I* * * * *    ( ( ( [( 7 7 7 [7 7 7r>   r   r  r  c                P                         d          dfddD             S )a  
    Render ``event_dict`` into keyword arguments for `logging.log`.

    The ``event`` field is translated into ``msg`` and the rest of the
    *event_dict* is added as ``extra``.

    This allows you to defer formatting to `logging`.

    .. versionadded:: 17.1.0
    .. versionchanged:: 22.1.0
       ``exc_info``, ``stack_info``, and ``stackLevel`` are passed as proper
       kwargs and not put into ``extra``.
    rf   )r   r   c                D    i | ]}|v |                     |          S r4   r  ).0r<   r  s     r=   
<dictcomp>z(render_to_log_kwargs.<locals>.<dictcomp>l  s<     
 
 
Z 
r""r>   )rx   rA   
stackLevelr9  r  r  r  s     `r=   r$   r$   Y  sQ    " ~~g&& 
 
 
 
>
 
 
 r>   c                  p     e Zd ZdZ	 	 	 	 	 	 	 d$d% fdZd& fdZed'd            Zed(d#            Z xZ	S ))r"   a  
    Call *structlog* processors on `logging.LogRecord`\s.

    This is an implementation of a `logging.Formatter` that can be used to
    format log entries from both *structlog* and `logging`.

    Its static method `wrap_for_formatter` must be the final processor in
    *structlog*'s processor chain.

    Please refer to :ref:`processor-formatter` for examples.

    Arguments:

        foreign_pre_chain:
            If not `None`, it is used as a processor chain that is applied to
            **non**-*structlog* log entries before the event dictionary is
            passed to *processors*. (default: `None`)

        processors:
            A chain of *structlog* processors that is used to process **all**
            log entries. The last one must render to a `str` which then gets
            passed on to `logging` for output.

            Compared to *structlog*'s regular processor chains, there's a few
            differences:

            - The event dictionary contains two additional keys:

              #. ``_record``: a `logging.LogRecord` that either was created
                  using `logging` APIs, **or** is a wrapped *structlog* log
                  entry created by `wrap_for_formatter`.

              #. ``_from_structlog``: a `bool` that indicates whether or not
                 ``_record`` was created by a *structlog* logger.

              Since you most likely don't want ``_record`` and
              ``_from_structlog`` in your log files,  we've added the static
              method `remove_processors_meta` to ``ProcessorFormatter`` that
              you can add just before your renderer.

            - Since this is a `logging` *formatter*, raising
              `structlog.DropEvent` will crash your application.

        keep_exc_info:
            ``exc_info`` on `logging.LogRecord`\ s is added to the
            ``event_dict`` and removed afterwards. Set this to ``True`` to keep
            it on the `logging.LogRecord`. (default: False)

        keep_stack_info:
            Same as *keep_exc_info* except for ``stack_info``. (default: False)

        logger:
            Logger which we want to push through the *structlog* processor
            chain. This parameter is necessary for some of the processors like
            `filter_by_level`. (default: None)

        pass_foreign_args:
            If True, pass a foreign log record's ``args`` attribute to the
            ``event_dict`` under ``positional_args`` key. (default: False)

        processor:
            A single *structlog* processor used for rendering the event
            dictionary before passing it off to `logging`. Must return a `str`.
            The event dictionary does **not** contain ``_record`` and
            ``_from_structlog``.

            This parameter exists for historic reasons. Please use *processors*
            instead.

    Raises:

        TypeError: If both or neither *processor* and *processors* are passed.

    .. versionadded:: 17.1.0
    .. versionadded:: 17.2.0 *keep_exc_info* and *keep_stack_info*
    .. versionadded:: 19.2.0 *logger*
    .. versionadded:: 19.2.0 *pass_foreign_args*
    .. versionadded:: 21.3.0 *processors*
    .. deprecated:: 21.3.0
       *processor* (singular) in favor of *processors* (plural). Removal is not
       planned.
    Nr4   F	processorProcessor | Noner1   Sequence[Processor] | Noneforeign_pre_chainkeep_exc_inforB   keep_stack_infor   logging.Logger | Nonepass_foreign_argsrh   r   kwargsr'   r(   c                6   |	                     dd          }
 t                      j        |d|
i|	 |r|rd}t          |          |  || j        |f| _        n|r|| _        nd}t          |          || _        || _        || _        || _	        || _
        d S )Nfmtr+   zBThe `processor` and `processors` arguments are mutually exclusive.z2Either `processor` or `processors` must be passed.)r  rY   r   	TypeErrorremove_processors_metar1   rB  rC  rD  r   rF  )rK   r?  r1   rB  rC  rD  r   rF  rh   rG  rI  r   r\   s               r=   r   zProcessorFormatter.__init__  s     jj..$2C26222 	! 	!VCC.. , #:IFDOO 	!(DOOFCC.. !2*.!2r>   r   r   r^   c                   t          j        |j                  }t          |dt                    }t          |dd          }|t          ur?|dk    r9| j        | j        }|j        }|j                                        }||d<   d|d<   n| j        }|j	        
                                }|                                |dd	}| j        r
|j        |d
<   d|_        |j        r
|j        |d<   |j        r
|j        |d<   | j        sd|_        d|_        | j        sd|_        | j        pdD ]} ||||          }| j        D ]} ||||          }||_        t+                                          |          S )z
        Extract *structlog*'s `event_dict` from ``record.msg`` and format it.

        *record* has been patched by `wrap_for_formatter` first though, so the
         type isn't quite right.
        rV   _name__structlog_sentinel__Nr"  T_from_structlogF)rf   r"  rO  r   r4   rx   rA   )r5   makeLogRecordr.  getattr	_SENTINELr   rM  r   copy	levelnamelower
getMessagerF  rh   rx   rA   rC  exc_textrD  rB  r1   rY   r,   )rK   r   r   	meth_nameedprocpr\   s          r=   r,   zProcessorFormatter.format  s    &v77I66FG-EFF	""y4L'L'L{&I
 ""B"ByM$(B !![F(..00I**,,!#( B % 4(.$%FK
  1!':  5#)#4< % '"&"&' )$(! .4" 1 1T&)R00 	* 	*A69b))BB
ww~~f%%%r>   rU   rM   r  r   2tuple[tuple[EventDict], dict[str, dict[str, Any]]]c                    |fd| |difS )a5  
        Wrap *logger*, *name*, and *event_dict*.

        The result is later unpacked by `ProcessorFormatter` when
        formatting log entries.

        Use this static method as the renderer (i.e. final processor) if you
        want to use `ProcessorFormatter` in your `logging` configuration.
        r   )rV   rM  r4   )r   rM   r  s      r=   wrap_for_formatterz%ProcessorFormatter.wrap_for_formatter,  s     }wFT(J(JKKKr>   r  r   r  c                    |d= |d= |S )z
        Remove ``_record`` and ``_from_structlog`` from *event_dict*.

        These keys are added to the event dictionary, before
        `ProcessorFormatter`'s *processors* are run.

        .. versionadded:: 21.3.0
        r"  rO  r4   r=  s      r=   rK  z)ProcessorFormatter.remove_processors_meta;  s     y!()r>   )Nr4   NFFNF)r?  r@  r1   rA  rB  rA  rC  rB   rD  rB   r   rE  rF  rB   rh   r   rG  r   r'   r(   )r   r   r'   r^   )r   rU   rM   r^   r  r   r'   r\  r  )
rP   rQ   rR   rS   r   r,   staticmethodr^  rK  r   r   s   @r=   r"   r"   t  s        Q Qj '+138<# %(,"' 3  3  3  3  3  3  3D@& @& @& @& @& @&D L L L \L    \    r>   r"   )r%   r&   r'   r(   )rh   r   r   r   r'   r   )r   rU   r~   r^   r  r   r'   r   )r  rU   r  r^   r  r   r'   r   );rS   
__future__r   r   r   r)  r5   r7   r   typingr   r   r   r   r	    r   _baser   _framesr   r   _log_levelsr   r   r   r   
exceptionsr   r1   r   r   r   r   r   r   __all__NOTSETr#   objectrR  Loggerr@   r   r   r   r    r!   r   r   r   	LogRecordr.  r]   r0  r   r$   	Formatterr"   r4   r>   r=   <module>rn     s  
  # " " " " "           



       @ @ @ @ @ @ @ @ @ @ @ @ @ @       " " " " " " B B B B B B B B F F F F F F F F F F * * * * * * ! ! ! ! ! ! ) ) ) ) ) ) I I I I I I I I I I I I I I    29 + + + + + +\ FHH	I I I I IW^ I I I,SP SP SP SP SP/ SP SP SPl
7 7 7 7 Y
 Y
 Y
 Y
 Y
 Y
 Y
 Y
x.' .' .' .' .' .' .' .'b) ) ) ) ) ) ) )X   6   .    %7$
Az1eR 
4466 
:7 :7 :7 :7 :7 :7 :7 :7z   6V V V V V* V V V V Vr>   