org.objectweb.cjdbc.common.log
Class StaticNoDebugLogger

java.lang.Object
  extended byorg.objectweb.cjdbc.common.log.Trace
      extended byorg.objectweb.cjdbc.common.log.StaticNoDebugLogger

public class StaticNoDebugLogger
extends Trace

This is a wrapper where debug logging has been statically disabled. It should improve the performance if one wants to completely disable debug traces.

Version:
1.0
Author:
Emmanuel Cecchet

Field Summary
 
Fields inherited from class org.objectweb.cjdbc.common.log.Trace
 
Constructor Summary
StaticNoDebugLogger(org.apache.log4j.Logger log4jLogger)
          Creates a new StaticNoDebugLogger object from a given log4j Logger.
 
Method Summary
 void debug(java.lang.Object message)
          This method is overriden with an empty body.
 void debug(java.lang.Object message, java.lang.Throwable t)
          This method is overriden with an empty body.
 boolean isDebugEnabled()
          Checks whether this category is enabled for the DEBUG Level.
 
Methods inherited from class org.objectweb.cjdbc.common.log.Trace
error, error, fatal, fatal, getLogger, info, info, isErrorEnabled, isFatalEnabled, isInfoEnabled, isWarnEnabled, warn, warn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StaticNoDebugLogger

public StaticNoDebugLogger(org.apache.log4j.Logger log4jLogger)
Creates a new StaticNoDebugLogger object from a given log4j Logger.

Parameters:
log4jLogger - the log4j Logger
Method Detail

debug

public void debug(java.lang.Object message,
                  java.lang.Throwable t)
This method is overriden with an empty body.

Overrides:
debug in class Trace
Parameters:
message - the message object to log
t - the exception to log, including its stack trace
See Also:
Trace.debug(Object, Throwable)

debug

public void debug(java.lang.Object message)
This method is overriden with an empty body.

Overrides:
debug in class Trace
Parameters:
message - the message object to log
See Also:
Trace.debug(Object)

isDebugEnabled

public boolean isDebugEnabled()
Description copied from class: Trace
Checks whether this category is enabled for the DEBUG Level.

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.

Overrides:
isDebugEnabled in class Trace
Returns:
false
See Also:
Trace.isDebugEnabled()


Copyright © 2002, 2005 - ObjectWeb Consortium - All Rights Reserved.