ó
    öÞ jŒ  ã                  ó"  • S r SSKJr  SSKJrJr  SSK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JrJr  / SQr " S S5      r\ S   SS jj5       r " S S5      r " S S5      r " S S\
5      r " S S5      r " S S5      rg)ze
Helpers to test your application's logging behavior.

.. versionadded:: 20.1.0

See :doc:`testing`.
é    )Úannotations)Ú	GeneratorÚIterable)Úcontextmanager)ÚAnyÚ
NamedTupleÚNoReturné   )Ú	configureÚ
get_config)Úmap_method_name)Ú	DropEvent)Ú	EventDictÚ	ProcessorÚWrappedLogger)ÚCapturedCallÚCapturingLoggerÚCapturingLoggerFactoryÚ
LogCaptureÚReturnLoggerÚReturnLoggerFactoryÚcapture_logsc                  óH   • \ rS rSr% SrS\S'   S	S jr        S
S jrSrg)r   é%   a–  
Class for capturing log messages in its entries list.
Generally you should use `structlog.testing.capture_logs`,
but you can use this class if you want to capture logs with other patterns.

:ivar List[structlog.typing.EventDict] entries: The captured log entries.

.. versionadded:: 20.1.0

.. versionchanged:: 24.3.0
   Added mapping from "exception" to "error"
   Added mapping from "warn" to "warning"
