Class LogQuery
- java.lang.Object
-
- com.google.appengine.api.log.LogQuery
-
- All Implemented Interfaces:
Serializable,Cloneable
public final class LogQuery extends Object implements Cloneable, Serializable
Allows users to customize the behavior ofLogService.fetch(LogQuery).startTimeis the earliest request completion or last-update time that results should be fetched for, in seconds since the Unix epoch. Ifnullthen no requests will be excluded for ending too long ago.endTimeis the latest request completion or last-update time that results should be fetched for, in seconds since the Unix epoch. Ifnullthen no requests will be excluded for ending too recently.offsetis a cursor into the log stream retrieved from a previously emittedRequestLogs.getOffset(). This iterator will begin returning logs immediately after the record from which the offset came. Ifnull, the query will begin atstartTime.minLogLevelis aLogService.LogLevelwhich serves as a filter on the requests returned. Requests with no application logs at or above the specified level will be omitted. Works even ifincludeAppLogsis not True.includeIncompleteselects whether requests that have started but not yet finished should be included in the query. Defaults to False.includeAppLogsspecifies whether or not to include application logs in the query results. Defaults to False.majorVersionIdsspecifies versions of the application's default module for which logs records should retrieved.versionsspecifies module versions of the application for which logs should be retrieved.requestIds, if notempty(), indicates that instead of a time-based scan, logs for the specified requests should be returned. See the Request IDs section of the Java Servlet Environment documentation for how to retrieve these IDs at runtime. Malformed request IDs cause an exception and unrecognized request IDs are ignored. This option may not be combined with other filtering options such as startTime, endTime, offset, or minLogLevel. WhenrequestIdsis notempty(),majorVersionIdsare ignored. Logs are returned in the order requested.batchSizespecifies the internal batching strategy of the returnedIterable<RequestLogs>. Has no impact on the result of the query.Notes on usage:
The recommended way to instantiate aLogQueryobject is to statically importLogQuery.Builder.* and invoke a static creation method followed by an instance mutator (if needed):
There are a couple of ways to configureimport static com.google.appengine.api.log.LogQuery.Builder.*; ... // All requests, including application logs. iter = logService.fetch(withIncludeAppLogs(true)); // All requests ending in the past day (or still running) with an info log or higher. Calendar cal = Calendar.getInstance(); cal.add(Calendar.DAY_OF_MONTH, -1); iter = logService.fetch(withEndTimeMillis(cal.time()) .includeIncomplete(true).minimumLogLevel(LogService.INFO));LogQueryto limitLogService.fetch(LogQuery)to only return log records for specific module versions.versions(List)(LogQuery.Builder.withVersions(List)) - Includes designated module versions for the application.majorVersionIds(List)(LogQuery.Builder.withMajorVersionIds(List)) - Includes designated versions of the default module for the application.
LogQueryonly one of these methods may be used. If neither is used,LogService.fetch(LogQuery)results may include any module version. It is not allowed to call bothversions(List)(LogQuery.Builder.withVersions(List)) andrequestIds(List)(LogQuery.Builder.withRequestIds(List)for the sameLogQuery.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLogQuery.BuilderContains static creation methods forLogQuery.static classLogQuery.VersionSpecifies a version of a module.
-
Constructor Summary
Constructors Constructor Description LogQuery()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LogQuerybatchSize(int batchSize)Sets the batch size.LogQueryclone()Makes a copy of a provided LogQuery.LogQueryendTimeMillis(long endTimeMillis)Sets the end time to a value in milliseconds.LogQueryendTimeUsec(long endTimeUsec)Sets the end time to a value in microseconds.@Nullable IntegergetBatchSize()@Nullable LonggetEndTimeMillis()@Nullable LonggetEndTimeUsec()BooleangetIncludeAppLogs()BooleangetIncludeIncomplete()List<String>getMajorVersionIds()@Nullable LogService.LogLevelgetMinLogLevel()@Nullable StringgetOffset()List<String>getRequestIds()@Nullable LonggetStartTimeMillis()@Nullable LonggetStartTimeUsec()List<LogQuery.Version>getVersions()LogQueryincludeAppLogs(boolean includeAppLogs)Sets include application logs.LogQueryincludeIncomplete(boolean includeIncomplete)Sets include incomplete.LogQuerymajorVersionIds(List<String> versionIds)Sets the major version identifiers to query.LogQueryminLogLevel(LogService.LogLevel minLogLevel)Sets the minimum log level.LogQueryoffset(String offset)Sets the offset.LogQueryrequestIds(List<String> requestIds)Sets the list of request ids to query.LogQuerystartTimeMillis(long startTimeMillis)Sets the start time to a value in milliseconds.LogQuerystartTimeUsec(long startTimeUsec)Sets the start time to a value in microseconds.LogQueryversions(List<LogQuery.Version> versions)Restricts the query to log records for the specified module versions.
-
-
-
Method Detail
-
clone
public LogQuery clone()
Makes a copy of a provided LogQuery.- Returns:
- A new LogQuery whose fields are copied from the given LogQuery.
-
offset
public LogQuery offset(String offset)
Sets the offset. Please read the class javadoc for an explanation of how offset is used.- Parameters:
offset- The offset to set.- Returns:
this(for chaining)
-
startTimeMillis
public LogQuery startTimeMillis(long startTimeMillis)
Sets the start time to a value in milliseconds. Please read the class javadoc for an explanation of how start time is used.- Parameters:
startTimeMillis- The start time to set, in milliseconds.- Returns:
this(for chaining)
-
startTimeUsec
public LogQuery startTimeUsec(long startTimeUsec)
Sets the start time to a value in microseconds. Please read the class javadoc for an explanation of how start time is used.- Parameters:
startTimeUsec- The start time to set, in microseconds.- Returns:
this(for chaining)
-
endTimeMillis
public LogQuery endTimeMillis(long endTimeMillis)
Sets the end time to a value in milliseconds. Please read the class javadoc for an explanation of how end time is used.- Parameters:
endTimeMillis- The end time to set, in milliseconds.- Returns:
this(for chaining)
-
endTimeUsec
public LogQuery endTimeUsec(long endTimeUsec)
Sets the end time to a value in microseconds. Please read the class javadoc for an explanation of how end time is used.- Parameters:
endTimeUsec- The end time to set, in microseconds.- Returns:
this(for chaining)
-
batchSize
public LogQuery batchSize(int batchSize)
Sets the batch size. Please read the class javadoc for an explanation of how batch size is used.- Parameters:
batchSize- The batch size to set. Must be greater than 0.- Returns:
this(for chaining)
-
minLogLevel
public LogQuery minLogLevel(LogService.LogLevel minLogLevel)
Sets the minimum log level. Please read the class javadoc for an explanation of how minimum log level is used.- Parameters:
minLogLevel- The minimum log level to set.- Returns:
this(for chaining)
-
includeIncomplete
public LogQuery includeIncomplete(boolean includeIncomplete)
Sets include incomplete. Please read the class javadoc for an explanation of how include incomplete is used.- Parameters:
includeIncomplete- The value to set.- Returns:
this(for chaining)
-
includeAppLogs
public LogQuery includeAppLogs(boolean includeAppLogs)
Sets include application logs. Please read the class javadoc for an explanation of how include application logs is used.- Parameters:
includeAppLogs- The value to set.- Returns:
this(for chaining)
-
majorVersionIds
public LogQuery majorVersionIds(List<String> versionIds)
Sets the major version identifiers to query. Please read the class javadoc for an explanation of how major versions are used.- Parameters:
versionIds- The major version identifier list to set.- Returns:
this(for chaining)
-
versions
public LogQuery versions(List<LogQuery.Version> versions)
Restricts the query to log records for the specified module versions. Please read the class javadoc for usage information.- Parameters:
versions- The list of module versions to query.- Returns:
this(for chaining)
-
requestIds
public LogQuery requestIds(List<String> requestIds)
Sets the list of request ids to query. See the class javadoc for an explanation of how request ids are used.- Parameters:
requestIds- The request id list to set.- Returns:
this(for chaining)
-
getOffset
public @Nullable String getOffset()
- Returns:
- The offset, or
nullif none was provided.
-
getBatchSize
public @Nullable Integer getBatchSize()
- Returns:
- The batch size, or
nullif none was provided.
-
getEndTimeMillis
public @Nullable Long getEndTimeMillis()
- Returns:
- The end time in milliseconds, or
nullif none was provided.
-
getEndTimeUsec
public @Nullable Long getEndTimeUsec()
- Returns:
- The end time in microseconds, or
nullif none was provided.
-
getIncludeAppLogs
public Boolean getIncludeAppLogs()
- Returns:
- Whether or not application logs should be returned.
-
getIncludeIncomplete
public Boolean getIncludeIncomplete()
- Returns:
- Whether or not incomplete request logs should be returned.
-
getMinLogLevel
public @Nullable LogService.LogLevel getMinLogLevel()
- Returns:
- The minimum log level, or
nullif none was provided.
-
getStartTimeMillis
public @Nullable Long getStartTimeMillis()
- Returns:
- The start time in milliseconds, or
nullif none was provided.
-
getStartTimeUsec
public @Nullable Long getStartTimeUsec()
- Returns:
- The start time in microseconds, or
nullif none was provided.
-
getMajorVersionIds
public List<String> getMajorVersionIds()
- Returns:
- The list of major app versions that should be queried over, or an empty list if none were set.
-
getVersions
public List<LogQuery.Version> getVersions()
- Returns:
- The list possibly empty list of module versions that should be queried over.
-
-