Class LoggerRegistry<T extends ExtendedLogger>
ExtendedLogger
registry by LoggerContext
implementations.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
LoggerRegistry.MapFactory
implementation usingConcurrentHashMap
.static interface
LoggerRegistry.MapFactory<T extends ExtendedLogger>
Data structure contract for the internal storage of admitted loggers.static class
LoggerRegistry.WeakMapFactory<T extends ExtendedLogger>
LoggerRegistry.MapFactory
implementation usingWeakHashMap
. -
Constructor Summary
ConstructorDescriptionLoggerRegistry
(LoggerRegistry.MapFactory<T> mapFactory) Constructs an instance ignoring the given the map factory. -
Method Summary
Modifier and TypeMethodDescription@Nullable T
Returns the logger associated with the given name.@Nullable T
getLogger
(String name, @Nullable MessageFactory messageFactory) Returns the logger associated with the given name and message factory.getLoggers
(Collection<T> destination) boolean
Checks if a logger associated with the given name exists.boolean
hasLogger
(String name, Class<? extends MessageFactory> messageFactoryClass) Checks if a logger associated with the given name and message factory type exists.boolean
hasLogger
(String name, MessageFactory messageFactory) Checks if a logger associated with the given name and message factory exists.void
putIfAbsent
(String name, @Nullable MessageFactory messageFactory, T logger) Registers the provided logger.
-
Constructor Details
-
LoggerRegistry
public LoggerRegistry() -
LoggerRegistry
Constructs an instance ignoring the given the map factory.- Parameters:
mapFactory
- a map factory
-
-
Method Details
-
getLogger
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
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 namemessageFactory
- a message factory- Returns:
- the logger associated with the given name and message factory
-
getLoggers
-
getLoggers
-
hasLogger
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
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 namemessageFactory
- a message factory- Returns:
true
, if the logger exists;false
otherwise.- Since:
- 2.5
-
hasLogger
Checks if a logger associated with the given name and message factory type exists.- Parameters:
name
- a logger namemessageFactoryClass
- a message factory class- Returns:
true
, if the logger exists;false
otherwise.- Since:
- 2.5
-
putIfAbsent
Registers the provided logger.The logger will be registered using the keys provided by the
name
andmessageFactory
parameters and the values ofLogger.getName()
andLogger.getMessageFactory()
.- Parameters:
name
- a logger namemessageFactory
- a message factorylogger
- a logger instance
-