zlist[EventDict]Úentriesc                ó   • / U l         g ©N©r   ©Úselfs    ÚK/var/www/html/gaurav/venv/lib/python3.13/site-packages/structlog/testing.pyÚ__init__ÚLogCapture.__init__6   s	   € Øˆ�ó    c                ó`   • [        U5      US'   U R                  R                  U5        [        e)NÚ	log_level)r   r   Úappendr   )r    Ú_Úmethod_nameÚ
event_dicts       r!   Ú__call__ÚLogCapture.__call__9   s*   € ô #2°+Ó">ˆ
�;ÑØ�‰×Ñ˜JÔ'äˆr$   r   N©ÚreturnÚNone)r(   r   r)   Ústrr*   r   r.   r	   ©	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__annotations__r"   r+   Ú__static_attributes__© r$   r!   r   r   %   s9   ‡ ñð ÓôðØðØ-0ðØ>Gðà	÷r$   r   c              #  ó   #   • [        5       n[        5       S   nUR                  5       n UR                  5         UR	                  U 5        UR                  U5        [        US9  UR                  v •  UR                  5         UR	                  U5        [        US9  g! UR                  5         UR	                  U5        [        US9  f = f7f)ae  
Context manager that appends all logging statements to its yielded list
while it is active. Disables all configured processors for the duration
of the context manager.

Attention: this is **not** thread-safe!

Args:
    processors: Processors to apply before the logs are captured.

.. versionadded:: 20.1.0
.. versionadded:: 25.5.0 *processors* parameter
Ú
processors)r;   N)r   r   ÚcopyÚclearÚextendr'   r   r   )r;   ÚcapÚconfigured_processorsÚold_processorss       r!   r   r   B   s¶   é € ô" ‹,€Cô '›L¨Ñ6ÐØ*×/Ñ/Ó1€Nð4à×#Ñ#Ô%Ø×$Ñ$ ZÔ0Ø×$Ñ$ SÔ)ÜÐ2Ò3Ø�k‰kÒð 	×#Ñ#Ô%Ø×$Ñ$ ^Ô4ÜÐ2Ó3øð 	×#Ñ#Ô%Ø×$Ñ$ ^Ô4ÜÐ2Ó3üs   ‚(C«A	B Á4+CÂ,CÃCc                  óN   • \ rS rSrSrSS jr\=r=r=r=r	r
\=r=r=r=r=rrSrg)r   ég   a1  
Return the arguments that it's called with.

>>> from structlog import ReturnLogger
>>> ReturnLogger().info("hello")
'hello'
>>> ReturnLogger().info("hello", when="again")
(('hello',), {'when': 'again'})

.. versionchanged:: 0.3.0
    Allow for arbitrary arguments and keyword arguments to be passed in.
c                ó>   • [        U5      S:X  a  U(       d  US   $ X4$ )zI
Return tuple of ``args, kw`` or just ``args[0]`` if only one arg passed
r
   r   )Úlen)r    ÚargsÚkws      r!   ÚmsgÚReturnLogger.msgu   s!   € ô
 ˆt‹9˜‹>¦"Ø˜‘7ˆNàˆxˆr$   r9   N)rF   r   rG   r   r.   r   )r2   r3   r4   r5   r6   rH   ÚlogÚdebugÚinfoÚwarnÚwarningÚfatalÚfailureÚerrÚerrorÚcriticalÚ	exceptionr8   r9   r$   r!   r   r   g   sE   † ñôð +.Ð-€CÐ-ˆ%Ð-�$Ð-˜ Ø;>Ð>€EÐ>ˆGÐ>�cÐ>˜EÐ> H«yr$   r   c                  ó,   • \ rS rSrSrSS jrSS jrSrg)	r   éƒ   z¨
Produce and cache `ReturnLogger`\ s.

To be used with `structlog.configure`\ 's *logger_factory*.

Positional arguments are silently ignored.

.. versionadded:: 0.4.0
c                ó"   • [        5       U l        g r   )r   Ú_loggerr   s    r!   r"   ÚReturnLoggerFactory.__init__Ž   s   € Ü#“~ˆ�r$   c                ó   • U R                   $ r   ©rX   ©r    rF   s     r!   r+   ÚReturnLoggerFactory.__call__‘   s   € Ø�|‰|Ðr$   r[   Nr-   )rF   r   r.   r   )r2   r3   r4   r5   r6   r"   r+   r8   r9   r$   r!   r   r   ƒ   s   † ñô&÷r$   r   c                  ó8   • \ rS rSr% SrS\S'   S\S'   S\S'   S	rg
)r   é•   zÿ
A call as captured by `CapturingLogger`.

Can also be unpacked like a tuple.

Args:
    method_name: The method name that got called.

    args: A tuple of the positional arguments.

    kwargs: A dict of the keyword arguments.

.. versionadded:: 20.2.0
r0   r)   ztuple[Any, ...]rF   zdict[str, Any]Úkwargsr9   N)r2   r3   r4   r5   r6   r7   r8   r9   r$   r!   r   r   •   s   ‡ ñð ÓØ
ÓØÖr$   r   c                  óB   • \ rS rSr% SrS\S'   S
S jrSS jrSS jrSr	g	)r   éª   z×
Store the method calls that it's been called with.

This is nicer than `ReturnLogger` for unit tests because the bound logger
doesn't have to cooperate.

**Any** method name is supported.

.. versionadded:: 20.2.0
zlist[CapturedCall]Úcallsc                ó   • / U l         g r   ©rc   r   s    r!   r"   ÚCapturingLogger.__init__¸   s	   € Øˆ�
r$   c                ó4   • S[        U R                  5       S3$ )Nz<CapturingLogger with z	 call(s)>)rE   rc   r   s    r!   Ú__repr__ÚCapturingLogger.__repr__»   s   € Ø'¬¨D¯J©J«Ð'8¸	ÐBÐBr$   c                ó   ^ ^• SUU 4S jjnU$ )z
Capture call to `calls`
c                 óP   >• TR                   R                  [        TX5      5        g r   )rc   r'   r   )rF   rG   Únamer    s     €€r!   rJ   Ú(CapturingLogger.__getattr__.<locals>.logÃ   s   ø€ Ø�J‰J×Ñœl¨4°Ó:Õ;r$   )rF   r   rG   r   r.   r/   r9   )r    rl   rJ   s   `` r!   Ú__getattr__ÚCapturingLogger.__getattr__¾   s   ù€ ÷
	<ð 	<ð ˆ
r$   re   Nr-   )r.   r0   )rl   r0   r.   r   )
r2   r3   r4   r5   r6   r7   r"   rh   rn   r8   r9   r$   r!   r   r   ª   s   ‡ ñ	ð ÓôôC÷r$   r   c                  ó8   • \ rS rSr% SrS\S'   S	S jrS
S jrSrg)r   éÉ   a  
Produce and cache `CapturingLogger`\ s.

Each factory produces and reuses only **one** logger.

You can access it via the ``logger`` attribute.

To be used with `structlog.configure`\ 's *logger_factory*.

Positional arguments are silently ignored.

.. versionadded:: 20.2.0
r   Úloggerc                ó"   • [        5       U l        g r   )r   rr   r   s    r!   r"   ÚCapturingLoggerFactory.__init__Ú   s   € Ü%Ó'ˆ�r$   c                ó   • U R                   $ r   ©rr   r\   s     r!   r+   ÚCapturingLoggerFactory.__call__Ý   s   € Ø�{‰{Ðr$   rv   Nr-   )rF   r   r.   r   r1   r9   r$   r!   r   r   É   s   ‡ ñð Óô(÷r$   r   N)r9   )r;   zIterable[Processor]r.   z&Generator[list[EventDict], None, None])r6   Ú
__future__r   Úcollections.abcr   r   Ú
contextlibr   Útypingr   r   r	   Ú_configr   r   Ú_log_levelsr   Ú
exceptionsr   r   r   r   Ú__all__r   r   r   r   r   r   r   r9   r$   r!   Ú<module>r€      s—   ðñõ #ç /Ý %ß ,Ñ ,ç *Ý (Ý !ß 7Ñ 7ò€÷ñ ð: à&(ð!4Ø#ð!4à+ô!4ó ð!4÷H?ñ ?÷8ñ ô$�:ô ÷*ñ ÷>ò r$   