ó
    öÞ jÔx  ã                  ó   • S r SSKJr  SSKrSSKrSSKrSSKrSSKrSSKrSSK	r	SSK
r
SSKrSSKJrJrJr  SSKJrJr  SSKJrJrJrJrJr  SSKJrJrJr  SS	KJrJr  SS
K J!r!  SSK"J#r#  SSK$J%r%  SSKJ&r&J'r'J(r(J)r)  / SQr* " S S5      r+ " S S5      r,        S8S jr- " S S5      r. " S S5      r/ " S S5      r0S9S jr1 " S S5      r2\2" 5       r3 \2" \%" 5       5      r4  " S S5      r5        S:S jr6 " S  S!5      r7S;S" jr8 " S# S$5      r9 " S% S&5      r: " S' S(\Rv                  5      r<S<S) jr=S<S* jr>S<S+ jr?S<S, jr@S<S- jrAS<S. jrBS<S/ jrCS<S0 jrDS<S1 jrES<S2 jrFS<S3 jrG " S4 S55      rH " S6 S75      rIg)=z8
Processors useful regardless of the logging framework.
é    )ÚannotationsN)ÚCallableÚ
CollectionÚSequence)Ú	FrameTypeÚTracebackType)ÚAnyÚClassVarÚ
NamedTupleÚTextIOÚcasté   )Ú_find_first_app_frame_and_nameÚ_format_exceptionÚ_format_stack)ÚNAME_TO_LEVELÚadd_log_level©Úget_processname)Ú_ASYNC_CALLING_THREAD)ÚExceptionDictTransformer)Ú	EventDictÚExceptionTransformerÚExcInfoÚWrappedLogger)r   ÚCallsiteParameterÚCallsiteParameterAdderÚEventRenamerÚExceptionPrettyPrinterÚJSONRendererÚKeyValueRendererÚLogfmtRendererÚStackInfoRendererÚTimeStamperÚUnicodeDecoderÚUnicodeEncoderr   Údict_tracebacksÚformat_exc_infoc                  óV   • \ rS rSrSr    S       SS jjr        S	S jrSrg)
r!   éD   a–  
Render ``event_dict`` as a list of ``Key=repr(Value)`` pairs.

Args:
    sort_keys: Whether to sort keys when formatting.

    key_order:
        List of keys that should be rendered in this exact order.  Missing
        keys will be rendered as ``None``, extra keys depending on
        *sort_keys* and the dict class.

    drop_missing:
        When ``True``, extra keys in *key_order* will be dropped rather
        than rendered as ``None``.

    repr_native_str:
        When ``True``, :func:`repr()` is also applied to native strings.

