edu.isi.pegasus.common.logging.logger
public class Default extends LogManager
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 |
---|---|
private static int |
CONFIG_MESSAGE_TYPE
The type value to indicate a CONFIG message.
|
private static int |
CONSOLE_MESSAGE_TYPE
The type value to indicate a CONSOLE message.
|
private static int |
DEBUG_MESSAGE_TYPE
The type value to indicate a DEBUG message.
|
private static int |
ERROR_MESSAGE_TYPE
The type value to indicate an ERROR message.
|
private static int |
FATAL_MESSAGE_TYPE
The type value to indicate a FATAL error message.
|
private static int |
INFO_MESSAGE_TYPE
The type value to indicate an INFORMATIVE message.
|
private static Default |
logger
Ensures only one object is created always.
|
private PrintStream |
mErrStream
The stream to which all the error messages are logged.By default it is
System.err
|
private static Currently |
mFormatter
This is used to format the time stamp.
|
private int |
mMask
The mask that needs to be deployed to determine what messages are to be
logged.
|
private PrintStream |
mOutStream
The stream to which one writes.
|
private static int |
TRACE_MESSAGE_TYPE
The type value to indicate a DEBUG message.
|
private static int |
WARNING_MESSAGE_TYPE
The type value to indicate a WARNING message.
|
CONFIG_MESSAGE_LEVEL, CONSOLE_MESSAGE_LEVEL, DEBUG_MESSAGE_LEVEL, DEFAULT_LOGGER, ERROR_MESSAGE_LEVEL, FATAL_MESSAGE_LEVEL, INFO_MESSAGE_LEVEL, LOG4J_LOGGER, mDebugLevel, MESSAGE_DONE_PREFIX, mLogFormatter, PROPERTIES_PREFIX, TRACE_MESSAGE_LEVEL, VERSION, WARNING_MESSAGE_LEVEL
Constructor and Description |
---|
Default()
The constructor.
|
Modifier and Type | Method and Description |
---|---|
private int |
generateMask(int level,
boolean info)
Generates the appropriate mask value, corresponding to the level
passed.
|
int |
getLevel()
Returns the debug level.
|
private String |
getPrefix(int type)
Returns the prefix that needs to be logged corresponding to a particular
message type, when a message is being logged.
|
private PrintStream |
getPrintStream(int level)
Returns a PrintWriter stream on which to log the message.
|
private PrintStream |
getPrintStream(String out)
Sets an internal writer to point to a particular stream.
|
String |
getTimeStamp()
Gets the timestamp nicely formatted.
|
void |
initialize(LogFormatter formatter,
Properties properties)
Sets the log formatter to use for formatting the messages.
|
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.
|
private void |
log(String message,
int level,
boolean comp)
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.
|
void |
logAlreadyFormattedMessage(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.
|
void |
logEventCompletion(int level)
Logs the completion message on the basis of the debug level.
|
void |
setErrorWriter(OutputStream err)
Certains levels like FATAL, ERROR and WARN can be set to log to a
different stream, than the default stream used for writing other messages.
|
void |
setErrorWriter(String out)
Certains levels like FATAL, ERROR and WARN can be set to log to a
different stream, than the default stream used for writing other messages.
|
void |
setLevel(int level)
Sets the debug level.
|
protected void |
setLevel(int level,
boolean info)
Sets the debug level.
|
void |
setLevel(org.apache.log4j.Level level)
Sets the debug level.
|
void |
setOutputWriter(OutputStream out)
Sets the writer associated with the class to the one specified for all
type of messages other than error messages.
|
void |
setOutputWriter(String out)
Sets the writer associated with the class to the one specified for all
type of messages other than error messages.
|
void |
setWriters(String out)
Sets both the output writer and the error writer to the same
underlying writer.
|
add, add, getInstance, log, log, logAndReset, logEntityHierarchyMessage, logEntityHierarchyMessage, logEventCompletion, logEventStart, logEventStart, logEventStart, logEventStart, sanityCheckOnDirectory, sanityCheckOnFile
private static final int FATAL_MESSAGE_TYPE
private static final int ERROR_MESSAGE_TYPE
private static final int CONSOLE_MESSAGE_TYPE
private static final int WARNING_MESSAGE_TYPE
private static final int INFO_MESSAGE_TYPE
private static final int CONFIG_MESSAGE_TYPE
private static final int DEBUG_MESSAGE_TYPE
private static final int TRACE_MESSAGE_TYPE
private static Default logger
private PrintStream mOutStream
setOutputWriter(java.lang.String)
private PrintStream mErrStream
private int mMask
private static Currently mFormatter
public void initialize(LogFormatter formatter, Properties properties)
initialize
in class LogManager
formatter
- the formatter to use.properties
- properties that the underlying implementations understandpublic void setLevel(org.apache.log4j.Level level)
setLevel
in class LogManager
level
- the level to which the debug level needs to be set to.public void setLevel(int level)
setLevel
in class LogManager
level
- the level to which the debug level needs to be set to.protected void setLevel(int level, boolean info)
setLevel
in class LogManager
level
- the level to which the debug level needs to be set to.info
- boolean denoting whether the INFO messages need to be
logged or not.public int getLevel()
getLevel
in class LogManager
public void setWriters(String out)
setWriters
in class LogManager
out
- is the name of a file to append to. Special names are
stdout
and stderr
, which map to the
system's respective streams.#setWriters(OutputStream)
public void setOutputWriter(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.setOutputWriter(OutputStream)
public void setOutputWriter(OutputStream out)
out
- the stream to which the messages are logged.setErrorWriter(OutputStream)
public void setErrorWriter(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.setErrorWriter(OutputStream)
public void setErrorWriter(OutputStream err)
err
- the stream to which error messages are to be logged.public void log(String message, Exception e, int level)
log
in class LogManager
message
- the message to be logged.e
- the exception to be loggedlevel
- the level on which the message has to be logged.setLevel(int)
,
LogManager.log(String,int)
public void logAlreadyFormattedMessage(String message, int level)
logAlreadyFormattedMessage
in class LogManager
message
- the message to be logged.level
- the level on which the message has to be logged.setLevel(int)
,
log(String,int,boolean)
private void log(String message, int level, boolean comp)
message
- the message to be logged.level
- the level on which the message has to be logged.comp
- boolean indicating whether a completion message
follows or not.setLevel(int)
public String getTimeStamp()
public void logEventCompletion(int level)
logEventCompletion
in class LogManager
level
- the debug level of the start message for whose completion
you want.private int generateMask(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.private String getPrefix(int type)
type
- the type for which prefix is required.private PrintStream getPrintStream(String out) throws IOException
out
- is the name of a file to append to. Special names are
stdout
and stderr
, which map to the
system's respective streams.IOException
- in case of being unable to open a stream.private PrintStream getPrintStream(int level)
level
- the level