Class LogFeature

    • Field Detail

      • consoleAppender

        protected org.apache.logging.log4j.core.appender.ConsoleAppender consoleAppender
      • hiddenAppender

        protected org.apache.logging.log4j.core.appender.ConsoleAppender hiddenAppender
      • originalLevelByLogger

        protected Map<LoggerLevelKey,​org.apache.logging.log4j.Level> originalLevelByLogger
        Stores the original log level for a given logger name, which allows us to restore the level as defined before launching the tests.
        Since:
        11.1
    • Constructor Detail

      • LogFeature

        public LogFeature()
    • Method Detail

      • beforeRun

        public void beforeRun​(FeaturesRunner runner)
        Before running tests. At this point Guice modules are registered and injector created.

        Specified by:
        beforeRun in interface RunnerFeature
        Since:
        11.1
      • beforeMethodRun

        public void beforeMethodRun​(FeaturesRunner runner,
                                    org.junit.runners.model.FrameworkMethod method,
                                    Object test)
        Before a test method is invoked.

        Specified by:
        beforeMethodRun in interface RunnerFeature
        Since:
        11.1
      • setConsoleLogThreshold

        public void setConsoleLogThreshold​(String level)
        Since:
        9.10
      • restoreConsoleLog

        public void restoreConsoleLog()
      • addConsoleThresholdLogLevel

        protected void addConsoleThresholdLogLevel​(FeaturesRunner runner,
                                                   org.junit.runners.model.FrameworkMethod method)
        Adds the console threshold log level. To be proceed a Class / Method should be annotated by
        Parameters:
        runner - the feature runner, cannot be null
        method - the framework method, can be null
        Since:
        11.1
        See Also:
        ConsoleLogLevelThreshold, setConsoleLogThreshold(String)
      • restoreConsoleThresholdLogLevel

        protected void restoreConsoleThresholdLogLevel​(FeaturesRunner runner,
                                                       org.junit.runners.model.FrameworkMethod method)
        Restores the console threshold log level. Based on if Class or Method is annotated by ConsoleLogLevelThreshold.

        restoreConsoleLog()

        Since:
        11.1
      • addOrUpdateLoggerLevel

        protected void addOrUpdateLoggerLevel​(FeaturesRunner runner,
                                              org.junit.runners.model.FrameworkMethod method)
        Adds or updates the logger level.

        The definition of LoggerLevel can be done on a given Class / Method test. At the end of the test each overriding logger must be restored to its original value for this the purpose we should save the original level.

        restoreLoggerLevel(FeaturesRunner, FrameworkMethod) to see how the restore part will be happened.

        Parameters:
        runner - the feature runner, cannot be null
        method - the framework method, can be null
        Since:
        11.1
      • restoreLoggerLevel

        protected void restoreLoggerLevel​(FeaturesRunner runner,
                                          org.junit.runners.model.FrameworkMethod method)
        Restores the original value of the logger level.

        addOrUpdateLoggerLevel(FeaturesRunner, FrameworkMethod)} to see how we store the original value and set the new one.

        Parameters:
        runner - the feature runner, cannot be null
        method - the framework method, can be null
        Since:
        11.1
      • buildKey

        protected LoggerLevelKey buildKey​(LoggerLevel logger,
                                          org.junit.runners.model.FrameworkMethod method)
        Builds the logger key.
        Since:
        11.1