public class ReadOnlyFileStorage extends Object implements ReadableLogStorage
| Modifier and Type | Class and Description |
|---|---|
protected static class |
ReadOnlyFileStorage.FileInfo |
protected class |
ReadOnlyFileStorage.FileInfoComparator |
protected static class |
ReadOnlyFileStorage.PageInfo |
| Modifier and Type | Field and Description |
|---|---|
static String |
CATEGORY_PROPERTY |
static String |
DATE_ONLY_FORMAT |
static String |
DATE_PROPERTY |
static String |
LEVEL_PROPERTY |
static String |
MESSAGE_PROPERTY |
static String |
THREAD_PROPERTY |
| Constructor and Description |
|---|
ReadOnlyFileStorage() |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the storage
|
protected LogRecord |
createRecord(Map<Integer,String> map,
ReadOnlyFileStorage.FileInfo logFileInfo) |
int |
getSize()
Get the size of storage (in records)
|
int |
load(List<LogRecord> list,
SearchCondition<LogRecord> condition,
int pageNumber,
int pageSize)
Read the records and load them into a provided list
|
protected LogRecord |
readRecord(ReadOnlyFileStorage.FileInfo logFileInfo) |
protected void |
readTheLine(RandomAccessFile logFile,
Map<Integer,String> map,
int columnIndex) |
void |
setColumnSep(String columnSep)
Log column separator such as '|'
|
void |
setColumnsMap(Map<Integer,String> columnsMap)
Identifies the columns which this reader should use
when creating a LogRecord.
|
void |
setFileNameComparator(Comparator<String> comp)
Optional comparator which can be used for sorting the
new log files found after the latest scan iteration.
|
void |
setFileNameDateFormat(String fileNameDateFormat)
Optional pattern for parsing the file date
|
void |
setFileNameDatePattern(String fileNameDatePattern)
Sets the regular expression for capturing the date from the file name
If set then it must contain a single capturing group only.
|
void |
setLevelsMap(Map<String,String> map)
Optional map for converting the levels.
|
void |
setLogLocation(String location)
Sets the log location.
|
void |
setLogLocations(List<String> locations)
A list of log files, the oldest files are expected to be in the top
of the list
|
protected void |
setLogRecordDate(LogRecord record,
String logDate,
ReadOnlyFileStorage.FileInfo logFileInfo) |
protected void |
setLogRecordLevel(LogRecord record,
String logLevel) |
void |
setNumberOfColumns(String number)
Sets the number of columns per record
|
void |
setRecordDateFormat(String format)
The format for parsing the log date
|
void |
setUseFileModifiedDate(boolean useFileModifiedDate)
Indicates if the file modified date needs to be used for
creating a LogRecord date - in case the actual log record
contains no year/month/hour information.
|
public static final String LEVEL_PROPERTY
public static final String DATE_PROPERTY
public static final String MESSAGE_PROPERTY
public static final String CATEGORY_PROPERTY
public static final String THREAD_PROPERTY
public static final String DATE_ONLY_FORMAT
public int getSize()
getSize in interface ReadableLogStoragepublic int load(List<LogRecord> list, SearchCondition<LogRecord> condition, int pageNumber, int pageSize)
load in interface ReadableLogStoragelist - the list saved records should be added tocondition - the condition loaded records must meet, can be nullpageNumber - the initial page to have records loaded fromprotected LogRecord readRecord(ReadOnlyFileStorage.FileInfo logFileInfo)
protected LogRecord createRecord(Map<Integer,String> map, ReadOnlyFileStorage.FileInfo logFileInfo)
protected void setLogRecordDate(LogRecord record, String logDate, ReadOnlyFileStorage.FileInfo logFileInfo)
protected void readTheLine(RandomAccessFile logFile, Map<Integer,String> map, int columnIndex) throws IOException
IOExceptionpublic void setColumnSep(String columnSep)
columnSep - the separatorpublic void setNumberOfColumns(String number)
number - the number of columns per recordpublic void setColumnsMap(Map<Integer,String> columnsMap)
columnsMap - the map, the key is the column number (starting from 1)
and the value is the name of the property such as 'message'.
The following properties are supported at the moment:
'date', 'level' 'category', 'thread', 'message'.public void setLogLocations(List<String> locations)
locations - the locationspublic void setLogLocation(String location)
location - the location, if it is a directory then
the on-demand scanning will be enabledpublic void setRecordDateFormat(String format)
Please see SimpleDateFormat
public void setLevelsMap(Map<String,String> map)
map - the map of levelspublic void setFileNameComparator(Comparator<String> comp)
comp - the comparatorpublic void close()
ReadableLogStorageclose in interface ReadableLogStoragepublic void setUseFileModifiedDate(boolean useFileModifiedDate)
public void setFileNameDatePattern(String fileNameDatePattern)
fileNameDatePattern - public void setFileNameDateFormat(String fileNameDateFormat)
fileNameDateFormat - Apache CXF