Class Logger

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

public class Logger extends Object implements ILogger
Implementation of ILogger
  • Field Details

    • loggingActionQueue

      protected final AbstractActionQueue loggingActionQueue
      The LoggingActionQueue that handles all our messages thread-safely by taking them off the top of a queue.
  • Constructor Details

    • Logger

      public Logger(Constants constants, ExecutorService executorService, String name)
      Constructor
      Parameters:
      constants - used for determining enabled log levels
      executorService - provides thread handling for the logs, used to build a LoggingActionQueue
      name - sets a name on the LoggingActionQueue to aid debugging, to help distinguish queues.
    • Logger

      public Logger(Logger logger)
      A constructor meant for use by descendant classes
      Parameters:
      logger - an existing instance of a running logger, needed in order to have the descendant logger using the same AbstractActionQueue, which is necessary so logs don't interleave with each other.
  • 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
      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
      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
    • stop

      public void stop()
      Description copied from interface: ILogger
      When we are shutting down the system it is necessary to explicitly stop the logger.

      The logger has to stand apart from the rest of the system, or else we'll have circular dependencies.

      Specified by:
      stop in interface ILogger
    • 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
      Parameters:
      msg - a lambda for what is to be logged. example: () -> "Hello"
    • getActiveLogLevels

      public Map<LoggingLevel,Boolean> getActiveLogLevels()
      Description copied from interface: ILogger
      This method can be used to adjust the active log levels, which is a mapping of keys of LoggingLevel to boolean values. If the boolean value is true, that level of logging is enabled.
      Specified by:
      getActiveLogLevels in interface ILogger