use of org.apache.karaf.shell.log.LruList in project fabric8 by jboss-fuse.
the class LogQuery method getLogEventList.
public LogResults getLogEventList(int count, Predicate<PaxLoggingEvent> predicate) {
LogResults answer = new LogResults();
answer.setHost(getHostName());
long from = Long.MAX_VALUE;
long to = Long.MIN_VALUE;
if (appender != null) {
LruList events = appender.getEvents();
if (events != null) {
Iterable<PaxLoggingEvent> iterable = events.getElements();
if (iterable != null) {
int matched = 0;
for (PaxLoggingEvent event : iterable) {
if (event != null) {
long timestamp = event.getTimeStamp();
if (timestamp > to) {
to = timestamp;
}
if (timestamp < from) {
from = timestamp;
}
if (predicate == null || predicate.matches(event)) {
answer.addEvent(Logs.newInstance(event));
matched += 1;
if (count > 0 && matched >= count) {
break;
}
}
}
}
}
}
} else {
LOG.warn("No VmLogAppender available!");
}
answer.setFromTimestamp(from);
answer.setToTimestamp(to);
return answer;
}
Aggregations