o
    1Éliß  ã                   @   s(   d Z ddlZddlZddlZdd„ ZdS )z
Diagnostic utilities
é    Nc                    s   ‡ fdd„}|S )aÌ  Create a decorator that logs and reraises any exceptions that escape
    the decorated function

    :param logging.Logger logger:
    :returns: the decorator
    :rtype: callable

    Usage example

    import logging

    from pika.diagnostics_utils import create_log_exception_decorator

    _log_exception = create_log_exception_decorator(logging.getLogger(__name__))

    @_log_exception
    def my_func_or_method():
        raise Exception('Oops!')

    c                    s   t  ˆ ¡‡ ‡fdd„ƒ}|S )z£The decorator returned by the parent function

        :param func: function to be wrapped
        :returns: the function wrapper
        :rtype: callable
        c                     s6   zˆ | i |¤ŽW S    ˆ  dd tjt ¡ Ž ¡¡ ‚ )að  The wrapper function returned by the decorator. Invokes the
            function with the given args/kwargs and returns the function's
            return value. If the function exits with an exception, logs the
            exception traceback and re-raises the

            :param args: positional args passed to wrapped function
            :param kwargs: keyword args passed to wrapped function
            :returns: whatever the wrapped function returns
            :rtype: object
            z6Wrapped func exited with exception. Caller's stack:
%sÚ )Ú	exceptionÚjoinÚ	tracebackÚformat_exceptionÚsysÚexc_info)ÚargsÚkwargs)ÚfuncÚlogger© úe/var/www/html/tatsat2dev/dashboard-backend/venv/lib/python3.10/site-packages/pika/diagnostic_utils.pyÚlog_exception_func_wrap(   s   þzVcreate_log_exception_decorator.<locals>.log_exception.<locals>.log_exception_func_wrap)Ú	functoolsÚwraps)r   r   ©r   )r   r   Úlog_exception    s   z5create_log_exception_decorator.<locals>.log_exceptionr   )r   r   r   r   r   Úcreate_log_exception_decorator
   s   r   )Ú__doc__r   r   r   r   r   r   r   r   Ú<module>   s
    