
    
                        S r SSKJr  SSKJr  SSKJr  SSK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rS r " S S\R$                  5      r\
R(                  \
R*                  " \
R,                  R.                  \
R,                  R0                  5       " S S\
R2                  5      5       5       rSSS.\l        g)z'logging 'tail' command.    )absolute_import)division)unicode_literalsN)util)arg_parsers)base)
exceptions)log)	platformszYhttps://cloud.google.com/logging/docs/reference/tools/gcloud-logging#install_live_tailingc                  @   [         R                  R                  5       n U [         R                  R                  :X  a  gU [         R                  R                  [         R                  R
                  4;   a  SR                  [        5      $ SR                  [        5      $ )zAReturns platform-specific guidance on setup for the tail command.zIThe installation of the Cloud SDK is corrupted, and gRPC is inaccessible.zPlease ensure that the gRPC module is installed and the environment is correctly configured. Run:
  sudo pip3 install grpcio
and set:
  export CLOUDSDK_PYTHON_SITEPACKAGES=1
For more information, see {}zPlease ensure that the gRPC module is installed and the environment is configured to allow gcloud to use the installation. For help, see {})r   OperatingSystemCurrentWINDOWSLINUXMACOSXformat_TAILING_INSTALL_LINK)
current_oss    lib/surface/logging/tail.py_GrpcSetupHelpMessager   !   s     ((002*9,,444 I--33--446 6	P f"#	$M
F !"    c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )NoGRPCInstalledError;   z$Unable to import grpc-based modules.c                 <   > [         [        U ]  [        5       5        g )N)superr   __init__r   )self	__class__s    r   r   NoGRPCInstalledError.__init__>   s    	
./D/FGr    )__name__
__module____qualname____firstlineno____doc__r   __static_attributes____classcell__)r   s   @r   r   r   ;   s    ,H Hr   r   c                   4    \ rS rSrSr\S 5       rS rS rSr	g)TailB   zTail log entries.c                 $   U R                  SSSS9  U R                  SS[        R                  " 5       SS9  U R                  S	S
9nUR                  SSSSS9  UR                  SSSS9  UR                  SSSS9  [        R
                  " U S5        g)z!Registers flags for this command.
log_filterzFilter expression that specifies the log entries to return. A detailed guide on the Logging query language can be found at: https://cloud.google.com/logging/docs/view/logging-query-language.?)helpnargsz--buffer-windowFa>  The duration of time for which entries should be buffered for ordering before being returned. A longer buffer window helps to return logs in chronological order, but it also increases the latency from when entries are received by Cloud Logging to when they are returned. If unset, Cloud Logging will use 2s by default.)requiredtyper/   zUThese arguments are used in conjunction with the parent to construct a view resource.)r/   z
--locationTLOCATIONzjLocation of the bucket. If this argument is provided, then `--bucket` and `--view` must also be specified.)r1   metavarr/   z--bucketzfId of the bucket. If this argument is provided, then `--location` and `--view` must also be specified.)r1   r/   z--viewzfId of the view. If this argument is provided, then `--location` and `--bucket` must also be specified.zlog entries to tailN)add_argumentr   Durationadd_argument_groupr   AddParentArgs)parser
view_groups     r   Args	Tail.ArgsG   s     Q    !!#  
 **% + &J :	  ; <  =
 >  ? 	v45r   c           	          SSK Jn  [        R
                  R                  S5        [        R                  " U5      nUR                  S5      (       ab  [        R                  " [        R                  " [        R                  " USUR                  5      SUR                  5      SUR                  5      nS nUR                  (       aB  UR                  S:  d  UR                  S:  a  [        R                  " S	5        UR                  nUR!                  5       n[        R"                  " [$        R&                  5        UR)                  U/UR*                  =(       d    S
US9$ ! [         a    [        5       ef = f)Nr   )tailingzInitializing tail session.location	locationsbucketsviews<   z0The buffer window must be set between 0s and 1m. )buffer_window_seconds)googlecloudsdk.api_lib.loggingr>   ImportErrorr   r
   errPrintr   GetParentFromArgsIsSpecifiedCreateResourceNamer?   bucketviewbuffer_windowerror	LogTailerSetLogFileVerbosityloggingWARNINGTailLogsr-   )r   argsr>   parentrE   tailers         r   _Run	Tail._Runt   s/   #8
 GGMM./##D)F
##&&

!
!%%fk4==I&'.		;f !			a	4#5#5#:		DE"00 F
 GOO,??	23  5 5+  # ""#s   E# #E8c                 $    U R                  U5      $ )zGets called when the user runs this command.

Args:
  args: an argparse namespace. All the arguments that were provided to this
    command invocation.

Returns:
  An iterator of log entries.
)rY   )r   rV   s     r   RunTail.Run   s     99T?r   r!   N)
r"   r#   r$   r%   r&   staticmethodr;   rY   r\   r'   r!   r   r   r*   r*   B   s$     *6 *6X5>
r   r*   a  
         {command} streams newly received log entries. Log entries matching
         `log-filter` are returned in the order that Cloud Logging received
         them. If the log entries come from multiple logs, then entries from
         different logs might be mixed in the results. To help return log
         entries in order, use `--buffer-window`.

         Before you can use {command}, you must complete the installation
         instructions at
         [Live tailing log entries](https://cloud.google.com/logging/docs/reference/tools/gcloud-logging#live-tailing).

         For the quotas and limits associated with {command},
         see [Logging API quotas and limits](https://cloud.google.com/logging/quotas#api-limits).
    a          To stream log entries from Google Compute Engine instances, run:

          $ {command} "resource.type=gce_instance"

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

          $ {command} "severity>=ERROR"

        To stream log entries with severity ERROR but only output the timestamps
        and instance IDs, run:

          $ {command} "severity>=ERROR" --format="default(timestamp,resource["labels"]["instance_id"])"

        To stream with minimal latency but potentially incorrect ordering:

          $ {command} "resource.type=gce_instance" --buffer-window=0s

        To stream log entries in your project's syslog log from Compute Engine
        instances containing payloads that include the word `SyncAddress` and
        format the output in `JSON` format, run:

          $ {command} "resource.type=gce_instance AND log_id(syslog) AND textPayload:SyncAddress" --format=json

        To stream log entries from a folder, run:

          $ {command} "resource.type=global" --folder=[FOLDER_ID]

        Detailed information about filters can be found at:
        https://cloud.google.com/logging/docs/view/logging-query-language
    )DESCRIPTIONEXAMPLES)r&   
__future__r   r   r   rS   rF   r   googlecloudsdk.callioper   r   r	   googlecloudsdk.corer
   googlecloudsdk.core.utilr   r   r   ToolExceptionr   DefaultUniverseOnlyReleaseTracksReleaseTrackALPHABETACommandr*   detailed_helpr!   r   r   <module>rm      s     &  '  / / ( . # .s "4H:33 H D%%++T->->-C-CDY4<< Y E Y|		#0 r   