All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.teamscale.test_impacted.commons.LoggerUtils Maven / Gradle / Ivy

Go to download

A JUnit 5 engine that handles retrieving impacted tests from Teamscale and organizes their execution

There is a newer version: 34.2.0
Show newest version
package com.teamscale.test_impacted.commons;

import java.util.logging.ConsoleHandler;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;

/**
 * Provides access to a JUL Logger which is configured to print to the console in a not too noisy format as this appears
 * in the console when executing tests.
 */
public class LoggerUtils {

	private static final Logger MAIN_LOGGER;

	static {
		MAIN_LOGGER = Logger.getLogger("com.teamscale");
		MAIN_LOGGER.setUseParentHandlers(false);
		ConsoleHandler handler = new ConsoleHandler();
		handler.setFormatter(new SimpleFormatter() {

			@Override
			public synchronized String format(LogRecord lr) {
				return String.format("[%1$s] %2$s%n", lr.getLevel().getLocalizedName(), lr.getMessage());
			}
		});
		MAIN_LOGGER.addHandler(handler);
	}

	/**
	 * Returns a logger for the given class.
	 */
	public static Logger getLogger(Class clazz) {
		return Logger.getLogger(clazz.getName());
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy