Package org.ametys.runtime.log
Class MemoryAppender
- java.lang.Object
-
- org.apache.log4j.AppenderSkeleton
-
- org.ametys.runtime.log.MemoryAppender
-
- All Implemented Interfaces:
Appender
,OptionHandler
public class MemoryAppender extends AppenderSkeleton
Log appender that stores a pile of logs in memory.
-
-
Field Summary
Fields Modifier and Type Field Description private static long
__LOG_EXPIRATION_TIME
Time of expiration of a log (10 minutes)private static long
__TIME_DURATION_BEFORE_NEXT_CLEAN
Time duration between 2 cleansing of logs queue (10 seconds)private long
_lastCleanTime
private LinkedList<MemoryLogRecord>
_logsQueue
-
Fields inherited from class org.apache.log4j.AppenderSkeleton
closed, errorHandler, headFilter, layout, name, tailFilter, threshold
-
-
Constructor Summary
Constructors Constructor Description MemoryAppender()
Default constructor for the memory appender
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private boolean
_matchCategoryFilter(List<String> filterCategories, MemoryLogRecord record)
protected void
append(LoggingEvent event)
void
close()
List<MemoryLogRecord>
getEvents(long fromTimestamp)
Get the logs from a given timestampList<MemoryLogRecord>
getEvents(long fromTimestamp, List<String> filterCategories)
Get the logs from a given timestamp and filtered by specific categoriesvoid
removeExpiredEvents(long from)
Remove the expired log records every 10 secondsboolean
requiresLayout()
-
Methods inherited from class org.apache.log4j.AppenderSkeleton
activateOptions, addFilter, clearFilters, doAppend, finalize, getErrorHandler, getFilter, getFirstFilter, getLayout, getName, getThreshold, isAsSevereAsThreshold, setErrorHandler, setLayout, setName, setThreshold
-
-
-
-
Field Detail
-
__LOG_EXPIRATION_TIME
private static final long __LOG_EXPIRATION_TIME
Time of expiration of a log (10 minutes)- See Also:
- Constant Field Values
-
__TIME_DURATION_BEFORE_NEXT_CLEAN
private static final long __TIME_DURATION_BEFORE_NEXT_CLEAN
Time duration between 2 cleansing of logs queue (10 seconds)- See Also:
- Constant Field Values
-
_lastCleanTime
private long _lastCleanTime
-
_logsQueue
private LinkedList<MemoryLogRecord> _logsQueue
-
-
Constructor Detail
-
MemoryAppender
public MemoryAppender()
Default constructor for the memory appender
-
-
Method Detail
-
append
protected void append(LoggingEvent event)
- Specified by:
append
in classAppenderSkeleton
-
getEvents
public List<MemoryLogRecord> getEvents(long fromTimestamp)
Get the logs from a given timestamp- Parameters:
fromTimestamp
- If greater than 0, get the events more recent than this timestamp parameter. If equals or less than 0, returns all events- Returns:
- The log events
-
getEvents
public List<MemoryLogRecord> getEvents(long fromTimestamp, List<String> filterCategories)
Get the logs from a given timestamp and filtered by specific categories- Parameters:
fromTimestamp
- If greater than 0, get the events more recent than this timestamp parameter. If equals or less than 0, returns all eventsfilterCategories
- The filter categories- Returns:
- The log events
-
_matchCategoryFilter
private boolean _matchCategoryFilter(List<String> filterCategories, MemoryLogRecord record)
-
removeExpiredEvents
public void removeExpiredEvents(long from)
Remove the expired log records every 10 seconds- Parameters:
from
- The expiration date in milliseconds
-
requiresLayout
public boolean requiresLayout()
-
close
public void close()
-
-