@Test void queryTest() throws Exception { Log4jMemoryAppender appender = new Log4jMemoryAppender(false); create(appender, LogLevel.INFO, "de.merlin.Simply", "The lazy fox jumps over the river."); create(appender, LogLevel.DEBUG, "de.merlin.Fox","Everything fine."); create(appender, LogLevel.ERROR, "de.merlin.Fox","Oups, simply try everything harder."); testQuery(appender, null, null, "The lazy", "Everything", "Oups,"); testQuery(appender, LogLevel.INFO, null, "The lazy", "Oups,"); testQuery(appender, null, "every", "Everything", "Oups,"); testQuery(appender, LogLevel.INFO, "every", "Oups,"); testQuery(appender, LogLevel.INFO, "simply", "The lazy", "Oups,"); }
public List<LoggingEventData> query(LogFilter filter, Locale locale) { List<LoggingEventData> result = new ArrayList<>(); if (filter == null) { return result; } int maxSize = filter.getMaxSize() != null ? filter.getMaxSize() : MAX_RESULT_SIZE; if (maxSize > MAX_RESULT_SIZE) { maxSize = MAX_RESULT_SIZE; } int counter = 0; I18n i18n = CoreI18n.getDefault().get(locale); if (filter.isAscendingOrder()) { for (int i = 0; i < queue.getSize(); i++) { LoggingEventData resultEvent = getResultEvent(filter, i18n, queue.get(i), locale); if (resultEvent == null) continue; result.add(resultEvent); if (++counter > maxSize) break; } } else { for (int i = queue.getSize(); i >= 0; i--) { LoggingEventData resultEvent = getResultEvent(filter, i18n, queue.get(i), locale); if (resultEvent == null) continue; result.add(resultEvent); if (++counter > maxSize) break; } } return result; }
Log4jMemoryAppender extends AppenderSkeleton { public List<LoggingEventData> query(LogFilter filter, Locale locale) { List<LoggingEventData> result = new ArrayList<>(); if (filter == null) { return result; } int maxSize = filter.getMaxSize() != null ? filter.getMaxSize() : MAX_RESULT_SIZE; if (maxSize > MAX_RESULT_SIZE) { maxSize = MAX_RESULT_SIZE; } int counter = 0; I18n i18n = CoreI18n.getDefault().get(locale); if (filter.isAscendingOrder()) { for (int i = 0; i < queue.getSize(); i++) { LoggingEventData resultEvent = getResultEvent(filter, i18n, queue.get(i), locale); if (resultEvent == null) continue; result.add(resultEvent); if (++counter > maxSize) break; } } else { for (int i = queue.getSize(); i >= 0; i--) { LoggingEventData resultEvent = getResultEvent(filter, i18n, queue.get(i), locale); if (resultEvent == null) continue; result.add(resultEvent); if (++counter > maxSize) break; } } return result; } }
Log4jMemoryAppender extends AppenderSkeleton { public List<LoggingEventData> query(LogFilter filter, Locale locale) { List<LoggingEventData> result = new ArrayList<>(); if (filter == null) { return result; } int maxSize = filter.getMaxSize() != null ? filter.getMaxSize() : MAX_RESULT_SIZE; if (maxSize > MAX_RESULT_SIZE) { maxSize = MAX_RESULT_SIZE; } int counter = 0; I18n i18n = CoreI18n.getDefault().get(locale); if (filter.isAscendingOrder()) { for (int i = 0; i < queue.getSize(); i++) { LoggingEventData resultEvent = getResultEvent(filter, i18n, queue.get(i), locale); if (resultEvent == null) continue; result.add(resultEvent); if (++counter > maxSize) break; } } else { for (int i = queue.getSize(); i >= 0; i--) { LoggingEventData resultEvent = getResultEvent(filter, i18n, queue.get(i), locale); if (resultEvent == null) continue; result.add(resultEvent); if (++counter > maxSize) break; } } return result; } Log4jMemoryAppender();   Log4jMemoryAppender(boolean ignoreMultipleInstance); }
Log4jMemoryAppender extends AppenderSkeleton { public List<LoggingEventData> query(LogFilter filter, Locale locale) { List<LoggingEventData> result = new ArrayList<>(); if (filter == null) { return result; } int maxSize = filter.getMaxSize() != null ? filter.getMaxSize() : MAX_RESULT_SIZE; if (maxSize > MAX_RESULT_SIZE) { maxSize = MAX_RESULT_SIZE; } int counter = 0; I18n i18n = CoreI18n.getDefault().get(locale); if (filter.isAscendingOrder()) { for (int i = 0; i < queue.getSize(); i++) { LoggingEventData resultEvent = getResultEvent(filter, i18n, queue.get(i), locale); if (resultEvent == null) continue; result.add(resultEvent); if (++counter > maxSize) break; } } else { for (int i = queue.getSize(); i >= 0; i--) { LoggingEventData resultEvent = getResultEvent(filter, i18n, queue.get(i), locale); if (resultEvent == null) continue; result.add(resultEvent); if (++counter > maxSize) break; } } return result; } Log4jMemoryAppender();   Log4jMemoryAppender(boolean ignoreMultipleInstance); static Log4jMemoryAppender getInstance(); List<LoggingEventData> query(LogFilter filter, Locale locale); void close(); boolean requiresLayout(); }
Log4jMemoryAppender extends AppenderSkeleton { public List<LoggingEventData> query(LogFilter filter, Locale locale) { List<LoggingEventData> result = new ArrayList<>(); if (filter == null) { return result; } int maxSize = filter.getMaxSize() != null ? filter.getMaxSize() : MAX_RESULT_SIZE; if (maxSize > MAX_RESULT_SIZE) { maxSize = MAX_RESULT_SIZE; } int counter = 0; I18n i18n = CoreI18n.getDefault().get(locale); if (filter.isAscendingOrder()) { for (int i = 0; i < queue.getSize(); i++) { LoggingEventData resultEvent = getResultEvent(filter, i18n, queue.get(i), locale); if (resultEvent == null) continue; result.add(resultEvent); if (++counter > maxSize) break; } } else { for (int i = queue.getSize(); i >= 0; i--) { LoggingEventData resultEvent = getResultEvent(filter, i18n, queue.get(i), locale); if (resultEvent == null) continue; result.add(resultEvent); if (++counter > maxSize) break; } } return result; } Log4jMemoryAppender();   Log4jMemoryAppender(boolean ignoreMultipleInstance); static Log4jMemoryAppender getInstance(); List<LoggingEventData> query(LogFilter filter, Locale locale); void close(); boolean requiresLayout();  }