Class LoggerBridge


  • public final class LoggerBridge
    extends java.lang.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 Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.Map<org.slf4j.Logger,​java.util.Map<org.slf4j.event.Level,​LoggerBridge>> INSTANCES  
      private static java.util.Map<org.slf4j.event.Level,​java.lang.invoke.MethodHandle> IS_LEVEL_ENABLED  
      private java.lang.invoke.MethodHandle isLevelEnabled  
      private java.lang.invoke.MethodHandle log  
      private static java.util.Map<org.slf4j.event.Level,​java.lang.invoke.MethodHandle> LOG  
      private static java.util.Map<org.slf4j.event.Level,​java.lang.invoke.MethodHandle> LOG_THROWABLE  
      private static org.slf4j.Logger LOGGER  
      private java.lang.invoke.MethodHandle logThrowable  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      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.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static LoggerBridge getInstance​(org.slf4j.Logger delegate, org.slf4j.event.Level level)
      Creates or gets the LoggerBridge instance for the delegate Logger and Level.
      private static java.lang.invoke.MethodHandle getIsLevelEnabledMethodHandle​(org.slf4j.event.Level level)  
      private static java.lang.invoke.MethodHandle getLogMethodHandle​(org.slf4j.event.Level level)  
      private static java.lang.invoke.MethodHandle getLogThrowableMethodHandle​(org.slf4j.event.Level level)  
      boolean isLevelEnabled()
      Checks if the delegate logger is active for the configured level.
      void log​(java.lang.String format, java.lang.Object... arguments)
      Submits a log event to the delegate logger at the level of this LoggerBridge.
      void log​(java.lang.String message, java.lang.Throwable t)
      Submits a log event to the delegate logger at the level of this LoggerBridge.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LOGGER

        private static final org.slf4j.Logger LOGGER
      • INSTANCES

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

        private static final java.util.Map<org.slf4j.event.Level,​java.lang.invoke.MethodHandle> IS_LEVEL_ENABLED
      • LOG

        private static final java.util.Map<org.slf4j.event.Level,​java.lang.invoke.MethodHandle> LOG
      • LOG_THROWABLE

        private static final java.util.Map<org.slf4j.event.Level,​java.lang.invoke.MethodHandle> LOG_THROWABLE
      • isLevelEnabled

        private final java.lang.invoke.MethodHandle isLevelEnabled
      • log

        private final java.lang.invoke.MethodHandle log
      • logThrowable

        private final java.lang.invoke.MethodHandle logThrowable
    • Constructor Detail

      • 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:
        java.lang.AssertionError - if there is an error instantiating the required LoggerBridge instance
    • Method Detail

      • 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:
        java.lang.AssertionError - if there is an error instantiating the required LoggerBridge instance
      • getIsLevelEnabledMethodHandle

        private static java.lang.invoke.MethodHandle getIsLevelEnabledMethodHandle​(org.slf4j.event.Level level)
      • getLogMethodHandle

        private static java.lang.invoke.MethodHandle getLogMethodHandle​(org.slf4j.event.Level level)
      • getLogThrowableMethodHandle

        private static java.lang.invoke.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​(java.lang.String format,
                        java.lang.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​(java.lang.String message,
                        java.lang.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