org.jmlspecs.eclipse.jdt.internal.compiler.util
Class Log

java.lang.Object
  extended by org.jmlspecs.eclipse.jdt.internal.compiler.util.Log
Direct Known Subclasses:
Console

public class Log
extends java.lang.Object

This class provides a uniform interface for logging informational and error messages. Do not use it for messages to the user in the course of normal interaction with the tool. Instead, the informational output is for debugging and tracing purposes; the error output is for internal error reporting (and not, for example, for reports to users about erroneous user input).

Log.on is a boolean flag to be used in user code as a convenience test, as in
if (Log.on) Log.log(msg);
The test happens before the method call. Note that output sent to System.out may be lost depending on the manner in which Eclipse is started (it might also end up in a command terminal or in a parent Console during plugin development).


Field Summary
static Log log
          Holds a current value for the log object, for convenience
static boolean on
          A flag used to record whether or not to output tracing information.
 
Constructor Summary
Log()
           
 
Method Summary
static void errorlog(java.lang.String msg, java.lang.Throwable e)
          Records an error message to the current log
 void ierrorlog(java.lang.String msg, java.lang.Throwable e)
          Records an error message to the current log
 void ilog(java.lang.String msg)
          Records an informational message to the current log
static void initializeState(boolean on)
          Initializes any internal state of the log, e.g.
static void log(java.lang.String msg)
          Records an informational message to the current log
static java.io.PrintStream logPrintStream()
          Creates a PrintStream that, when written to, writes to the Eclipse Console of the current log object
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

public static Log log
Holds a current value for the log object, for convenience


on

public static boolean on
A flag used to record whether or not to output tracing information.

Constructor Detail

Log

public Log()
Method Detail

initializeState

public static void initializeState(boolean on)
Initializes any internal state of the log, e.g. based on stored preferences or properties.

Parameters:
on - Sets (globally) whether anything is desired to be logged or not. This is simply to be tested in code prior to calling log() or errorlog(), to avoid the method invocation when logging is off, as in if (Log.on) Log.log(msg);

log

public static void log(java.lang.String msg)
Records an informational message to the current log

Parameters:
msg - The message to log

errorlog

public static void errorlog(java.lang.String msg,
                            java.lang.Throwable e)
Records an error message to the current log

Parameters:
msg - The message to log
e - An associated exception (may be null)

ilog

public void ilog(java.lang.String msg)
Records an informational message to the current log

Parameters:
msg - The message to log
e - An associated exception (may be null)

ierrorlog

public void ierrorlog(java.lang.String msg,
                      java.lang.Throwable e)
Records an error message to the current log

Parameters:
msg - The message to log
e - An associated exception (may be null)

logPrintStream

public static java.io.PrintStream logPrintStream()
Creates a PrintStream that, when written to, writes to the Eclipse Console of the current log object

Returns:
a PrintStream connected to the Eclipse Console