Google Code offered in: English - Español - 日本語 - 한국어 - Português - Pусский - 中文(简体) - 中文(繁體)
The google.appengine.api.logservice package provides methods allowing applications to periodically flush logs during long-running requests.
This package has the following functions:
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.