Package com.google.appengine.api.log

Examples of com.google.appengine.api.log.LogQuery


    super.tearDown();
  }

  private static void runTest(
      long timeOffset, long startTimeUsec, long endTimeUsec, int numShards, long[] startTimes) {
    LogQuery logQuery = LogQuery.Builder.withDefaults();
    logQuery.startTimeUsec(timeOffset + startTimeUsec);
    logQuery.endTimeUsec(timeOffset + endTimeUsec);
    LogInput input = new LogInput(logQuery, numShards);
    List<? extends InputReader<RequestLogs>> readers = input.createReaders();
    assertEquals("Incorrect number of readers", startTimes.length, readers.size());
    for (int i = 0; i < startTimes.length; i++) {
      LogInputReader reader = (LogInputReader) readers.get(i);
View Full Code Here


      // We intentionally perform one extra fetch to ensure there are no extra logs
    }
  }

  private LogInputReader createReader(long startTimeUsec, long endTimeUsec) {
    LogQuery logQuery = LogQuery.Builder.withDefaults();
    logQuery.startTimeUsec(startTimeUsec);
    logQuery.endTimeUsec(endTimeUsec);
    ArrayList<String> versionList = new ArrayList<>();
    versionList.add(VERSION_ID);
    logQuery.majorVersionIds(versionList);
    return new LogInputReader(logQuery);
  }
View Full Code Here

    log.warning(resultsCount + " rows exported");
  }

  public Iterable<RequestLogs> queryForLogs(long logRangeStartMs, long logRangeEndMs, LogsExportConfiguration exportConfig, LogsFieldExporterSet exporterSet) {
    LogService ls = LogServiceFactory.getLogService();
    LogQuery lq = new LogQuery();
    lq = lq.startTimeMillis(logRangeStartMs)
        .endTimeMillis(logRangeEndMs)
        .includeAppLogs(true);

    if (exportConfig.getLogLevel() != null) {
      lq = lq.minLogLevel(exportConfig.getLogLevel());
    }
   
    List<Version> appVersions = exporterSet.applicationVersionsToExport();
    if (appVersions != null && appVersions.size() > 0) {
      lq = lq.versions(appVersions);
    }

    Iterable<RequestLogs> logs = ls.fetch(lq);
    return logs;
  }
View Full Code Here

        break;
      }
      long curEndTimeUsec = Math.round(startTimeUsec + (i * perShardTimeUsec));
      // Ensure we do not go past the end time due to rounding
      curEndTimeUsec = (curEndTimeUsec > endTimeUsec) ? endTimeUsec : curEndTimeUsec;
      LogQuery readerLogQuery = logQuery.clone();
      readerLogQuery.startTimeUsec(curStartTimeUsec);
      readerLogQuery.endTimeUsec(curEndTimeUsec);
      LogInputReader reader = new LogInputReader(readerLogQuery);
      readers.add(reader);
      curStartTimeUsec = curEndTimeUsec;
    }
    return readers;
View Full Code Here

    }
  }

  private static boolean wasRequestCompleted(String requestId) {
    if (requestId != null) {
      LogQuery query = LogQuery.Builder.withRequestIds(Collections.singletonList(requestId));
      for (RequestLogs requestLog : LOG_SERVICE.fetch(query)) {
        if (requestLog.isFinished()) {
          log.info("Previous un-released lock for request " + requestId + " has finished");
          return true;
        }
View Full Code Here

    @Override
    protected Navigation run() throws Exception {
        response.setCharacterEncoding("utf-8");
        response.setContentType("application/json");
        LogQuery query =
            new LogQuery()
                .batchSize(LIMIT)
                .minLogLevel(LogLevel.INFO)
                .includeAppLogs(true);
        if (StringUtil.isEmpty(asString("offset")) == false) {
            query.offset(asString("offset"));
        }
        Iterator<RequestLogs> i =
            LogServiceFactory.getLogService().fetch(query).iterator();
        List<LogDTO> logs = new ArrayList<LogDTO>(LIMIT);
        int count = 0;
View Full Code Here

        assertNotNull("2nd log message not found in appLogLines", msg2Index);
        assertTrue("Expected first logged message to come before second logged message", msg1Index < msg2Index);
    }

    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())) {
View Full Code Here

    }

    @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)
View Full Code Here

    public void testLogLinesAreReturnedOnlyWhenRequested() {
        Logger log = Logger.getLogger(LogServiceTest.class.getName());
        log.info("hello_testLogLinesAreReturnedOnlyWhenRequested");
        flush(log);

        for (RequestLogs logs : service.fetch(new LogQuery().includeIncomplete(true).includeAppLogs(false))) {
            assertTrue("AppLogLines should be empty", logs.getAppLogLines().isEmpty());
        }

        for (RequestLogs logs : service.fetch(new LogQuery().includeIncomplete(true).includeAppLogs(true))) {
            if (!logs.getAppLogLines().isEmpty()) {
                // if we've found at least one appLogLine, the test passed
                return;
            }
        }
View Full Code Here

    }

    @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();
View Full Code Here

TOP

Related Classes of com.google.appengine.api.log.LogQuery

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.