Package de.mnl.osgi.lf4osgi.core
Class BufferingLoggerFactory
- java.lang.Object
-
- de.mnl.osgi.lf4osgi.core.BufferingLoggerFactory
-
- All Implemented Interfaces:
LoggerFactory
public class BufferingLoggerFactory extends Object implements LoggerFactory
A factory for creatingBufferingLoggers.
-
-
Field Summary
Fields Modifier and Type Field Description static StringBUFFER_SIZE_PROPERTYstatic StringLOG_THRESHOLD_PROPERTY
-
Constructor Summary
Constructors Constructor Description BufferingLoggerFactory()Instantiates a new buffering logger factory with an event buffer with given size, buffering only events with at least the given threshold.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddEvent(BufferedEvent event)Adds the event, removing the oldest event if the buffer sise is reached.voidflush(LoggerFactory factory)Forward all buffered events.LoggergetLogger(Class<?> clazz)<L extends Logger>
LgetLogger(Class<?> clazz, Class<L> loggerType)LoggergetLogger(String name)<L extends Logger>
LgetLogger(String name, Class<L> loggerType)<L extends Logger>
LgetLogger(Bundle bundle, String name, Class<L> loggerType)BufferingLoggerFactorysetBufferSize(int bufferSize)Sets the buffer size.BufferingLoggerFactorysetThreshold(LogLevel threshold)Sets the threshold.LogLevelthreshold()
-
-
-
Field Detail
-
LOG_THRESHOLD_PROPERTY
public static final String LOG_THRESHOLD_PROPERTY
- See Also:
- Constant Field Values
-
BUFFER_SIZE_PROPERTY
public static final String BUFFER_SIZE_PROPERTY
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BufferingLoggerFactory
public BufferingLoggerFactory()
Instantiates a new buffering logger factory with an event buffer with given size, buffering only events with at least the given threshold.
-
-
Method Detail
-
setBufferSize
public BufferingLoggerFactory setBufferSize(int bufferSize)
Sets the buffer size.- Parameters:
bufferSize- the buffer size- Returns:
- the buffering logger factory
-
setThreshold
public BufferingLoggerFactory setThreshold(LogLevel threshold)
Sets the threshold.- Parameters:
threshold- the threshold- Returns:
- the buffering logger factory
-
addEvent
public void addEvent(BufferedEvent event)
Adds the event, removing the oldest event if the buffer sise is reached.- Parameters:
event- the event
-
flush
public void flush(LoggerFactory factory)
Forward all buffered events.- Parameters:
factory- the factory
-
getLogger
public Logger getLogger(String name)
- Specified by:
getLoggerin interfaceLoggerFactory
-
getLogger
public Logger getLogger(Class<?> clazz)
- Specified by:
getLoggerin interfaceLoggerFactory
-
getLogger
public <L extends Logger> L getLogger(String name, Class<L> loggerType)
- Specified by:
getLoggerin interfaceLoggerFactory
-
getLogger
public <L extends Logger> L getLogger(Class<?> clazz, Class<L> loggerType)
- Specified by:
getLoggerin interfaceLoggerFactory
-
-