|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.isi.ikcap.workflows.util.logging.EventLogMessage
public class EventLogMessage
This is a modification of gov.lbl.netlogger.LogMessage This class lets you easily construct a set of typed (name, value) pairs that formats itself as a CEDPS Best Practices log message.
Name and value pairs are added into the record with add() methods which, by virtue of returning the newly modified LogMessage instance, can be chained together.
The user can set the timestamp to something other than the time of the call by calling setTimeStamp{Millis,Nanos}() as part of the chain.
To format the message, call toString(). The output format is CEDPS "Best Practices" format.
Since the addition of the nanosecond timestamp (which is rounded down to microseconds, and no I don't want to discuss it), this class requires Java 1.5
| Nested Class Summary | |
|---|---|
private static class |
EventLogMessage.Log4jFilter
In log4j, ignore all messages not specifically directed at this appender. |
| Field Summary | |
|---|---|
static String |
APPENDER
|
private StringBuffer |
buf
|
private static GregorianCalendar |
calendar
|
static String |
DATE_KW
|
private int |
dateEnd
|
private int |
dateStart
|
private static char[] |
DIGIT
|
private static Escape |
escape
|
static String |
EVENT_KW
|
static String |
FAKE_DATE
|
private static SimpleDateFormat |
format
|
static String |
LEVEL_KW
|
private static long |
micro0
|
private static long |
micro1
|
private long |
micro2
|
private static long |
nano0
|
private static String |
timeString
|
private static Lock |
timeStringLock
|
private int |
usecEnd
|
private int |
usecStart
|
| Constructor Summary | |
|---|---|
protected |
EventLogMessage(String eventName)
Create a new LogMessage at the current time with a given event name. |
| Method Summary | |
|---|---|
EventLogMessage |
add(String key,
double value)
Add a double. |
EventLogMessage |
add(String key,
float value)
Add a float. |
EventLogMessage |
add(String key,
int value)
Add an int. |
EventLogMessage |
add(String key,
long value)
Add a long. |
EventLogMessage |
add(String key,
String value)
Add a string. |
EventLogMessage |
addList(String key,
List list)
|
EventLogMessage |
addMap(String key,
Map map)
Add a Map to the buffer. |
EventLogMessage |
addMsg(String msg)
Add an natural language message to the log message. |
EventLogMessage |
addPair(String key,
String pairKey,
String pairValue)
Add a key,value pair The result looks like: key = (pairKey, pairValue) |
EventLogMessage |
addTime(String key,
long timeInMillis)
|
private void |
addTimeStamp()
Add a timestamp to the message. |
EventLogMessage |
addWQ(String key,
String value)
Add a string. |
EventLogMessage |
setTimeStampMillis(long millis)
Set the timestamp from milliseconds returned by System.currentTimeMillis(). |
EventLogMessage |
setTimeStampNanos(long nano1)
Set the timestamp from nanoseconds returned by System.nanoTime(). |
String |
toString()
Format a message in CEDPS Best Practices format. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private final StringBuffer buf
private static long micro0
private static long nano0
private static long micro1
private long micro2
private static String timeString
private static SimpleDateFormat format
private static final GregorianCalendar calendar
private static Lock timeStringLock
public static final String APPENDER
public static final String EVENT_KW
public static final String DATE_KW
public static final String FAKE_DATE
private final int dateStart
private final int dateEnd
private final int usecStart
private final int usecEnd
public static final String LEVEL_KW
private static final char[] DIGIT
private static Escape escape
| Constructor Detail |
|---|
protected EventLogMessage(String eventName)
setTimeStampMillis or setTimeStampNanos.
eventName - Name of this logging event.setTimeStampMillis(long),
setTimeStampNanos(long)| Method Detail |
|---|
public EventLogMessage add(String key,
String value)
public EventLogMessage addWQ(String key,
String value)
public EventLogMessage add(String key,
int value)
public EventLogMessage add(String key,
long value)
public EventLogMessage add(String key,
float value)
public EventLogMessage add(String key,
double value)
public EventLogMessage addPair(String key,
String pairKey,
String pairValue)
key - pairKey - pairValue -
public EventLogMessage addTime(String key,
long timeInMillis)
public EventLogMessage addMap(String key,
Map map)
key - map -
public EventLogMessage addList(String key,
List list)
public EventLogMessage addMsg(String msg)
msg -
public EventLogMessage setTimeStampMillis(long millis)
public EventLogMessage setTimeStampNanos(long nano1)
public String toString()
toString in class Objectprivate void addTimeStamp()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||