public class LogLine extends Object implements Comparable<LogLine>
date [level] ?[channel] ?host ?T:threadname loggerclass?.method()?:line message ?some more linesExample:
Syslog class, in
particular ProtomatterFormat.| Modifier and Type | Field and Description |
|---|---|
private String |
channel
If we have a channel, this is it.
|
private String |
classname
The class that called the logger, without package.
|
private Date |
date
The date parsed from the log line.
|
private String |
host
The host name, if applicabale.
|
private int |
level
The log level, one of the five Syslog levels as an int.
|
private int |
linenr
If we have a line number, zero for none.
|
static List<String> |
LOGLEVEL
No public access to the Syslog log strings, thus repeat here.
|
static char |
LOGLEVELEND
Char that marks the start of the log level indicator.
|
static char |
LOGLEVELSTART
Char that marks the start of the log level indicator.
|
private String |
message
The log message itself.
|
private String |
method
If the class is augmented with a method name.
|
private String[] |
multipart
For multi-part log messages.
|
private String |
thread
If we have a thread name, this is it.
|
static String |
THREADNAME
The string marking an thread-name start.
|
| Constructor and Description |
|---|
LogLine(String line,
DateFormat df,
boolean host)
Constructs a log line without a multipart extension.
|
LogLine(String line,
String[] ext,
DateFormat df,
boolean hashost)
Constructs a log line with a multi-part extension given as the following
lines after a valid log line.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(LogLine o)
Natural ordering according to date.
|
private static String |
extractDate(String line)
Cuts the first part of the log line, up to '[' and returns the trimmed
string.
|
private static String |
extractLevel(String line)
Returns the part of the line between '[' and ']', not including these
sparators.
|
private static String |
extractRemainder(String line)
Returns the part of the line between '[' and ']', not including these
sparators.
|
String |
getChannel()
Returns the channel.
|
String |
getClassname()
Returns the logging class name.
|
Date |
getDate()
Returns the date.
|
String |
getHost()
Returns the host name.
|
int |
getLevel()
Returns the level.
|
String |
getLevelString()
Returns the level.
|
int |
getLineNumber()
Returns the line number.
|
String |
getMessage()
Returns the message part.
|
String |
getMethod()
Returns the method.
|
String[] |
getMultiline()
Returns the multi line part of the log message or null, if there isn't
any.
|
String |
getThread()
Returns the thread name.
|
long |
getTimelag(LogLine that)
Returns the time lag between this log line and the argument, which is
negative if the argument is after this.
|
int |
hashCode()
The hash is the hash of the date.
|
boolean |
isMultiline()
Tests, if the log-line has a multiline extension.
|
static boolean |
isRegular(String line,
DateFormat df)
Returns true, if this line is a regular log line.
|
void |
setMultiline(String[] ext)
Sets the multiline part of the log line.
|
String |
toLogLine(DateFormat df,
boolean showlevel,
boolean showchannel,
boolean showhost,
boolean showthread,
boolean showclass,
boolean showmethod,
boolean showmessage,
boolean showextend)
Converts the log line to s astring using the specified date format.
|
String |
toString()
Converts to a compact version with a single space separator between
items.
|
String |
toString(DateFormat df)
Converts to a compact version with a single space separator between
items.
|
public static final List<String> LOGLEVEL
public static final char LOGLEVELSTART
public static final char LOGLEVELEND
public static final String THREADNAME
private final Date date
private final int level
private String channel
private String host
private String thread
private String classname
private String method
private int linenr
private String message
private String[] multipart
public LogLine(String line, DateFormat df, boolean host) throws ParseException
ParseExceptionpublic LogLine(String line, String[] ext, DateFormat df, boolean hashost) throws ParseException
ParseExceptionpublic void setMultiline(String[] ext)
public int hashCode()
public Date getDate()
public int getLevel()
public String getLevelString()
public String getChannel()
public String getClassname()
public String getMethod()
public int getLineNumber()
public String getThread()
public String getHost()
public String getMessage()
public boolean isMultiline()
public String[] getMultiline()
public int compareTo(LogLine o)
compareTo in interface Comparable<LogLine>public String toString()
For converting this log-line using a different date
format than the default one, use the toLogLine(java.text.DateFormat, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean) method instead.
public String toString(DateFormat df)
For converting this log-line using a different date
format than the default one, use the toLogLine(java.text.DateFormat, boolean, boolean, boolean, boolean, boolean, boolean, boolean, boolean) method instead.
public String toLogLine(DateFormat df, boolean showlevel, boolean showchannel, boolean showhost, boolean showthread, boolean showclass, boolean showmethod, boolean showmessage, boolean showextend)
public long getTimelag(LogLine that)
public static boolean isRegular(String line, DateFormat df)
private static final String extractDate(String line)
private static final String extractLevel(String line)