use of com.google.appengine.api.log.AppLogLine in project teammates by TEAMMATES.
the class EmailLogEntryTest method emailLog_withAppLogLine_constructionFailAsNotInCorrectFormat.
@Test
public void emailLog_withAppLogLine_constructionFailAsNotInCorrectFormat() {
String logMessage = "NotInDesiredFormat";
AppLogLine appLog = new AppLogLine();
appLog.setLogMessage(logMessage);
appLog.setTimeUsec(410333L);
EmailLogEntry logEntry = new EmailLogEntry(appLog);
assertEquals("", logEntry.getReceiver());
assertEquals("", logEntry.getSubject());
assertEquals("", logEntry.getContent());
assertEquals(410L, logEntry.getTime());
assertFalse(logEntry.isTestData());
}
use of com.google.appengine.api.log.AppLogLine in project teammates by TEAMMATES.
the class EmailLogEntryTest method emailLog_withAppLogLine_constructCorrectly.
@Test
public void emailLog_withAppLogLine_constructCorrectly() {
String logMessage = "TEAMMATESEMAILLOG|||myRecipient@email.com|||mySubject|||myContent";
AppLogLine appLog = new AppLogLine();
appLog.setLogMessage(logMessage);
appLog.setTimeUsec(2456L);
EmailLogEntry logEntry = new EmailLogEntry(appLog);
assertEquals(logMessage, logEntry.generateLogMessage());
assertEquals("myRecipient@email.com", logEntry.getReceiver());
assertEquals("mySubject", logEntry.getSubject());
assertEquals("myContent", logEntry.getContent());
assertEquals(2L, logEntry.getTime());
assertFalse(logEntry.isTestData());
}
use of com.google.appengine.api.log.AppLogLine in project teammates by TEAMMATES.
the class AdminActivityLogPageAction method searchLogsWithExactTimePeriod.
/**
* Retrieves all logs in the time period specified in the query.
*/
private List<ActivityLogEntry> searchLogsWithExactTimePeriod(AdminLogQuery query, AdminActivityLogPageData data) {
GaeLogApi logApi = new GaeLogApi();
List<AppLogLine> searchResult = logApi.fetchLogs(query);
nextEndTimeToSearch = data.getFromDate() - 1;
totalLogsSearched = searchResult.size();
return filterLogsForActivityLogPage(searchResult, data);
}
use of com.google.appengine.api.log.AppLogLine in project teammates by TEAMMATES.
the class AdminActivityLogPageAction method searchLogsWithTimeIncrement.
/**
* Retrieves enough logs within MAX_SEARCH_PERIOD hours.
*/
private List<ActivityLogEntry> searchLogsWithTimeIncrement(AdminLogQuery query, AdminActivityLogPageData data) {
List<ActivityLogEntry> appLogs = new LinkedList<>();
totalLogsSearched = 0;
GaeLogApi logApi = new GaeLogApi();
long startTime = query.getEndTime() - SEARCH_TIME_INCREMENT;
query.setTimePeriod(startTime, query.getEndTime());
for (int i = 0; i < MAX_SEARCH_TIMES; i++) {
if (appLogs.size() >= RELEVANT_LOGS_PER_PAGE) {
break;
}
List<AppLogLine> searchResult = logApi.fetchLogs(query);
List<ActivityLogEntry> filteredLogs = filterLogsForActivityLogPage(searchResult, data);
appLogs.addAll(filteredLogs);
totalLogsSearched += searchResult.size();
query.moveTimePeriodBackward(SEARCH_TIME_INCREMENT);
}
data.setFromDate(query.getStartTime() + SEARCH_TIME_INCREMENT);
nextEndTimeToSearch = query.getEndTime();
return appLogs;
}
use of com.google.appengine.api.log.AppLogLine in project teammates by TEAMMATES.
the class CompileLogsAction method getErrorLogs.
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;
}
Aggregations