FINAL
The LogService allows an application to query for request and application logs. Application logs are added to a the current request log by calling {@link http://php.net/manual/en/function.syslog.php syslog(int $priority, string $message)}. The $priority used when creating the application log is translated into a different scale of severity used by the LogService based on the following mappings,
- LOG_DEBUG => LogService::LEVEL_DEBUG
- LOG_INFO => LogService::LEVEL_INFO
- LOG_NOTICE => LogService::LEVEL_INFO
- LOG_WARNING => LogService::LEVEL_WARNING
- LOG_ERR => LogService::LEVEL_ERROR
- LOG_CRIT => LogService::LEVEL_CRITICAL
- LOG_ALERT => LogService::LEVEL_CRITICAL
- LOG_EMERG => LogService::LEVEL_CRITICAL
When fetching application logs or filtering request logs by severity use the LogService's severity levels.
Uses traits
\google\appengine\api\log\ApiProxyAccess
Constants
LEVEL_DEBUG
Constants for application log levels.
LEVEL_INFO
LEVEL_WARNING
LEVEL_ERROR
LEVEL_CRITICAL
MAX_BATCH_SIZE
The maximum number of request logs returned in each batch.
Methods
fetch
STATIC
fetch(array $options = array()) : \google\appengine\api\log\Iterator
Get request logs matching the given options in reverse chronological order of request end time.
Parameters
Name | Description |
---|---|
|
Optional associateive arrary of filters and modifiers from following:
|
Returns
\google\appengine\api\log\Iterator
The matching RequestLog items.
fetchById
STATIC
fetchById(mixed $request_ids, boolean $include_app_logs = true) : array<mixed,\google\appengine\api\log\RequestLog>
Get request logs for the given request log ids and optionally include the application logs addded during each request. Request log ids that are not found are ignored so the returned array may have fewer items than $request_ids.
Parameters
Name | Description |
---|---|
|
A string request id or an array of string request
ids obtained from |
|
Should applicaiton logs be included in the fetched request logs. Defaults to true - application logs are included. |
Returns
array<mixed,\google\appengine\api\log\RequestLog>
The request logs for ids that were found.
log
STATIC
log(integer $severity, string $message)
Add an app log at a particular Google App Engine severity level.
Parameters
Name | Description |
---|---|
|
The Google App Engine severity level for the log. |
|
The message to log. |
flush
STATIC
flush()
Write all buffered log messages to the log storage. Logs may not be immediately available to read.
setAutoFlushEntries
STATIC
setAutoFlushEntries(integer $entries)
Set the maximum number of log entries to buffer before they are automaticallly flushed upon adding the next log entry.
Parameters
Name | Description |
---|---|
|
Number of log entries to buffer. |
setAutoFlushBytes
STATIC
setAutoFlushBytes(integer $bytes)
Sets the maximum size of logs to buffer before they are automaticallly flushed upon adding the next log entry.
Parameters
Name | Description |
---|---|
|
Size of logs to buffer in bytes. |
setLogFlushTimeLimit
STATIC
setLogFlushTimeLimit(integer $seconds)
Sets the maximum amount of time in seconds before the buffered logs are automatically flushed upon adding the next log entry.
Parameters
Name | Description |
---|---|
|
Time in seconds. Use zero or negative value to disable the time limit. |
getAppEngineLogLevel
STATIC
getAppEngineLogLevel(integer $syslog_level) : integer
Translates a PHP
Parameters
Name | Description |
---|---|
|
The priority level passed to
|
Returns
integer
The app engine severity level.