
    "h                        d dl mZ d dlZd dlZd dlmZ d dlmZ d dlm	Z	 ddl
mZ ddlmZ dd	Z	 dej                  d
	 	 	 	 	 ddZddZy)    )annotationsN)StringIO)	FrameType)Callable   )_ASYNC_CALLING_STACK)ExcInfoc                    t               }t        j                  | d   | d   | d   d|       |j                         }|j	                          |dd dk(  r|dd }|S )z`
    Prettyprint an `exc_info` tuple.

    Shamelessly stolen from stdlib's logging module.
    r   r      N
)r   	tracebackprint_exceptiongetvalueclose)exc_infosioss      N/var/www/html/sandstorm/venv/lib/python3.12/site-packages/structlog/_frames.py_format_exceptionr      s^     *Chqk8A;T3OAIIKv~crFH    )	_getframec               d   t        dg| xs g z         }t        j                   |             }|j                  j                  d      xs d}|j	                  |      rP|j
                  d}	 ||fS |j
                  }|j                  j                  d      xs d}|j	                  |      rP||fS )ap  
    Remove all intra-structlog calls and return the relevant app frame.

    Args:
        additional_ignores:
            Additional names with which the first frame must not start.

        _getframe:
            Callable to find current frame. Only for testing to avoid
            monkeypatching of sys._getframe.

    Returns:
        tuple of (frame, name)
    	structlog__name__?)tupler   get	f_globals
startswithf_back)additional_ignoresr   ignoresfnames        r   _find_first_app_frame_and_namer&   $   s    & [M%7%=2>?G  -A;;??:&-#D
//'
"88D d7N HH{{z*1c //'
" d7Nr   c                    t               }|j                  d       t        j                  | |       |j	                         }|d   dk(  r|dd }|j                          |S )z?
    Pretty-print the stack of *frame* like logging would.
    zStack (most recent call last):
)filer   r   N)r   writer   print_stackr   r   )framer   sinfos      r   _format_stackr-   C   sX     *CII01%c*LLNERyDcr
IIKLr   )r   r	   returnstr)N)r"   zlist[str] | Noner   zCallable[[], FrameType]r.   ztuple[FrameType, str])r+   r   r.   r/   )
__future__r   sysr   ior   typesr   typingr   contextvarsr   r	   r   r   r&   r-    r   r   <module>r7      s]    # 
     - $ ,0 *-( ' 	>r   