
    1                     8   d 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l
mZ ddl
mZ dd	lmZ dd
lmZ ej"                   ej$                  ej&                  j(                  ej&                  j*                         G d dej,                                      Zy)z#Command to tail logs for a service.    )absolute_import)division)unicode_literals)base)read)flags)	streaming)
properties)storec                   0    e Zd ZdZdddZed        Zd Zy)Tailz#Tail logs for a Cloud Run revision.z          {command} tails log-entries for a particular
          Cloud Run revision in real time.  The log entries are formatted for
          consumption in a terminal.
          a|            To tail log entries for a Cloud Run revision, run:

            $ {command} my-revision

          To tail log entries with severity ERROR or higher, run:

            $ {command} my-revision --log-filter="severity>=ERROR"

          Detailed information about filters can be found at:
          [](https://cloud.google.com/logging/docs/view/advanced_filters)
          )DESCRIPTIONEXAMPLESc                 T    | j                  dd       t        j                  |        y )NrevisionzName for a Cloud Run revision.)help)add_argumentread_logs_libLogFilterArgs)parsers    &lib/surface/run/revisions/logs/tail.pyArgsz	Tail.Args8   s$    

)IJ'    c                 F   g }|j                  d      r|j                  |j                         |j                  ddz         |j                  d|j                  z         |j                  dt	        j
                  |d      z         |j                  d       t        j                  j                  j                  j                  d	      }d
j                  |      }t        j                         } ||d|t        j                               }| j!                  |      S )N
log_filterzresource.type=%scloud_run_revisionz resource.labels.revision_name=%szresource.labels.location=%sT)promptzseverity>=DEFAULT)required run)
project_id
log_formatr   token)IsSpecifiedappendr   r   r   	GetRegionr
   VALUEScoreprojectGetjoinr	   LogStreamingWrapperr   GetFreshAccessTokenIfEnabled _DefaultOperationResponseHandler)selfargsfiltersr!   
filter_strcommand_executorresponses          r   RunzTail.Run=   s    G%nnT__%NN%(<<=NN5EFNN0??456 7NN&'""''//33T3BJ'"J 446002	H 00::r   N)__name__
__module____qualname____doc__detailed_helpstaticmethodr   r5    r   r   r   r      s1     ,-, ( (;r   r   N)r9   
__future__r   r   r   googlecloudsdk.callioper   googlecloudsdk.command_lib.logsr   r   googlecloudsdk.command_lib.runr   r	   googlecloudsdk.corer
   googlecloudsdk.core.credentialsr   DefaultUniverseOnlyReleaseTracksReleaseTrackALPHABETABinaryBackedCommandr   r<   r   r   <module>rI      s|    * &  ' ( A 0 4 * 1 D%%++T->->-C-CD0;4## 0; E 0;r   