.. versionadded:: 0.2.0 *key_order*
.. versionadded:: 16.1.0 *drop_missing*
.. versionadded:: 17.1.0 *repr_native_str*
Nc                ó^   • [        XU5      U l        USL a  [        U l        g SS jnXPl        g )NTc                óF   • [        U [        5      (       a  U $ [        U 5      $ ©N)Ú
isinstanceÚstrÚrepr)Úinsts    ÚN/var/www/html/gaurav/venv/lib/python3.13/site-packages/structlog/processors.pyÚ_reprÚ(KeyValueRenderer.__init__.<locals>._repri   s   € Ü˜d¤C×(Ñ(Ø�Kä˜D“zÐ!ó    )r1   r	   Úreturnr/   )Ú_items_sorterÚ_ordered_itemsr0   r3   )ÚselfÚ	sort_keysÚ	key_orderÚdrop_missingÚrepr_native_strr3   s         r2   Ú__init__ÚKeyValueRenderer.__init__\   s.   € ô ,¨IÀ,ÓOˆÔà˜dÒ"ÜˆD�Jô"ð �Jr5   c                óX   ^ • SR                  U 4S jT R                  U5       5       5      $ )NÚ c              3  óT   >#   • U H  u  pUS -   TR                  U5      -   v •  M      g7f)Ú=N)r3   )Ú.0ÚkÚvr9   s      €r2   Ú	<genexpr>Ú,KeyValueRenderer.__call__.<locals>.<genexpr>t   s(   øé € ð 
Ù0O©¨ˆA�‰G�d—j‘j “mÖ#Ò0Oùs   ƒ%()Újoinr8   )r9   Ú_Ú__Ú
event_dicts   `   r2   Ú__call__ÚKeyValueRenderer.__call__q   s.   ø€ ð �x‰xô 
Ø04×0CÑ0CÀJÔ0Oó
ó 
ð 	
r5   )r8   r3   ©FNFT)r:   Úboolr;   úSequence[str] | Noner<   rP   r=   rP   ©rJ   r   rK   r/   rL   r   r6   r/   ©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r>   rM   Ú__static_attributes__© r5   r2   r!   r!   D   se   † ñð2  Ø*.Ø"Ø $ðàðð (ðð ð	ð
 õð*
Øð
Ø$'ð
Ø5>ð
à	÷
r5   r!   c                  óV   • \ rS rSrSr    S       SS jjr        S	S jrSrg)
r"   éy   a  
Render ``event_dict`` using the logfmt_ format.

.. _logfmt: https://brandur.org/logfmt

Args:
    sort_keys: Whether to sort keys when formatting.

    key_order:
        List of keys that should be rendered in this exact order. Missing
        keys are rendered with empty values, extra keys depending on
        *sort_keys* and the dict class.

    drop_missing:
        When ``True``, extra keys in *key_order* will be dropped rather
        than rendered with empty values.

    bool_as_flag:
        When ``True``, render ``{"flag": True}`` as ``flag``, instead of
        ``flag=true``. ``{"flag": False}`` is always rendered as
        ``flag=false``.

Raises:
    ValueError: If a key contains non-printable or whitespace characters.

.. versionadded:: 21.5.0
Nc                ó2   • [        XU5      U l        X@l        g r-   )r7   r8   Úbool_as_flag)r9   r:   r;   r<   r^   s        r2   r>   ÚLogfmtRenderer.__init__–   s   € ô ,¨IÀ,ÓOˆÔØ(Õr5   c                ó’  • / nU R                  U5       GH  u  pV[        S U 5       5      (       a  SU S3n[        U5      eUc  UR                  U S35        MG  [	        U[
        5      (       a7  U R                  (       a  U(       a  UR                  U 5        Mˆ  U(       a  SOSn[        U5      nSU;   =(       d    SU;   =(       d    SU;   nU(       a  SU;   a  UR                  SS	5      nUR                  SS
5      R                  SS5      nU(       a  SU S3nUR                  U SU 35        GM"     SR                  U5      $ )Nc              3  ó(   #   • U H	  oS :*  v •  M     g7f)rA   NrZ   )rD   Úcs     r2   rG   Ú*LogfmtRenderer.__call__.<locals>.<genexpr>¥   s   é € Ð)¡S ˜–8¢Sùs   ‚zInvalid key: "Ú"rC   ÚtrueÚfalserA   Ú\z\\z\"Ú
z\n)
r8   ÚanyÚ
ValueErrorÚappendr.   rP   r^   r/   ÚreplacerI   )	r9   rJ   rK   rL   ÚelementsÚkeyÚvalueÚmsgÚbackslashes_need_escapings	            r2   rM   ÚLogfmtRenderer.__call__    s,  € ð !ˆØ×-Ñ-¨j×9‰JˆCÜÑ)¡SÓ)×)Ñ)Ø& s e¨1Ð-�Ü  “oÐ%à‰}Ø—‘ 3 % q 	Ô*Ùä˜%¤×&Ñ&Ø×$×$®Ø—O‘O s eÔ-ÙÞ"'™¨W�ä˜“JˆEà�u‘×<  u¡×<°°u±ð &ö )¨T°U«]ØŸ™ d¨FÓ3�à—M‘M # uÓ-×5Ñ5°d¸EÓBˆEæ(Ø˜E˜7 !˜�à�O‰O˜s˜e 1 U GÐ,×-ñ7 :ð: �x‰x˜Ó!Ð!r5   )r8   r^   rO   )r:   rP   r;   rQ   r<   rP   r^   rP   rR   rS   rZ   r5   r2   r"   r"   y   se   † ñð<  Ø*.Ø"Ø!ð)àð)ð (ð)ð ð	)ð
 õ)ð!"Øð!"Ø$'ð!"Ø5>ð!"à	÷!"r5   r"   c                ó¨   ^^• T(       a  U (       a  SUU4S jjnU$ T(       a  SUU4S jjnU$ U (       a  SS jnU$ [         R                  " S5      nU$ )zw
Return a function to sort items from an ``event_dict``.

See `KeyValueRenderer` for an explanation of the parameters.
c                ó¶   >• / nT H3  nU R                  US 5      nUc	  T(       a  M!  UR                  X#45        M5     U[        U R                  5       5      -  nU$ r-   )Úpoprk   ÚsortedÚitems©rL   rw   rn   ro   r<   r;   s       €€r2   Úordered_itemsÚ$_items_sorter.<locals>.ordered_itemsÑ   sY   ø€ ØˆEÛ �Ø"Ÿ™ s¨DÓ1�ØÑ$¯L¨LØ—L‘L # Ö.ñ !ð
 ”V˜J×,Ñ,Ó.Ó/Ñ/ˆEàˆLr5   c                ó¢   >• / nT H3  nU R                  US 5      nUc	  T(       a  M!  UR                  X#45        M5     XR                  5       -  nU$ r-   )ru   rk   rw   rx   s       €€r2   ry   rz   Þ   sR   ø€ ØˆEÛ �Ø"Ÿ™ s¨DÓ1�ØÑ$¯L¨LØ—L‘L # Ö.ñ !ð
 ×%Ñ%Ó'Ñ'ˆEàˆLr5   c                ó4   • [        U R                  5       5      $ r-   )rv   rw   )rL   s    r2   ry   rz   ë   s   € Ü˜*×*Ñ*Ó,Ó-Ð-r5   rw   )rL   r   r6   zlist[tuple[str, Any]])ÚoperatorÚmethodcaller)r:   r;   r<   ry   s    `` r2   r7   r7   Ä   sc   ù€ ö –Y÷		ð 		ðD Ðö/ 
÷		ð 		ð* Ðö 
ô	.ð Ðô	 !×-Ò-Øó
ˆð Ðr5   c                  ób   • \ rS rSr% SrS\S'   S\S'    S
     SS jjr        SS jrSrg	)r&   éö   a3  
Encode unicode values in ``event_dict``.

Args:
    encoding: Encoding to encode to (default: ``"utf-8"``).

    errors:
        How to cope with encoding errors (default ``"backslashreplace"``).

Just put it in the processor chain before the renderer.

.. note:: Not very useful in a Python 3-only world.
r/   Ú	_encodingÚ_errorsc                ó   • Xl         X l        g r-   ©r�   r‚   ©r9   ÚencodingÚerrorss      r2   r>   ÚUnicodeEncoder.__init__  ó   € ð "ŒØ�r5   c                ó¶   • UR                  5        HD  u  pE[        U[        5      (       d  M  UR                  U R                  U R
                  5      X4'   MF     U$ r-   )rw   r.   r/   Úencoder�   r‚   ©r9   ÚloggerÚnamerL   rn   ro   s         r2   rM   ÚUnicodeEncoder.__call__  sH   € ð %×*Ñ*Ö,‰JˆCÜ˜%¤×%Ó%Ø"'§,¡,¨t¯~©~¸t¿|¹|Ó"L�
“ñ -ð Ðr5   r„   N)úutf-8Úbackslashreplace©r†   r/   r‡   r/   r6   ÚNone©r�   r   rŽ   r/   rL   r   r6   r   ©	rT   rU   rV   rW   rX   Ú__annotations__r>   rM   rY   rZ   r5   r2   r&   r&   ö   s[   ‡ ñð ƒNØƒLð 6HðØðØ/2ðà	õðØ#ðØ+.ðØ<Eðà	÷r5   r&   c                  ób   • \ rS rSr% SrS\S'   S\S'    S
     SS jjr        SS jrSrg	)r%   i  aO  
Decode byte string values in ``event_dict``.

Args:
    encoding: Encoding to decode from (default: ``"utf-8"``).

    errors: How to cope with encoding errors (default: ``"replace"``).

Useful to prevent ``b"abc"`` being rendered as as ``'b"abc"'``.

Just put it in the processor chain before the renderer.

.. versionadded:: 15.4.0
r/   r�   r‚   c                ó   • Xl         X l        g r-   r„   r…   s      r2   r>   ÚUnicodeDecoder.__init__+  r‰   r5   c                ó¶   • UR                  5        HD  u  pE[        U[        5      (       d  M  UR                  U R                  U R
                  5      X4'   MF     U$ r-   )rw   r.   ÚbytesÚdecoder�   r‚   rŒ   s         r2   rM   ÚUnicodeDecoder.__call__1  sH   € ð %×*Ñ*Ö,‰JˆCÜ˜%¤×'Ó'Ø"'§,¡,¨t¯~©~¸t¿|¹|Ó"L�
“ñ -ð Ðr5   r„   N)r�   rl   r’   r”   r•   rZ   r5   r2   r%   r%     sZ   ‡ ñð ƒNØƒLð 6?ðØðØ/2ðà	õðØ#ðØ+.ðØ<Eðà	÷r5   r%   c                  ó`   • \ rS rSrSr\R                  4     SS jjr        SS jrSr	g)	r    i;  aÇ  
Render the ``event_dict`` using ``serializer(event_dict, **dumps_kw)``.

Args:
    dumps_kw:
        Are passed unmodified to *serializer*.  If *default* is passed, it
        will disable support for ``__structlog__``-based serialization.

    serializer:
        A :func:`json.dumps`-compatible callable that will be used to
        format the string.  This can be used to use alternative JSON
        encoders (default: :func:`json.dumps`).

        .. seealso:: :doc:`performance` for examples.

.. versionadded:: 0.2.0 Support for ``__structlog__`` serialization method.
.. versionadded:: 15.4.0 *serializer* parameter.
.. versionadded:: 18.2.0
   Serializer's *default* parameter can be overwritten now.
c                óH   • UR                  S[        5        X l        Xl        g )NÚdefault)Ú
setdefaultÚ_json_fallback_handlerÚ	_dumps_kwÚ_dumps)r9   Ú
serializerÚdumps_kws      r2   r>   ÚJSONRenderer.__init__Q  s   € ð
 	×Ñ˜IÔ'=Ô>Ø!ŒØ �r5   c                ó<   • U R                   " U40 U R                  D6$ )zD
