Ë
    ëÏjû  ã                  óV  — U d Z ddlmZ ddlZddlZddlmZmZ ddlm	Z	 ddl
mZ ddlZddl
mZmZmZ d	Z ee«      Z ej&                  d
«      Zded
<    ej&                  d«      Zded<   i 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ej>                  dd„«       Z y) a°  
Primitives to deal with a concurrency supporting context, as introduced in
Python 3.7 as :mod:`contextvars`.

.. versionadded:: 20.1.0
.. versionchanged:: 21.1.0
   Reimplemented without using a single dict as context carrier for improved
   isolation. Every key-value pair is a separate `contextvars.ContextVar` now.
.. versionchanged:: 23.3.0
   Callsite parameters are now also collected under asyncio.

See :doc:`contextvars`.
é    )ÚannotationsN)Ú	GeneratorÚMapping)Ú	FrameType)ÚAnyé   )ÚBindableLoggerÚ	EventDictÚWrappedLoggerÚ
structlog_Ú_ASYNC_CALLING_STACKz!contextvars.ContextVar[FrameType]Ú_ASYNC_CALLING_THREADz'contextvars.ContextVar[tuple[int, str]]z&dict[str, contextvars.ContextVar[Any]]Ú_CONTEXT_VARSc                 óÊ   — i } t        j                  «       }|D ]G  }|j                  j                  t        «      sŒ#||   t
        usŒ/||   | |j                  t        d <   ŒI | S )zh
    Return a copy of the *structlog*-specific context-local context.

    .. versionadded:: 21.2.0
    N)ÚcontextvarsÚcopy_contextÚnameÚ
startswithÚSTRUCTLOG_KEY_PREFIXÚEllipsisÚSTRUCTLOG_KEY_PREFIX_LEN)ÚrvÚctxÚks      úR/var/www/html/gaurav-v2/venv/lib/python3.12/site-packages/structlog/contextvars.pyÚget_contextvarsr   5   sa   € ð 
€BÜ
×
"Ñ
"Ó
$€CãˆØ�6‰6×ÑÔ1Õ2°s¸1±vÄXÒ7MØ47¸±FˆBˆq�v‰vÔ.Ð/Ð0Ò1ð ð €Ió    c                ób   — t        «       }|j                  t        j                  | «      «       |S )z‹
    Return a copy of the current context-local context merged with the context
    from *bound_logger*.

    .. versionadded:: 21.2.0
    )r   ÚupdateÚ	structlogÚget_context)Úbound_loggerr   s     r   Úget_merged_contextvarsr#   E   s(   € ô Ó
€CØ‡J�JŒy×$Ñ$ \Ó2Ô3à€Jr   c                óà   — t        j                  «       }|D ]T  }|j                  j                  t        «      sŒ#||   t
        usŒ/|j                  |j                  t        d ||   «       ŒV |S )a  
    A processor that merges in a global (context-local) context.

    Use this as your first processor in :func:`structlog.configure` to ensure
    context-local context is included in all log calls.

    .. versionadded:: 20.1.0
    .. versionchanged:: 21.1.0 See toplevel note.
    N)r   r   r   r   r   r   Ú
setdefaultr   )ÚloggerÚmethod_nameÚ
event_dictr   r   s        r   Úmerge_contextvarsr)   R   sc   € ô ×
"Ñ
"Ó
$€CãˆØ�6‰6×ÑÔ1Õ2°s¸1±vÄXÒ7MØ×!Ñ! !§&¡&Ô)AÐ)BÐ"CÀSÈÁVÕLð ð Ðr   c                 ó¤   — t        j                  «       } | D ]7  }|j                  j                  t        «      sŒ#|j                  t        «       Œ9 y)zÛ
    Clear the context-local context.

    The typical use-case for this function is to invoke it early in request-
    handling code.

    .. versionadded:: 20.1.0
    .. versionchanged:: 21.1.0 See toplevel note.
    N)r   r   r   r   r   Úsetr   )r   r   s     r   Úclear_contextvarsr,   g   s:   € ô ×
