
    	h                    t    d Z ddlmZ ddlmZmZmZmZ ddlm	Z	 ddlm
Z
mZmZmZ  G d d          ZddZdS )z"
Logger wrapper and helper class.
    )annotations)AnyIterableMappingSequence)	DropEvent   )BindableLoggerContext	ProcessorWrappedLoggerc                  t    e Zd ZU dZded<   	 d"d	Zd#dZd$dZd$dZd%dZ	d&dZ
d&dZd%dZd'dZ	 d(d)d!Zd S )*BoundLoggerBasea  
    Immutable context carrier.

    Doesn't do any actual logging; examples for useful subclasses are:

    - the generic `BoundLogger` that can wrap anything,
    - `structlog.stdlib.BoundLogger`.
    - `structlog.twisted.BoundLogger`,

    See also `custom-wrappers`.
    r   _loggerlogger
processorsIterable[Processor]contextr   c                0    || _         || _        || _        d S N)r   _processors_context)selfr   r   r   s       \/var/www/html/web-builder-api.evdpl.com/venv/lib/python3.11/site-packages/structlog/_base.py__init__zBoundLoggerBase.__init__+   s     %    returnstrc                X    d                     | j        j        | j        | j                  S )Nz#<{}(context={!r}, processors={!r})>)format	__class____name__r   r   )r   s    r   __repr__zBoundLoggerBase.__repr__5   s+    4;;N#T]D4D
 
 	
r   otherobjectboolc                F    	 | j         |j         k    S # t          $ r Y dS w xY w)NF)r   AttributeErrorr   r$   s     r   __eq__zBoundLoggerBase.__eq__:   s8    	=EN22 	 	 	55	s    
  c                .    |                      |           S r   )r*   r)   s     r   __ne__zBoundLoggerBase.__ne__@   s    ;;u%%%%r   
new_valuesr   c           	     p    |                      | j        | j         | j        j         | j        fi |          S )zS
        Return a new logger with *new_values* added to the existing ones.
        )r!   r   r   r   r   r-   s     r   bindzBoundLoggerBase.bindC   sA     ~~L#DM#DM@@Z@@
 
 	
r   keysc                H    |                                  }|D ]
}|j        |= |S )z
        Return a new logger with *keys* removed from the context.

        Raises:

            KeyError: If the key is not part of the context.
        )r0   r   r   r1   blkeys       r   unbindzBoundLoggerBase.unbindM   s2     YY[[ 	! 	!CC  	r   c                n    |                                  }|D ]}|j                            |d           |S )zs
        Like :meth:`unbind`, but best effort: missing keys are ignored.

        .. versionadded:: 18.2.0
        N)r0   r   popr3   s       r   
try_unbindzBoundLoggerBase.try_unbind[   s>     YY[[ 	' 	'CKOOC&&&&	r   c                N    | j                                           | j        di |S )z
        Clear context and binds *new_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.
         )r   clearr0   r/   s     r   newzBoundLoggerBase.newg   s0     	ty&&:&&&r   method_nameevent
str | Noneevent_kwdict[str, Any]'tuple[Sequence[Any], Mapping[str, Any]]c                d   | j                                         } |j        di | |||d<   | j        D ]} || j        ||          }t          |t          t          t          f          r|fi fS t          |t                    r|S t          |t                    rd|fS d}t          |          )a'  
        Combines creates an ``event_dict`` and runs the chain.

        Call it to combine your *event* and *context* into an event_dict and
        process using the processor chain.

        Arguments:

            method_name:
                The name of the logger method.  Is passed into the processors.

            event:
                The event -- usually the first positional argument to a logger.

            event_kw:
                Additional event keywords.  For example if someone calls
                ``log.info("foo", bar=42)``, *event* would to be ``"foo"`` and
                *event_kw* ``{"bar": 42}``.

        Raises:

            structlog.DropEvent: if log entry should be dropped.

            ValueError:
                if the final processor doesn't return a str, bytes, bytearray,
                tuple, or a dict.

        Returns:
             `tuple` of ``(*args, **kw)``

        .. note::

            Despite underscore available to custom wrapper classes.

            See also `custom-wrappers`.

        .. versionchanged:: 14.0.0
            Allow final processor to return a `dict`.
        .. versionchanged:: 20.2.0
            Allow final processor to return `bytes`.
        .. versionchanged:: 21.2.0
            Allow final processor to return a `bytearray`.
        Nr?   r;   zLast processor didn't return an appropriate value.  Valid return values are a dict, a tuple of (args, kwargs), bytes, or a str.)r   copyupdater   r   
isinstancer   bytes	bytearraytupledict
ValueError)r   r>   r?   rA   
event_dictprocmsgs          r   _process_eventzBoundLoggerBase._process_eventu   s    ` -,,..

%%H%%%"'Jw$ 	E 	EDdlKDDJJj3y"9:: 	%="$$j%(( 	 j$'' 	"z>!Z 	 oor   Nc                    	 |                      |||          \  }} t          | j        |          |i |S # t          $ r Y dS w xY w)a  
        Run processor chain on event & call *method_name* on wrapped logger.

        DRY convenience method that runs :func:`_process_event`, takes care of
        handling :exc:`structlog.DropEvent`, and finally calls *method_name* on
        :attr:`_logger` with the result.

        Arguments:

            method_name:
                The name of the method that's going to get called.  Technically
                it should be identical to the method the user called because it
                also get passed into processors.

            event:
                The event -- usually the first positional argument to a logger.

            event_kw:
                Additional event keywords.  For example if someone calls
                ``log.info("foo", bar=42)``, *event* would to be ``"foo"`` and
                *event_kw* ``{"bar": 42}``.

        .. note::

            Despite underscore available to custom wrapper classes.

            See also `custom-wrappers`.
        N)rP   getattrr   r   )r   r>   r?   rA   argskws         r   _proxy_to_loggerz BoundLoggerBase._proxy_to_logger   se    >	**;xHHHD"574<55tBrBBB 	 	 	44	s   47 
AA)r   r   r   r   r   r   )r   r   )r$   r%   r   r&   )r-   r   r   r   )r1   r   r   r   )r>   r   r?   r@   rA   rB   r   rC   r   )r>   r   r?   r@   rA   r   r   r   )r"   
__module____qualname____doc____annotations__r   r#   r*   r,   r0   r6   r9   r=   rP   rU   r;   r   r   r   r      s
        
 
        
 
 
 

   & & & &
 
 
 
   
 
 
 

' 
' 
' 
'G G G GT 59# # # # # # #r   r   bound_loggerr
   r   r   c                    | j         S )aK  
    Return *bound_logger*'s context.

    The type of *bound_logger* and the type returned depend on your
    configuration.

    Arguments:

        bound_logger: The bound logger whose context you want.

    Returns:

        The *actual* context from *bound_logger*. It is *not* copied first.

    .. versionadded:: 20.2.0
    )r   )rZ   s    r   get_contextr\      s    $   r   N)rZ   r
   r   r   )rX   
__future__r   typingr   r   r   r   structlog.exceptionsr   r
   r   r   r   r   r\   r;   r   r   <module>r`      s     # " " " " " 3 3 3 3 3 3 3 3 3 3 3 3 * * * * * * E E E E E E E E E E E EN N N N N N N Nb! ! ! ! ! !r   