
                         2   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*                  R,                  5       " S S\
R.                  5      5       5       rg)z'Command to read logs for a worker pool.    )absolute_import)division)print_function)unicode_literals)common)	formatter)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 a Cloud Run worker pool.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.
          aV            To read log entries from for a Cloud Run Worker Pool, run:

            $ {command} my-worker-pool

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

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

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

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

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

            $ {command} my-worker-pool --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worker_poolz!Name for a Cloud Run worker pool.)help)add_argumentread_logs_libLogFilterArgsLoggingReadArgs)parsers    )lib/surface/run/worker_pools/logs/read.pyArgs	Read.ArgsC   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_worker_poolz'resource.labels.worker_pool_name = %s 
zresource.labels.location = %s 
T)promptzseverity >= DEFAULT 
)order_bylimit)IsSpecifiedr   appendr   r   	GetRegionr   MakeTimestampFiltersr   	FetchLogsJoinFiltersorderr#   	FormatLogreversedr   outPrint)selfargsfilterslineslogslog_line
output_loglines           r   RunRead.RunI   s
   #'#3#3L#A#AtrGNN*-DDENN2T5E5EE 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   r7   __static_attributes__r9   r   r   r   r       s1     /-< * *
r   r   N)r>   
__future__r   r   r   r   googlecloudsdk.api_lib.loggingr   r   googlecloudsdk.callioper	   googlecloudsdk.command_lib.logsr
   r   googlecloudsdk.command_lib.runr   googlecloudsdk.corer   r+   UniverseCompatibleReleaseTracksReleaseTrackALPHACommandr   r9   r   r   <module>rM      sz    . &  % ' 1 4 ( A 0 #	 D%%++,A4<< A - Ar   