// it waits for valid log header,
// and add the multiple log lines to the specific log header
// (since we are reading from bottom up
// those multiple lines belongs to the next valid log
// header.
LogMessage logMessage = null;
if (isErrorHeader(line)) {
if (!errorLine.equals("")) {
errorLine = (String) errorLine.subSequence(0, (errorLine.length() - 1));
logMessage = getLogMessageForType(errorLine);
if (logMessage != null) {
logsList.add(logMessage);
}
errorLine = "";
}
// when there are log messages with multiple lines one
// after the other
// next line is also considered as a error line
errorLine = line;
} else if (isFatalHeader(line)) {
if (!errorLine.equals("")) {
errorLine = (String) errorLine.subSequence(0, (errorLine.length() - 1));
logMessage = getLogMessageForType(errorLine);
if (logMessage != null) {
logsList.add(logMessage);
}
errorLine = "";
}
errorLine = line;
} else if (isTraceHeader(line)) {
if (!errorLine.equals("")) {
errorLine = (String) errorLine.subSequence(0, (errorLine.length() - 1));
logMessage = getLogMessageForType(errorLine);
if (logMessage != null) {
logsList.add(logMessage);
}
errorLine = "";
}
errorLine = line;
} else if (isInfoHeader(line)) {
if (!errorLine.equals("")) {
errorLine = (String) errorLine.subSequence(0, (errorLine.length() - 1));
logMessage = getLogMessageForType(errorLine);
if (logMessage != null) {
logsList.add(logMessage);
}
errorLine = "";
}
errorLine = line;
} else if (isWarnHeader(line)) {
if (!errorLine.equals("")) {
errorLine = (String) errorLine.subSequence(0, (errorLine.length() - 1));
logMessage = getLogMessageForType(errorLine);
if (logMessage != null) {
logsList.add(logMessage);
}
errorLine = "";
}
errorLine = line;
} else if (isDebugHeader(line)) {
if (!errorLine.equals("")) {
errorLine = (String) errorLine.subSequence(0, (errorLine.length() - 1));
logMessage = getLogMessageForType(errorLine);
if (logMessage != null) {
logsList.add(logMessage);
}
errorLine = "";
}
errorLine = line;
} else if (!isLogHeader(line)) {
// if a log line has no valid log header that log line
// is considered as a error line.
errorLine = errorLine + line + LoggingConstants.RegexPatterns.NEW_LINE;
} else if (isLogHeader(line)) {
if (!errorLine.equals("")) {
errorLine = (String) errorLine.subSequence(0, (errorLine.length() - 1));
logMessage = getLogMessageForType(errorLine);
if (logMessage != null) {
logsList.add(logMessage);
}
errorLine = "";
}
logMessage = getLogMessageForType(line);
if (logMessage != null) {
logsList.add(logMessage);
}
} else {
log.warn("The log message " + line + " is ignored.");
}
}
index++;
}
if (!errorLine.equals("")) {
LogMessage logMessage = getLogMessageForType(errorLine);
if (logMessage != null) {
logsList.add(logMessage);
} else {
log.warn("The log message " + errorLine + " is ignored.");
}