The return type of this depends on the return type of self._dumps.
©r¤   r£   ©r9   r�   rŽ   rL   s       r2   rM   ÚJSONRenderer.__call__Z  s   € ð �{Š{˜:Ñ8¨¯©Ñ8Ð8r5   r©   N)r¥   zCallable[..., str | bytes]r¦   r	   r6   r“   )r�   r   rŽ   r/   rL   r   r6   zstr | bytes)
rT   rU   rV   rW   rX   ÚjsonÚdumpsr>   rM   rY   rZ   r5   r2   r    r    ;  sV   † ñð. 26·±ð!à.ð!ð ð!ð 
õ	!ð9Ø#ð9Ø+.ð9Ø<Eð9à	÷9r5   r    c                óž   • SSK Jn  [        X5      (       a  U R                  $  U R	                  5       $ ! [
         a    [        U 5      s $ f = f)zI
Serialize custom datatypes and pass the rest to __structlog__ & repr().
r   )Ú_ThreadLocalDictWrapper)Ústructlog.threadlocalr¯   r.   Ú_dictÚ__structlog__ÚAttributeErrorr0   )Úobjr¯   s     r2   r¢   r¢   c  sI   € õ
 >ä�#×/Ñ/Ø�y‰yÐðØ× Ñ Ó"Ð"øÜó Ü�C‹yÒðús   ¤4 ´AÁAc                  óH   • \ rS rSrSr\4   SS jjr        SS jrSrg)	ÚExceptionRendereris  a¨  
Replace an ``exc_info`` field with an ``exception`` field which is rendered
by *exception_formatter*.

The contents of the ``exception`` field depends on the return value of the
*exception_formatter* that is passed:

- The default produces a formatted string via Python's built-in traceback
  formatting (this is :obj:`.format_exc_info`).
