edu.isi.pegasus.common.logging
public abstract class LogManager extends Object
Eventually, each of the level can have a different writer stream underneath.
The messages can be logged at various levels. The various levels of logging with increasing levels of verbosity are displayed in the following table.
Logging Level | Description |
---|---|
FATAL | all fatal error messages are logged in this level. |
ERROR | all non fatal error messages are logged in this level. |
WARNING | all warning messages are logged in this level. |
INFO | all information logging messages are logged in this level. |
CONFIG | all configuration messages are logged in this level. |
DEBUG | all debug messages are logged in this level. |
Modifier and Type | Field and Description |
---|---|
static int |
CONFIG_MESSAGE_LEVEL
The level value, to indicate a CONFIG message.
|
static int |
CONSOLE_MESSAGE_LEVEL
The level value, to indicate a CONSOLE error message.
|
static int |
DEBUG_MESSAGE_LEVEL
The level value, to indicate a DEBUG message.
|
static String |
DEFAULT_LOGGER
The default Logger
|
static int |
ERROR_MESSAGE_LEVEL
The level value, to indicate an ERROR message.
|
static int |
FATAL_MESSAGE_LEVEL
The level value, to indicate a FATAL error message.
|
static int |
INFO_MESSAGE_LEVEL
The level value, to indicate a INFO message.
|
static String |
LOG4J_LOGGER
The Log4j logger.
|
protected int |
mDebugLevel
The debug level.
|
static String |
MESSAGE_DONE_PREFIX
Suffx for an event completion message.
|
protected LogFormatter |
mLogFormatter
The LogFormatter to use to format the message.
|
private static LogManager |
mLogger
Ensures only one object is created always.
|
static String |
PROPERTIES_PREFIX
Prefix for the property subset to use with the LogManager
|
static int |
TRACE_MESSAGE_LEVEL
The level value, to indicate a DEBUG message.
|
static String |
VERSION
The version of the Logging API
|
static int |
WARNING_MESSAGE_LEVEL
The level value, to indicate a WARNING error message.
|
Constructor and Description |
---|
LogManager()
The constructor.
|
Modifier and Type | Method and Description |
---|---|
LogManager |
add(String value)
Add to the internal log buffer message a value with the default key.
|
LogManager |
add(String key,
String value)
Add to the internal log buffer message a value with the key oassed
The buffer is logged later when the log() method is called.
|
static LogManager |
getInstance(String logger,
String formatter)
To get a reference to the the object.
|
abstract int |
getLevel()
Returns the debug level.
|
abstract void |
initialize(LogFormatter formatter,
Properties properties)
Sets the log formatter to use for formatting the messages.
|
void |
log(int level)
Log the message represented by the internal log buffer.
|
abstract void |
log(String message,
Exception e,
int level)
Logs the exception on the appropriate queue if the level of the message
is less than or equal to the level set for the Logger.
|
void |
log(String message,
int level)
Logs the message on the appropriate queue if the level of the message
is less than or equal to the level set for the Logger.
|
protected abstract void |
logAlreadyFormattedMessage(String message,
int level)
A stop gap function .
|
void |
logAndReset(int level)
Creates a log message with the contents of the internal log buffer.
|
void |
logEntityHierarchyMessage(String parentType,
String parentID,
String childIDType,
Collection<String> childIDs)
Log a message that connects the parent entities with the
children.
|
void |
logEntityHierarchyMessage(String parentType,
String parentID,
String childIDType,
Collection<String> childIDs,
int level)
Log a message that connects the parent entities with the
children.
|
void |
logEventCompletion()
Logs the completion message on the basis of the debug level.
|
abstract void |
logEventCompletion(int level)
Logs the completion message on the basis of the debug level.
|
void |
logEventStart(String name,
Map<String,String> map)
Log an event start message to the INFO Level
|
void |
logEventStart(String name,
Map<String,String> map,
int level)
Log an event start message.
|
void |
logEventStart(String name,
String entityName,
String entityID)
Log an event start message to INFO level
|
void |
logEventStart(String name,
String entityName,
String entityID,
int level)
Log an event start message.
|
protected static void |
sanityCheckOnDirectory(File dir)
Checks the destination location for existence, if it can
be created, if it is writable etc.
|
protected static void |
sanityCheckOnFile(File file)
Checks the destination location for existence, if it can
be created, if it is writable etc.
|
void |
setLevel(int level)
Sets the debug level.
|
protected abstract void |
setLevel(int level,
boolean info)
Sets the debug level.
|
void |
setLevel(org.apache.log4j.Level level)
Sets the debug level.
|
abstract void |
setWriters(String out)
Sets both the output writer and the error writer to the same
underlying writer.
|
public static final String VERSION
public static final String PROPERTIES_PREFIX
public static final String MESSAGE_DONE_PREFIX
public static final int FATAL_MESSAGE_LEVEL
public static final int ERROR_MESSAGE_LEVEL
public static final int CONSOLE_MESSAGE_LEVEL
public static final int WARNING_MESSAGE_LEVEL
public static final int INFO_MESSAGE_LEVEL
public static final int CONFIG_MESSAGE_LEVEL
public static final int DEBUG_MESSAGE_LEVEL
public static final int TRACE_MESSAGE_LEVEL
private static LogManager mLogger
public static final String DEFAULT_LOGGER
public static final String LOG4J_LOGGER
protected int mDebugLevel
protected LogFormatter mLogFormatter
public static LogManager getInstance(String logger, String formatter)
logger
- the logger to use for loggingformatter
- the log formatter to use for formatting messagespublic abstract void initialize(LogFormatter formatter, Properties properties)
formatter
- the formatter to use.properties
- properties that the underlying implementations understandprotected static void sanityCheckOnFile(File file) throws IOException
file
- is the file to write out to.IOException
- in case of error while writing out files.protected static void sanityCheckOnDirectory(File dir) throws IOException
dir
- is the new base directory to optionally create.IOException
- in case of error while writing out files.public void setLevel(org.apache.log4j.Level level)
level
- the level to which the debug level needs to be set to.public void setLevel(int level)
level
- the level to which the debug level needs to be set to.protected abstract void setLevel(int level, boolean info)
level
- the level to which the debug level needs to be set to.info
- boolean denoting whether the CONSOLE messages need to be
logged or not.public abstract int getLevel()
public abstract void setWriters(String out)
out
- is the name of a file to append to. Special names are
stdout
and stderr
, which map to the
system's respective streams.public void log(int level)
level
- the level on which the message has to be logged.public void logAndReset(int level)
level
- the level on which the message has to be logged.public abstract void log(String message, Exception e, int level)
message
- the message to be logged.e
- the exception to be loggedlevel
- the level on which the message has to be logged.setLevel(int)
,
log(String,int)
protected abstract void logAlreadyFormattedMessage(String message, int level)
message
- already formatted messagelevel
- the level on which to log.public void log(String message, int level)
message
- the message to be logged.level
- the level on which the message has to be logged.setLevel(int)
public void logEventStart(String name, String entityName, String entityID)
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.public void logEventStart(String name, String entityName, String entityID, int level)
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.level
- the level at which event needs to be logged.public void logEventStart(String name, Map<String,String> map)
name
- the name of the event to be associatedmap
- Map indexed by entity name . The values is corresponding
EntityIDpublic void logEventStart(String name, Map<String,String> map, int level)
name
- the name of the event to be associatedmap
- Map indexed by entity name . The values is corresponding
EntityIDlevel
- the level to log topublic void logEventCompletion()
public abstract void logEventCompletion(int level)
level
- the debug level of the start message for whose completion
you want.public void logEntityHierarchyMessage(String parentType, String parentID, String childIDType, Collection<String> childIDs)
parentType
- the type of parent entityparentID
- the id of the parent entitychildIDType
- the type of children entitieschildIDs
- Collection of children id'spublic void logEntityHierarchyMessage(String parentType, String parentID, String childIDType, Collection<String> childIDs, int level)
parentType
- the type of parent entityparentID
- the id of the parent entitychildIDType
- the type of children entitieschildIDs
- Collection of children id'slevel
- the logging level.public LogManager add(String value)
value
- public LogManager add(String key, String value)
key
- value
-