
    "h#                        U d Z ddlmZ ddlZddlZddlZddlmZ ddlmZm	Z	 ddl
mZmZmZmZ i Zded<   dd	Z G d
 d      Z G d d      Z G d d      Z G d d      Z G d d      Z G d d      Zy)z(
Logger classes responsible for output.
    )annotationsN)PicklingError)stderrstdout)IOAnyBinaryIOTextIOzdict[IO[Any], threading.Lock]WRITE_LOCKSc                n    t         j                  |       }|t        j                         }|t         | <   |S N)r   get	threadingLock)filelocks     N/var/www/html/sandstorm/venv/lib/python3.12/site-packages/structlog/_output.py_get_lock_for_filer      s0    ??4 D|~~ DK    c                  n    e Zd ZdZd	d
dZddZddZddZddZddZ	e	xZ
xZxZxZZe	xZxZxZxZxZZy)PrintLoggera  
    Print events into a file.

    Args:
        file: File to print to. (default: `sys.stdout`)

    >>> from structlog import PrintLogger
    >>> PrintLogger().info("hello")
    hello

    Useful if you follow `current logging best practices
    <logging-best-practices>`.

    Also very useful for testing and examples since `logging` is finicky in
    doctests.

    .. versionchanged:: 22.1.0
       The implementation has been switched to use `print` for better
       monkeypatchability.
    Nc                V    |xs t         | _        t        | j                        | _        y r   )r   _filer   _lockselfr   s     r   __init__zPrintLogger.__init__7   s    ^V
'

3
r   c                d    | j                   t        u ry| j                   t        u ryt        d      )=
        Our __getattr__ magic makes this necessary.
        r   r   z>Only PrintLoggers to sys.stdout and sys.stderr can be pickled.r   r   r   r   r   s    r   __getstate__zPrintLogger.__getstate__<   2     ::::L
 	
r   c                p    |dk(  rt         | _        nt        | _        t        | j                        | _        yr   r   Nr   r   r   r   r   r   states     r   __setstate__zPrintLogger.__setstate__J   *     HDJDJ'

3
r   c                    | j                   t        t        fvrt        j                  d      | j                  | j                         }t        |j                         |_        |S )zY
        Create a new PrintLogger with the same attributes. Similar to pickling.
        zAOnly PrintLoggers to sys.stdout and sys.stderr can be deepcopied.)r   r   r   copyerror	__class__r   r   r   memodictnewselfs      r   __deepcopy__zPrintLogger.__deepcopy__U   sT     ::ff--**% 
 ..,*7==9r   c                "    d| j                   dS )Nz<PrintLogger(file=)>r   r!   s    r   __repr__zPrintLogger.__repr__e       #DJJ>44r   c                    | j                   t        ur| j                   nd}| j                  5  t        ||d       ddd       y# 1 sw Y   yxY w)z"
        Print *message*.
        NT)r   flush)r   r   r   print)r   messagefs      r   msgzPrintLogger.msgh   sB     **F2DJJZZ 	/'.	/ 	/ 	/s   AAr   r   zTextIO | Nonereturnstrr(   r   r@   None)r0   dict[str, object]r@   r   r;   rA   r@   rC   __name__
__module____qualname____doc__r   r"   r)   r2   r6   r=   logdebuginfowarnwarningfatalfailureerrr-   critical	exception r   r   r   r   !   s^    *4

	4 5/ +.-C-%-$-;>>E>G>c>E>Hyr   r   c                  "    e Zd ZdZdddZddZy)PrintLoggerFactoryz
    Produce `PrintLogger`\ s.

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

    Args:
        file: File to print to. (default: `sys.stdout`)

    Positional arguments are silently ignored.

    .. versionadded:: 0.4.0
    Nc                    || _         y r   r5   r   s     r   r   zPrintLoggerFactory.__init__   	    
r   c                ,    t        | j                        S r   )r   r   r   argss     r   __call__zPrintLoggerFactory.__call__       4::&&r   r   r>   )r\   r   r@   r   rG   rH   rI   rJ   r   r]   rU   r   r   rW   rW   t       'r   rW   c                  n    e Zd ZdZd	d
dZddZddZddZddZddZ	e	xZ
xZxZxZZe	xZxZxZxZxZZy)WriteLoggera  
    Write events into a file.

    Args:
        file: File to print to. (default: `sys.stdout`)

    >>> from structlog import WriteLogger
    >>> WriteLogger().info("hello")
    hello

    Useful if you follow
    `current logging best practices <logging-best-practices>`.

    Also very useful for testing and examples since `logging` is finicky in
    doctests.

    A little faster and a little less versatile than `structlog.PrintLogger`.

    .. versionadded:: 22.1.0
    Nc                    |xs t         j                  | _        | j                  j                  | _        | j                  j
                  | _        t        | j                        | _        y r   )	sysr   r   write_writer9   _flushr   r   r   s     r   r   zWriteLogger.__init__   sD    'SZZ
jj&&jj&&'

3
r   c                d    | j                   t        u ry| j                   t        u ryt        d      )r   r   r   z>Only WriteLoggers to sys.stdout and sys.stderr can be pickled.r    r!   s    r   r"   zWriteLogger.__getstate__   r#   r   c                p    |dk(  rt         | _        nt        | _        t        | j                        | _        yr%   r&   r'   s     r   r)   zWriteLogger.__setstate__   r*   r   c                ^   | j                   t        j                  t        j                  fvrt	        j
                  d      | j                  | j                         }|j                   j                  |_        |j                   j                  |_
        t        |j                         |_        |S )zY
        Create a new WriteLogger with the same attributes. Similar to pickling.
        zAOnly WriteLoggers to sys.stdout and sys.stderr can be deepcopied.)r   rd   r   r   r,   r-   r.   re   rf   r9   rg   r   r   r/   s      r   r2   zWriteLogger.__deepcopy__   s~     ::cjj#**55**% 
 .., ,, ,,*7==9r   c                "    d| j                   dS )Nz<WriteLogger(file=r4   r5   r!   s    r   r6   zWriteLogger.__repr__   r7   r   c                    | j                   5  | j                  |dz          | j                          ddd       y# 1 sw Y   yxY w)z,
        Write and flush *message*.
        
