edu.isi.pegasus.common.logging.format
Class AbstractLogFormatter

java.lang.Object
  extended by edu.isi.pegasus.common.logging.format.AbstractLogFormatter
All Implemented Interfaces:
LogFormatter
Direct Known Subclasses:
Netlogger, Simple

public abstract class AbstractLogFormatter
extends Object
implements LogFormatter

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

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

Field Summary
private static String DEFAULT_KEY
          The default key to use for logging messages
protected  String mProgram
          The name of the program.
protected  Stack<Event> mStack
          The Stack of event objects maintained internally
 
Constructor Summary
AbstractLogFormatter()
          The default constructor.
 
Method Summary
 LogFormatter add(String value)
          Add to the log message with just a value.
 LogFormatter add(String key, String value)
          Add to the log message for the event on the top.
abstract  void addEvent(String name, String entityName, String entityID)
          Adds the event that is to be associated with the log messages onto an internal stack
 String createEntityHierarchyMessage(String parentType, String parentID, String childIdType, Collection<String> childIDs)
          Creates a log message that connects the parent entities with the children.
 String createLogMessage()
          Creates a log message with the contents of the internal log buffer.
 String createLogMessageAndReset()
          Creates a log message with the contents of the internal log buffer.
 String getEndEventMessage()
          Creates the end message for the event on top of the stack.
 String getEventName()
          Returns the name of event that is currently associated with the log messages and is on the top of the stack
 String getProgramName(String name)
          Returns the program name for the software whose log statement are logged.
 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(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 String DEFAULT_KEY
The default key to use for logging messages


mProgram

protected String mProgram
The name of the program.


mStack

protected Stack<Event> mStack
The Stack of event objects maintained internally

Constructor Detail

AbstractLogFormatter

public AbstractLogFormatter()
The default constructor.

Method Detail

setProgramName

public void setProgramName(String name)
Sets the program name for the software whose log statement are logged.

Specified by:
setProgramName in interface LogFormatter
Parameters:
name -

getProgramName

public String getProgramName(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(String name,
                              String entityName,
                              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 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 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 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(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(String key,
                        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 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 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 String createEntityHierarchyMessage(String parentType,
                                           String parentID,
                                           String childIdType,
                                           Collection<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


Copyright © 2011 The University of Southern California. All Rights Reserved.