本文整理汇总了Java中com.google.appengine.api.log.LogService类的典型用法代码示例。如果您正苦于以下问题:Java LogService类的具体用法?Java LogService怎么用?Java LogService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LogService类属于com.google.appengine.api.log包,在下文中一共展示了LogService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getMedianPendingTime
import com.google.appengine.api.log.LogService; //导入依赖的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
示例2: doGet
import com.google.appengine.api.log.LogService; //导入依赖的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
示例3: testRequestIds
import com.google.appengine.api.log.LogService; //导入依赖的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
示例4: testLogLevelInAppLogLineMatchesActualLogLevelUsedWhenLogging
import com.google.appengine.api.log.LogService; //导入依赖的package包/类
@Test
public void testLogLevelInAppLogLineMatchesActualLogLevelUsedWhenLogging() {
Logger log = Logger.getLogger(LogLevelTest.class.getName());
log.finest("finest_testLogLevelMatches");
log.finer("finer_testLogLevelMatches");
log.fine("fine_testLogLevelMatches");
log.config("config_testLogLevelMatches");
log.info("info_testLogLevelMatches");
log.warning("warning_testLogLevelMatches");
log.severe("severe_testLogLevelMatches");
flush(log);
assertLogContains("finest_testLogLevelMatches", LogService.LogLevel.DEBUG);
assertLogContains("finer_testLogLevelMatches", LogService.LogLevel.DEBUG);
assertLogContains("fine_testLogLevelMatches", LogService.LogLevel.DEBUG);
assertLogContains("config_testLogLevelMatches", LogService.LogLevel.DEBUG);
// we can't test the following on dev appserver, because it returns incorrect logLevels
// more info at http://code.google.com/p/googleappengine/issues/detail?id=8651
//TODO:Renable after project compiles and runs.
// assertLogContains("info_testLogLevelMatches", LogService.LogLevel.INFO);
// assertLogContains("warning_testLogLevelMatches", LogService.LogLevel.WARN);
// assertLogContains("severe_testLogLevelMatches", LogService.LogLevel.ERROR);
}
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:25,代码来源:LogLevelTest.java
示例5: getErrorLogs
import com.google.appengine.api.log.LogService; //导入依赖的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
示例6: doGet
import com.google.appengine.api.log.LogService; //导入依赖的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
示例7: doAfter
import com.google.appengine.api.log.LogService; //导入依赖的package包/类
protected void doAfter(ServiceLifecycleEvent event) {
Object service = event.getService();
if (service instanceof DatastoreService) {
invoke(service, "clearCache");
} else if (service instanceof LogService) {
invoke(service, "clearLog");
}
}
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:9,代码来源:CapeDwarfServicesLifecycle.java
示例8: findLogLine
import com.google.appengine.api.log.LogService; //导入依赖的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
示例9: assertLogContains
import com.google.appengine.api.log.LogService; //导入依赖的package包/类
protected void assertLogContains(String text, LogService.LogLevel logLevel) {
int retryMax = 4;
AppLogLine logLine = findLogLineContaining(text, retryMax);
assertNotNull("log should contain '" + text + "', but it does not", logLine);
if (logLevel != null) {
assertEquals("incorrect logLevel for text '" + text + "'", logLevel, logLine.getLogLevel());
}
}
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:9,代码来源:LoggingTestBase.java
示例10: testAllKindsOfLogQueries
import com.google.appengine.api.log.LogService; //导入依赖的package包/类
@Test
public void testAllKindsOfLogQueries() {
List<String> exceptions = new ArrayList<String>();
assertLogQueryExecutes(new LogQuery(), "testDefaultQuery", exceptions);
assertLogQueryExecutes(new LogQuery().minLogLevel(LogService.LogLevel.WARN), "testMinLogLevel", exceptions);
assertLogQueryExecutes(new LogQuery().includeIncomplete(true), "testIncludeIncompleteTrue", exceptions);
assertLogQueryExecutes(new LogQuery().includeIncomplete(false), "testIncludeIncompleteFalse", exceptions);
assertLogQueryExecutes(new LogQuery().includeAppLogs(true), "testIncludeAppLogsTrue", exceptions);
assertLogQueryExecutes(new LogQuery().includeAppLogs(false), "testIncludeAppLogsFalse", exceptions);
assertLogQueryExecutes(new LogQuery().batchSize(20), "testBatchSize", exceptions);
assertLogQueryExecutes(new LogQuery().offset(null), "testOffset", exceptions);
assertLogQueryExecutes(new LogQuery().versions(Arrays.asList(new LogQuery.Version("module1", "1"), new LogQuery.Version("module2", "3"))), "testVersions", exceptions);
assertLogQueryExecutes(new LogQuery().majorVersionIds(Arrays.asList("1", "2", "3")), "testMajorVersionIds", exceptions);
// TODO assertLogQueryExecutes(new LogQuery().serverVersions(Collections.singletonList(Pair.of((String) null, (String) null))), "testServerVersions", exceptions);
assertLogQueryExecutes(new LogQuery().startTimeMillis(System.currentTimeMillis()), "testStartTimeMillis", exceptions);
assertLogQueryExecutes(new LogQuery().startTimeUsec(1000L * System.currentTimeMillis()), "testStartTimeUsec", exceptions);
assertLogQueryExecutes(new LogQuery().endTimeMillis(System.currentTimeMillis()), "testEndTimeMillis", exceptions);
assertLogQueryExecutes(new LogQuery().endTimeUsec(1000L * System.currentTimeMillis()), "testEndTimeUsec", exceptions);
assertLogQueryExecutes(new LogQuery().requestIds(Arrays.asList(getCurrentRequestId())), "testRequestIds", exceptions);
assertLogQueryExecutes(
new LogQuery()
.minLogLevel(LogService.LogLevel.WARN)
.includeIncomplete(true)
.includeAppLogs(true)
.batchSize(20)
.offset(null)
.majorVersionIds(Arrays.asList("1", "2", "3"))
.startTimeMillis(System.currentTimeMillis() - 3000L)
.endTimeMillis(System.currentTimeMillis() - 2000L),
"testCombo", exceptions);
assertEquals(exceptions.toString(), 0, exceptions.size());
}
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:33,代码来源:LogServiceTest.java
示例11: testAllKindsOfLogQueriesWithBuilder
import com.google.appengine.api.log.LogService; //导入依赖的package包/类
@Test
public void testAllKindsOfLogQueriesWithBuilder() {
List<String> exceptions = new ArrayList<String>();
assertLogQueryExecutes(LogQuery.Builder.withDefaults(), "testDefaultQuery", exceptions);
assertLogQueryExecutes(LogQuery.Builder.withMinLogLevel(LogService.LogLevel.WARN), "testMinLogLevel", exceptions);
assertLogQueryExecutes(LogQuery.Builder.withIncludeIncomplete(true), "testIncludeIncompleteTrue", exceptions);
assertLogQueryExecutes(LogQuery.Builder.withIncludeIncomplete(false), "testIncludeIncompleteFalse", exceptions);
assertLogQueryExecutes(LogQuery.Builder.withIncludeAppLogs(true), "testIncludeAppLogsTrue", exceptions);
assertLogQueryExecutes(LogQuery.Builder.withIncludeAppLogs(false), "testIncludeAppLogsFalse", exceptions);
assertLogQueryExecutes(LogQuery.Builder.withBatchSize(20), "testBatchSize", exceptions);
assertLogQueryExecutes(LogQuery.Builder.withOffset(null), "testOffset", exceptions);
assertLogQueryExecutes(LogQuery.Builder.withVersions(Arrays.asList(new LogQuery.Version("module1", "1"), new LogQuery.Version("module2", "3"))), "testVersions", exceptions);
assertLogQueryExecutes(LogQuery.Builder.withMajorVersionIds(Arrays.asList("1", "2", "3")), "testMajorVersionIds", exceptions);
// TODO assertLogQueryExecutes(LogQuery.Builder.withServerVersions(Collections.singletonList(Pair.of((String) null, (String) null))), "testServerVersions", exceptions);
assertLogQueryExecutes(LogQuery.Builder.withStartTimeMillis(System.currentTimeMillis()), "testStartTimeMillis", exceptions);
assertLogQueryExecutes(LogQuery.Builder.withStartTimeUsec(1000L * System.currentTimeMillis()), "testStartTimeUsec", exceptions);
assertLogQueryExecutes(LogQuery.Builder.withEndTimeMillis(System.currentTimeMillis()), "testEndTimeMillis", exceptions);
assertLogQueryExecutes(LogQuery.Builder.withEndTimeUsec(1000L * System.currentTimeMillis()), "testEndTimeUsec", exceptions);
assertLogQueryExecutes(LogQuery.Builder.withRequestIds(Arrays.asList(getCurrentRequestId())), "testRequestIds", exceptions);
assertLogQueryExecutes(
LogQuery.Builder
.withMinLogLevel(LogService.LogLevel.WARN)
.includeIncomplete(true)
.includeAppLogs(true)
.batchSize(20)
.offset(null)
.majorVersionIds(Arrays.asList("1", "2", "3"))
.startTimeMillis(System.currentTimeMillis() - 3000L)
.endTimeMillis(System.currentTimeMillis() - 2000L),
"testCombo", exceptions);
assertEquals(exceptions.toString(), 0, exceptions.size());
}
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:33,代码来源:LogServiceTest.java
示例12: setUp
import com.google.appengine.api.log.LogService; //导入依赖的package包/类
@Before public void setUp() {
RequestStatusCheckerImpl.logger.addHandler(logHandler);
RequestStatusCheckerImpl.logService = mock(LogService.class);
}
开发者ID:google,项目名称:nomulus,代码行数:5,代码来源:RequestStatusCheckerImplTest.java
示例13: clear
import com.google.appengine.api.log.LogService; //导入依赖的package包/类
protected static void clear() {
LogService service = LogServiceFactory.getLogService();
TestLifecycleEvent event = TestLifecycles.createServiceLifecycleEvent(LoggingTestBase.class, service);
TestLifecycles.after(event);
}
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:6,代码来源:LoggingTestBase.java
示例14: testGetters
import com.google.appengine.api.log.LogService; //导入依赖的package包/类
@Test
@InSequence(20)
public void testGetters() throws Exception {
long batchSize = 20;
long startMilliTime = System.currentTimeMillis() - 3000L;
long endMilliTime = System.currentTimeMillis() - 2000L;
List<String> majorVersions = Arrays.asList("1", "2", "3");
LogQuery logQuery = new LogQuery()
.batchSize((int) batchSize)
.startTimeMillis(startMilliTime)
.endTimeMillis(endMilliTime)
.minLogLevel(LogService.LogLevel.WARN)
.includeIncomplete(true)
.includeAppLogs(true)
.offset(null)
.majorVersionIds(majorVersions);
executeQuery(logQuery);
// The LogQuery should be unmodified, so you can re-use.
assertEquals(batchSize, (long)logQuery.getBatchSize());
assertEquals(startMilliTime, (long)logQuery.getStartTimeMillis());
assertEquals(startMilliTime * 1000, (long)logQuery.getStartTimeUsec());
assertEquals(endMilliTime, (long)logQuery.getEndTimeMillis());
assertEquals(endMilliTime * 1000, (long)logQuery.getEndTimeUsec());
assertEquals(LogService.LogLevel.WARN, logQuery.getMinLogLevel());
assertEquals(true, logQuery.getIncludeIncomplete());
assertEquals(true, logQuery.getIncludeAppLogs());
assertEquals(null, logQuery.getOffset());
assertEquals(majorVersions, logQuery.getMajorVersionIds());
assertEquals(new ArrayList<String>(), logQuery.getRequestIds());
List<LogQuery.Version> versions = Arrays.asList(new LogQuery.Version("module1", "1"), new LogQuery.Version("module2", "3"));
logQuery = new LogQuery()
.versions(versions)
.startTimeMillis(startMilliTime);
executeQuery(logQuery);
assertEquals(versions, logQuery.getVersions());
}
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:42,代码来源:LogQueryTest.java
示例15: executeQuery
import com.google.appengine.api.log.LogService; //导入依赖的package包/类
private void executeQuery(LogQuery logQuery) {
LogService service = LogServiceFactory.getLogService();
Iterator<RequestLogs> iterator = service.fetch(logQuery).iterator();
}
开发者ID:GoogleCloudPlatform,项目名称:appengine-tck,代码行数:5,代码来源:LogQueryTest.java
注:本文中的com.google.appengine.api.log.LogService类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论