Class AbstractLogFormatter
- java.lang.Object
-
- edu.isi.pegasus.common.logging.format.AbstractLogFormatter
-
- All Implemented Interfaces:
LogFormatter
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 Modifier and Type Field Description private static java.lang.String
DEFAULT_KEY
The default key to use for logging messagesprotected 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 Description AbstractLogFormatter()
The default constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description 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 stackjava.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 stackjava.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 stackEvent
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
-
-
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 interfaceLogFormatter
- 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 interfaceLogFormatter
- 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 interfaceLogFormatter
- Parameters:
name
- the name of the event to be associatedentityName
- the primary entity that is associated with the event e.g. workflowentityID
- the id of that entity.
-
popEvent
public Event popEvent()
Pop the event on top of the internal stack.- Specified by:
popEvent
in interfaceLogFormatter
- 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 interfaceLogFormatter
- 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 interfaceLogFormatter
- 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 interfaceLogFormatter
- 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 interfaceLogFormatter
- 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 interfaceLogFormatter
- 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 interfaceLogFormatter
- 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 interfaceLogFormatter
- 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 interfaceLogFormatter
- Parameters:
parentType
- the type of parent entityparentID
- the id of the parent entitychildIdType
- the type of children entitieschildIDs
- Collection of children id's- Returns:
- the entity hierarchy message
-
-