o
    *i                     @   s   d Z ddlZddlZddlmZ ddlmZmZmZ ddl	m
Z
 g dZe ZeG dd dZdd	ee fd
dZdeeef defddZee d dS )z.
Logger configuration for Compressed Tensors.
    N)	dataclass)AnyDictOptional)logger)LoggerConfigconfigure_loggerr   c                   @   sV   e Zd ZU dZeed< dZeed< dZee	 ed< dZ
ee	 ed< dZee	 ed	< dS )
r   FdisabledTclear_loggersINFOconsole_log_levelNlog_filelog_file_level)__name__
__module____qualname__r	   bool__annotations__r
   r   r   strr   r    r   r   V/home/ubuntu/veenaModal/venv/lib/python3.10/site-packages/compressed_tensors/logger.pyr   "   s   
 r   configc                 C   s  | pt  }ttdrd|_ttdrd|_td }dur'| |_td }dur3||_td }durA| |_	|jrKt
d dS t
d |jrWt
  |jrgt
jtj|j d	td
 |jsm|j	r|jpqd}|j	pvd}t
j|| dtd dS dS )aH  
    Configure the logger for Compressed Tensors.
    This function sets up the console and file logging
    as per the specified or default parameters.

    Note: Environment variables take precedence over the function parameters.

    :param config: The configuration for the logger to use.
    :type config: LoggerConfig
    COMPRESSED_TENSORS_LOG_DISABLEDT COMPRESSED_TENSORS_CLEAR_LOGGERSCOMPRESSED_TENSORS_LOG_LEVELNCOMPRESSED_TENSORS_LOG_FILE!COMPRESSED_TENSORS_LOG_FILE_LEVELcompressed_tensorsz){time} | {function} | {level} - {message})levelformatfilterzcompressed_tensors.logr   )r   	serializer    )r   r   osgetenvr	   r
   upperr   r   r   r   disableenableremoveaddsysstdoutsupport_log_once)r   logger_configr   r   r   r   r   r   r   +   sD   







r   recordreturnc                 C   sV   | d  dd}t| d dd}tt|| d  }|r"|tv r"dS |r)t| dS )	ad  
    Support logging only once using `.bind(log_once=True)`

    ```
    logger.bind(log_once=False).info("This will log multiple times")
    logger.bind(log_once=False).info("This will log multiple times")
    logger.bind(log_once=True).info("This will only log once")
    logger.bind(log_once=True).info("This will only log once")  # skipped
    ```
    extralog_onceFr   namenonemessageT)getgetattrhashr   _logged_oncer(   )r-   r0   r   r3   r   r   r   r+   b   s   
r+   )r   )N)__doc__r"   r)   dataclassesr   typingr   r   r   logurur   __all__setr7   r   r   r   r   r+   r   r   r   r   <module>   s   7