/*
 * Copyright 2015-2017 the original author or authors.
 *
 * All rights reserved. This program and the accompanying materials are
 * made available under the terms of the Eclipse Public License v2.0 which
 * accompanies this distribution and is available at
 *
 * http://www.eclipse.org/legal/epl-v20.html
 */

package org.junit.platform.commons.logging;

import static org.apiguardian.api.API.Status.INTERNAL;

import java.util.ArrayList;
import java.util.List;
import java.util.logging.LogRecord;

import org.apiguardian.api.API;

/**
 * {@code LogRecordListener} is only intended for testing purposes within
 * JUnit's own test suite.
 *
 * @since 1.1
 */
@API(status = INTERNAL, since = "1.1")
public class LogRecordListener {

	private final List<LogRecord> logRecords = new ArrayList<>();

	/**
	 * Inform the listener of a {@link LogRecord} that was submitted to JUL for
	 * processing.
	 */
	public void logRecordSubmitted(LogRecord logRecord) {
		this.logRecords.add(logRecord);
	}

	/**
	 * Get the list of {@link LogRecord log records} that have been
	 * {@linkplain #logRecordSubmitted submitted} to this listener.
	 *
	 * <p>As stated in the JavaDoc for {@code LogRecord}, a submitted
	 * {@code LogRecord} should not be updated by the client application. Thus,
	 * the {@code LogRecords} in the returned list should only be inspected for
	 * testing purposes and not modified in any way.
	 */
	public List<LogRecord> getLogRecords() {
		return this.logRecords;
	}

}

@@ -352,16 +352,66 @@
 gging;%0A%0A
+import static java.util.stream.Collectors.toList;%0A
 import s
@@ -457,16 +457,16 @@
 TERNAL;%0A
-
 %0Aimport 
@@ -577,16 +577,66 @@
 api.API;
+%0Aimport org.junit.platform.commons.JUnitException;
 %0A%0A/**%0A *
@@ -1545,16 +1545,16 @@
 rds() %7B%0A
-
 %09%09return
@@ -1575,10 +1575,974 @@
 ds;%0A%09%7D%0A%0A
+%09/**%0A%09 * Get the list of %7B@link LogRecord log records%7D that have been%0A%09 * %7B@linkplain #logRecordSubmitted submitted%7D to this listener%0A%09 * for the given class.%0A%09 *%0A%09 * %3Cp%3EAs stated in the JavaDoc for %7B@code LogRecord%7D, a submitted%0A%09 * %7B@code LogRecord%7D should not be updated by the client application. Thus,%0A%09 * the %7B@code LogRecords%7D in the returned list should only be inspected for%0A%09 * testing purposes and not modified in any way.%0A%09 *%0A%09 * @param clazz the class for which to get the log records; never %7B@code null%7D%0A%09 */%0A%09public List%3CLogRecord%3E getLogRecords(Class%3C?%3E clazz) %7B%0A%09%09// NOTE: we cannot use org.junit.platform.commons.util.Preconditions here%0A%09%09// since that would introduce a package cycle.%0A%09%09if (clazz == null) %7B%0A%09%09%09throw new JUnitException(%22Class must not be null%22);%0A%09%09%7D%0A%0A%09%09// @formatter:off%0A%09%09return this.logRecords.stream()%0A%09%09%09%09.filter(logRecord -%3E logRecord.getLoggerName().equals(clazz.getName()))%0A%09%09%09%09.collect(toList());%0A%09%09// @formatter:on%0A%09%7D%0A%0A
 %7D%0A

Introduce basic filtering support in LogRecordListener