com.isti.util.logging
Class AbstractIstiLogger

java.lang.Object
  extended by com.isti.util.logging.AbstractIstiLogger
All Implemented Interfaces:
IstiLogger
Direct Known Subclasses:
IstiConsoleLogger

public abstract class AbstractIstiLogger
extends java.lang.Object
implements IstiLogger

Class MessageLogger defines an abstract ISTI logger. To implement an ISTI logger, the programmer needs only to extend this class and provide an implementation for the logMessage(int level, String str, Throwable t) method.


Field Summary
 
Fields inherited from interface com.isti.util.logging.IstiLogger
ALL_MSGS, ALL_MSGS_STR, DEBUG, DEBUG_STR, DEBUG2, DEBUG2_STR, DEBUG3, DEBUG3_STR, DEBUG4, DEBUG4_STR, DEBUG5, DEBUG5_STR, ERROR, ERROR_STR, INFO, INFO_STR, NO_MSGS, NO_MSGS_STR, WARNING, WARNING_STR
 
Constructor Summary
AbstractIstiLogger()
           
 
Method Summary
 boolean debug(java.lang.String str)
          Sends the given string to the log file with the message level set to 'DEBUG'.
 boolean debug2(java.lang.String str)
          Sends the given string to the log file with the message level set to 'DEBUG2'.
 boolean debug3(java.lang.String str)
          Sends the given string to the log file with the message level set to 'DEBUG3'.
 boolean debug4(java.lang.String str)
          Sends the given string to the log file with the message level set to 'DEBUG4'.
 boolean debug5(java.lang.String str)
          Sends the given string to the log file with the message level set to 'DEBUG5'.
 boolean error(java.lang.String str)
          Sends the given string to the log file with the message level set to 'ERROR'.
 boolean error(java.lang.String str, java.lang.Throwable t)
          Sends the given string to the log file with the message level set to 'ERROR'.
static java.lang.String getLevelString(int level)
          Returns a String corresponding to the given message level value.
static java.lang.String getLevelStringNull(int level)
          Returns a String corresponding to the given message level value.
protected  java.lang.String getMessage(int level)
          Gets the message for the level.
protected  java.lang.String getMessage(int level, java.lang.String str, java.lang.Throwable t)
          Gets the message for the level and string.
protected  java.lang.String getMessage(java.lang.String str, java.lang.Throwable t)
          Get the message for the string and the Throwable.
 int getMinLevel()
          Get the minimum level for all output messages.
 boolean info(java.lang.String str)
          Sends the given string to the log file with the message level set to 'INFO'.
 boolean isLoggable(int level)
          Determines if a message of the given level would actually be logged.
static java.lang.Integer levelStringToValue(java.lang.String str)
          Gets the integer value that corresponds to the given message level String.
protected abstract  boolean logMessage(int level, java.lang.String str, java.lang.Throwable t)
          Sends the given string to the log file.
 boolean println(int level, java.lang.String str)
          Sends the given string to the log file.
 boolean println(int level, java.lang.String str, java.lang.Throwable t)
          Sends the given string to the log file.
 boolean println(java.lang.String str)
          Sends the given string to the log file.
 boolean warning(java.lang.String str)
          Sends the given string to the log file with the message level set to 'WARNING'.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractIstiLogger

public AbstractIstiLogger()
Method Detail

debug

public boolean debug(java.lang.String str)
Sends the given string to the log file with the message level set to 'DEBUG'.

Specified by:
debug in interface IstiLogger
Parameters:
str - the string to be outputted.
Returns:
true if successful, false if an I/O error was detected.

debug2

public boolean debug2(java.lang.String str)
Sends the given string to the log file with the message level set to 'DEBUG2'.

Specified by:
debug2 in interface IstiLogger
Parameters:
str - the string to be outputted.
Returns:
true if successful, false if an I/O error was detected.

debug3

public boolean debug3(java.lang.String str)
Sends the given string to the log file with the message level set to 'DEBUG3'.

Specified by:
debug3 in interface IstiLogger
Parameters:
str - the string to be outputted.
Returns:
true if successful, false if an I/O error was detected.

debug4

public boolean debug4(java.lang.String str)
Sends the given string to the log file with the message level set to 'DEBUG4'.

Specified by:
debug4 in interface IstiLogger
Parameters:
str - the string to be outputted.
Returns:
true if successful, false if an I/O error was detected.

debug5

public boolean debug5(java.lang.String str)
Sends the given string to the log file with the message level set to 'DEBUG5'.

