
                         &   S r SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJ	r	  SSK
Jr  SS	KJr  SS
KJr  SSKJr  \R&                  " \R(                  R*                  \R(                  R,                  5       " S S\R.                  5      5       rg)z)Command to read logs for a job execution.    )absolute_import)division)print_function)unicode_literals)common)	FormatLog)base)read)flags)logc                   8    \ rS rSrSrSSS.r\S 5       rS rSr	g	)
Read   z'Read logs for Cloud Run job executions.a            {command} reads log entries. Log entries matching *--log-filter* are
          returned according to the specified --order.
          If the log entries come from multiple logs, then entries from
          different logs might be intermingled in the results.
          aX            To read log entries from for a Cloud Run job execution, run:

            $ {command} my-job-execution

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

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

          To read log entries written in a specific time window, run:

            $ {command} my-job-execution --log-filter='timestamp<="2015-05-31T23:59:59Z" AND timestamp>="2015-05-31T00:00:00Z"'

          To read up to 10 log entries in your job payloads that include the
          word `SearchText` and format the output in `JSON` format, run:

            $ {command} my-job-execution --log-filter="textPayload:SearchText" --limit=10 --format=json

          Detailed information about filters can be found at:
          [](https://cloud.google.com/logging/docs/view/advanced_filters)
          )DESCRIPTIONEXAMPLESc                 |    U R                  SSS9  [        R                  " U 5        [        R                  " U 5        g )N	executionz#Name for a Cloud Run job execution.)help)add_argumentread_logs_libLogFilterArgsLoggingReadArgs)parsers    ,lib/surface/run/jobs/executions/logs/read.pyArgs	Read.Args@   s2    
*OP'!!&)    c                    UR                  S5      (       a  UR                  /O/ nUR                  SS-  5        UR                  SUR                  -  5        UR                  S[        R
                  " USS9-  5        UR                  S5        U[        R                  " U5      -  n/ n[        R                  " [        R                  " U5      UR                  UR                  S	9nU H(  n[        U5      nU(       d  M  UR                  U5        M*     [        U5       H"  n[        R                   R#                  U5        M$     g )
N
log_filterzresource.type = %s 
cloud_run_jobz1labels."run.googleapis.com/execution_name" = %s 
zresource.labels.location = %s 
T)promptzseverity >= DEFAULT 
)order_bylimit)IsSpecifiedr   appendr   r   	GetRegionr   MakeTimestampFiltersr   	FetchLogsJoinFiltersorderr#   r   reversedr   outPrint)selfargsfilterslineslogslog_line
output_loglines           r   RunRead.RunF   s
   #'#3#3L#A#AtrGNN*_<=NN<
..	 NN*U__T$-OO NN+,}11$77GE!!'*jjD X&j	Z  
 	ggmmD  r    N)
__name__
__module____qualname____firstlineno____doc__detailed_helpstaticmethodr   r6   __static_attributes__r8   r   r   r   r      s/    /-< * *
r   r   N)r=   
__future__r   r   r   r   googlecloudsdk.api_lib.loggingr   (googlecloudsdk.api_lib.logging.formatterr   googlecloudsdk.callioper	   googlecloudsdk.command_lib.logsr
   r   googlecloudsdk.command_lib.runr   googlecloudsdk.corer   ReleaseTracksReleaseTrackALPHABETACommandr   r8   r   r   <module>rM      sp    0 &  % ' 1 > ( A 0 # D%%++T->->-C-CDB4<< B EBr   