- If you pass a :class:`~structlog.tracebacks.ExceptionDictTransformer`, it
  becomes a list of stack dicts that can be serialized to JSON.

If *event_dict* contains the key ``exc_info``, there are three possible
behaviors:

1. If the value is a tuple, render it into the key ``exception``.
2. If the value is an Exception render it into the key ``exception``.
3. If the value true but no tuple, obtain exc_info ourselves and render
   that.

If there is no ``exc_info`` key, the *event_dict* is not touched. This
behavior is analog to the one of the stdlib's logging.

Args:
    exception_formatter:
        A callable that is used to format the exception from the
        ``exc_info`` field into the ``exception`` field.

.. seealso::
    :doc:`exceptions` for a broader explanation of *structlog*'s exception
    features.

.. versionadded:: 22.1.0
c                ó   • Xl         g r-   ©Úformat_exception)r9   Úexception_formatters     r2   r>   ÚExceptionRenderer.__init__—  s
   € ð !4Õr5   c                ór   • [        UR                  SS 5      5      nU(       a  U R                  U5      US'   U$ )NÚexc_infoÚ	exception)Ú_figure_out_exc_inforu   r¹   )r9   r�   rŽ   rL   r½   s        r2   rM   ÚExceptionRenderer.__call__�  s7   € ô (¨
¯©°zÀ4Ó(HÓIˆÞØ&*×&;Ñ&;¸HÓ&EˆJ�{Ñ#àÐr5   r¸   N)rº   r   r6   r“   r”   ©	rT   rU   rV   rW   rX   r   r>   rM   rY   rZ   r5   r2   r¶   r¶   s  sJ   † ñ!ðJ 5Fð4à1ð4ð 
õ4ðØ#ðØ+.ðØ<Eðà	÷r5   r¶   c                  ól   • \ rS rSrSrSr   S	       S
S jjr        SS jrSS jrSS jr	Sr
g)r$   iÎ  aŸ  
Add a timestamp to ``event_dict``.

Args:
    fmt:
        strftime format string, or ``"iso"`` for `ISO 8601
        <https://en.wikipedia.org/wiki/ISO_8601>`_, or `None` for a `UNIX
        timestamp <https://en.wikipedia.org/wiki/Unix_time>`_.

    utc: Whether timestamp should be in UTC or local time.

    key: Target key in *event_dict* for added timestamps.

.. versionchanged:: 19.2.0 Can be pickled now.
)Ú_stamperÚfmtrn   ÚutcNc                óP   • XUsU l         U l        U l        [        XU5      U l        g r-   ©rÄ   rÅ   rn   Ú_make_stamperrÃ   ©r9   rÄ   rÅ   rn   s       r2   r>   ÚTimeStamper.__init__á  s&   € ð (+°Ð$ˆŒ�$”(˜DœHä% c°Ó4ˆ�r5   c                ó$   • U R                  U5      $ r-   )rÃ   rª   s       r2   rM   ÚTimeStamper.__call__ë  s   € ð �}‰}˜ZÓ(Ð(r5   c                óJ   • U R                   U R                  U R                  S.$ ©N©rÄ   rÅ   rn   rÏ   )r9   s    r2   Ú__getstate__ÚTimeStamper.__getstate__ð  s   € Ø—x‘x¨¯©¸¿¹ÑBÐBr5   c                ó`   • US   U l         US   U l        US   U l        [        S0 UD6U l        g )NrÄ   rÅ   rn   rZ   rÇ   )r9   Ústates     r2   Ú__setstate__ÚTimeStamper.__setstate__ó  s2   € Ø˜‘<ˆŒØ˜‘<ˆŒØ˜‘<ˆŒä%Ñ.¨Ñ.ˆ�r5   ©NTÚ	timestamp)rÄ   ú
str | NonerÅ   rP   rn   r/   r6   r“   r”   )r6   údict[str, Any])rÓ   rÙ   r6   r“   )rT   rU   rV   rW   rX   Ú	__slots__r>   rM   rÐ   rÔ   rY   rZ   r5   r2   r$   r$   Î  st   † ñð  2€Ið ØØð	5àð5ð ð5ð ð	5ð
 
õ5ð)Ø#ð)Ø+.ð)Ø<Eð)à	ô)ô
C÷/r5   r$   c                ó  ^ ^^	• T c  U(       d  Sn[        U5      eU(       a  S
S jm	OS
S jm	T c
  SU4S jjnU$ T R                  5       S:X  a  SUU	4S jjnSUU	4S jjnU(       a  U$ U$ SU UU	4S jjnSU UU	4S	 jjnU(       a  U$ U$ )z
Create a stamper function.
zUNIX timestamps are always UTC.c                 ól   • [         R                   R                  [         R                  R                  S9$ )N)Útz)ÚdatetimeÚnowÚtimezonerÅ   rZ   r5   r2   rß   Ú_make_stamper.<locals>.now	  s(   € Ü×$Ñ$×(Ñ(¬H×,=Ñ,=×,AÑ,AÐ(ÐBÐBr5   c                 ó>   • [         R                   R                  5       $ r-   )rÞ   rß   rZ   r5   r2   rß   rá     s   € ô ×$Ñ$×(Ñ(Ó*Ð*r5   c                ó8   >• [         R                   " 5       U T'   U $ r-   )Útime)rL   rn   s    €r2   Ústamper_unixÚ#_make_stamper.<locals>.stamper_unix  s   ø€ Ü"Ÿiši›kˆJ�s‰OàÐr5   ÚISOc                ó8   >• T" 5       R                  5       U T'   U $ r-   )Ú	isoformat©rL   rn   rß   s    €€r2   Ústamper_iso_localÚ(_make_stamper.<locals>.stamper_iso_local  s   ø€ Ù!›eŸo™oÓ/ˆJ�s‰OØÐr5   c                óX   >• T" 5       R                  5       R                  SS5      U T'   U $ )Nz+00:00ÚZ)ré   rl   rê   s    €€r2   Ústamper_iso_utcÚ&_make_stamper.<locals>.stamper_iso_utc"  s(   ø€ Ù!›eŸo™oÓ/×7Ñ7¸À#ÓFˆJ�s‰OØÐr5   c                óV   >• T" 5       R                  5       R                  T5      U T'   U $ r-   )Ú
astimezoneÚstrftime©rL   rÄ   rn   rß   s    €€€r2   Ústamper_fmt_localÚ(_make_stamper.<locals>.stamper_fmt_local+  s(   ø€ Ù›%×*Ñ*Ó,×5Ñ5°cÓ:ˆ
�3‰ØÐr5   c                ó:   >• T" 5       R                  T5      U T'   U $ r-   )ró   rô   s    €€€r2   Ústamper_fmt_utcÚ&_make_stamper.<locals>.stamper_fmt_utc/  s   ø€ Ù›%Ÿ.™.¨Ó-ˆ
�3‰ØÐr5   )r6   zdatetime.datetime)rL   r   r6   r   )rj   Úupper)
rÄ   rÅ   rn   rp   rå   rë   rï   rõ   rø   rß   s
   ` `      @r2   rÈ   rÈ   û  s—   ú€ ð �{ž3Ø/ˆÜ˜‹oÐö õ	Cô
	+ð
 �{÷	ð
 Ðà
‡y�yƒ{�eÓ÷	ð 	÷	ð 	ö Ø"Ð"à Ð ÷ñ ÷ñ ö ØÐàÐr5   c                  óT   • \ rS rSrSrSr   S     SS jjr        S	S jrSrg)
ÚMaybeTimeStamperi9  a  
A timestamper that only adds a timestamp if there is none.

This allows you to overwrite the ``timestamp`` key in the event dict for
example when the event is coming from another system.

It takes the same arguments as `TimeStamper`.

.. versionadded:: 23.2.0
)ÚstamperNc                ó"   • [        XUS9U l        g rÎ   )r$   rý   rÉ   s       r2   r>   ÚMaybeTimeStamper.__init__G  s   € ô # s¸Ñ=ˆ�r5   c                ó^   • U R                   R                  U;  a  U R                  XU5      $ U$ r-   )rý   rn   rª   s       r2   rM   ÚMaybeTimeStamper.__call__O  s-   € ð �<‰<×Ñ :Ó-Ø—<‘< ¨jÓ9Ð9àÐr5   rÖ   )rÄ   rØ   rÅ   rP   rn   r/   r”   ©	rT   rU   rV   rW   rX   rÚ   r>   rM   rY   rZ   r5   r2   rü   rü   9  s_   † ñ	ð €Ið ØØð	>àð>ð ð>ð õ	>ðØ#ðØ+.ðØ<Eðà	÷r5   rü   c                óü  • [        U [        5      (       a  U R                  X R                  4$ [        U [        5      (       a‡  [        U 5      S:X  ax  [        U S   [        5      =(       a    [        U S   [        5      n[        U S   [        5      nU S   SL =(       d    [        U S   [        5      nU(       a  U(       a	  U(       a  U $ U (       a,  [        R                  " 5       nUS:X  a  g[        [        U5      $ g)z�
Try to convert *v* into an ``exc_info`` tuple.

Return ``None`` if *v* does not represent an exception or if there is no
current exception.
é   r   r   é   N)NNN)r.   ÚBaseExceptionÚ	__class__Ú__traceback__ÚtupleÚlenÚtypeÚ
issubclassr   Úsysr½   r   r   )rF   Úhas_typeÚhas_excÚhas_tbÚresults        r2   r¿   r¿   X  s¾   € ô �!”]×#Ñ#Ø—‘˜Q§¡Ð0Ð0ä�!”U×Ñ¤ A£¨!£Ü˜a ™d¤DÓ)×M¬j¸¸1¹¼}Ó.MˆÜ˜Q˜q™T¤=Ó1ˆØ�1‘˜�×@¤¨A¨a©D´-Ó!@ˆÞž¦FØˆHæÜ—’“ˆØÐ'Ó'ØÜ”G˜VÓ$Ð$àr5   c                  óN   • \ rS rSrSrS\4     SS jjr        SS jrSrg)	r   ir  a  
Pretty print exceptions rendered by *exception_formatter* and remove them
from the ``event_dict``.

Args:
    file: Target file for output (default: ``sys.stdout``).
    exception_formatter:
        A callable that is used to format the exception from the
        ``exc_info`` field into the ``exception`` field.

This processor is mostly for development and testing so you can read
exceptions properly formatted.

It behaves like `format_exc_info`, except that it removes the exception data
from the event dictionary after printing it using the passed
*exception_formatter*, which defaults to Python's built-in traceback formatting.

It's tolerant to having `format_exc_info` in front of itself in the
processor chain but doesn't require it.  In other words, it handles both
``exception`` as well as ``exc_info`` keys.

.. versionadded:: 0.4.0

.. versionchanged:: 16.0.0
   Added support for passing exceptions as ``exc_info`` on Python 3.

.. versionchanged:: 25.4.0
   Fixed *exception_formatter* so that it overrides the default if set.
Nc                óN   • X l         Ub  Xl        g [        R                  U l        g r-   )r¹   Ú_filer  Ústdout)r9   Úfilerº   s      r2   r>   ÚExceptionPrettyPrinter.__init__‘  s    € ð
 !4ÔØÑØ�JäŸ™ˆD�Jr5   c                óÊ   • UR                  SS 5      nUc3  [        UR                  SS 5      5      nU(       a  U R                  U5      nU(       a  [        X@R                  S9  U$ )Nr¾   r½   )r  )ru   r¿   r¹   Úprintr  )r9   r�   rŽ   rL   Úexcr½   s         r2   rM   ÚExceptionPrettyPrinter.__call__œ  sV   € ð �n‰n˜[¨$Ó/ˆØ‰;Ü+¨J¯N©N¸:ÀtÓ,LÓMˆHÞØ×+Ñ+¨HÓ5�æÜ�#ŸJ™JÒ'àÐr5   )r  r¹   )r  zTextIO | Nonerº   r   r6   r“   r”   rÁ   rZ   r5   r2   r   r   r  sV   † ñð@ #Ø4Eð	$àð	$ð 2ð	$ð 
õ		$ðØ#ðØ+.ðØ<Eðà	÷r5   r   c                  óD   • \ rS rSrSrSrSSS jjr        S	S jrSrg)
r#   i«  ad  
Add stack information with key ``stack`` if ``stack_info`` is `True`.

Useful when you want to attach a stack dump to a log entry without
involving an exception and works analogously to the *stack_info* argument
of the Python standard library logging.

Args:
    additional_ignores:
        By default, stack frames coming from *structlog* are ignored. With
        this argument you can add additional names that are ignored, before
        the stack starts being rendered. They are matched using
        ``startswith()``, so they don't have to match exactly. The names
        are used to find the first relevant name, therefore once a frame is
        found that doesn't start with *structlog* or one of
        *additional_ignores*, **no filtering** is applied to subsequent
        frames.

.. versionadded:: 0.4.0
.. versionadded:: 22.1.0  *additional_ignores*
©Ú_additional_ignoresNc                ó   • Xl         g r-   r  )r9   Úadditional_ignoress     r2   r>   ÚStackInfoRenderer.__init__Ä  s   € Ø#5Õ r5   c                ó|   • UR                  SS 5      (       a$  [        [        U R                  5      S   5      US'   U$ )NÚ
stack_infor   Ústack)ru   r   r   r  rª   s       r2   rM   ÚStackInfoRenderer.__call__Ç  s?   € ð �>‰>˜,¨×-Ñ-Ü"/Ü.¨t×/GÑ/GÓHÈÑKó#ˆJ�wÑð Ðr5   r-   )r   úlist[str] | Noner6   r“   r”   r  rZ   r5   r2   r#   r#   «  s8   † ñð, )€Iö6ðØ#ðØ+.ðØ<Eðà	÷r5   r#   c                  óD   • \ rS rSrSrSrSrSrSrSr	Sr
S	rS
rSrSrSrSrg)r   iÒ  a‡  
Callsite parameters that can be added to an event dictionary with the
`structlog.processors.CallsiteParameterAdder` processor class.

The string values of the members of this enum will be used as the keys for
the callsite parameters in the event dictionary.

.. versionadded:: 21.5.0

.. versionadded:: 25.5.0
   `QUAL_NAME` parameter.

.. versionadded:: 26.1.0
   `QUAL_MODULE` parameter.
ÚpathnameÚfilenameÚmoduleÚqual_moduleÚ	func_nameÚ	qual_nameÚlinenoÚthreadÚthread_nameÚprocessÚprocess_namerZ   N)rT   rU   rV   rW   rX   ÚPATHNAMEÚFILENAMEÚMODULEÚQUAL_MODULEÚ	FUNC_NAMEÚ	QUAL_NAMEÚLINENOÚTHREADÚTHREAD_NAMEÚPROCESSÚPROCESS_NAMErY   rZ   r5   r2   r   r   Ò  sF   † ñð" €Hð €Hð €Fà€Kà€Ið €Ià€Fà€Fà€Kà€Gà!ƒLr5   r   c                ó.   • UR                   R                  $ r-   )Úf_codeÚco_filename©r*  Úframes     r2   Ú_get_callsite_pathnamerC  ÿ  ó   € Ø�<‰<×#Ñ#Ð#r5   c                óh   • [         R                  R                  UR                  R                  5      $ r-   )ÚosÚpathÚbasenamer?  r@  rA  s     r2   Ú_get_callsite_filenamerI    s!   € Ü�7‰7×Ñ˜EŸL™L×4Ñ4Ó5Ð5r5   c                ó¨   • [         R                  R                  [         R                  R                  UR                  R
                  5      5      S   $ ©Nr   )rF  rG  ÚsplitextrH  r?  r@  rA  s     r2   Ú_get_callsite_modulerM    s5   € Ü�7‰7×ÑœBŸG™G×,Ñ,¨U¯\©\×-EÑ-EÓFÓGÈÑJÐJr5   c                ó.   • UR                   R                  $ r-   )r?  Úco_namerA  s     r2   Ú_get_callsite_func_namerP    s   € Ø�<‰<×ÑÐr5   c                ó.   • UR                   R                  $ r-   )r?  Úco_qualnamerA  s     r2   Ú_get_callsite_qual_namerS    rD  r5   c                ó   • U $ r-   rZ   rA  s     r2   Ú_get_callsite_qual_modulerU    s   € Ø€Mr5   c                ó   • UR                   $ r-   )Úf_linenorA  s     r2   Ú_get_callsite_linenorX    s   € Ø�>‰>Ðr5   c                óh   • [         R                  " S 5      nUc  [        R                  " 5       $ US   $ rK  )r   ÚgetÚ	threadingÚ	get_ident©r*  rB  Úthread_infos      r2   Ú_get_callsite_threadr_    s1   € Ü'×+Ò+¨DÓ1€KØÑÜ×"Ò"Ó$Ð$à�q‰>Ðr5   c                ó|   • [         R                  " S 5      nUc  [        R                  " 5       R                  $ US   $ )Nr   )r   rZ  r[  Úcurrent_threadrŽ   r]  s      r2   Ú_get_callsite_thread_namerb  #  s7   € Ü'×+Ò+¨DÓ1€KØÑÜ×'Ò'Ó)×.Ñ.Ð.à�q‰>Ðr5   c                ó,   • [         R                  " 5       $ r-   )rF  ÚgetpidrA  s     r2   Ú_get_callsite_processre  +  s   € Ü�9Š9‹;Ðr5   c                ó   • [        5       $ r-   r   rA  s     r2   Ú_get_callsite_process_namerg  /  s   € ÜÓÐr5   c                  ó€  • \ rS rSr% Sr\R                  \\R                  \	\R                  \\R                  \\R                  \\R                   \\R$                  \\R(                  \\R,                  \\R0                  \\R4                  \0rS\S'   \R                  S\R                  S\R                  S\R                  S\R$                  S	\R(                  S
\R,                  S\R0                  S\R4                  S0	rS\S'   \" \5      r S\S'    " S S\!5      r"Sr#\ S4     SS jjr$        SS jr%Sr&g)r   i3  a�  
Adds parameters of the callsite that an event dictionary originated from to
the event dictionary. This processor can be used to enrich events
dictionaries with information such as the function name, line number and
filename that an event dictionary originated from.

If the event dictionary has an embedded `logging.LogRecord` object and did
not originate from *structlog* then the callsite information will be
determined from the `logging.LogRecord` object. For event dictionaries
without an embedded `logging.LogRecord` object the callsite will be
determined from the stack trace, ignoring all intra-structlog calls, calls
from the `logging` module, and stack frames from modules with names that
start with values in ``additional_ignores``, if it is specified.

The keys used for callsite parameters in the event dictionary are the
string values of `CallsiteParameter` enum members.

Args:
    parameters:
        A collection of `CallsiteParameter` values that should be added to
        the event dictionary.

    additional_ignores:
        Additional names with which a stack frame's module name must not
        start for it to be considered when determening the callsite.

.. note::

    When used with `structlog.stdlib.ProcessorFormatter` the most efficient
    configuration is to either use this processor in ``foreign_pre_chain``
    of `structlog.stdlib.ProcessorFormatter` and in ``processors`` of
    `structlog.configure`, or to use it in ``processors`` of
    `structlog.stdlib.ProcessorFormatter` without using it in
    ``processors`` of `structlog.configure` and ``foreign_pre_chain`` of
    `structlog.stdlib.ProcessorFormatter`.

.. versionadded:: 21.5.0
zBClassVar[dict[CallsiteParameter, Callable[[str, FrameType], Any]]]Ú	_handlersr(  r)  r*  ÚfuncNamer.  r/  Ú
threadNamer1  ÚprocessNamez&ClassVar[dict[CallsiteParameter, str]]Ú_record_attribute_mapz ClassVar[set[CallsiteParameter]]Ú_all_parametersc                  ó*   • \ rS rSr% S\S'   S\S'   Srg)Ú%CallsiteParameterAdder._RecordMappingiy  r/   Úevent_dict_keyÚrecord_attributerZ   N)rT   rU   rV   rW   r–   rY   rZ   r5   r2   Ú_RecordMappingrp  y  s   ‡ ØÓØÖr5   rs  )Ú_active_handlersr  Ú_record_mappingsNc                óN  • Uc  / nS/UQU l         / U l        / U l        U H‚  nU R                  R                  X0R                  U   45        U R
                  R                  U5      =n c  MM  U R                  R                  U R                  UR                  U5      5        M„     g )NÚlogging)	r  rt  ru  rk   ri  rm  rZ  rs  ro   )r9   Ú
parametersr   Ú	parameterÚrecord_attrs        r2   r>   ÚCallsiteParameterAdder.__init__  sº   € ð
 Ñ%Ø!#Ðð %.Ð#CÐ0BÐ#CˆÔ ð ð 	Ôð NPˆÔÛ#ˆIØ×!Ñ!×(Ñ(ØŸN™N¨9Ñ5Ð6ôð  $×9Ñ9×=Ñ=¸iÓHÐH�Øóð ×%Ñ%×,Ñ,Ø×'Ñ'Ø!Ÿ™Ø#óöò $r5   c                óP  • UR                  S5      nUR                  SS5      nUbA  U(       d:  U R                   H(  nUR                  UR                     X6R                  '   M*     U$ [        U R                  S9u  pxU R                   H  u  pšU
" X‡5      X9R                  '   M     U$ )NÚ_recordÚ_from_structlogF)r   )	rZ  ru  Ú__dict__rr  rq  r   r  rt  ro   )r9   r�   rŽ   rL   ÚrecordÚfrom_structlogÚmappingrB  r*  ry  Úhandlers              r2   rM   ÚCallsiteParameterAdder.__call__œ  s¨   € ð ,6¯>©>¸)Ó+DˆØ)Ÿ~™~Ð.?ÀÓGˆð Ñ¦nØ×0Ô0�Ø5;·_±_Ø×,Ñ,ñ6�
×1Ñ1Ó2ñ 1ð
 Ðä6Ø#×7Ñ7ñ
‰ˆð #'×"7Ô"7ÑˆIÙ*1°&Ó*@ˆJ—‘Ó'ñ #8ð Ðr5   )rx  zCollection[CallsiteParameter]r   r&  r6   r“   ©r�   zlogging.LoggerrŽ   r/   rL   r   r6   r   )'rT   rU   rV   rW   rX   r   r3  rC  r4  rI  r5  rM  r6  rU  r7  rP  r8  rS  r9  rX  r:  r_  r;  rb  r<  re  r=  rg  ri  r–   rm  Úsetrn  r   rs  rÚ   r>   rM   rY   rZ   r5   r2   r   r   3  sŽ  ‡ ñ%ðV 	×"Ñ"Ð$:Ø×"Ñ"Ð$:Ø× Ñ Ð"6Ø×%Ñ%Ð'@Ø×#Ñ#Ð%<Ø×#Ñ#Ð%<Ø× Ñ Ð"6Ø× Ñ Ð"6Ø×%Ñ%Ð'@Ø×!Ñ!Ð#8Ø×&Ñ&Ð(Bð	ð ð ó ð" 	×"Ñ" JØ×"Ñ" JØ× Ñ  (Ø×#Ñ# ZØ× Ñ  (Ø× Ñ  (Ø×%Ñ% |Ø×!Ñ! 9Ø×&Ñ&¨ð
EÐÐAó 
ñ 9<Ð<MÓ8N€OÐ5ÓNô˜ô ð P€Ið 5DØ/3ðà1ðð -ðð 
õ	ð:Ø$ðØ,/ðØ=Fðà	÷r5   r   c                  ó@   • \ rS rSrSrSSS jjr        S	S jrSrg)
r   iµ  a  
Rename the ``event`` key in event dicts.

This is useful if you want to use consistent log message keys across
platforms and/or use the ``event`` key for something custom.

.. warning::

   It's recommended to put this processor right before the renderer, since
   some processors may rely on the presence and meaning of the ``event``
   key.

Args:
    to: Rename ``event_dict["event"]`` to ``event_dict[to]``

    replace_by:
        Rename ``event_dict[replace_by]`` to ``event_dict["event"]``.
        *replace_by* missing from ``event_dict`` is handled gracefully.

.. versionadded:: 22.1.0

See also the :ref:`rename-event` recipe.
Nc                ó   • Xl         X l        g r-   )ÚtoÚ
replace_by)r9   r‰  rŠ  s      r2   r>   ÚEventRenamer.__init__Î  s   € ØŒØ$�r5   c                ó¤   • UR                  S5      nXCU R                  '   U R                  b#  UR                  U R                  S 5      nUb  XSS'   U$ )NÚevent)ru   r‰  rŠ  )r9   r�   rŽ   rL   r�  rŠ  s         r2   rM   ÚEventRenamer.__call__Ò  sP   € ð —‘˜wÓ'ˆØ#�4—7‘7Ñà�?‰?Ñ&Ø#Ÿ™¨¯©¸Ó>ˆJØÑ%Ø&0˜7Ñ#àÐr5   )rŠ  r‰  r-   )r‰  r/   rŠ  rØ   r…  rS   rZ   r5   r2   r   r   µ  s1   † ñö0%ðØ$ðØ,/ðØ=Fðà	÷r5   r   )r:   rP   r;   rQ   r<   rP   r6   z/Callable[[EventDict], list[tuple[str, object]]])r´   r	   r6   r	   )rÄ   rØ   rÅ   rP   rn   r/   r6   z Callable[[EventDict], EventDict])rF   r	   r6   zExcInfo | None)r*  r/   rB  r   r6   r	   )JrX   Ú
__future__r   rÞ   Úenumr¬   rw  r}   rF  r  r[  rä   Úcollections.abcr   r   r   Útypesr   r   Útypingr	   r
   r   r   r   Ú_framesr   r   r   Ú_log_levelsr   r   Ú_utilsr   Úcontextvarsr   Ú
tracebacksr   r   r   r   r   Ú__all__r!   r"   r7   r&   r%   r    r¢   r¶   r(   r'   r$   rÈ   rü   r¿   r   r#   ÚEnumr   rC  rI  rM  rP  rS  rU  rX  r_  rb  re  rg  r   r   rZ   r5   r2   Ú<module>r›     s³  ðñõ #ã Û Û Û Û Û 	Û 
Û Û ç :Ñ :ß *÷õ ÷ñ ÷
 6Ý #Ý .Ý 0÷ó ò€÷&2
ñ 2
÷jH"ñ H"ðV/Øð/à#ð/ð ð/ð 5ô	/÷dñ ÷D ñ  ÷F%9ñ %9ôP÷ 1ñ 1ñh $Ó%€ðñ( $Ñ$<Ó$>Ó?€ð÷"*/ñ */ðZ;Ø	ð;Øð;Ø%(ð;à%ô;÷|ñ ô>÷46ñ 6÷r$ñ $ôN*"˜Ÿ	™	ô *"ôZ$ô6ôKô ô$ôôôôôô÷ñ ÷D(ò (r5   