Logo Search packages:      
Sourcecode: cdk version File versions  Download package

org::openscience::cdk::tools::LoggingTool Class Reference

List of all members.


Detailed Description

Useful for logging messages. Often used as a class static variable instantiated like:
 public class SomeClass {
     private static LoggingTool logger;
     public SomeClass() {
         logger = new LoggingTool(this);
     }
 }
 
There is no special reason not to make the logger private and static, as the logging information is closely bound to one specific Class, not subclasses and not instances.

The logger has five logging levels:

DEBUG
Default mode. Used for information you might need to track down the cause of a bug in the source code, or to understand how an algorithm works.
WARNING
This indicates a special situation which is unlike to happen, but for which no special actions need to be taken. E.g. missing information in files, or an unknown atom type. The action is normally something user friendly.
INFO
For reporting informative information to the user that he might easily disregard. Real important information should be given to the user using a GUI element.
FATAL
This level is used for situations that should not have happened *and* that lead to a situation where this program can no longer function (rare in Java).
ERROR
This level is used for situations that should not have happened *and* thus indicate a bug.

Consider that the debugging will not always be turned on. Therefore, it is better not to concatenate string in the logger.debug() call, but have the LoggingTool do this when appropriate. In other words, use:

 logger.debug("The String X has this value: ", someString);
 logger.debug("The int Y has this value: ", y);
 
instead of:
 logger.debug("The String X has this value: " + someString);
 logger.debug("The int Y has this value: " + y);
 

For logging calls that require even more computation you can use the isDebugEnabled() method:

 if (logger.isDebugEnabled()) {
   logger.info("The 1056389822th prime that is used is: ",
     calculatePrime(1056389822));
 }
 

The class uses log4j as a backend if available, and System.out otherwise.

.module core .builddepends log4j.jar

Definition at line 92 of file LoggingTool.java.


Public Member Functions

void debug (Object obj, Object obj2, Object obj3, Object obj4, Object obj5)
void debug (Object obj, Object obj2, Object obj3, Object obj4)
void debug (Object obj, Object obj2, Object obj3)
void debug (Object object, boolean bool)
void debug (Object object, double number)
void debug (Object object, int number)
void debug (Object object, Object object2)
void debug (Object object)
void dumpClasspath ()
void dumpSystemProperties ()
void error (Object obj, Object obj2, Object obj3, Object obj4, Object obj5)
void error (Object obj, Object obj2, Object obj3, Object obj4)
void error (Object obj, Object obj2, Object obj3)
void error (Object object, Object object2)
void error (Object object, boolean bool)
void error (Object object, double number)
void error (Object object, int number)
void error (Object object)
void fatal (Object object)
void info (Object obj, Object obj2, Object obj3, Object obj4, Object obj5)
void info (Object obj, Object obj2, Object obj3, Object obj4)
void info (Object obj, Object obj2, Object obj3)
void info (Object object, Object object2)
void info (Object object, boolean bool)
void info (Object object, double number)
void info (Object object, int number)
void info (Object object)
boolean isDebugEnabled ()
 LoggingTool (Class classInst)
 LoggingTool (Object object)
 LoggingTool ()
void setStackLength (int length)
void warn (Object obj, Object obj2, Object obj3, Object obj4, Object obj5)
void warn (Object obj, Object obj2, Object obj3, Object obj4)
void warn (Object obj, Object obj2, Object obj3)
void warn (Object object, Object object2)
void warn (Object object, double number)
void warn (Object object, boolean bool)
void warn (Object object, int number)
void warn (Object object)

Static Public Member Functions

static void configureLog4j ()

Public Attributes

final int DEFAULT_STACK_LENGTH = 5

Private Member Functions

void debugString (String string)
void debugThrowable (Throwable problem)
void errorString (String string)
void infoString (String string)
void printToSTDOUT (String level, String message)
void warnString (String string)

Private Attributes

String classname
boolean doDebug = false
Logger log4jLogger
LoggingTool logger
int stackLength
boolean toSTDOUT = false

The documentation for this class was generated from the following file:

Generated by  Doxygen 1.6.0   Back to index