Class LoggerBridge

java.lang.Object
org.terracotta.utilities.logging.LoggerBridge

public final class LoggerBridge extends Object
Bridge to permit variable-level use of SLF4j.

This class maintains a static reference to the LoggerBridge instances created by getInstance(Logger, Level).

  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • INSTANCES

      private static final Map<org.slf4j.Logger,Map<org.slf4j.event.Level,LoggerBridge>> INSTANCES
    • IS_LEVEL_ENABLED

      private static final Map<org.slf4j.event.Level,MethodHandle> IS_LEVEL_ENABLED
    • LOG

      private static final Map<org.slf4j.event.Level,MethodHandle> LOG
    • LOG_THROWABLE

      private static final Map<org.slf4j.event.Level,MethodHandle> LOG_THROWABLE
    • isLevelEnabled

      private final MethodHandle isLevelEnabled
    • log

      private final MethodHandle log
    • logThrowable

      private final MethodHandle logThrowable
  • Constructor Details

    • LoggerBridge

      private LoggerBridge(org.slf4j.Logger delegate, org.slf4j.event.Level level)
      Creates a LoggerBridge instance sending logging calls to the designated Logger at the specified level.
      Parameters:
      delegate - the delegate Logger
      level - the level at which the log method records
      Throws:
      AssertionError - if there is an error instantiating the required LoggerBridge instance
  • Method Details

    • getInstance

      public static LoggerBridge getInstance(org.slf4j.Logger delegate, org.slf4j.event.Level level)
      Creates or gets the LoggerBridge instance for the delegate Logger and Level.
      Parameters:
      delegate - the Logger to which logging calls are delegated
      level - the Level at which the returned LoggingBridge logs
      Returns:
      a LoggingBridge instance
      Throws:
      AssertionError - if there is an error instantiating the required LoggerBridge instance
    • getIsLevelEnabledMethodHandle

      private static MethodHandle getIsLevelEnabledMethodHandle(org.slf4j.event.Level level)
    • getLogMethodHandle

      private static MethodHandle getLogMethodHandle(org.slf4j.event.Level level)
    • getLogThrowableMethodHandle

      private static MethodHandle getLogThrowableMethodHandle(org.slf4j.event.Level level)
    • isLevelEnabled

      public boolean isLevelEnabled()
      Checks if the delegate logger is active for the configured level.
      Returns:
      true if the delegate logger is configured to record events of the level of this LoggerBridge
    • log

      public void log(String format, Object... arguments)
      Submits a log event to the delegate logger at the level of this LoggerBridge.
      Parameters:
      format - the log message format
      arguments - the arguments for the message
    • log

      public void log(String message, Throwable t)
      Submits a log event to the delegate logger at the level of this LoggerBridge.
      Parameters:
      message - the log message format
      t - the Throwable to log with message