org.sandev.basics.nodecommon
Interface Logger

All Known Implementing Classes:
UserWorkLog

public interface Logger

The Logger interface defines methods and constants used for logging messages and events. Logger implementations must be properly synchronized so that logfile messages do not become garbled in the event of multiple simultaneous calls to a log method. It is worth noting that several nodes running off the same root node may share a single Logger instance.

Logging is a critical system function, so any exception thrown by a Logger will likely result in a node shutdown, or a systemwide shutdown.

The Logger interface can be mapped directly to a variety of standard logging implementations including java.util.logging.Logger, log4j etc. This interface solely reflects the requirements of the generated SAND code w/r/t logging. It is highly recommended that logging be a lightweight, fast, local operation, with any information distribution taking place at the application level.


Field Summary
static int LOGLEVEL_DEBUG
           
static int LOGLEVEL_ERROR
           
static int LOGLEVEL_FATAL
           
static int LOGLEVEL_INFO
           
static java.lang.String LOGLEVEL_STR_DEBUG
           
static java.lang.String LOGLEVEL_STR_ERROR
           
static java.lang.String LOGLEVEL_STR_FATAL
           
static java.lang.String LOGLEVEL_STR_INFO
           
static java.lang.String LOGLEVEL_STR_WARN
           
static java.lang.String[] LOGLEVEL_STRINGS
          The order of elements in this array is important; it's set up so that you can use one of the LOGLEVEL_* constants to look up a LOGLEVEL_STR_* constant.
static int LOGLEVEL_WARN
           
 
Method Summary
 int getLogLevel()
          Return the log level.
 void init(java.lang.String instanceName)
          Initialize this logger with a unique identifying name used to determine the source of a message during logfile analysis.
 void log(int severity, java.lang.String msg)
          Log a message.
 void setLogLevel(int severity)
          Set the level for this logger.
 

Field Detail

LOGLEVEL_DEBUG

public static final int LOGLEVEL_DEBUG
See Also:
Constant Field Values

LOGLEVEL_INFO

public static final int LOGLEVEL_INFO
See Also:
Constant Field Values

LOGLEVEL_WARN

public static final int LOGLEVEL_WARN
See Also:
Constant Field Values

LOGLEVEL_ERROR

public static final int LOGLEVEL_ERROR
See Also:
Constant Field Values

LOGLEVEL_FATAL

public static final int LOGLEVEL_FATAL
See Also:
Constant Field Values

LOGLEVEL_STR_DEBUG

public static final java.lang.String LOGLEVEL_STR_DEBUG
See Also:
Constant Field Values

LOGLEVEL_STR_INFO

public static final java.lang.String LOGLEVEL_STR_INFO
See Also:
Constant Field Values

LOGLEVEL_STR_WARN

public static final java.lang.String LOGLEVEL_STR_WARN
See Also:
Constant Field Values

LOGLEVEL_STR_ERROR

public static final java.lang.String LOGLEVEL_STR_ERROR
See Also:
Constant Field Values

LOGLEVEL_STR_FATAL

public static final java.lang.String LOGLEVEL_STR_FATAL
See Also:
Constant Field Values

LOGLEVEL_STRINGS

public static final java.lang.String[] LOGLEVEL_STRINGS
The order of elements in this array is important; it's set up so that you can use one of the LOGLEVEL_* constants to look up a LOGLEVEL_STR_* constant. For example:

String stopped = LOGLEVEL_STRINGS[LOGLEVEL_DEBUG];

Method Detail

init

public void init(java.lang.String instanceName)
          throws LoggerException
Initialize this logger with a unique identifying name used to determine the source of a message during logfile analysis. The init method is called once with the instance name of the node as part of creating a new instance.

Throws:
LoggerException

log

public void log(int severity,
                java.lang.String msg)
         throws LoggerException
Log a message. See the LOGLEVEL_* constants, and the log method in each node for details.

Throws:
LoggerException

setLogLevel

public void setLogLevel(int severity)
Set the level for this logger. Only messages with severity >= the log level will be logged; messages with severity < the log level are discarded. The value must be one of the Logger.LOGLEVEL_* constants.


getLogLevel

public int getLogLevel()
Return the log level.