edu.isi.pegasus.common.logging.format

## Class AbstractLogFormatter

- java.lang.Object
- - edu.isi.pegasus.common.logging.format.AbstractLogFormatter

All Implemented Interfaces:
  LogFormatter

Direct Known Subclasses:
  Netlogger, Simple

    public abstract class AbstractLogFormatter
    extends java.lang.Object
    implements LogFormatter

The abstract formatter that implements all of the functions except the addEvent function

Version:
  $Revision$
Author:
  Karan Vahi, Gaurang Mehta

### Field Summary

Fields
`private static java.lang.String` `DEFAULT_KEY` The default key to use for logging messages
`protected java.lang.String` `mProgram` The name of the program.
`protected java.util.Stack<Event>` `mStack` The Stack of event objects maintained internally

### Constructor Summary

Constructors
Constructor and Description
`AbstractLogFormatter()` The default constructor.

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`LogFormatter` `add(java.lang.String value)` Add to the log message with just a value.
`LogFormatter` `add(java.lang.String key, java.lang.String value)` Add to the log message for the event on the top.
`abstract void` `addEvent(java.lang.String name, java.lang.String entityName, java.lang.String entityID)` Adds the event that is to be associated with the log messages onto an internal stack
`java.lang.String` `createEntityHierarchyMessage(java.lang.String parentType, java.lang.String parentID, java.lang.String childIdType, java.util.Collection<java.lang.String> childIDs)` Creates a log message that connects the parent entities with the children.
`java.lang.String` `createLogMessage()` Creates a log message with the contents of the internal log buffer.
`java.lang.String` `createLogMessageAndReset()` Creates a log message with the contents of the internal log buffer.
`java.lang.String` `getEndEventMessage()` Creates the end message for the event on top of the stack.
`java.lang.String` `getEventName()` Returns the name of event that is currently associated with the log messages and is on the top of the stack
`java.lang.String` `getProgramName(java.lang.String name)` Returns the program name for the software whose log statement are logged.
`java.lang.String` `getStartEventMessage()` Creates the start message for the event on top of the internal stack
`Event` `popEvent()` Pop the event on top of the internal stack.
`void` `setProgramName(java.lang.String name)` Sets the program name for the software whose log statement are logged.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface edu.isi.pegasus.common.logging.LogFormatter

`addEvent`

### Field Detail

#### DEFAULT_KEY

    private static java.lang.String DEFAULT_KEY

The default key to use for logging messages

#### mProgram

    protected java.lang.String mProgram

The name of the program.

#### mStack

    protected java.util.Stack<Event> mStack

The Stack of event objects maintained internally

### Constructor Detail

#### AbstractLogFormatter

    public AbstractLogFormatter()

The default constructor.

### Method Detail

#### setProgramName

    public void setProgramName(java.lang.String name)

Sets the program name for the software whose log statement are logged.

Specified by:
  `setProgramName` in interface `LogFormatter`
Parameters:
  `name` -

#### getProgramName

    public java.lang.String getProgramName(java.lang.String name)

Returns the program name for the software whose log statement are logged.

Specified by:
  `getProgramName` in interface `LogFormatter`
Parameters:
  `name` -
Returns:
  name of the program

#### addEvent

    public abstract void addEvent(java.lang.String name,
                                  java.lang.String entityName,
                                  java.lang.String entityID)

Adds the event that is to be associated with the log messages onto an internal stack

Specified by:
  `addEvent` in interface `LogFormatter`
Parameters:
  `name` - the name of the event to be associated
  `entityName` - the primary entity that is associated with the event e.g. workflow
  `entityID` - the id of that entity.

#### popEvent

    public Event popEvent()

Pop the event on top of the internal stack.

Specified by:
  `popEvent` in interface `LogFormatter`
Returns:
  event on top , else null

#### getEventName

    public java.lang.String getEventName()

Returns the name of event that is currently associated with the log messages and is on the top of the stack

Specified by:
  `getEventName` in interface `LogFormatter`
Returns:
  name of the event.

#### getStartEventMessage

    public java.lang.String getStartEventMessage()

Creates the start message for the event on top of the internal stack

Specified by:
  `getStartEventMessage` in interface `LogFormatter`
Returns:
  start event message

#### getEndEventMessage

    public java.lang.String getEndEventMessage()

Creates the end message for the event on top of the stack.

Specified by:
  `getEndEventMessage` in interface `LogFormatter`
Returns:
  end event message

#### add

    public LogFormatter add(java.lang.String value)

Add to the log message with just a value.

Specified by:
  `add` in interface `LogFormatter`
Parameters:
  `value` -
Returns:
  self-reference

#### add

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

Add to the log message for the event on the top.

Specified by:
  `add` in interface `LogFormatter`
Parameters:
  `key` -
  `value` -
Returns:
  Self-reference, so calls can be chained

#### createLogMessage

    public java.lang.String createLogMessage()

Creates a log message with the contents of the internal log buffer.

Specified by:
  `createLogMessage` in interface `LogFormatter`
Returns:
  the log message

#### createLogMessageAndReset

    public java.lang.String createLogMessageAndReset()

Creates a log message with the contents of the internal log buffer. It then resets the buffer before returning the log message

Specified by:
  `createLogMessageAndReset` in interface `LogFormatter`
Returns:
  log message.

#### createEntityHierarchyMessage

    public java.lang.String createEntityHierarchyMessage(java.lang.String parentType,
                                                         java.lang.String parentID,
                                                         java.lang.String childIdType,
                                                         java.util.Collection<java.lang.String> childIDs)

Creates a log message that connects the parent entities with the children. For e.g. can we use to create the log messages connecting the jobs with the workflow they are part of.

Specified by:
  `createEntityHierarchyMessage` in interface `LogFormatter`
Parameters:
  `parentType` - the type of parent entity
  `parentID` - the id of the parent entity
  `childIdType` - the type of children entities
  `childIDs` - Collection of children id's
Returns:
  the entity hierarchy message