
    @                         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	\R                  5      rS
SS.\l        g)zapp logs read command.    )	logs_util)common)base)flags)log)
propertiesc                   .    \ rS rSrSr\S 5       rS rSrg)Read   z1Reads log entries for the current App Engine app.c                 *   [         R                  R                  U 5        [         R                  R                  U 5        [         R                  R                  U 5        [         R
                  R                  U 5        U R                  SS[        SSS9  g)z Register flags for this command.z--limitF   zNumber of log entries to show.)requiredtypedefaulthelpN)r   SERVICEAddToParserVERSIONLEVELLOGSadd_argumentint)parsers    lib/surface/app/logs/read.pyArgs	Read.Args   sl     
MMf%	MMf%	KKF#	JJ6"
	E #*J  L    c                    [         R                  " 5       nUR                  [         R                  5        UR                  [         R                  5        UR                  [         R
                  5        [        R                  R                  R                  R                  SS9n[         R                  " X1R                  UR                  UR                  UR                  5      n/ n[         R"                  " SR%                  U5      SUR&                  S9 H#  nUR)                  UR+                  U5      5        M%     [-        U5       H"  n[.        R0                  R3                  U5        M$     g)zThis is what gets called when the user runs this command.

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

Returns:
  The list of log entries.
T)r   z AND DESC)
log_filterorder_bylimitN)r   
LogPrinterRegisterFormatterFormatRequestLogEntryFormatNginxLogEntryFormatAppEntryr   VALUEScoreprojectGet
GetFilterslogsserviceversionlevelr   	FetchLogsjoinr"   appendFormatreversedr   outPrint)selfargsprinterr*   filterslinesentrylines           r   RunRead.Run'   s    ""$Gi==>i;;<i667$$,,00$0?G""7IIt||#'<<=G E!!W\\'-B+1(,

4 ll7>>%()4 	ggmmD  r    N)	__name__
__module____qualname____firstlineno____doc__staticmethodr   r?   __static_attributes__rA   r   r   r
   r
      s    9L Lr   r
   z        Display the latest log entries from stdout, stderr and crash log for the
        current Google App Engine app in a human readable format. This command
        requires that the caller have the logging.logEntries.list
        permission.
    a          To display the latest entries for the current app, run:

          $ {command}

        To show only the entries with severity at `warning` or higher, run:

          $ {command} --level=warning

        To show only the entries with a specific version, run:

          $ {command} --version=v1

        To show only the 10 latest log entries for the default service, run:

          $ {command} --limit=10 --service=default

        To show only the logs from the request log for standard apps, run:

          $ {command} --logs=request_log

        To show only the logs from the request log for Flex apps, run:

          $ {command} --logs=nginx.request
    )DESCRIPTIONEXAMPLESN)rF   googlecloudsdk.api_lib.appr   googlecloudsdk.api_lib.loggingr   googlecloudsdk.callioper   googlecloudsdk.command_lib.appr   googlecloudsdk.corer   r   Commandr
   detailed_helprA   r   r   <module>rR      sC     1 1 ( 0 # *&4<< &R  r   