edu.isi.pegasus.common.logging.logger

## Class Default

- java.lang.Object
- - edu.isi.pegasus.common.logging.LogManager
  - - edu.isi.pegasus.common.logging.logger.Default

    public class Default
    extends LogManager

The logging class that to log messages at different levels. Currently the following levels are supported.

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.

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

### Field Summary

Fields
`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 java.io.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 java.io.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.

### Fields inherited from class edu.isi.pegasus.common.logging.LogManager

`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 Summary

Constructors
Constructor and Description
`Default()` The constructor.

### Method Summary

All Methods Instance Methods Concrete Methods
`private int` `generateMask(int level, boolean info)` Generates the appropriate mask value, corresponding to the level passed.
`int` `getLevel()` Returns the debug level.
`private java.lang.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 java.io.PrintStream` `getPrintStream(int level)` Returns a PrintWriter stream on which to log the message.
`private java.io.PrintStream` `getPrintStream(java.lang.String out)` Sets an internal writer to point to a particular stream.
`java.lang.String` `getTimeStamp()` Gets the timestamp nicely formatted.
`void` `initialize(LogFormatter formatter, java.util.Properties properties)` Sets the log formatter to use for formatting the messages.
`void` `log(java.lang.String message, java.lang.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(java.lang.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(java.lang.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(java.io.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(java.lang.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(java.io.OutputStream out)` Sets the writer associated with the class to the one specified for all type of messages other than error messages.
`void` `setOutputWriter(java.lang.String out)` Sets the writer associated with the class to the one specified for all type of messages other than error messages.
`void` `setWriters(java.lang.String out)` Sets both the output writer and the error writer to the same underlying writer.

### Methods inherited from class edu.isi.pegasus.common.logging.LogManager

`add, add, getInstance, log, log, logAndReset, logEntityHierarchyMessage, logEntityHierarchyMessage, logEventCompletion, logEventStart, logEventStart, logEventStart, logEventStart, sanityCheckOnDirectory, sanityCheckOnFile`

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

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

### Field Detail

#### FATAL_MESSAGE_TYPE

    private static final int FATAL_MESSAGE_TYPE

The type value to indicate a FATAL error message.

See Also:
  Constant Field Values

#### ERROR_MESSAGE_TYPE

    private static final int ERROR_MESSAGE_TYPE

The type value to indicate an ERROR message.

See Also:
  Constant Field Values

#### CONSOLE_MESSAGE_TYPE

    private static final int CONSOLE_MESSAGE_TYPE

The type value to indicate a CONSOLE message.

See Also:
  Constant Field Values

#### WARNING_MESSAGE_TYPE

    private static final int WARNING_MESSAGE_TYPE

The type value to indicate a WARNING message.

See Also:
  Constant Field Values

#### INFO_MESSAGE_TYPE

    private static final int INFO_MESSAGE_TYPE

The type value to indicate an INFORMATIVE message.

See Also:
  Constant Field Values

#### CONFIG_MESSAGE_TYPE

    private static final int CONFIG_MESSAGE_TYPE

The type value to indicate a CONFIG message.

See Also:
  Constant Field Values

#### DEBUG_MESSAGE_TYPE

    private static final int DEBUG_MESSAGE_TYPE

The type value to indicate a DEBUG message.

See Also:
  Constant Field Values

#### TRACE_MESSAGE_TYPE

    private static final int TRACE_MESSAGE_TYPE

The type value to indicate a DEBUG message.

See Also:
  Constant Field Values

#### logger

    private static Default logger

Ensures only one object is created always. Implements the Singleton.

#### mOutStream

    private java.io.PrintStream mOutStream

The stream to which one writes. It is System.out by default for the current release. One can set it using setOutputWriter.

See Also:
  `setOutputWriter(java.lang.String)`

#### mErrStream

    private java.io.PrintStream mErrStream

The stream to which all the error messages are logged.By default it is System.err

#### mMask

    private int mMask

The mask that needs to be deployed to determine what messages are to be logged.

#### mFormatter

    private static Currently mFormatter

This is used to format the time stamp.

### Constructor Detail

#### Default

    public Default()

The constructor.

### Method Detail

#### initialize

    public void initialize(LogFormatter formatter,
                           java.util.Properties properties)

Sets the log formatter to use for formatting the messages.

Specified by:
  `initialize` in class `LogManager`
Parameters:
  `formatter` - the formatter to use.
  `properties` - properties that the underlying implementations understand

#### setLevel

    public void setLevel(org.apache.log4j.Level level)

Sets the debug level. All those messages are logged which have a level less than equal to the debug level.

Overrides:
  `setLevel` in class `LogManager`
Parameters:
  `level` - the level to which the debug level needs to be set to.

#### setLevel

    public void setLevel(int level)

Sets the debug level. All those messages are logged which have a level less than equal to the debug level.