Nr   rf   rg   r   r;   s     r   r=   zWriteLogger.msg   s9     ZZ 	KK$'KKM	 	 		   %;Ar   r>   r?   rB   )r0   rD   r@   rb   rE   rF   rU   r   r   rb   rb      s^    *4
	4$5 +.-C-%-$-;>>E>G>c>E>Hyr   rb   c                  "    e Zd ZdZdddZddZy)WriteLoggerFactoryz
    Produce `WriteLogger`\ s.

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

    Args:
        file: File to print to. (default: `sys.stdout`)

    Positional arguments are silently ignored.

    .. versionadded:: 22.1.0
    Nc                    || _         y r   r5   r   s     r   r   zWriteLoggerFactory.__init__   rY   r   c                ,    t        | j                        S r   )rb   r   r[   s     r   r]   zWriteLoggerFactory.__call__   r^   r   r   r>   )r\   r   r@   rb   r_   rU   r   r   rr   rr      r`   r   rr   c                  r    e Zd ZdZdZd
ddZddZddZddZddZ	dd	Z
e
xZxZxZxZZe
xZxZxZxZxZZy)BytesLoggeraL  
    Writes bytes into a file.

    Args:
        file: File to print to. (default: `sys.stdout`\ ``.buffer``)

    Useful if you follow `current logging best practices
    <logging-best-practices>` together with a formatter that returns bytes
    (e.g. `orjson <https://github.com/ijl/orjson>`_).

    .. versionadded:: 20.2.0
    )r   rg   r   rf   Nc                    |xs t         j                  j                  | _        | j                  j                  | _        | j                  j                  | _        t        | j                        | _	        y r   )
rd   r   bufferr   re   rf   r9   rg   r   r   r   s     r   r   zBytesLogger.__init__  sJ    .SZZ..
jj&&jj&&'

3
r   c                    | j                   t        j                  j                  u ry| j                   t        j                  j                  u ryt        d      )r   r   r   z>Only BytesLoggers to sys.stdout and sys.stderr can be pickled.)r   rd   r   rx   r   r   r!   s    r   r"   zBytesLogger.__getstate__  sF     ::***::***L
 	
r   c                ,   |dk(  r t         j                  j                  | _        nt         j                  j                  | _        | j                  j
                  | _        | j                  j                  | _        t        | j                        | _
        yr%   )rd   r   rx   r   r   re   rf   r9   rg   r   r   r'   s     r   r)   zBytesLogger.__setstate__  s`     H**DJ**DJjj&&jj&&'

3
r   c                   | j                   t        j                  j                  t        j                  j                  fvrt        j                  d      | j                  | j                         }|j                   j                  |_	        |j                   j                  |_        t        |j                         |_        |S )zY
        Create a new BytesLogger with the same attributes. Similar to pickling.
        zAOnly BytesLoggers to sys.stdout and sys.stderr can be deepcopied.)r   rd   r   rx   r   r,   r-   r.   re   rf   r9   rg   r   r   r/   s      r   r2   zBytesLogger.__deepcopy__'  s     ::cjj//1B1BCC**% 
 .., ,, ,,*7==9r   c                "    d| j                   dS )Nz<BytesLogger(file=r4   r5   r!   s    r   r6   zBytesLogger.__repr__9  r7   r   c                    | j                   5  | j                  |dz          | j                          ddd       y# 1 sw Y   yxY w)z"
        Write *message*.
           
Nrn   ro   s     r   r=   zBytesLogger.msg<  s9     ZZ 	KK%(KKM	 	 	rp   r   r   zBinaryIO | Noner?   rB   )r0   rD   r@   rv   )r;   bytesr@   rC   )rG   rH   rI   rJ   	__slots__r   r"   r)   r2   r6   r=   rK   rL   rM   rN   rO   rP   rQ   rR   r-   rS   rT   rU   r   r   rv   rv      se     7I4
4$5 +.-C-%-$-;>>E>G>c>E>Hyr   rv   c                  &    e Zd ZdZdZdddZddZy)	BytesLoggerFactorya  
    Produce `BytesLogger`\ s.

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

    Args:
        file: File to print to. (default: `sys.stdout`\ ``.buffer``)

    Positional arguments are silently ignored.

    .. versionadded:: 20.2.0
    r5   Nc                    || _         y r   r5   r   s     r   r   zBytesLoggerFactory.__init__X  rY   r   c                ,    t        | j                        S r   )rv   r   r[   s     r   r]   zBytesLoggerFactory.__call__[  r^   r   r   r   )r\   r   r@   rv   )rG   rH   rI   rJ   r   r   r]   rU   r   r   r   r   H  s     I'r   r   )r   zIO[Any]r@   zthreading.Lock)rJ   
__future__r   r,   rd   r   pickler   r   r   typingr   r   r	   r
   r   __annotations__r   r   rW   rb   rr   rv   r   rU   r   r   <module>r      s{    #  
     , , .0* /P? P?f' '*T? T?n' '*P? P?f' 'r   