Class TestLogger

java.lang.Object
com.renomad.minum.logging.Logger
com.renomad.minum.logging.TestLogger
All Implemented Interfaces:
ILogger

public final class TestLogger extends Logger
This implementation of Logger has a few extra functions that only apply to tests, like test(String)
  • Field Details

  • Constructor Details

  • Method Details

    • logDebug

      public void logDebug(ThrowingSupplier<String,Exception> msg)
      Description copied from interface: ILogger
      Logs helpful debugging information
      Specified by:
      logDebug in interface ILogger
      Overrides:
      logDebug in class Logger
      Parameters:
      msg - a lambda for what is to be logged. example: () -> "Hello"
    • logTrace

      public void logTrace(ThrowingSupplier<String,Exception> msg)
      Description copied from interface: ILogger
      Logs helpful debugging information

      Similar to ILogger.logDebug(ThrowingSupplier) but used for code that runs very often, requires extra calculation, or has data of large size.

      It is possible to disable trace logs and thus avoid performance impacts unless the data is needed for deeper investigation.

      Specified by:
      logTrace in interface ILogger
      Overrides:
      logTrace in class Logger
      Parameters:
      msg - a lambda for what is to be logged. example: () -> "Hello"
    • logAudit

      public void logAudit(ThrowingSupplier<String,Exception> msg)
      Description copied from interface: ILogger
      This is for logging business-related topics

      This log type is expected to be printed least-often, and should directly relate to a user action. An example would be "New user created: alice"

      msg a lambda for what is to be logged. example: () -> "Hello"
      Specified by:
      logAudit in interface ILogger
      Overrides:
      logAudit in class Logger
    • logAsyncError

      public void logAsyncError(ThrowingSupplier<String,Exception> msg)
      Description copied from interface: ILogger
      Logs helpful debugging information inside threads
      Specified by:
      logAsyncError in interface ILogger
      Overrides:
      logAsyncError in class Logger
      Parameters:
      msg - a lambda for what is to be logged. example: () -> "Hello"
    • findFirstMessageThatContains

      public String findFirstMessageThatContains(String value, int lines)
      Provides an ability to search over the recent past log messages, case-insensitively.
      Parameters:
      lines - number of lines of log messages to look back through, up to MAX_CACHE_SIZE
    • doesMessageExist

      public boolean doesMessageExist(String value, int lines)
      Whether the given string exists in the log messages. May exist multiple times.
      Parameters:
      value - a string to search in the log
      lines - how many lines back to examine
      Returns:
      whether this string was found, even if there were multiple places it was found.
    • doesMessageExist

      public boolean doesMessageExist(String value)
      Whether the given string exists in the log messages. May exist multiple times.
      Parameters:
      value - a string to search in the log
      Returns:
      whether or not this string was found, even if there were multiple places it was found.
    • findFirstMessageThatContains

      public String findFirstMessageThatContains(String value)
      Looks back through the last 3 log messages for one that contains the provided value. Returns the whole line if found and an exception if not found.

      See findFirstMessageThatContains(String, int) if you want to search through more than 3. However, it is only possible to search up to MAX_CACHE_SIZE

    • test

      public void test(String msg)
      A helper function to log a test title prefixed with "TEST:"
      Also collects data about the previously-run test
    • getTestCount

      public int getTestCount()
    • toString

      public String toString()
      Overrides:
      toString in class Object