Class AbstractLoggerAdapter<L>

  • Type Parameters:
    L - the Logger class to adapt
    All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, LoggerAdapter<L>
    Direct Known Subclasses:
    AbstractLoggerAdapter, LogAdapter

    public abstract class AbstractLoggerAdapter<L>
    extends java.lang.Object
    implements LoggerAdapter<L>
    Provides an abstract base class to use for implementing LoggerAdapter.
    Since:
    2.1
    • Field Detail

      • registry

        protected final java.util.Map<LoggerContext,​java.util.concurrent.ConcurrentMap<java.lang.String,​L>> registry
        A map to store loggers for their given LoggerContexts.
    • Constructor Detail

      • AbstractLoggerAdapter

        public AbstractLoggerAdapter()
    • Method Detail

      • getLogger

        public L getLogger​(java.lang.String name)
        Description copied from interface: LoggerAdapter
        Gets a named logger. Implementations should defer to the abstract methods in AbstractLoggerAdapter.
        Specified by:
        getLogger in interface LoggerAdapter<L>
        Parameters:
        name - the name of the logger to get
        Returns:
        the named logger
      • getLoggersInContext

        public java.util.concurrent.ConcurrentMap<java.lang.String,​L> getLoggersInContext​(LoggerContext context)
        Gets or creates the ConcurrentMap of named loggers for a given LoggerContext.
        Parameters:
        context - the LoggerContext to get loggers for
        Returns:
        the map of loggers for the given LoggerContext
      • newLogger

        protected abstract L newLogger​(java.lang.String name,
                                       LoggerContext context)
        Creates a new named logger for a given LoggerContext.
        Parameters:
        name - the name of the logger to create
        context - the LoggerContext this logger will be associated with
        Returns:
        the new named logger
      • getContext

        protected LoggerContext getContext​(java.lang.Class<?> callerClass)
        Gets the LoggerContext associated with the given caller class.
        Parameters:
        callerClass - the caller class
        Returns:
        the LoggerContext for the calling class
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable