/*
 * 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 v1.0 which
 * accompanies this distribution and is available at
 *
 * http://www.eclipse.org/legal/epl-v10.html
 */

package org.junit.jupiter.engine;

import static org.junit.platform.commons.util.AnnotationUtils.findAnnotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.junit.jupiter.api.extension.AfterAllCallback;
import org.junit.jupiter.api.extension.BeforeAllCallback;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.junit.platform.commons.util.PreconditionViolationException;

/**
 * Class-level extension that turns on full logging (i.e., {@link Level#ALL})
 * for all specified classes for the duration of the current test container.
 *
 * <h3>Example Usage</h3>
 * <pre class="code">
 * {@literal @}FullLogging(ExecutableInvoker.class)
 * class MyTestClass { ... }
 * </pre>
 *
 * @since 5.0
 */
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@ExtendWith(FullLogging.Extension.class)
public @interface FullLogging {

	Class<?>[] value();

	class Extension implements BeforeAllCallback, AfterAllCallback {

		private final Map<String, Level> previouslyActiveLogLevels = new HashMap<>();

		@Override
		public void beforeAll(ExtensionContext context) throws Exception {
			Class<?> testClass = context.getRequiredTestClass();

			// @formatter:off
			Class<?>[] loggerClasses = findAnnotation(testClass, FullLogging.class)
					.orElseThrow(() -> new PreconditionViolationException("@FullLogging must be declared on class " +
							testClass.getName()))
					.value();

			Arrays.stream(loggerClasses)
					.map(Class::getName)
					.forEach(loggerName -> {
						Logger logger = Logger.getLogger(loggerName);
						previouslyActiveLogLevels.put(loggerName, logger.getLevel());
						logger.setLevel(Level.ALL);
					});
			// @formatter:on
		}

		@Override
		public void afterAll(ExtensionContext context) throws Exception {
			previouslyActiveLogLevels.forEach(
				(loggerName, previousLogLevel) -> Logger.getLogger(loggerName).setLevel(previousLogLevel));
		}

	}

}

@@ -342,16 +342,66 @@
 ngine;%0A%0A
+import static java.util.stream.Collectors.toList;%0A
 import s
@@ -632,16 +632,44 @@
 Target;%0A
+import java.util.ArrayList;%0A
 import j
@@ -707,24 +707,47 @@
 il.HashMap;%0A
+import java.util.List;%0A
 import java.
@@ -1354,16 +1354,26 @@
 Logging(
+classes = 
 Executab
@@ -1597,23 +1597,87 @@
 ss%3C?%3E%5B%5D 
-value()
+classes() default FullLogging.class;%0A%0A%09String%5B%5D classNames() default %22%22
 ;%0A%0A%09clas
@@ -1985,32 +1985,31 @@
 %0A%09%09%09
-Class%3C?%3E%5B%5D loggerClasses
+FullLogging fullLogging
  = f
@@ -2187,81 +2187,501 @@
 ()))
+;
 %0A%09%09%09
-%09%09.value();%0A%0A%09%09%09Arrays.stream(loggerClasses)%0A%09%09%09%09%09.map(Class::get
+// @formatter:on%0A%0A%09%09%09Class%3C?%3E%5B%5D classes = fullLogging.classes();%0A%09%09%09String%5B%5D classNames = fullLogging.classNames();%0A%09%09%09List%3CString%3E loggerNames = new ArrayList%3C%3E();%0A%0A%09%09%09if (classes.length %3E 0 && classes%5B0%5D != FullLogging.class) %7B%0A%09%09%09%09loggerNames.addAll(Arrays.stream(classes).map(Class::getName).collect(toList()));%0A%09%09%09%7D%0A%0A%09%09%09if (classNames.length %3E 0 && !classNames%5B0%5D.equals(%22%22)) %7B%0A%09%09%09%09loggerNames.addAll(Arrays.asList(classNames));%0A%09%09%09%7D%0A%0A%09%09%09// @formatter:off%0A%09%09%09Arrays.stream(class
 Name
+s
 )%0A%09%09
@@ -2766,16 +2766,21 @@
 ;%0A%09%09%09%09%09%09
+this.
 previous
@@ -2873,16 +2873,20 @@
 ;%0A%09%09%09%09%09%7D
+%0A%09%09%09
 );%0A%09%09%09//
@@ -2988,16 +2988,21 @@
 on %7B%0A%09%09%09
+this.
 previous

Support class/logger names in @FullLogging as well as class references