org.aglets.log
Interface LogCategory

All Known Implementing Classes:
ConsoleCategory, Log4jCategory, QuietCategory

public interface LogCategory

Abstract logging system interface. Hides actual implementation of hierachal logging system.

Version:
1.0
Author:
Robert Bergstrom

Method Summary
 void debug(java.lang.Object msg)
          Logs a message at debug priority.
 void error(java.lang.Object msg)
          Logs a message at error priority.
 void error(java.lang.Object msg, java.lang.Exception exc)
          Logs a message at error priority and passes an exception for logging.
 void fatal(java.lang.Object msg)
          Logs a message at fatal priority.
 void info(java.lang.Object msg)
          Logs a mesasge at info priority.
 boolean isDebugEnabled()
          Check whether this category is enabled for the DEBUG priority.
 void warn(java.lang.Object msg)
          Logs a message at warn priority.
 

Method Detail

fatal

public void fatal(java.lang.Object msg)
Logs a message at fatal priority.
Parameters:
msg - Message to be logged.
Since:
1.0

error

public void error(java.lang.Object msg)
Logs a message at error priority.
Parameters:
msg - Message to be logged.
Since:
1.0

error

public void error(java.lang.Object msg,
                  java.lang.Exception exc)
Logs a message at error priority and passes an exception for logging.
Parameters:
msg - Message to be logged.
exc - Description of Parameter
Since:
1.0

warn

public void warn(java.lang.Object msg)
Logs a message at warn priority.
Parameters:
msg - Message to be logged.
Since:
1.0

info

public void info(java.lang.Object msg)
Logs a mesasge at info priority.
Parameters:
msg - Message to be logged.
Since:
1.0

debug

public void debug(java.lang.Object msg)
Logs a message at debug priority.
Parameters:
msg - Message to be logged.
Since:
1.0

isDebugEnabled

public boolean isDebugEnabled()
Check whether this category is enabled for the DEBUG priority.

This function is intended to lessen the computational cost of disabled log debug statements.

For some cat Category object, when you write,

      cat.debug("This is entry number: " + i );
  

You incur the cost constructing the message, concatenatiion in this case, regardless of whether the message is logged or not.

If you are worried about speed, then you should write

 	 if(cat.isDebugEnabled()) { 
 	   cat.debug("This is entry number: " + i );
 	 }
  

This way you will not incur the cost of parameter construction if debugging is disabled for cat. On the other hand, if the cat is debug enabled, you will incur the cost of evaluating whether the category is debug enabled twice. Once in isDebugEnabled and once in the debug. This is an insignificant overhead since evaluating a category takes about 1%% of the time it takes to actually log.

Returns:
boolean - true if this category is debug enabled, false otherwise.