|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectstella.log.LogLine
public class LogLine
Convenience class to hold a log line produced by protomatter. The log line has a format like, where ? means optional
date [level] ?[channel] ?host ?T:threadname loggerclass?.method()?:line message
?some more lines
As the host cannot easily be separated from the rest of the log line, we have
to indicate wether hosts are used. Updated 29-03-2012 to work with new
Syslog class, in particular ProtomatterFormat.
| Field Summary | |
|---|---|
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 Summary | |
|---|---|
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. |
|
| Method Summary | |
|---|---|
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final List<String> LOGLEVEL
public static final char LOGLEVELSTART
public static final char LOGLEVELEND
public static final String THREADNAME
private Date date
private 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
| Constructor Detail |
|---|
public LogLine(String line,
DateFormat df,
boolean host)
throws ParseException
ParseException
public LogLine(String line,
String[] ext,
DateFormat df,
boolean hashost)
throws ParseException
ParseException| Method Detail |
|---|
public void setMultiline(String[] ext)
public int hashCode()
hashCode in class Objectpublic 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.
toString in class Object
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)
private static final String extractRemainder(String line)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||