Specified by:
debug5 in interface IstiLogger
Parameters:
str - the string to be outputted.
Returns:
true if successful, false if an I/O error was detected.

error

public boolean error(java.lang.String str)
Sends the given string to the log file with the message level set to 'ERROR'.

Specified by:
error in interface IstiLogger
Parameters:
str - the string to be outputted.
Returns:
true if successful, false if an I/O error was detected.

error

public boolean error(java.lang.String str,
                     java.lang.Throwable t)
Sends the given string to the log file with the message level set to 'ERROR'.

Parameters:
str - the string to be outputted or null if only Throwable is used.
t - Throwable associated with a log message or null if none.
Returns:
true if successful, false if an I/O error was detected.

getLevelString

public static java.lang.String getLevelString(int level)
Returns a String corresponding to the given message level value.

Parameters:
level - the message level.
Returns:
a String corresponding to the given message level value, or "level#" if the value is not matched.

getLevelStringNull

public static java.lang.String getLevelStringNull(int level)
Returns a String corresponding to the given message level value.

Parameters:
level - the message level.
Returns:
a String corresponding to the given message level value, or null if the value is not matched.

info

public boolean info(java.lang.String str)
Sends the given string to the log file with the message level set to 'INFO'.

Specified by:
info in interface IstiLogger
Parameters:
str - the string to be outputted.
Returns:
true if successful, false if an I/O error was detected.

getMinLevel

public int getMinLevel()
Get the minimum level for all output messages. This method should be overridden.

Returns:
the minimum level for all output messages.
See Also:
isLoggable(int)

isLoggable

public boolean isLoggable(int level)
Determines if a message of the given level would actually be logged.

Specified by:
isLoggable in interface IstiLogger
Parameters:
level - a message logging level.
Returns:
true if the given message level is currently being logged.
See Also:
getMinLevel()

levelStringToValue

public static java.lang.Integer levelStringToValue(java.lang.String str)
Gets the integer value that corresponds to the given message level String. A case-insensitive comparison is used.

Parameters:
str - the message level string to interpret.
Returns:
the integer value that corresponds to the given message level String or null if the String could not be matched.

println

public boolean println(int level,
                       java.lang.String str)
Sends the given string to the log file. (And possibly the console--see the 'consoleLevel' parameter on the constructor.)

Specified by:
println in interface IstiLogger
Parameters:
level - the message level to be used.
str - the string to be outputted.
Returns:
true if successful, false if an I/O error was detected.

println

public boolean println(int level,
                       java.lang.String str,
                       java.lang.Throwable t)
Sends the given string to the log file. (And possibly the console--see the 'consoleLevel' parameter on the constructor.)

Specified by:
println in interface IstiLogger
Parameters:
level - the message level to be used.
str - the string to be outputted or null if only Throwable is used.
t - Throwable associated with a log message or null if none.
Returns:
true if successful, false if an I/O error was detected.

println

public boolean println(java.lang.String str)
Sends the given string to the log file. (And possibly the console--see the 'consoleLevel' parameter on the constructor.)

Specified by:
println in interface IstiLogger
Parameters:
str - the string to be outputted.
Returns:
true if successful, false if an I/O error was detected.

warning

public boolean warning(java.lang.String str)
Sends the given string to the log file with the message level set to 'WARNING'.

Specified by:
warning in interface IstiLogger
Parameters:
str - the string to be outputted.
Returns:
true if successful, false if an I/O error was detected.

getMessage

protected java.lang.String getMessage(int level)
Gets the message for the level.

Parameters:
level - the message level.
Returns:
the message.

getMessage

protected java.lang.String getMessage(int level,
                                      java.lang.String str,
                                      java.lang.Throwable t)
Gets the message for the level and string. If there is a string and a Throwable then a newline is added to the end of the message.

Parameters:
level - the message level.
str - the string to be outputted or null if only Throwable is used.
t - Throwable associated with a log message or null if none.
Returns:
the message.

getMessage

protected java.lang.String getMessage(java.lang.String str,
                                      java.lang.Throwable t)
Get the message for the string and the Throwable.

Parameters:
str - the string to be outputted.
t - Throwable associated with a log message or null if none.
Returns:
the message.

logMessage

protected abstract boolean logMessage(int level,
                                      java.lang.String str,
                                      java.lang.Throwable t)
Sends the given string to the log file. (And possibly the console--see the 'consoleLevel' parameter on the constructor.)

Parameters:
level - the message level to be used.
str - the string to be outputted.
t - Throwable associated with a log message or null if none.
Returns:
true if successful, false if an I/O error was detected.
See Also:
getMessage(String, Throwable)