public LogEntries where(Predicate<LogEntry> predicate) { final Predicate<LogEntry> predicateToAppend; if (not) { predicateToAppend = predicate.negate(); not = false; } else { predicateToAppend = predicate; } return new LogEntries(this.predicate.and(predicateToAppend)); }
public List<LogEntry> list() { ensureCompletableState(); return Collections.unmodifiableList(entries).stream().filter(predicate).collect(Collectors.toList()); }
public int count() { ensureCompletableState(); return list().size(); }
public LogEntries withThrowable() { return where(e -> e.throwable != null); }
public LogEntries withThrowable(Throwable throwable) { return where(e -> Objects.equals(throwable, e.throwable)); }
public LogEntries withMessage(CharSequence message) { return where(e -> e.message.equals(message)); }
public LogEntries before(long timestamp) { return where(e -> e.timestamp < timestamp); }
public LogEntries tagged(String tag) { return where(e -> Objects.equals(e.tag, tag)); }
public LogEntries tagged() { return where(e -> e.tag != null); }
public LogEntries forLevel(int level) { return where(e -> e.level == level); }
public LogEntries withThrowableType(Class<? extends Throwable> throwableClass) { return where(e -> e.throwable != null && throwableClass.isInstance(e.throwable)); }
public LogEntries forLevelAndAbove(int level) { return where(e -> e.level >= level); }
public LogEntries containing(CharSequence substring) { return where(e -> e.message.contains(substring)); }
public LogEntries withArg() { return where(e -> ! e.getArgs().isEmpty()); }
public LogEntries after(long timestamp) { return where(e -> e.timestamp > timestamp); }
/** * Obtains a queryable view of the stored {@link LogEntry} records. * * @return A queryable view of log entries. */ public LogEntries entries() { return new LogEntries(__ -> true); }
public LogEntries withArgType(Class<?> argClass) { return where(e -> e.getArgs().stream().filter(argClass::isInstance).findFirst().isPresent()); }
public LogEntries withArg(Object arg) { return where(e -> e.getArgs().contains(arg)); }
public LogEntries forLevelAndBelow(int level) { return where(e -> e.level <= level); }