"Ñ
"Ó
$€CÛˆØ�6‰6×ÑÔ1Õ2Ø�E‰E”(�Oñ r   c                 óð   — i }| j                  «       D ]-  \  }}t        › |› �}	 t        |   }|j                  |«      ||<   Œ/ |S # t        $ r' t	        j
                  |t        ¬«      }|t        |<   Y ŒGw xY w)a  
    Put keys and values into the context-local context.

    Use this instead of :func:`~structlog.BoundLogger.bind` when you want some
    context to be global (context-local).

    Return the mapping of `contextvars.Token`\s resulting
    from setting the backing :class:`~contextvars.ContextVar`\s.
    Suitable for passing to :func:`reset_contextvars`.

    .. versionadded:: 20.1.0
    .. versionchanged:: 21.1.0 Return the `contextvars.Token` mapping
        rather than None. See also the toplevel note.
    )Údefault)Úitemsr   r   ÚKeyErrorr   Ú
ContextVarr   r+   )Úkwr   r   ÚvÚstructlog_kÚvars         r   Úbind_contextvarsr6   w   s‚   € ð 
€BØ—‘–
‰ˆˆ1Ü-Ð.¨q¨cÐ2ˆð	-Ü Ñ,ˆCð
 —‘˜“
ˆˆ1Šð ð €Iøô ò 	-Ü×(Ñ(¨¼hÔGˆCØ),ŒM˜+Ó&ð	-ús   ¤	AÁ-A5Á4A5c                 ó|   — | j                  «       D ])  \  }}t        › |› �}t        |   }|j                  |«       Œ+ y)z\
    Reset contextvars corresponding to the given Tokens.

    .. versionadded:: 21.1.0
    N)r/   r   r   Úreset)r2   r   r3   r4   r5   s        r   Úreset_contextvarsr9   ”   s<   € ð —‘–
‰ˆˆ1Ü-Ð.¨q¨cÐ2ˆÜ˜KÑ(ˆØ�	‰	�!�ñ r   c                 óp   — | D ]1  }t         › |› �}|t        v sŒt        |   j                  t        «       Œ3 y)a"  
    Remove *keys* from the context-local context if they are present.

    Use this instead of :func:`~structlog.BoundLogger.unbind` when you want to
    remove keys from a global (context-local) context.

    .. versionadded:: 20.1.0
    .. versionchanged:: 21.1.0 See toplevel note.
    N)r   r   r+   r   )Úkeysr   r4   s      r   Úunbind_contextvarsr<       s8   € ó ˆÜ-Ð.¨q¨cÐ2ˆØœ-Ò'Ü˜+Ñ&×*Ñ*¬8Õ4ñ r   c               +  ó<  K  — t        «       }|j                  «       | j                  «       z  D �ci c]  }|||   “Œ
 }}t        di | ¤Ž 	 d–— t        | j                  «       Ž  t        di |¤Ž yc c}w # t        | j                  «       Ž  t        di |¤Ž w xY w­w)zÐ
    Bind *kw* to the current context-local context. Unbind or restore *kw*
    afterwards. Do **not** affect other keys.

    Can be used as a context manager or decorator.

    .. versionadded:: 21.4.0
    N© )r   r;   r6   r<   )r2   Úcontextr   Úsaveds       r   Úbound_contextvarsrA   °   s�   è ø€ ô Ó€GØ$+§L¡L£N°R·W±W³YÒ$>Ó?Ñ$>˜qˆQ�˜‘
‰]Ð$>€EÐ?äÑ�rÒð"Ûä˜BŸG™G›IÑ&ÜÑ!˜5Ó!ùò @øô 	˜BŸG™G›IÑ&ÜÑ!˜5Ó!üs'   ‚.B°A1½BÁA6 Á'BÁ6#BÂB)Úreturnúdict[str, Any])r"   r	   rB   rC   )r&   r   r'   Ústrr(   r
   rB   r
   )rB   ÚNone)r2   r   rB   z$Mapping[str, contextvars.Token[Any]])r2   zcontextvars.Token[Any]rB   rE   )r;   rD   rB   rE   )r2   r   rB   zGenerator[None, None, None])!Ú__doc__Ú
__future__r   Ú
contextlibr   Úcollections.abcr   r   Útypesr   Útypingr   r    r	   r
   r   r   Úlenr   r1   r   Ú__annotations__r   r   r   r#   r)   r,   r6   r9   r<   ÚcontextmanagerrA   r>   r   r   Ú<module>rO      så   ðòõ #ã Û ç .Ý Ý ã ç <Ñ <ð $Ð ÙÐ3Ó4Ð ð €K×ÑÐ1Ó2ð Ð7ó ð €K×ÑÐ2Ó3ð Ð>ó ð 9;€Ð5Ó :óó 
ðØðØ(+ðØ9Bðàóó*ó ó:	ó5ð  ×Ñò"ó ñ"r   