
    	]j                     R    d Z ddlZddlZddlmZ dZ G d dej                        Zy)zLogging handler for Google Container Engine (GKE).

Formats log messages in a JSON format, so that Kubernetes clusters with the
fluentd Google Cloud plugin installed can format their log messages so that
metadata such as log level is properly captured.
    N)format_stackdriver_jsonzGContainerEngineHandler is deprecated. Use StructuredLogHandler instead.c                   4     e Zd ZdZddd fd
Z fdZ xZS )ContainerEngineHandleraA  Handler to format log messages the format expected by GKE fluent.

    This handler is written to format messages for the Google Container Engine
    (GKE) fluentd plugin, so that metadata such as log level are properly set.

    DEPRECATED:  use StructuredLogHandler to write formatted logs to standard out instead.
    N)namestreamc                x    t         t        |   |       || _        t	        j
                  t        t               y)z
        Args:
            name (Optional[str]): The name of the custom log in Cloud Logging.
            stream (Optional[IO]): Stream to be used by the handler.

        )r   N)superr   __init__r   warningswarn_DEPRECATION_MSGDeprecationWarning)selfr   r   	__class__s      [/root/env/lib/python3.12/site-packages/google/cloud/logging_v2/handlers/container_engine.pyr
   zContainerEngineHandler.__init__)   s/     	$d4F4C	&(:;    c                 B    t         t        |   |      }t        ||      S )zFormat the message into JSON expected by fluentd.

        Args:
            record (logging.LogRecord): The log record.

        Returns:
            str: A JSON string formatted for GKE fluentd.
        )r	   r   formatr   )r   recordmessager   s      r   r   zContainerEngineHandler.format4   s$     .<VD&vw77r   )__name__
__module____qualname____doc__r
   r   __classcell__)r   s   @r   r   r       s      $D 	<
8 
8r   r   )	r   logging.handlersloggingr   )google.cloud.logging_v2.handlers._helpersr   r   StreamHandlerr    r   r   <module>r!      s2      M N 
8W22 8r   