edu.isi.ikcap.workflows.util.logging

## Class EventLogMessage

- java.lang.Object
- - edu.isi.ikcap.workflows.util.logging.EventLogMessage

    public class EventLogMessage
    extends java.lang.Object

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

Author:
  Dan Gunter dkgunter@lbl.gov, Wolfgang Hoschek whoschek@lbl.gov, Paul Groth pgroth@isi.edu

### Nested Class Summary

Nested Classes
`private static class` `EventLogMessage.Log4jFilter` In log4j, ignore all messages not specifically directed at this appender.

### Field Summary

Fields
`static java.lang.String` `APPENDER`
`private java.lang.StringBuffer` `buf`
`private static java.util.GregorianCalendar` `calendar`
`static java.lang.String` `DATE_KW`
`private int` `dateEnd`
`private int` `dateStart`
`private static char[]` `DIGIT`
`private static Escape` `escape`
`static java.lang.String` `EVENT_KW`
`static java.lang.String` `FAKE_DATE`
`private static java.text.SimpleDateFormat` `format`
`static java.lang.String` `LEVEL_KW`
`private static long` `micro0`
`private static long` `micro1`
`private long` `micro2`
`private static long` `nano0`
`private static java.lang.String` `timeString`
`private static java.util.concurrent.locks.Lock` `timeStringLock`
`private int` `usecEnd`
`private int` `usecStart`

### Constructor Summary

Constructors
`protected` `EventLogMessage(java.lang.String eventName)` Create a new LogMessage at the current time with a given event name.

### Method Summary

All Methods Instance Methods Concrete Methods
`EventLogMessage` `add(java.lang.String key, double value)` Add a double.
`EventLogMessage` `add(java.lang.String key, float value)` Add a float.
`EventLogMessage` `add(java.lang.String key, int value)` Add an int.
`EventLogMessage` `add(java.lang.String key, long value)` Add a long.
`EventLogMessage` `add(java.lang.String key, java.lang.String value)` Add a string.
`EventLogMessage` `addList(java.lang.String key, java.util.List list)`
`EventLogMessage` `addMap(java.lang.String key, java.util.Map map)` Add a Map to the buffer.
`EventLogMessage` `addMsg(java.lang.String msg)` Add an natural language message to the log message.
`EventLogMessage` `addPair(java.lang.String key, java.lang.String pairKey, java.lang.String pairValue)` Add a key,value pair The result looks like: key = (pairKey, pairValue)
`EventLogMessage` `addTime(java.lang.String key, long timeInMillis)`
`private void` `addTimeStamp()` Add a timestamp to the message.
`EventLogMessage` `addWQ(java.lang.String key, java.lang.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().
`java.lang.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

#### buf

    private final java.lang.StringBuffer buf

#### micro0

    private static long micro0

#### nano0

    private static long nano0

#### micro1

    private static long micro1

#### micro2

    private long micro2

#### timeString

    private static java.lang.String timeString

#### format

    private static java.text.SimpleDateFormat format

#### calendar

    private static final java.util.GregorianCalendar calendar

#### timeStringLock

    private static java.util.concurrent.locks.Lock timeStringLock

#### APPENDER

    public static final java.lang.String APPENDER

See Also:
  Constant Field Values

#### EVENT_KW

    public static final java.lang.String EVENT_KW

See Also:
  Constant Field Values

#### DATE_KW

    public static final java.lang.String DATE_KW

See Also:
  Constant Field Values

#### FAKE_DATE

    public static final java.lang.String FAKE_DATE

See Also:
  Constant Field Values

#### dateStart

    private final int dateStart

#### dateEnd

    private final int dateEnd

#### usecStart

    private final int usecStart

#### usecEnd

    private final int usecEnd

#### LEVEL_KW

    public static final java.lang.String LEVEL_KW

See Also:
  Constant Field Values

#### DIGIT

    private static final char[] DIGIT

#### escape

    private static Escape escape

### Constructor Detail

#### EventLogMessage

    protected EventLogMessage(java.lang.String eventName)

Create a new LogMessage at the current time with a given event name. The timestamp is set at creation time, but can be changed later with `setTimeStampMillis` or `setTimeStampNanos`.

Parameters:
  `eventName` - Name of this logging event.
See Also:
  `setTimeStampMillis(long)`, `setTimeStampNanos(long)`

### Method Detail

#### add

    public EventLogMessage add(java.lang.String key,
                               java.lang.String value)

Add a string.

Returns:
  Self-reference, so calls can be chained

#### addWQ

    public EventLogMessage addWQ(java.lang.String key,
                                 java.lang.String value)

Add a string. Strings automatically have quotes around them and are escaped

Returns:
  Self-reference, so calls can be chained

#### add

    public EventLogMessage add(java.lang.String key,
                               int value)

Add an int.

Returns:
  Self-reference, so calls can be chained

#### add

    public EventLogMessage add(java.lang.String key,
                               long value)

Add a long.

Returns:
  Self-reference, so calls can be chained

#### add

    public EventLogMessage add(java.lang.String key,
                               float value)

Add a float.

Returns:
  Self-reference, so calls can be chained

#### add

    public EventLogMessage add(java.lang.String key,
                               double value)

Add a double.

Returns:
  Self-reference, so calls can be chained

#### addPair

    public EventLogMessage addPair(java.lang.String key,
                                   java.lang.String pairKey,
                                   java.lang.String pairValue)

Add a key,value pair The result looks like: key = (pairKey, pairValue)

Parameters:
  `key` -
  `pairKey` -
  `pairValue` -

#### addTime

    public EventLogMessage addTime(java.lang.String key,
                                   long timeInMillis)

#### addMap

    public EventLogMessage addMap(java.lang.String key,
                                  java.util.Map map)

Add a Map to the buffer. Represents maps as a series of (key, value) in quotes. The method assumes that both keys and values toString method returns a "nice" string representation. The method escapes all quotes

Parameters:
  `key` -
  `map` -
Returns:

#### addList

    public EventLogMessage addList(java.lang.String key,
                                   java.util.List list)

#### addMsg

    public EventLogMessage addMsg(java.lang.String msg)

Add an natural language message to the log message. The string is put in quotes and is escaped

Parameters:
  `msg` -
Returns:

#### setTimeStampMillis

    public EventLogMessage setTimeStampMillis(long millis)

Set the timestamp from milliseconds returned by System.currentTimeMillis().

Returns:
  'this' so we can chain

#### setTimeStampNanos

    public EventLogMessage setTimeStampNanos(long nano1)

Set the timestamp from nanoseconds returned by System.nanoTime().

Returns:
  'this' so we can chain

#### toString

    public java.lang.String toString()

Format a message in CEDPS Best Practices format.

Overrides:
  `toString` in class `java.lang.Object`
Returns:
  Formatted message string
See Also:
  CEDPS "Best Practices" format

#### addTimeStamp

    private void addTimeStamp()

Add a timestamp to the message.