
    &`i@                     8   U d dl Z d dlmZmZ d dlmZmZ d dlmZ d dl	m
Z
 d dlmZmZ d dlmZ d dlmZ d d	lmZ  G d
 de          Z G d de          Z ej                    Zeed<    ed          e G d d                                  Zde_        dS )    N)ABCabstractmethod)	dataclassfield)Set)CoreContextFilter)JSONFormatterTextFormatter)default_impl)LOGRECORD_STANDARD_ATTRS)	PublicAPIc                   N    e Zd Zedee         fd            Zedd            ZdS )LoggingConfiguratorreturnc                     t           NNotImplementedErrorselfs    {/home/jaya/work/projects/VOICE-AGENT/VIET/agent-env/lib/python3.11/site-packages/ray/_private/ray_logging/logging_config.pyget_supported_encodingsz+LoggingConfigurator.get_supported_encodings       !!    logging_configLoggingConfigc                     t           r   r   )r   r   s     r   	configurezLoggingConfigurator.configure   r   r   Nr   r   )__name__
__module____qualname__r   r   strr   r    r   r   r   r      s]        "S " " " ^" " " " ^" " "r   r   c                   4    e Zd Zd Zdee         fdZddZdS )	DefaultLoggingConfiguratorc                 J    t                      t                      d| _        d S )N)TEXTJSON)r
   r	   _encoding_to_formatterr   s    r   __init__z#DefaultLoggingConfigurator.__init__   s%    !OO!OO'
 '
###r   r   c                 4    | j                                         S r   )r*   keysr   s    r   r   z2DefaultLoggingConfigurator.get_supported_encodings   s    *//111r   r   r   c                    | j         |j                 }|                    |j                   t	                      }t          j                    }|                    |j                   |	                    |           |
                    |           t          j                    }|                    |j                   |                    |           t          j        d          }|                    |j                   |j        d d          D ]}|                    |           |                    |           d|_        d S )NrayF)r*   encoding!set_additional_log_standard_attrsadditional_log_standard_attrsr   loggingStreamHandlersetLevel	log_levelsetFormatter	addFilter	getLogger
addHandlerhandlersremoveHandler	propagate)r   r   	formattercore_context_filterhandlerroot_logger
ray_loggerhs           r   r   z$DefaultLoggingConfigurator.configure!   s@   /0GH	338	
 	
 	
 011'))1222Y'''-...'))^5666w'''&u--
N4555$QQQ' 	( 	(A$$Q''''g&&&$
r   Nr   )r    r!   r"   r+   r   r#   r   r   r$   r   r   r&   r&      sV        
 
 
2S 2 2 2 2% % % % % %r   r&   _logging_configuratoralpha)	stabilityc                   `    e Zd ZU dZeed<   dZeed<    ee          Z	eed<   d Z
d Zd	 Zd
S )r   r(   r0   INFOr6   )default_factoryr2   c           	         | j         t                                          vr>t          d| j          dt	          t                                                               | j        D ]%}|t          vrt          d| dt                     &d S )NzInvalid encoding type: z. Valid encoding types are: z+Unknown python logging standard attribute: z. The valid attributes are: )r0   rD   r   
ValueErrorlistr2   r   )r   attrs     r   __post_init__zLoggingConfig.__post_init__K   s    = 5 M M O OOOK$- K K-EEGGHHK K   6 	 	D333 2$ 2 2/2 2   4	 	r   c                 :    t                               |            dS )z9Set up the logging configuration for the current process.N)rD   r   r   s    r   _configure_loggingz LoggingConfig._configure_logging[   s    ''-----r   c                 .    |                                   dS )z!Set up the logging configuration.N)rP   r   s    r   _applyzLoggingConfig._apply_   s    !!!!!r   N)r    r!   r"   r0   r#   __annotations__r6   r   rL   r2   rN   rP   rR   r$   r   r   r   r   B   s          HcIs +0%*E*E*E!4EEE   . . ." " " " "r   r   aK  
    Logging configuration for a Ray job. These configurations are used to set up the
    root logger of the driver process and all Ray tasks and actor processes that belong
    to the job.

    Examples: 1. Configure the logging to use TEXT encoding.
        .. testcode::

            import ray
            import logging

            ray.init(
                logging_config=ray.LoggingConfig(encoding="TEXT", log_level="INFO", additional_log_standard_attrs=['name'])
            )

            @ray.remote
            def f():
                logger = logging.getLogger(__name__)
                logger.info("This is a Ray task")

            ray.get(f.remote())
            ray.shutdown()

        .. testoutput::
            :options: +MOCK

            2025-02-12 12:25:16,836 INFO test-log-config.py:11 -- This is a Ray task name=__main__ job_id=01000000 worker_id=51188d9448be4664bf2ea26ac410b67acaaa970c4f31c5ad3ae776a5 node_id=f683dfbffe2c69984859bc19c26b77eaf3866c458884c49d115fdcd4 task_id=c8ef45ccd0112571ffffffffffffffffffffffff01000000 task_name=f task_func_name=test-log-config.f timestamp_ns=1739391916836884000

    2. Configure the logging to use JSON encoding.
        .. testcode::

            import ray
            import logging

            ray.init(
                logging_config=ray.LoggingConfig(encoding="JSON", log_level="INFO", additional_log_standard_attrs=['name'])
            )

            @ray.remote
            def f():
                logger = logging.getLogger(__name__)
                logger.info("This is a Ray task")

            ray.get(f.remote())
            ray.shutdown()

        .. testoutput::
            :options: +MOCK

            {"asctime": "2025-02-12 12:25:48,766", "levelname": "INFO", "message": "This is a Ray task", "filename": "test-log-config.py", "lineno": 11, "name": "__main__", "job_id": "01000000", "worker_id": "6d307578014873fcdada0fa22ea6d49e0fb1f78960e69d61dfe41f5a", "node_id": "69e3a5e68bdc7eb8ac9abb3155326ee3cc9fc63ea1be04d11c0d93c7", "task_id": "c8ef45ccd0112571ffffffffffffffffffffffff01000000", "task_name": "f", "task_func_name": "test-log-config.f", "timestamp_ns": 1739391948766949000}

    Args:
        encoding: Encoding type for the logs. The valid values are
            {list(_logging_configurator.get_supported_encodings())}
        log_level: Log level for the logs. Defaults to 'INFO'. You can set
            it to 'DEBUG' to receive more detailed debug logs.
        additional_log_standard_attrs: List of additional standard python logger attributes to
            include in the log. Defaults to an empty list. The list of already
            included standard attributes are: "asctime", "levelname", "message",
            "filename", "lineno", "exc_text". The list of valid attributes are specified
            here: http://docs.python.org/library/logging.html#logrecord-attributes
    )r3   abcr   r   dataclassesr   r   typingr   ray._common.filtersr   ray._common.formattersr	   r
   ray._private.ray_loggingr   "ray._private.ray_logging.constantsr   ray.util.annotationsr   r   r&   get_logging_configuratorrD   rS   r   __doc__r$   r   r   <module>r^      s    # # # # # # # # ( ( ( ( ( ( ( (       1 1 1 1 1 1 ? ? ? ? ? ? ? ? 1 1 1 1 1 1 G G G G G G * * * * * *" " " " "# " " " %  %  %  %  %!4  %  %  %F .S\-R-T-T * T T T W
" " " " " " "  "@=   r   