Package com.google.appengine.api.log

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


    @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

    private RequestLogs getRequestLogs1() throws EntityNotFoundException {
        return getRequestLogs(getRequest1Id());
    }

    private RequestLogs getRequestLogs(String request1Id) {
        LogQuery logQuery = new LogQuery().requestIds(Collections.singletonList(request1Id));
        Iterator<RequestLogs> iterator = findLogLine(logQuery, 2);
        if (iterator == null || !iterator.hasNext()) {
            return null;
        }
        return iterator.next();
View Full Code Here

        String infoLogMsg = "info_incompleteRequest-" + System.currentTimeMillis();
        log.info(infoLogMsg);
        flush(log);
        sync(5000)// Yes, even after a flush we need to wait for the logs to be available.

        LogQuery debugLogQuery = new LogQuery().includeAppLogs(true).includeIncomplete(true).minLogLevel(DEBUG);
        assertLogQueryReturns("info_createCompleteRequest1", debugLogQuery);
        assertLogQueryReturns("warning_createCompleteRequest1", debugLogQuery);
        assertLogQueryReturns("severe_createCompleteRequest2", debugLogQuery);
        assertLogQueryReturns("info_createCompleteRequest3", debugLogQuery);
        assertLogQueryReturns(infoLogMsg, debugLogQuery);

        LogQuery warnLogQuery = new LogQuery().includeAppLogs(true).includeIncomplete(true).minLogLevel(WARN);
        assertLogQueryReturns("info_createCompleteRequest1", warnLogQuery);
        assertLogQueryReturns("warning_createCompleteRequest1", warnLogQuery);
        assertLogQueryReturns("severe_createCompleteRequest2", warnLogQuery);
        assertLogQueryDoesNotReturn("info_createCompleteRequest3", warnLogQuery);
        assertLogQueryDoesNotReturn(infoLogMsg, warnLogQuery);

        LogQuery errorLogQuery = new LogQuery().includeAppLogs(true).includeIncomplete(true).minLogLevel(ERROR);
        assertLogQueryReturns("severe_createCompleteRequest2", errorLogQuery);
        assertLogQueryDoesNotReturn("info_createCompleteRequest1", errorLogQuery);
        assertLogQueryDoesNotReturn("warning_createCompleteRequest1", errorLogQuery);
        assertLogQueryDoesNotReturn("info_createCompleteRequest3", errorLogQuery);
        assertLogQueryDoesNotReturn(infoLogMsg, errorLogQuery);
View Full Code Here

        String infoLogMsg = "info_incompleteRequest-" + System.currentTimeMillis();
        log.info(infoLogMsg);
        flush(log);
        sync(5000)// Yes, even after a flush we need to wait for the logs to be available.

        assertLogQueryReturns(infoLogMsg, new LogQuery().includeAppLogs(true).includeIncomplete(true));

        assertLogQueryReturns("info_createCompleteRequest1", new LogQuery().includeAppLogs(true).includeIncomplete(true));
        assertLogQueryDoesNotReturn(infoLogMsg, new LogQuery().includeAppLogs(true)
            .includeIncomplete(false).startTimeMillis(System.currentTimeMillis() - 60000));
    }
View Full Code Here

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

    @Test
    @InSequence(20)
    public void testGetBatchSize() throws Exception {
        long size = 1;
        LogService service = LogServiceFactory.getLogService();
        LogQuery logQuery = new LogQuery().requestIds(Arrays.asList(request1Id, request2Id)).batchSize((int)size);

        Iterator<RequestLogs> iterator = service.fetch(logQuery).iterator();
        assertNotNull(iterator.next());
        // TODO: renable when expected behavior is confirmed.
//        assertFalse("Batch size 1 so there should not be another log", iterator.hasNext());
        long batchSize = logQuery.getBatchSize();
        assertEquals(size, batchSize);
    }
View Full Code Here

TOP

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

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.