public class LogParser extends PropertyContainer
| Modifier and Type | Class and Description |
|---|---|
static class |
LogParser.Tail
Test reading from a remote host.
|
| Modifier and Type | Field and Description |
|---|---|
static DateFormat |
DEFDATEFORMAT
Default property value.
|
private static boolean |
DEFHASHOST
Default property value.
|
static String |
KEY_DATEFORMAT
The date format used in the log.
|
static String |
KEY_HASHOST
If true, a host name follows the log level.
|
KEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATORCONFIG, KEY_CLASS| Constructor and Description |
|---|
LogParser(Map<String,String> prop)
Constructs a new log parser.
|
| Modifier and Type | Method and Description |
|---|---|
static List<LogLine> |
dateFilter(List<LogLine> log,
Date start,
Date end)
Filters the log levels from starting to ending date, inclusevely on both
edges.
|
static List<LogLine> |
dateFilter(List<LogLine> log,
Date start,
Date end,
boolean inv)
Filters the log levels from starting to ending date, inclusevely on both
edges.
|
static List<LogLine> |
dateFilter(List<LogLine> log,
Date start,
long ms)
Returns a date-filtered list starting from the stated date and spanning
for the indicated length in ms.
|
static List<LogLine> |
dateFilter(List<LogLine> log,
Date start,
long ms,
boolean inv)
Returns a date-filtered list starting from the stated date and spanning
for the indicated length in ms.
|
static List<LogLine> |
dateFilter(List<LogLine> log,
long ms,
Date end)
Returns a date-filtered list ending at the stated date and spanning
previously for the indicated length in ms.
|
static List<LogLine> |
dateFilter(List<LogLine> log,
long ms,
Date end,
boolean inv)
Returns a date-filtered list ending at the stated date and spanning
previously for the indicated length in ms.
|
static List<LogLine> |
levelFilter(List<LogLine> log,
int level)
Filters the list of log lines to contain only the requested levels.
|
List<LogLine> |
read(InputStream f)
Parses a log file to a list of logline objects, from an input stream.
|
List<LogLine> |
read(InputStream f,
boolean head)
Parses a log file to a list of logline objects.
|
List<LogLine> |
readFile(File f)
Parses a log file to a list of logline objects.
|
List<LogLine> |
readFile(File f,
boolean head)
Parses a log file to a list of logline objects.
|
List<LogLine> |
readList(List<String> lines,
boolean head)
Parses a log file to a list of logline objects.
|
static List<LogLine> |
readTail(File f,
int n,
boolean head,
DateFormat df,
boolean host)
Reads log line as tail from a (big) input file.
|
static List<LogLine> |
sshTail(String userhost,
File f,
int n,
boolean head,
DateFormat df,
boolean host)
Reads a log line from a remote host using ssh tail command.
|
augment, augment, augment, augment, augment, clone, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, initProperties, isNew, parseObject, parseObject, reload, reload, removeProperty, requires, rescanned, setObject, setProperties, setProperty, stringProperties, toStringpublic static final String KEY_DATEFORMAT
public static final String KEY_HASHOST
public static final DateFormat DEFDATEFORMAT
private static final boolean DEFHASHOST
public List<LogLine> read(InputStream f) throws ParseException
ParseExceptionpublic List<LogLine> read(InputStream f, boolean head) throws ParseException
ParseExceptionpublic List<LogLine> readFile(File f) throws ParseException
ParseExceptionpublic List<LogLine> readFile(File f, boolean head) throws ParseException
ParseExceptionpublic List<LogLine> readList(List<String> lines, boolean head) throws ParseException
ParseExceptionpublic static List<LogLine> levelFilter(List<LogLine> log, int level)
The argumental list is not altered by this method.
public static List<LogLine> dateFilter(List<LogLine> log, long ms, Date end)
public static List<LogLine> dateFilter(List<LogLine> log, long ms, Date end, boolean inv)
public static List<LogLine> dateFilter(List<LogLine> log, Date start, long ms)
public static List<LogLine> dateFilter(List<LogLine> log, Date start, long ms, boolean inv)
public static List<LogLine> dateFilter(List<LogLine> log, Date start, Date end)
start - The minimum date or null for any.end - The maximum date or null for any.public static List<LogLine> dateFilter(List<LogLine> log, Date start, Date end, boolean inv)
start - The minimum date or null for any.end - The maximum date or null for any.inv - If true, exclude all logs in the range.public static List<LogLine> readTail(File f, int n, boolean head, DateFormat df, boolean host) throws ParseException, IOException
ParseExceptionIOExceptionpublic static List<LogLine> sshTail(String userhost, File f, int n, boolean head, DateFormat df, boolean host) throws ParseException, IOException
userhost - user and host in form 'user@host'f - Name of the remote file to tailn - number of tail lines, 0 for defaulthead - If true, only main lines are recordeddf - The date format in the file or null if defaulthost - If false, log file does not contain host information. Defaults
to trueParseExceptionIOException