org.crosswire.common.util
Class Logger

java.lang.Object
  extended by org.crosswire.common.util.Logger

public final class Logger
extends Object

This class is very similar to Commons-Logging except it should be even smaller and have an API closer to the Log4J API (and even J2SE 1.4 logging). This implementation is lazy. The actual internal logger is not initialized until first use. Turns out that this class indirectly depends upon JSword's Project class to help find the logging configuration file. If it is not lazy, it looks in the wrong places for the configuration file.

Author:
Joe Walker [joe at eireneh dot com], DM Smith [dmsmith555 at yahoo dot com]
See Also:
for license details.
The copyright to this program is held by it's authors.

Field Summary
private static String CLASS_NAME
           
private static Logger cwLogger
           
private static boolean established
           
private static Level level
           
private  Logger logger
          The actual logger.
private static String ROOT_LOGGER
           
private  boolean showLocation
          Whether we dig into the call stack to get the method and line number of the caller.
 
Constructor Summary
private Logger(Class<T> id, boolean showLocation)
          Create a logger for the class.
 
Method Summary
 void debug(String msg)
          Log a message object with the FINEST level.
private  void doLogging(Level theLevel, String message, Throwable th)
           
 void error(String msg)
          Log a message object with the WARNING level.
 void error(String msg, Throwable th)
          Log a message object with the WARNING level.
private static void establishLogging()
           
 void fatal(String msg)
          Log a message object with the SEVERE level.
 void fatal(String msg, Throwable th)
          Log a message object with the SEVERE level.
static
<T> Logger
getLogger(Class<T> clazz)
          Get a new logger for the class that shows the class, method and line number of the caller.
static
<T> Logger
getLogger(Class<T> clazz, boolean showLocation)
          Get a new logger for the class that shows the class of the caller.
 void info(String msg)
          Log a message object with the INFO level.
 void info(String msg, Throwable th)
          Log a message object with the INFO level.
private  void initialize()
           
 void log(Level lev, String msg)
          Log a message with the supplied level.
 void log(Level lev, String msg, Throwable th)
          Log a message with the supplied level, recording the exception when not null.
static void outputEverything()
          Output everything
static void outputInfoMinimum()
          Output a minimum of stuff
static void outputNothing()
          Stop all logging output
private static void setLevel()
           
 void setLevel(Level newLevel)
          Set the level at which output occurs for this Logger.
 void warn(String msg)
          Log a message object with the FINE level.
 void warn(String msg, Throwable th)
          Log a message object with the FINE level.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ROOT_LOGGER

private static final String ROOT_LOGGER
See Also:
Constant Field Values

CLASS_NAME

private static final String CLASS_NAME

established

private static volatile boolean established

level

private static volatile Level level

logger

private Logger logger
The actual logger.


cwLogger

private static Logger cwLogger

showLocation

private boolean showLocation
Whether we dig into the call stack to get the method and line number of the caller.

Constructor Detail

Logger

private Logger(Class<T> id,
               boolean showLocation)
Create a logger for the class. Wrapped by #java.util.logging.Logger.getLogger(String).

Method Detail

getLogger

public static <T> Logger getLogger(Class<T> clazz)
Get a new logger for the class that shows the class, method and line number of the caller.

Parameters:
clazz - the class that holds the logger.

getLogger

public static <T> Logger getLogger(Class<T> clazz,
                                   boolean showLocation)
Get a new logger for the class that shows the class of the caller.

Parameters:
clazz - the class that holds the logger.
showLocation - when true it will get the method and line where logging occurred.

setLevel

public void setLevel(Level newLevel)
Set the level at which output occurs for this Logger.

Parameters:
newLevel - the level to apply

outputNothing

public static void outputNothing()
Stop all logging output


outputInfoMinimum

public static void outputInfoMinimum()
Output a minimum of stuff


outputEverything

public static void outputEverything()
Output everything


fatal

public void fatal(String msg)
Log a message object with the SEVERE level.

Parameters:
msg - the message to log.

fatal

public void fatal(String msg,
                  Throwable th)
Log a message object with the SEVERE level.

Parameters:
msg - the message object to log.

error

public void error(String msg)
Log a message object with the WARNING level.

Parameters:
msg - the message to log.

error

public void error(String msg,
                  Throwable th)
Log a message object with the WARNING level.

Parameters:
msg - the message to log.
th - the exception to note when not null

info

public void info(String msg)
Log a message object with the INFO level.

Parameters:
msg - the message object to log.

info

public void info(String msg,
                 Throwable th)
Log a message object with the INFO level.

Parameters:
msg - the message object to log.
th - the exception to note when not null

warn

public void warn(String msg)
Log a message object with the FINE level.

Parameters:
msg - the message object to log.

warn

public void warn(String msg,
                 Throwable th)
Log a message object with the FINE level.

Parameters:
msg - the message object to log.
th - the exception to note when not null

debug

public void debug(String msg)
Log a message object with the FINEST level.

Parameters:
msg - the message object to log.

log

public void log(Level lev,
                String msg)
Log a message with the supplied level.

Parameters:
lev - the level at which to log.
msg - the message to log.

log

public void log(Level lev,
                String msg,
                Throwable th)
Log a message with the supplied level, recording the exception when not null.

Parameters:
msg - the message object to log.

doLogging

private void doLogging(Level theLevel,
                       String message,
                       Throwable th)

initialize

private void initialize()

establishLogging

private static void establishLogging()

setLevel

private static void setLevel()

Copyright ? 2003-2011