Class LoggerProbe

java.lang.Object
org.junit.rules.ExternalResource
de.hybris.platform.integrationservices.util.LoggerProbe
All Implemented Interfaces:
org.junit.rules.TestRule, org.slf4j.Logger

public final class LoggerProbe extends org.junit.rules.ExternalResource implements org.slf4j.Logger
A test rule for retrieving SLF4J Loggers with adjusted log level compared to the default logback configuration and asserting that an output has happened.
  • Method Details

    • create

      public static LoggerProbe create(Class<?> type)
      Creates a probe for the specified logger.
      Parameters:
      type - type, for which a logger should be created.
      Returns:
      a logger probe to be used in tests
    • withLogLevel

      public LoggerProbe withLogLevel(LogLevel level)
      Sets log level for enabling/disabling output of certain messages.
      Parameters:
      level - level to apply for logging messages.
      Returns:
      a probe with log level applied.
    • before

      protected void before()
      Overrides:
      before in class org.junit.rules.ExternalResource
    • after

      protected void after()
      Overrides:
      after in class org.junit.rules.ExternalResource
    • getAllLoggedRecords

      public List<LogRecord> getAllLoggedRecords()
      Retrieves all records logged by this probe.
      Returns:
      a list of records in the order they were logged regardless of their log level
    • getAllLoggedMessages

      public List<String> getAllLoggedMessages()
      Retrieves all message logged by this probe.
      Returns:
      a list of message logged regardless of their log level
    • getMessagesLoggedAtInfo

      public List<String> getMessagesLoggedAtInfo()
      Retrieves all message logged at INFO level by this probe.
      Returns:
      a list of message logged at INFO level regardless of whether they had stack trace printed or not.
    • getMessagesLoggedAtInfoWithStackTrace

      public List<String> getMessagesLoggedAtInfoWithStackTrace()
      Retrieves all message logged at INFO level with the stack trace.
      Returns:
      only messages logged by this probe at INFO level, which had also a stack trace included.
    • getMessagesLoggedAtWarn

      public List<String> getMessagesLoggedAtWarn()
      Retrieves all message logged at WARN level by this probe.
      Returns:
      a list of message logged at WARN level regardless of whether they had stack trace printed or not.
    • getMessagesLoggedAtWarnWithStackTrace

      public List<String> getMessagesLoggedAtWarnWithStackTrace()
      Retrieves all message logged at WARN level with the stack trace.
      Returns:
      only messages logged by this probe at WARN level, which had also a stack trace included.
    • getMessagesLoggedAtError

      public List<String> getMessagesLoggedAtError()
      Retrieves all message logged at ERROR level by this probe.
      Returns:
      a list of message logged at ERROR level regardless of whether they had stack trace printed or not.
    • getMessagesLoggedAtErrorWithStackTrace

      public List<String> getMessagesLoggedAtErrorWithStackTrace()
      Retrieves all message logged at ERROR level with the stack trace.
      Returns:
      only messages logged by this probe at ERROR level, which had also a stack trace included.
    • getMessagesLoggedAtDebug

      public List<String> getMessagesLoggedAtDebug()
      Retrieves all message logged at DEBUG level by this probe.
      Returns:
      a list of message logged at DEBUG level regardless of whether they had stack trace printed or not.
    • getMessagesLoggedAtDebugWithStackTrace

      public List<String> getMessagesLoggedAtDebugWithStackTrace()
      Retrieves all message logged at DEBUG level with the stack trace.
      Returns:
      only messages logged by this probe at DEBUG level, which had also a stack trace included.
    • getMessagesLoggedAtTrace

      public List<String> getMessagesLoggedAtTrace()
      Retrieves all message logged at TRACE level by this probe.
      Returns:
      a list of message logged at TRACE level regardless of whether they had stack trace printed or not.
    • getMessagesLoggedAtTraceWithStackTrace

      public List<String> getMessagesLoggedAtTraceWithStackTrace()
      Retrieves all message logged at TRACE level with the stack trace.
      Returns:
      only messages logged by this probe at TRACE level, which had also a stack trace included.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getName

      public String getName()
      Specified by:
      getName in interface org.slf4j.Logger
    • isTraceEnabled

      public boolean isTraceEnabled()
      Specified by:
      isTraceEnabled in interface org.slf4j.Logger
    • trace

      public void trace(String s)
      Specified by:
      trace in interface org.slf4j.Logger
    • trace

      public void trace(String s, Object o)
      Specified by:
      trace in interface org.slf4j.Logger
    • trace

      public void trace(String s, Object o1, Object o2)
      Specified by:
      trace in interface org.slf4j.Logger
    • trace

      public void trace(String s, Object... objects)
      Specified by:
      trace in interface org.slf4j.Logger
    • trace

      public void trace(String s, Throwable throwable)
      Specified by:
      trace in interface org.slf4j.Logger
    • isTraceEnabled

      public boolean isTraceEnabled(org.slf4j.Marker marker)
      Specified by:
      isTraceEnabled in interface org.slf4j.Logger
    • trace

      public void trace(org.slf4j.Marker marker, String s)
      Specified by:
      trace in interface org.slf4j.Logger
    • trace

      public void trace(org.slf4j.Marker marker, String s, Object o)
      Specified by:
      trace in interface org.slf4j.Logger
    • trace

      public void trace(org.slf4j.Marker marker, String s, Object o1, Object o2)
      Specified by:
      trace in interface org.slf4j.Logger
    • trace

      public void trace(org.slf4j.Marker marker, String s, Object... objects)
      Specified by:
      trace in interface org.slf4j.Logger
    • trace

      public void trace(org.slf4j.Marker marker, String s, Throwable throwable)
      Specified by:
      trace in interface org.slf4j.Logger
    • isDebugEnabled

      public boolean isDebugEnabled()
      Specified by:
      isDebugEnabled in interface org.slf4j.Logger
    • debug

      public void debug(String s)
      Specified by:
      debug in interface org.slf4j.Logger
    • debug

      public void debug(String s, Object o)
      Specified by:
      debug in interface org.slf4j.Logger
    • debug

      public void debug(String s, Object o1, Object o2)
      Specified by:
      debug in interface org.slf4j.Logger
    • debug

      public void debug(String s, Object... objects)
      Specified by:
      debug in interface org.slf4j.Logger
    • debug

      public void debug(String s, Throwable throwable)
      Specified by:
      debug in interface org.slf4j.Logger
    • isDebugEnabled

      public boolean isDebugEnabled(org.slf4j.Marker marker)
      Specified by:
      isDebugEnabled in interface org.slf4j.Logger
    • debug

      public void debug(org.slf4j.Marker marker, String s)
      Specified by:
      debug in interface org.slf4j.Logger
    • debug

      public void debug(org.slf4j.Marker marker, String s, Object o)
      Specified by:
      debug in interface org.slf4j.Logger
    • debug

      public void debug(org.slf4j.Marker marker, String s, Object o1, Object o2)
      Specified by:
      debug in interface org.slf4j.Logger
    • debug

      public void debug(org.slf4j.Marker marker, String s, Object... objects)
      Specified by:
      debug in interface org.slf4j.Logger
    • debug

      public void debug(org.slf4j.Marker marker, String s, Throwable throwable)
      Specified by:
      debug in interface org.slf4j.Logger
    • isInfoEnabled

      public boolean isInfoEnabled()
      Specified by:
      isInfoEnabled in interface org.slf4j.Logger
    • info

      public void info(String s)
      Specified by:
      info in interface org.slf4j.Logger
    • info

      public void info(String s, Object o)
      Specified by:
      info in interface org.slf4j.Logger
    • info

      public void info(String s, Object o1, Object o2)
      Specified by:
      info in interface org.slf4j.Logger
    • info

      public void info(String s, Object... objects)
      Specified by:
      info in interface org.slf4j.Logger
    • info

      public void info(String s, Throwable throwable)
      Specified by:
      info in interface org.slf4j.Logger
    • isInfoEnabled

      public boolean isInfoEnabled(org.slf4j.Marker marker)
      Specified by:
      isInfoEnabled in interface org.slf4j.Logger
    • info

      public void info(org.slf4j.Marker marker, String s)
      Specified by:
      info in interface org.slf4j.Logger
    • info

      public void info(org.slf4j.Marker marker, String s, Object o)
      Specified by:
      info in interface org.slf4j.Logger
    • info

      public void info(org.slf4j.Marker marker, String s, Object o1, Object o2)
      Specified by:
      info in interface org.slf4j.Logger
    • info

      public void info(org.slf4j.Marker marker, String s, Object... objects)
      Specified by:
      info in interface org.slf4j.Logger
    • info

      public void info(org.slf4j.Marker marker, String s, Throwable throwable)
      Specified by:
      info in interface org.slf4j.Logger
    • isWarnEnabled

      public boolean isWarnEnabled()
      Specified by:
      isWarnEnabled in interface org.slf4j.Logger
    • warn

      public void warn(String s)
      Specified by:
      warn in interface org.slf4j.Logger
    • warn

      public void warn(String s, Object o)
      Specified by:
      warn in interface org.slf4j.Logger
    • warn

      public void warn(String s, Object... objects)
      Specified by:
      warn in interface org.slf4j.Logger
    • warn

      public void warn(String s, Object o1, Object o2)
      Specified by:
      warn in interface org.slf4j.Logger
    • warn

      public void warn(String s, Throwable throwable)
      Specified by:
      warn in interface org.slf4j.Logger
    • isWarnEnabled

      public boolean isWarnEnabled(org.slf4j.Marker marker)
      Specified by:
      isWarnEnabled in interface org.slf4j.Logger
    • warn

      public void warn(org.slf4j.Marker marker, String s)
      Specified by:
      warn in interface org.slf4j.Logger
    • warn

      public void warn(org.slf4j.Marker marker, String s, Object o)
      Specified by:
      warn in interface org.slf4j.Logger
    • warn

      public void warn(org.slf4j.Marker marker, String s, Object o1, Object o2)
      Specified by:
      warn in interface org.slf4j.Logger
    • warn

      public void warn(org.slf4j.Marker marker, String s, Object... objects)
      Specified by:
      warn in interface org.slf4j.Logger
    • warn

      public void warn(org.slf4j.Marker marker, String s, Throwable throwable)
      Specified by:
      warn in interface org.slf4j.Logger
    • isErrorEnabled

      public boolean isErrorEnabled()
      Specified by:
      isErrorEnabled in interface org.slf4j.Logger
    • error

      public void error(String s)
      Specified by:
      error in interface org.slf4j.Logger
    • error

      public void error(String s, Object o)
      Specified by:
      error in interface org.slf4j.Logger
    • error

      public void error(String s, Object o1, Object o2)
      Specified by:
      error in interface org.slf4j.Logger
    • error

      public void error(String s, Object... objects)
      Specified by:
      error in interface org.slf4j.Logger
    • error

      public void error(String s, Throwable throwable)
      Specified by:
      error in interface org.slf4j.Logger
    • isErrorEnabled

      public boolean isErrorEnabled(org.slf4j.Marker marker)
      Specified by:
      isErrorEnabled in interface org.slf4j.Logger
    • error

      public void error(org.slf4j.Marker marker, String s)
      Specified by:
      error in interface org.slf4j.Logger
    • error

      public void error(org.slf4j.Marker marker, String s, Object o)
      Specified by:
      error in interface org.slf4j.Logger
    • error

      public void error(org.slf4j.Marker marker, String s, Object o1, Object o2)
      Specified by:
      error in interface org.slf4j.Logger
    • error

      public void error(org.slf4j.Marker marker, String s, Object... objects)
      Specified by:
      error in interface org.slf4j.Logger
    • error

      public void error(org.slf4j.Marker marker, String s, Throwable throwable)
      Specified by:
      error in interface org.slf4j.Logger