Class LoggerRegistry<T extends ExtendedLogger>


  • @NullMarked
    public class LoggerRegistry<T extends ExtendedLogger>
    extends java.lang.Object
    Convenience class to be used as an ExtendedLogger registry by LoggerContext implementations.
    Since:
    2.6
    • Field Detail

      • loggerByMessageFactoryByName

        private final java.util.Map<java.lang.String,​java.util.Map<MessageFactory,​T extends ExtendedLogger>> loggerByMessageFactoryByName
      • lock

        private final java.util.concurrent.locks.ReadWriteLock lock
      • readLock

        private final java.util.concurrent.locks.Lock readLock
      • writeLock

        private final java.util.concurrent.locks.Lock writeLock
    • Constructor Detail

      • LoggerRegistry

        public LoggerRegistry()
      • LoggerRegistry

        @Deprecated
        public LoggerRegistry​(@Nullable LoggerRegistry.MapFactory<T> mapFactory)
        Deprecated.
        As of version 2.25.0, planned to be removed!
        Constructs an instance ignoring the given the map factory.
        Parameters:
        mapFactory - a map factory
    • Method Detail

      • getLogger

        @Deprecated
        public @Nullable T getLogger​(java.lang.String name)
        Deprecated.
        As of version 2.25.0, planned to be removed! Use getLogger(String, MessageFactory) instead.
        Returns the logger associated with the given name.

        There can be made no assumptions on the message factory of the returned logger. Callers are strongly advised to switch to getLogger(String, MessageFactory) and provide a message factory parameter!

        Parameters:
        name - a logger name
        Returns:
        the logger associated with the name
      • getLogger

        public @Nullable T getLogger​(java.lang.String name,
                                     @Nullable MessageFactory messageFactory)
        Returns the logger associated with the given name and message factory.

        In the absence of a message factory, there can be made no assumptions on the message factory of the returned logger. This lenient behaviour is only kept for backward compatibility. Callers are strongly advised to provide a message factory parameter to the method!

        Parameters:
        name - a logger name
        messageFactory - a message factory
        Returns:
        the logger associated with the given name and message factory
      • getLoggers

        public java.util.Collection<T> getLoggers()
      • getLoggers

        public java.util.Collection<T> getLoggers​(java.util.Collection<T> destination)
      • hasLogger

        @Deprecated
        public boolean hasLogger​(java.lang.String name)
        Deprecated.
        As of version 2.25.0, planned to be removed! Use hasLogger(String, MessageFactory) instead.
        Checks if a logger associated with the given name exists.

        There can be made no assumptions on the message factory of the found logger. Callers are strongly advised to switch to hasLogger(String, MessageFactory) and provide a message factory parameter!

        Parameters:
        name - a logger name
        Returns:
        true, if the logger exists; false otherwise.
      • hasLogger

        public boolean hasLogger​(java.lang.String name,
                                 @Nullable MessageFactory messageFactory)
        Checks if a logger associated with the given name and message factory exists.

        In the absence of a message factory, there can be made no assumptions on the message factory of the found logger. This lenient behaviour is only kept for backward compatibility. Callers are strongly advised to provide a message factory parameter to the method!

        Parameters:
        name - a logger name
        messageFactory - a message factory
        Returns:
        true, if the logger exists; false otherwise.
        Since:
        2.5
      • hasLogger

        public boolean hasLogger​(java.lang.String name,
                                 java.lang.Class<? extends MessageFactory> messageFactoryClass)
        Checks if a logger associated with the given name and message factory type exists.
        Parameters:
        name - a logger name
        messageFactoryClass - a message factory class
        Returns:
        true, if the logger exists; false otherwise.
        Since:
        2.5
      • putIfAbsent

        public void putIfAbsent​(java.lang.String name,
                                @Nullable MessageFactory messageFactory,
                                T logger)
        Registers the provided logger.

        The logger will be registered using the keys provided by the name and messageFactory parameters and the values of Logger.getName() and Logger.getMessageFactory().

        Parameters:
        name - a logger name
        messageFactory - a message factory
        logger - a logger instance
      • createLoggerRefByMessageFactoryMap

        private java.util.Map<MessageFactory,​T> createLoggerRefByMessageFactoryMap​(java.lang.String ignored)