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

            $ {command} my-job

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

            $ {command} my-job --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jobzName for a Cloud Run job.)help)add_argumentread_logs_libLogFilterArgs)parsers    !lib/surface/run/jobs/logs/tail.pyArgsz	Tail.Args5   s$    
$?@'    c                     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|      }| j                  |      S )N
log_filterzresource.type=%scloud_run_jobzresource.labels.job_name=%szresource.labels.location=%sT)promptzseverity>=DEFAULT)required run)
project_id
log_formatr   )IsSpecifiedappendr   r   r   	GetRegionr
   VALUEScoreprojectGetjoinr	   LogStreamingWrapper _DefaultOperationResponseHandler)selfargsfiltersr    
filter_strcommand_executorresponses          r   RunzTail.Run:   s    G%nnT__%NN%78NN0488;<NN0??456 7NN&'""''//33T3BJ'"J 446%JHH00::r   N)__name__
__module____qualname____doc__detailed_helpstaticmethodr   r2    r   r   r   r      s1     &
-( ( (;r   r   N)r6   
__future__r   r   r   googlecloudsdk.callioper   googlecloudsdk.command_lib.logsr   r   googlecloudsdk.command_lib.runr   r	   googlecloudsdk.corer
   UniverseCompatibleReleaseTracksReleaseTrackALPHABETABinaryBackedCommandr   r9   r   r   <module>rE      sy    & &  ' ( A 0 4 * D%%++T->->-C-CD*;4## *; E *;r   