Package de.cuioss.test.juli
Class TestLoggerFactory
- java.lang.Object
-
- de.cuioss.test.juli.TestLoggerFactory
-
public final class TestLoggerFactory extends Object
Central entry point for handlingTestLogHandler- Author:
- Oliver Wolff
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidaddLogger(TestLogLevel logLevel, String loggerName)Convenient method for setting a Log-Level in context of the givenTestLogLevelstatic voidconfigureLogger()Configures the logger sub-system according to the configuration found withinSystem.getProperties()and / or the file "cui_logger.properties" usually located directly in "src/test/resources".static TestLogHandlergetTestHandler()static Optional<TestLogHandler>getTestHandlerOption()static voidinstall()Adds aTestLogHandlerinstance to jul's root logger.static voiduninstall()Removes previously installedTestLogHandlerinstance and restores the previously storedHandler.getLevel().
-
-
-
Method Detail
-
install
public static void install()
Adds aTestLogHandlerinstance to jul's root logger. This method is reentrant, it ensures theTestLogHandleris installed only once
-
uninstall
public static void uninstall()
Removes previously installedTestLogHandlerinstance and restores the previously storedHandler.getLevel(). See alsoinstall().
-
configureLogger
public static void configureLogger()
Configures the logger sub-system according to the configuration found withinSystem.getProperties()and / or the file "cui_logger.properties" usually located directly in "src/test/resources".
-
getTestHandler
public static TestLogHandler getTestHandler()
- Returns:
- the configured
TestLogHandler - Throws:
AssertionError- in case noTestLogHandlercould be found. This is usually the case ifinstall()was not called prior to this request
-
getTestHandlerOption
public static Optional<TestLogHandler> getTestHandlerOption()
- Returns:
- the configured
TestLogHandlerif present
-
addLogger
public static void addLogger(TestLogLevel logLevel, String loggerName)
Convenient method for setting a Log-Level in context of the givenTestLogLevel- Parameters:
logLevel- to be setloggerName- if it isnullor empty it will set the root-logger for the actual Log-Level
-
-