Google Code offered in: English - Español - 日本語 - 한국어 - Português - Pусский - 中文(简体) - 中文(繁體)
The google.appengine.api.logservice
package provides functions allowing applications to periodically flush logs during long-running requests and to examine an application's request logs and application logs.
This package has the following functions:
Fetches an application's request and application logs. (Only logs for requests to the application making the fetch() request can be retrieved.) Returns an iterator that returns RequestLog objects, each of which contains the full log data for a request, both the request logs and any application logs for that request. Raises an InvalidArgumentError
if any of the input parameters are not of the correct type.
Arguments:
fetch()
across multiple HTTP requests, for instance to display pages of results. Subsequent fetch() calls made with the same parameters plus an offset will continue immediately after the RequestLog from which the offset was retrieved.include_app_logs
is not set to True. In ascending order, the available log levels are:
logservice.LOG_LEVEL_DEBUG
logservice.LOG_LEVEL_INFO
logservice.LOG_LEVEL_WARNING
logservice.LOG_LEVEL_ERROR
logservice.LOG_LEVEL_CRITICAL
logservice.fetch()
; you have to invoke it with its include_app_logs
parameter set to True.
Flushes log lines that are currently buffered.
Returns the last time that the log buffer was flushed.
Returns the contents of the logs buffer.
Returns the size of the log buffer, in bytes.
Returns the number of log lines currently buffered.
This method is invoked automatically to flush logs in the background. You can tune the autoflush function with the following constants:
logservice.AUTOFLUSH_ENABLED
– Controls whether the in-process logs buffer is automatically flushed during a request. If false, logs are flushed at the end of each request. If true, automatically flushes the log buffer in the background.logservice.AUTOFLUSH_EVERY_SECONDS
– If auto_flush() is enabled, flushes the logs buffer after this many seconds.logservice.AUTOFLUSH_EVERY_BYTES
– If auto_flush() is enabled, flushes the logs buffer once this many bytes have been logged.logservice.AUTOFLUSH_EVERY_LINES
– If auto_flush() is enabled, flushes the logs buffer once this many lines have been logged.These are module-level variables that apps can change directly. For example, you can disable autoflush entirely as follows:
from google.appengine.api import logservice logservice.AUTOFLUSH_ENABLED = False # When you want to flush manually, do this logservice.flush()
To flush every 20 lines, with no limit on time or bytes:
from google.appengine.api import logservice logservice.AUTOFLUSH_EVERY_SECONDS = None logservice.AUTOFLUSH_EVERY_BYTES = None logservice.AUTOFLUSH_EVERY_LINES = 20 # The default, but set here for clarity
Google recommends that you flush logs regularly. The RPCs are very fast, and not flushing your logs can make debugging difficult.