Overrides:
  `setLevel` in class `LogManager`
Parameters:
  `level` - the level to which the debug level needs to be set to.

#### setLevel

    protected void setLevel(int level,
                            boolean info)

Sets the debug level. All those messages are logged which have a level less than equal to the debug level. In case the boolean info is set, all the info messages are also logged.

Specified by:
  `setLevel` in class `LogManager`
Parameters:
  `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.

#### getLevel

    public int getLevel()

Returns the debug level.

Specified by:
  `getLevel` in class `LogManager`
Returns:
  the level to which the debug level has been set to.

#### setWriters

    public void setWriters(java.lang.String out)

Sets both the output writer and the error writer to the same underlying writer.

Specified by:
  `setWriters` in class `LogManager`
Parameters:
  `out` - is the name of a file to append to. Special names are `stdout` and `stderr`, which map to the system's respective streams.
See Also:
  `#setWriters(OutputStream)`

#### setOutputWriter

    public void setOutputWriter(java.lang.String out)

Sets the writer associated with the class to the one specified for all type of messages other than error messages.

Parameters:
  `out` - is the name of a file to append to. Special names are `stdout` and `stderr`, which map to the system's respective streams.
See Also:
  `setOutputWriter(OutputStream)`

#### setOutputWriter

    public void setOutputWriter(java.io.OutputStream out)

Sets the writer associated with the class to the one specified for all type of messages other than error messages. By default it is System.out.

Parameters:
  `out` - the stream to which the messages are logged.
See Also:
  `setErrorWriter(OutputStream)`

#### setErrorWriter

    public void setErrorWriter(java.lang.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. By default, these messages are logged to stderr. Note: The previous stream is not closed automatically.

Parameters:
  `out` - is the name of a file to append to. Special names are `stdout` and `stderr`, which map to the system's respective streams.
See Also:
  `setErrorWriter(OutputStream)`

#### setErrorWriter

    public void setErrorWriter(java.io.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. By default, these messages are logged to stderr. Note: The previous stream is not closed automatically.

Parameters:
  `err` - the stream to which error messages are to be logged.

#### log

    public void log(java.lang.String message,
                    java.lang.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. For INFO level message, the boolean indicating that a completion message is to follow is set to true always.

Specified by:
  `log` in class `LogManager`
Parameters:
  `message` - the message to be logged.
  `e` - the exception to be logged
  `level` - the level on which the message has to be logged.
See Also:
  `setLevel(int)`, `LogManager.log(String,int)`

#### logAlreadyFormattedMessage

    public void logAlreadyFormattedMessage(java.lang.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. For INFO level message, the boolean indicating that a completion message is to follow is set to true always.

Specified by:
  `logAlreadyFormattedMessage` in class `LogManager`
Parameters:
  `message` - the message to be logged.
  `level` - the level on which the message has to be logged.
See Also:
  `setLevel(int)`, `log(String,int,boolean)`

#### log

    private void log(java.lang.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.

Parameters:
  `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.
See Also:
  `setLevel(int)`

#### getTimeStamp

    public java.lang.String getTimeStamp()

Gets the timestamp nicely formatted. It generates the date-timestamp in extended ISO 8601 format. It generates the timestamp using the local timezone not the UTC. An example of the date-timestamp generated would be 2003-06-06T14:31:27-07:00 where -07:00 denotes the timezone offset of the local timezone from UTC.

Returns:
  the formattted timestamp;

#### logEventCompletion

    public void logEventCompletion(int level)

Logs the completion message on the basis of the debug level.

Specified by:
  `logEventCompletion` in class `LogManager`
Parameters:
  `level` - the debug level of the start message for whose completion you want.

#### generateMask

    private int generateMask(int level,
                             boolean info)

Generates the appropriate mask value, corresponding to the level passed.

Parameters:
  `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.
Returns:
  mask corresponding to the debug level passed.

#### getPrefix

    private java.lang.String getPrefix(int type)

Returns the prefix that needs to be logged corresponding to a particular message type, when a message is being logged. Should be returning an enumerated data type.

Parameters:
  `type` - the type for which prefix is required.
Returns:
  the message type

#### getPrintStream

    private java.io.PrintStream getPrintStream(java.lang.String out)
                                        throws java.io.IOException

Sets an internal writer to point to a particular stream.

Parameters:
  `out` - is the name of a file to append to. Special names are `stdout` and `stderr`, which map to the system's respective streams.
Returns:
  the corresponding PrintStream.
Throws:
  `java.io.IOException` - in case of being unable to open a stream.

#### getPrintStream

    private java.io.PrintStream getPrintStream(int level)

Returns a PrintWriter stream on which to log the message. Later on this, function would return the appropriate LOG4J queue on which the message needs to be logged.

Parameters:
  `level` - the level
Returns:
  PrintWriter for logging the message.