Ë
    ëÏjÄ  ã                  ó´   — d Z ddlmZ ddl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mZmZmZ ej                   d	k\  rdd
lmZ ndd
lmZ  G d„ d«      Zdd„Zy)z"
Logger wrapper and helper class.
é    )ÚannotationsN)ÚIterableÚMappingÚSequence)ÚAny)Ú	DropEventé   )ÚBindableLoggerÚContextÚ	ProcessorÚWrappedLogger)é   é   )ÚSelfc                  óœ   — 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y)Ú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   Ú_loggerc                ó.   — || _         || _        || _        y ©N)r   Ú_processorsÚ_context)ÚselfÚloggerÚ
processorsÚcontexts       úL/var/www/html/gaurav-v2/venv/lib/python3.12/site-packages/structlog/_base.pyÚ__init__zBoundLoggerBase.__init__4   s   € ð ˆŒØ%ˆÔØˆ�ó    c                ój   — d| j                   j                  › d| j                  ›d| j                  ›d�S )NÚ<z	(context=z, processors=z)>)Ú	__class__Ú__name__r   r   )r   s    r   Ú__repr__zBoundLoggerBase.__repr__>   s6   € Ø�4—>‘>×*Ñ*Ð+¨9°T·]±]Ð4EÀ]ÐSW×ScÑScÐRfÐfhÐiÐir   c                óT   — 	 | j                   |j                   k(  S # t        $ r Y yw xY w)NF)r   ÚAttributeError©r   Úothers     r   Ú__eq__zBoundLoggerBase.__eq__A   s,   € ð	Ø—=‘= E§N¡NÑ2Ð2øÜò 	Ùð	ús   ‚ ›	'¦'c                ó&   — | j                  |«       S r   )r(   r&   s     r   Ú__ne__zBoundLoggerBase.__ne__G   s   € Ø—;‘;˜uÓ%Ð%Ð%r   c           	     óš   — | j                  | 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   Ú
new_valuess     r   ÚbindzBoundLoggerBase.bindJ   sB   € ð �~‰~Ø�L‰LØ×ÑØ#ˆD�M‰M×#Ñ# D§M¡MÑ@°ZÑ@ó
ð 	
r   c                óN   — | j                  «       }|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.
        )r.   r   ©r   ÚkeysÚblÚkeys       r   ÚunbindzBoundLoggerBase.unbindT   s,   € ð �Y‰Y‹[ˆÛˆCØ—‘˜CÑ ð ð ˆ	r   c                ól   — | j                  «       }|D ]  }|j                  j                  |d«       Œ  |S )zs
        Like :meth:`unbind`, but best effort: missing keys are ignored.

        .. versionadded:: 18.2.0
        N)r.   r   Úpopr0   s       r   Ú
try_unbindzBoundLoggerBase.try_unbinda   s2   € ð �Y‰Y‹[ˆÛˆCØ�K‰K�O‰O˜C Õ&ð ð ˆ	r   c                óZ   — | j                   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 reused.
        © )r   Úclearr.   r,   s     r   ÚnewzBoundLoggerBase.newm   s(   € ð 	�‰×ÑÔàˆt�y‰yÑ&˜:Ñ&Ð&r   c                óX  — | j                   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.

        Args:
            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`.
        Úeventr9   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   Ú
isinstanceÚstrÚbytesÚ	bytearrayÚtupleÚdictÚ
ValueError)r   Úmethod_namer=   Úevent_kwÚ
event_dictÚprocÚmsgs          r   Ú_process_eventzBoundLoggerBase._process_event{   s¹   € ðZ Ÿ-™-×,Ñ,Ó.ˆ
Øˆ
×ÑÑ%˜HÒ%àÐØ"'ˆJ�wÑØ×$Ô$ˆDÙ˜dŸl™l¨K¸ÓD‰Jð %ô �j¤3¬¬yÐ"9Ô:Ø�= "Ð$Ð$ä�j¤%Ô(ð Ðä�j¤$Ô'Ø�z�>Ð!ðZð 	ô ˜‹oÐr   Nc                ó†   — 	 | j                  |||«      \  }} t        | j                  |«      |i |¤ŽS # t        $ r Y y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.

        Args:
            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)rL   Úgetattrr   r   )r   rG   r=   rH   ÚargsÚkws         r   Ú_proxy_to_loggerz BoundLoggerBase._proxy_to_loggerÁ   sN   € ð:	Ø×*Ñ*¨;¸¸xÓH‰HˆD�"Ø5”7˜4Ÿ<™<¨Ó5°tÐB¸rÑBÐBøÜò 	Ùð	ús   ‚14 ´	A ¿A )r   r   r   zIterable[Processor]r   r   )ÚreturnrA   )r'   ÚobjectrR   Úbool)r-   r   rR   r   )r1   rA   rR   r   )rG   rA   r=   ú
str | NonerH   zdict[str, Any]rR   z'tuple[Sequence[Any], Mapping[str, Any]]r   )rG   rA   r=   rU   rH   r   rR   r   )r"   Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__r   r#   r(   r*   r.   r4   r7   r;   rL   rQ   r9   r   r   r   r      s®   … ñ
ð Óðð àð ð (ð ð ó	 ójóó&ó
óó
ó
'ðDØðDØ'1ðDØ=KðDà	0óDðN 59ð!Øð!Ø'1ð!ØFIð!à	ô!r   r   c                ó   — | j                   S )aD  
    Return *bound_logger*'s context.

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

    Args:
        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   )Úbound_loggers    r   Úget_contextr\   å   s   € ð  × Ñ Ð r   )r[   r
   rR   r   )rX   Ú
__future__r   ÚsysÚcollections.abcr   r   r   Útypingr   Ústructlog.exceptionsr   r
   r   r   r   Úversion_infor   Útyping_extensionsr   r\   r9   r   r   Ú<module>rd      sL   ðñõ #ã 
ç 7Ñ 7Ý å *ç EÓ Eð ×Ñ�wÒÞå&÷Fñ FôR!r   