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 creatingBufferingLogger
s.
-
-
Field Summary
Fields Modifier and Type Field Description static String
BUFFER_SIZE_PROPERTY
static String
LOG_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 void
addEvent(BufferedEvent event)
Adds the event, removing the oldest event if the buffer sise is reached.void
flush(LoggerFactory factory)
Forward all buffered events.Logger
getLogger(Class<?> clazz)
<L extends Logger>
LgetLogger(Class<?> clazz, Class<L> loggerType)
Logger
getLogger(String name)
<L extends Logger>
LgetLogger(String name, Class<L> loggerType)
<L extends Logger>
LgetLogger(Bundle bundle, String name, Class<L> loggerType)
BufferingLoggerFactory
setBufferSize(int bufferSize)
Sets the buffer size.BufferingLoggerFactory
setThreshold(LogLevel threshold)
Sets the threshold.LogLevel
threshold()
-
-
-
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:
getLogger
in interfaceLoggerFactory
-
getLogger
public Logger getLogger(Class<?> clazz)
- Specified by:
getLogger
in interfaceLoggerFactory
-
getLogger
public <L extends Logger> L getLogger(String name, Class<L> loggerType)
- Specified by:
getLogger
in interfaceLoggerFactory
-
getLogger
public <L extends Logger> L getLogger(Class<?> clazz, Class<L> loggerType)
- Specified by:
getLogger
in interfaceLoggerFactory
-
-