本文整理汇总了Java中com.google.appengine.api.log.RequestLogs类的典型用法代码示例。如果您正苦于以下问题:Java RequestLogs类的具体用法?Java RequestLogs怎么用?Java RequestLogs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RequestLogs类属于com.google.appengine.api.log包,在下文中一共展示了RequestLogs类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: isRunning
import com.google.appengine.api.log.RequestLogs; //导入依赖的package包/类
/**
* Returns true if the given request is currently running.
*
* @see <a href="https://cloud.google.com/appengine/docs/standard/java/javadoc/com/google/appengine/api/log/LogQuery">appengine documentation</a>
*/
@Override
public boolean isRunning(String requestLogId) {
RequestLogs requestLogs =
Iterables.getOnlyElement(
logService.fetch(
LogQuery.Builder
.withRequestIds(Collections.singletonList(requestLogId))
.includeAppLogs(false)
.includeIncomplete(true)),
null);
// requestLogs will be null if that requestLogId isn't found at all, which can happen if the
// request is too new (it can take several seconds until the logs are available for "fetch").
// So we have to assume it's "running" in that case.
if (requestLogs == null) {
logger.infofmt(
"Queried an unrecognized requestLogId %s - assume it's running", requestLogId);
return true;
}
logger.infofmt(
"Found logs for requestLogId %s - isFinished: %s", requestLogId, requestLogs.isFinished());
return !requestLogs.isFinished();
}
开发者ID:google,项目名称:nomulus,代码行数:28,代码来源:RequestStatusCheckerImpl.java
示例2: getMedianPendingTime
import com.google.appengine.api.log.RequestLogs; //导入依赖的package包/类
@GET
@Path("/pending")
@Produces("text/plain")
public String getMedianPendingTime() {
LogService logService = LogServiceFactory.getLogService();
LogQuery logQuery = LogQuery.Builder.withIncludeAppLogs(false)
.startTimeMillis(System.currentTimeMillis() - TimeUnit.SECONDS.toMillis(60))
.endTimeMillis(System.currentTimeMillis());
StringBuilder content = new StringBuilder();
content.append("request.id,loading,pending,latency,mcycles\n");
Iterable<RequestLogs> logs = logService.fetch(logQuery);
for (RequestLogs log : logs) {
content.append(log.getRequestId()).append(",");
content.append(log.isLoadingRequest() ? "TRUE" : "FALSE").append(",");
content.append(log.getPendingTimeUsec()).append(",");
content.append(log.getLatencyUsec()).append(",");
content.append(log.getMcycles());
content.append("\n");
}
return content.toString();
}
开发者ID:bedatadriven,项目名称:appengine-hibernate,代码行数:25,代码来源:LogResources.java
示例3: doGet
import com.google.appengine.api.log.RequestLogs; //导入依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
resp.setContentType("text/plain");
if (req.getParameter("printLogs") != null) {
LogService ls = LogServiceFactory.getLogService();
LogQuery query = withIncludeAppLogs(true).minLogLevel(LogService.LogLevel.FATAL);
for (RequestLogs logs : ls.fetch(query)) {
for (AppLogLine logLine : logs.getAppLogLines()) {
if (logLine.getLogLevel().equals(LogService.LogLevel.FATAL)) {
resp.getWriter().println(logLine);
}
}
}
} else {
Logger logger = Logger.getLogger("com.foo");
resp.getWriter().println(logger.getLevel());
Logger logger2 = Logger.getLogger("com.foo.bar");
resp.getWriter().println(logger2.getLevel());
resp.getWriter().println(configRan);
logger2.severe("not null");
logger2.severe((String)null);
}
}
开发者ID:GoogleCloudPlatform,项目名称:appengine-java-vm-runtime,代码行数:25,代码来源:LoggingServlet.java
示例4: processLog
import com.google.appengine.api.log.RequestLogs; //导入依赖的package包/类
@Override
public void processLog(RequestLogs log) {
List<AppLogLine> logLines = log.getAppLogLines();
if ( logLines == null || logLines.size() <= 0 )
return;
List<AppLogLineEntity> appLogs = new ArrayList<AppLogLineEntity>();
LogLevel lvl = LogLevel.DEBUG;
for (AppLogLine logLine : logLines )
{
if ( LEVEL_PRIORITY.get(lvl) < LEVEL_PRIORITY.get(logLine.getLogLevel()) )
{
lvl = logLine.getLogLevel();
}
AppLogLineEntity ent = new AppLogLineEntity();
ent.setLogLevel(LEVEL_PRIORITY_NAME.get(lvl));
ent.setLogMessage(logLine.getLogMessage());
ent.setTimeUsec(logLine.getTimeUsec());
appLogs.add(ent);
}
level = LEVEL_PRIORITY_NAME.get(lvl);
logs = new Gson().toJson(appLogs);
}
开发者ID:steveseo,项目名称:l2bq,代码行数:27,代码来源:AppLogFieldExporter.java
示例5: testStartAndEndTimeUsec
import com.google.appengine.api.log.RequestLogs; //导入依赖的package包/类
@Test
@InSequence(20)
public void testStartAndEndTimeUsec() throws Exception {
RequestLogs requestLogs1 = getRequestLogs1();
long time1 = getTime(1);
long time2 = getTime(2);
long startTimeUsec = requestLogs1.getStartTimeUsec();
assertTrue("expected startTimeUsec to be >= " + time1 + ", but was " + startTimeUsec, startTimeUsec >= time1);
assertTrue("expected startTimeUsec to be <= " + time2 + ", but was " + startTimeUsec, startTimeUsec <= time2);
long endTimeUsec = requestLogs1.getEndTimeUsec();
assertTrue("expected endTimeUsec to be >= " + time1 + ", but was " + endTimeUsec, endTimeUsec >= time1);
assertTrue("expected endTimeUsec to be <= " + time2 + ", but was " + endTimeUsec, endTimeUsec <= time2);
assertTrue("expected endTimeUsec to be more than startTimeUsec, but it wasn't (startTime was " + startTimeUsec + "; endTime was " + endTimeUsec, startTimeUsec < endTimeUsec);
}
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:18,代码来源:RequestLogsTest.java
示例6: testMiscProperties
import com.google.appengine.api.log.RequestLogs; //导入依赖的package包/类
/**
* These could return different values from the implementations so just assert the basics.
*/
@Test
@InSequence(20)
public void testMiscProperties() throws Exception {
RequestLogs logs = getRequestLogs1();
assertNotNull("App Engine Release, e.g. 1.8.0, or empty string.", logs.getAppEngineRelease());
assertTrue("Estimated cost of this request, in dollars.", logs.getCost() >= 0.0);
assertTrue("Time required to process this request in microseconds.", logs.getLatencyUsec() >= 0);
assertTrue("Microseconds request spent in pending request queue, if was pending at all.", logs.getPendingTimeUsec() >= 0);
assertFalse("This should never be a loading request: " + logs.toString(), logs.isLoadingRequest());
String appId = SystemProperty.applicationId.get(); // appIds have a prefix according to datacenter.
assertTrue("The application ID that handled this request.", logs.getAppId().endsWith(appId));
long cycles = logs.getMcycles();
assertTrue("Number of machine cycles used to process this request: " + cycles, cycles >= 0);
String getOffsetMsg = "Base64-encoded offset used with subsequent LogQuery to continue reading logs at the point in time immediately following this request.";
assertNotNull(getOffsetMsg, logs.getOffset());
assertTrue("Should be Base64: " + logs.getOffset(), Base64.isBase64(logs.getOffset().getBytes()));
String mapEntryMsg = "File or class within the URL mapping used for this request: " + logs.getUrlMapEntry();
assertNotNull(mapEntryMsg, logs.getUrlMapEntry());
}
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:28,代码来源:RequestLogsTest.java
示例7: testRequestLogsAreSortedNewestFirst
import com.google.appengine.api.log.RequestLogs; //导入依赖的package包/类
@Test
@InSequence(20)
public void testRequestLogsAreSortedNewestFirst() throws EntityNotFoundException {
LogQuery query = new LogQuery().startTimeMillis(System.currentTimeMillis() - 60000);
Iterator<RequestLogs> iterator = findLogLine(query, 3);
Long previousEndTimeUsec = null;
while (iterator.hasNext()) {
RequestLogs requestLogs = iterator.next();
long endTimeUsec = requestLogs.getEndTimeUsec();
if (previousEndTimeUsec != null) {
assertTrue(
"RequestLogs with endTimeUsec " + endTimeUsec + " was returned after RequestLogs with endTimeUsec " + previousEndTimeUsec,
previousEndTimeUsec >= endTimeUsec);
}
previousEndTimeUsec = endTimeUsec;
}
}
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:19,代码来源:RequestLogsTest.java
示例8: testRequestIds
import com.google.appengine.api.log.RequestLogs; //导入依赖的package包/类
@Test
@InSequence(20)
public void testRequestIds() throws Exception {
LogService service = LogServiceFactory.getLogService();
LogQuery logQuery = new LogQuery().requestIds(Arrays.asList(request1Id, request2Id));
Iterator<RequestLogs> iterator = service.fetch(logQuery).iterator();
assertEquals(request1Id, iterator.next().getRequestId());
assertEquals(request2Id, iterator.next().getRequestId());
assertFalse(iterator.hasNext());
logQuery = new LogQuery().requestIds(Arrays.asList(request2Id));
iterator = service.fetch(logQuery).iterator();
assertEquals(request2Id, iterator.next().getRequestId());
assertFalse(iterator.hasNext());
}
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:17,代码来源:LogQueryTest.java
示例9: testLogLinesAreReturnedInSameOrderAsTheyAreLogged
import com.google.appengine.api.log.RequestLogs; //导入依赖的package包/类
@Test
public void testLogLinesAreReturnedInSameOrderAsTheyAreLogged() {
String logMark = getTimeStampRandom();
String msg1 = "msg 1 " + logMark;
String msg2 = "msg 2 " + logMark;
log.log(Level.INFO, msg1);
log.log(Level.INFO, msg2);
flush(log);
sync(15000);
RequestLogs requestLogs = getCurrentRequestLogs();
Integer msg1Index = null;
Integer msg2Index = null;
int i = 0;
for (AppLogLine appLogLine : requestLogs.getAppLogLines()) {
if (appLogLine.getLogMessage().contains(msg1)) {
msg1Index = i;
} else if (appLogLine.getLogMessage().contains(msg2)) {
msg2Index = i;
}
i++;
}
assertNotNull("1st log message not found in appLogLines", msg1Index);
assertNotNull("2nd log message not found in appLogLines", msg2Index);
assertTrue("Expected first logged message to come before second logged message", msg1Index < msg2Index);
}
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:27,代码来源:LoggingTest.java
示例10: getCurrentRequestLogs
import com.google.appengine.api.log.RequestLogs; //导入依赖的package包/类
public RequestLogs getCurrentRequestLogs() {
LogQuery logQuery = new LogQuery()
.includeAppLogs(true)
.includeIncomplete(true)
.startTimeMillis(System.currentTimeMillis() - 20000);
for (RequestLogs requestLogs : LogServiceFactory.getLogService().fetch(logQuery)) {
if (requestLogs.getRequestId().equals(getCurrentRequestId())) {
return requestLogs;
}
}
fail("Could not find RequestLogs for current request");
return null;
// not sure, why the following code throws LogServiceException: An error occurred retrieving logs from storage.
// LogQuery logQuery = new LogQuery()
// .includeAppLogs(true)
// .requestIds(Collections.singletonList(getCurrentRequestId()));
// Iterable<RequestLogs> iterable = LogServiceFactory.getLogService().fetch(logQuery);
// assertTrue("Could not find RequestLogs for current request", iterable.iterator().hasNext());
// return iterable.iterator().next();
}
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:22,代码来源:LoggingTest.java
示例11: testIsRunning_notFinished
import com.google.appengine.api.log.RequestLogs; //导入依赖的package包/类
@Test public void testIsRunning_notFinished() {
RequestLogs requestLogs = new RequestLogs();
requestLogs.setFinished(false);
when(RequestStatusCheckerImpl.logService.fetch(expectedLogQuery("12345678")))
.thenReturn(ImmutableList.of(requestLogs));
assertThat(requestStatusChecker.isRunning("12345678")).isTrue();
assertAboutLogs()
.that(logHandler)
.hasLogAtLevelWithMessage(Level.INFO, "isFinished: false");
}
开发者ID:google,项目名称:nomulus,代码行数:13,代码来源:RequestStatusCheckerImplTest.java
示例12: testIsRunning_finished
import com.google.appengine.api.log.RequestLogs; //导入依赖的package包/类
@Test public void testIsRunning_finished() {
RequestLogs requestLogs = new RequestLogs();
requestLogs.setFinished(true);
when(RequestStatusCheckerImpl.logService.fetch(expectedLogQuery("12345678")))
.thenReturn(ImmutableList.of(requestLogs));
assertThat(requestStatusChecker.isRunning("12345678")).isFalse();
assertAboutLogs()
.that(logHandler)
.hasLogAtLevelWithMessage(Level.INFO, "isFinished: true");
}
开发者ID:google,项目名称:nomulus,代码行数:13,代码来源:RequestStatusCheckerImplTest.java
示例13: getErrorLogs
import com.google.appengine.api.log.RequestLogs; //导入依赖的package包/类
private List<AppLogLine> getErrorLogs() {
LogService logService = LogServiceFactory.getLogService();
long endTime = new Date().getTime();
// Sets the range to 6 minutes to slightly overlap the 5 minute email timer
long queryRange = 1000 * 60 * 6;
long startTime = endTime - queryRange;
LogQuery q = LogQuery.Builder.withDefaults()
.includeAppLogs(true)
.startTimeMillis(startTime)
.endTimeMillis(endTime)
.minLogLevel(LogLevel.ERROR);
Iterable<RequestLogs> logs = logService.fetch(q);
List<AppLogLine> errorLogs = new ArrayList<>();
for (RequestLogs requestLogs : logs) {
List<AppLogLine> logList = requestLogs.getAppLogLines();
for (AppLogLine currentLog : logList) {
LogLevel logLevel = currentLog.getLogLevel();
if (LogLevel.FATAL == logLevel || LogLevel.ERROR == logLevel) {
errorLogs.add(currentLog);
}
}
}
return errorLogs;
}
开发者ID:TEAMMATES,项目名称:teammates,代码行数:32,代码来源:CompileLogsAction.java
示例14: fetchLogs
import com.google.appengine.api.log.RequestLogs; //导入依赖的package包/类
/**
* Retrieves logs using the query.
* @return logs fetched from server.
*/
public List<AppLogLine> fetchLogs(AdminLogQuery query) {
List<AppLogLine> logs = new LinkedList<>();
//fetch request log
Iterable<RequestLogs> records = LogServiceFactory.getLogService().fetch(query.getQuery());
for (RequestLogs record : records) {
//fetch application log
List<AppLogLine> appLogLines = record.getAppLogLines();
logs.addAll(appLogLines);
}
return logs;
}
开发者ID:TEAMMATES,项目名称:teammates,代码行数:16,代码来源:GaeLogApi.java
示例15: doGet
import com.google.appengine.api.log.RequestLogs; //导入依赖的package包/类
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
resp.setContentType("text/plain");
PrintWriter writer = resp.getWriter();
boolean applogs = true;
if ("false".equals(req.getParameter("applogs"))) {
applogs = false;
}
boolean combined = false;
if ("true".equals(req.getParameter("combined"))) {
combined = true;
}
LogQuery query = LogQuery.Builder.withIncludeAppLogs(true).includeIncomplete(true);
for (RequestLogs record : LogServiceFactory.getLogService().fetch(query)) {
Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(record.getStartTimeUsec() / 1000);
writer.println(String.format("\nDate: %s", cal.getTime().toString()));
if (combined) {
writer.println("COMBINED:" + record.getCombined());
} else {
writer.println("URL: " + record.getResource());
writer.println("");
}
if (applogs) {
List<AppLogLine> appLogs = record.getAppLogLines();
for (AppLogLine appLog : appLogs) {
writer.println("[" + appLog.getLogLevel() + "] " + appLog.getLogMessage());
}
}
}
}
开发者ID:GoogleCloudPlatform,项目名称:appengine-java-vm-runtime,代码行数:37,代码来源:LogViewerServlet.java
示例16: doGet
import com.google.appengine.api.log.RequestLogs; //导入依赖的package包/类
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
resp.setContentType("text/plain");
String exporterSetClassStr = AnalysisUtility.extractParameterOrThrow(req, AnalysisConstants.BIGQUERY_FIELD_EXPORTER_SET_PARAM);
String minuteHistoryStr = AnalysisUtility.extractParameterOrThrow(req, AnalysisConstants.MINUTES_HISTORY_PARAM);
BigqueryFieldExporterSet exporterSet = AnalysisUtility.instantiateExporterSet(exporterSetClassStr);
LogService ls = LogServiceFactory.getLogService();
LogQuery lq = new LogQuery();
int minutesHistory = Integer.parseInt(minuteHistoryStr);
long currMillis = System.currentTimeMillis();
lq = lq.startTimeUsec((currMillis - minutesHistory * 60 * 1000) * 1000)
.endTimeUsec(currMillis * 1000)
.includeAppLogs(true);
List<String> appVersions = exporterSet.applicationVersionsToExport();
if (appVersions != null) {
lq = lq.majorVersionIds(appVersions);
}
Iterable<RequestLogs> logs = ls.fetch(lq);
for (RequestLogs rl : logs) {
resp.getWriter().println(rl.getCombined());
for (AppLogLine line : rl.getAppLogLines()) {
resp.getWriter().print("\t");
resp.getWriter().println(line.getLogMessage());
}
resp.getWriter().println();
}
}
开发者ID:steveseo,项目名称:l2bq,代码行数:36,代码来源:TestLogsAccessibleServlet.java
示例17: processLog
import com.google.appengine.api.log.RequestLogs; //导入依赖的package包/类
@Override
public void processLog(RequestLogs log) {
apiMcycles = log.getApiMcycles();
cost = log.getCost();
responseSize = log.getResponseSize();
mcycles = log.getMcycles();
loadingRequest = log.isLoadingRequest();
pendingTimeUsec = log.getPendingTimeUsec();
latencyUsec = log.getLatencyUsec();
}
开发者ID:steveseo,项目名称:l2bq,代码行数:11,代码来源:PerformanceFieldExporter.java
示例18: findLogLine
import com.google.appengine.api.log.RequestLogs; //导入依赖的package包/类
protected Iterator<RequestLogs> findLogLine(LogQuery query, int retryMax) {
LogService service = LogServiceFactory.getLogService();
Iterator<RequestLogs> iterator = null;
for (int i = 0; i <= retryMax; i++) {
iterator = service.fetch(query).iterator();
if (iterator.hasNext()) {
return iterator;
}
pause(1500);
}
return iterator;
}
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:13,代码来源:LoggingTestBase.java
示例19: testClientIp
import com.google.appengine.api.log.RequestLogs; //导入依赖的package包/类
@Test
@InSequence(20)
public void testClientIp() throws Exception {
RequestLogs requestLogs1 = getRequestLogs1();
Property ip = property("testClientIp");
if (ip.exists()) {
assertEquals(ip.getPropertyValue(), requestLogs1.getIp());
} else {
assertRegexpMatches(REGEX_IP4, requestLogs1.getIp());
}
}
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:13,代码来源:RequestLogsTest.java
示例20: testApplicationInfo
import com.google.appengine.api.log.RequestLogs; //导入依赖的package包/类
@Test
@InSequence(20)
public void testApplicationInfo() throws Exception {
RequestLogs requestLogs1 = getRequestLogs1();
String versionId = requestLogs1.getVersionId();
assertTrue("1".equals(versionId) || versionId.startsWith("1."));
}
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:8,代码来源:RequestLogsTest.java
注:本文中的com.google.appengine.api.log.RequestLogs类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论