use of com.google.appengine.api.log.AppLogLine in project teammates by TEAMMATES.
the class AdminEmailLogPageAction method filterLogsForEmailLogPage.
private List<EmailLogEntry> filterLogsForEmailLogPage(List<AppLogLine> appLogLines, AdminEmailLogPageData data) {
List<EmailLogEntry> emailLogs = new LinkedList<>();
for (AppLogLine appLog : appLogLines) {
String logMsg = appLog.getLogMessage();
boolean isNotEmailLog = !logMsg.contains("TEAMMATESEMAILLOG");
if (isNotEmailLog) {
continue;
}
EmailLogEntry emailLogEntry = new EmailLogEntry(appLog);
if (data.shouldShowLog(emailLogEntry)) {
emailLogs.add(emailLogEntry);
}
}
return emailLogs;
}
use of com.google.appengine.api.log.AppLogLine in project teammates by TEAMMATES.
the class AdminEmailLogPageAction method searchEmailLogsWithTimeIncrement.
/**
* Searches enough email logs within MAX_SEARCH_PERIOD hours.
*/
private void searchEmailLogsWithTimeIncrement(AdminEmailLogPageData data) {
List<EmailLogEntry> emailLogs = new LinkedList<>();
List<String> versionToQuery = getVersionsForQuery(data.getVersions());
AdminLogQuery query = new AdminLogQuery(versionToQuery, null, data.getToDate());
int 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 (emailLogs.size() >= LOGS_PER_PAGE) {
break;
}
List<AppLogLine> searchResult = logApi.fetchLogs(query);
List<EmailLogEntry> filteredLogs = filterLogsForEmailLogPage(searchResult, data);
emailLogs.addAll(filteredLogs);
totalLogsSearched += searchResult.size();
query.moveTimePeriodBackward(SEARCH_TIME_INCREMENT);
}
data.setLogs(emailLogs);
long nextEndTimeToSearch = query.getEndTime();
String status = " Total Logs gone through in last search: " + totalLogsSearched + "<br>" + "<button class=\"btn-link\" id=\"button_older\" data-next-end-time-to-search=\"" + nextEndTimeToSearch + "\">Search More</button>";
data.setStatusForAjax(status);
statusToUser.add(new StatusMessage(status, StatusMessageColor.INFO));
}
use of com.google.appengine.api.log.AppLogLine in project teammates by TEAMMATES.
the class GaeLogApi method fetchLogs.
/**
* 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;
}
use of com.google.appengine.api.log.AppLogLine in project teammates by TEAMMATES.
the class EmailGeneratorTest method testGenerateCompiledLogsEmail.
@Test
public void testGenerateCompiledLogsEmail() throws IOException {
AppLogLine typicalLogLine = new AppLogLine();
typicalLogLine.setLogLevel(LogLevel.ERROR);
typicalLogLine.setLogMessage("Typical log message");
AppLogLine logLineWithLineBreak = new AppLogLine();
logLineWithLineBreak.setLogLevel(LogLevel.ERROR);
logLineWithLineBreak.setLogMessage("Log line \n with line break <br> and also HTML br tag");
EmailWrapper email = new EmailGenerator().generateCompiledLogsEmail(Arrays.asList(typicalLogLine, logLineWithLineBreak));
String subject = String.format(EmailType.SEVERE_LOGS_COMPILATION.getSubject(), Config.getAppVersion());
verifyEmail(email, Config.SUPPORT_EMAIL, subject, "/severeLogsCompilationEmail.html");
}
use of com.google.appengine.api.log.AppLogLine in project teammates by TEAMMATES.
the class ActivityLogEntryTest method logEntry_withMalformationAppLogLine_constructionFail.
@Test
public void logEntry_withMalformationAppLogLine_constructionFail() {
______TS("Fail: log message not in correct format");
AppLogLine appLog = new AppLogLine();
appLog.setLogMessage("TEAMMATESLOG||RANDOM");
ActivityLogEntry entry = ActivityLogEntry.buildFromAppLog(appLog);
assertTrue(entry.generateLogMessage().contains(Const.ActivityLog.MESSAGE_ERROR_LOG_MESSAGE_FORMAT));
String logMessageMalformation = "TEAMMATESLOG|||instructorHome|||Pageload|||true|||Instructor" + "|||UserName|||UserId|||UserEmail|||Message|||URL";
appLog.setLogMessage(logMessageMalformation);
entry = ActivityLogEntry.buildFromAppLog(appLog);
assertTrue(entry.generateLogMessage().contains(Const.ActivityLog.MESSAGE_ERROR_LOG_MESSAGE_FORMAT));
}
Aggregations