I have a List<LogEntry> that I need to filter out from the list every log that is not on Level.SEVERE.
And in addition I have a List of whitelisted logs that need to be filtered too.
These logs are contains only partial message so I have to use contains() to identified them.
My code looks like this:
LogEntries logEntries = driver.manage().logs().get(LogType.BROWSER);
List<LogEntry> logEntriesList = logEntries.getAll();
Stream<LogEntry> filtered =
logEntriesList.stream()
.filter(log -> log.getLevel().equals(Level.SEVERE));
for (String whitelisted : whitelistedLogs) {
filtered = filtered.filter(log -> !log.getMessage().contains(whitelisted));
}
Is there any way to avoid this for loop and get the same result?