com.izforge.izpack.util
Class Debug

java.lang.Object
  extended by com.izforge.izpack.util.Debug

public class Debug
extends java.lang.Object

This class is for debug purposes. It is highly recommended to use it on critical or experimental code places. To enable the debug mode of IzPack, just start the installer with the java parameter -DTRACE=true or -DSTACKTRACE=true to enable extendend output of the internal status of critical objects.
How to use it as IzPack Setup Developer:
Just import this class and use one of the methods:

Debug.trace( aCriticalObject )
- to print the status on console
Debug.error( aCriticalObject )
- to print the status on console and
print the stacktrace of a supressed Exception.
Additionally:
if -DLOG is given the output will be written in the File see #LOGFILENAME in the users Home directory.

Version:
$Revision: 2163 $ ($Id: Debug.java 2163 2008-05-18 13:48:36Z jponge $)
Author:
Julien Ponge, Klaus Bartz, Marc Eppelmann

Field Summary
static java.lang.String DLOG
          Parameter for public javacall "java -jar izpack.jar -DLOG" (Class.internal.variable: (DLOG = "LOG"))
static java.lang.String DSTACKTRACE
          Parameter for public javacall "java -jar izpack.jar -DSTACKTRACE" (Class.internal.variable: (DSTACKTRACE = "STACKTRACE"))
static java.lang.String DTRACE
          Parameter for public javacall "java -jar izpack.jar -DTRACE" (Class.internal.variable: (DTRACE = "TRACE"))
static java.lang.String IZPACK_LOGFILE
          System.Property Key: IZPACK_LOGFILE = "izpack.logfile"
private static boolean LOG
          internal initial unintialized LOG-flag
static int LOG_WITH_DATE
          LOG_WITH_DATE = 1
static int LOG_WITH_TIME_AND_DATE
          LOG_WITH_TIME_AND_DATE= LOG_WITH_DATE | LOG_WITH_TIME_STAMP = 3
static int LOG_WITH_TIME_STAMP
          LOG_WITH_TIME_STAMP = 2
static int LOG_WITHOUT_DATE
          LOG_WITHOUT_DATE = 0
static java.lang.String LOGFILE_EXTENSION
          LOGFILE_EXTENSION = ".txt"
static java.lang.String LOGFILE_PREFIX
          LOGFILE_PREFIX = "IzPack_Logfile_at_"
static java.lang.String LOGFILENAME
          LOGFILENAME = LOGFILE_PREFIX + System.currentTimeMillis() + LOGFILE_EXTENSION
private static boolean STACKTRACE
          internal initial unintialized STACKTRACE-flag
private static boolean TRACE
          internally initial unintialized TRACE-flag
 
Constructor Summary
Debug()
           
 
Method Summary
private static java.io.PrintWriter createLogFile()
          Creates the logfile to write log-infos into.
static void error(java.lang.Object s)
          Traces the given object and additional write their status in the LOGFILE.
static java.io.PrintWriter getLogFile()
          Get the Logfile
static boolean isLOG()
          Returns the LOG flag.
static boolean isSTACKTRACE()
          Returns the current STACKTRACE flag
static boolean isTRACE()
          Gets the current TRACE flag
static void log(java.lang.Object o)
          Logs the given Object in the created Logfile if -DLOG=true was given on commandline i.e: java -DLOG=true -jar izpack-installer.jar
static void log(java.lang.Object o, int withWhatFormat)
          Logs the given Object in the created Logfile if -DLOG=true was given on commandline i.e: java -DLOG=true -jar izpack-installer.jar
private static boolean logWithDate(int withWhatFormat)
          Indicates that to log with Date.
private static boolean logWithTimeStamp(int withWhatFormat)
          Indicates that to log with Timestamp.
static void setLOG(boolean aFlag)
          Sets The LOG like the given value
static java.io.PrintWriter setLogFile(java.io.PrintWriter aLogFile)
          Sets the Logfile
static void setSTACKTRACE(boolean aFlag)
          Sets the STACKTRACE like the given value
static void setTRACE(boolean aFlag)
          Sets the TRACE flag like the given value
static boolean stackTracing()
          Indicates if debug is stacktracing
static void trace(java.lang.Object s)
          Traces the internal status of the given Object
static boolean tracing()
          Indicates if debug is tracing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DLOG

public static final java.lang.String DLOG
Parameter for public javacall "java -jar izpack.jar -DLOG" (Class.internal.variable: (DLOG = "LOG"))

See Also:
Constant Field Values

DSTACKTRACE

public static final java.lang.String DSTACKTRACE
Parameter for public javacall "java -jar izpack.jar -DSTACKTRACE" (Class.internal.variable: (DSTACKTRACE = "STACKTRACE"))

See Also:
Constant Field Values

DTRACE

public static final java.lang.String DTRACE
Parameter for public javacall "java -jar izpack.jar -DTRACE" (Class.internal.variable: (DTRACE = "TRACE"))

See Also:
Constant Field Values

IZPACK_LOGFILE

public static final java.lang.String IZPACK_LOGFILE
System.Property Key: IZPACK_LOGFILE = "izpack.logfile"

See Also:
Constant Field Values

LOG_WITHOUT_DATE

public static final int LOG_WITHOUT_DATE
LOG_WITHOUT_DATE = 0

See Also:
Constant Field Values

LOG_WITH_DATE

public static final int LOG_WITH_DATE
LOG_WITH_DATE = 1

See Also:
Constant Field Values

LOG_WITH_TIME_STAMP

public static final int LOG_WITH_TIME_STAMP
LOG_WITH_TIME_STAMP = 2

See Also:
Constant Field Values

LOG_WITH_TIME_AND_DATE

public static final int LOG_WITH_TIME_AND_DATE
LOG_WITH_TIME_AND_DATE= LOG_WITH_DATE | LOG_WITH_TIME_STAMP = 3

See Also:
Constant Field Values

TRACE

private static boolean TRACE
internally initial unintialized TRACE-flag


STACKTRACE

private static boolean STACKTRACE
internal initial unintialized STACKTRACE-flag


LOG

private static boolean LOG
internal initial unintialized LOG-flag


LOGFILE_PREFIX

public static java.lang.String LOGFILE_PREFIX
LOGFILE_PREFIX = "IzPack_Logfile_at_"


LOGFILE_EXTENSION

public static java.lang.String LOGFILE_EXTENSION
LOGFILE_EXTENSION = ".txt"


LOGFILENAME

public static java.lang.String LOGFILENAME
LOGFILENAME = LOGFILE_PREFIX + System.currentTimeMillis() + LOGFILE_EXTENSION

Constructor Detail

Debug

public Debug()
Method Detail

trace

public static void trace(java.lang.Object s)
Traces the internal status of the given Object

Parameters:
s -

error

public static void error(java.lang.Object s)
Traces the given object and additional write their status in the LOGFILE.

Parameters:
s -

log

public static void log(java.lang.Object o)
Logs the given Object in the created Logfile if -DLOG=true was given on commandline i.e: java -DLOG=true -jar izpack-installer.jar

Parameters:
o - The Object to log, can be also an exception.

log

public static void log(java.lang.Object o,
                       int withWhatFormat)
Logs the given Object in the created Logfile if -DLOG=true was given on commandline i.e: java -DLOG=true -jar izpack-installer.jar

Parameters:
o - The Object to log
withWhatFormat - if the given MASK is greater than 0, Log with Date/Timestamp

logWithDate

private static boolean logWithDate(int withWhatFormat)
Indicates that to log with Date.

Parameters:
withWhatFormat - The whished Format
Returns:
true if to log with Date

logWithTimeStamp

private static boolean logWithTimeStamp(int withWhatFormat)
Indicates that to log with Timestamp.

Parameters:
withWhatFormat - The whished Format
Returns:
true if to log with Timestamp

createLogFile

private static java.io.PrintWriter createLogFile()
Creates the logfile to write log-infos into.

Returns:
The writer object instance

tracing

public static boolean tracing()
Indicates if debug is tracing

Returns:
true if tracing otherwise false

stackTracing

public static boolean stackTracing()
Indicates if debug is stacktracing

Returns:
true if stacktracing otherwise false

isLOG

public static boolean isLOG()
Returns the LOG flag.

Returns:
Returns the LOG flag.

setLOG

public static void setLOG(boolean aFlag)
Sets The LOG like the given value

Parameters:
aFlag - The LOG status to set to or not.

isSTACKTRACE

public static boolean isSTACKTRACE()
Returns the current STACKTRACE flag

Returns:
Returns the STACKTRACE.

setSTACKTRACE

public static void setSTACKTRACE(boolean aFlag)
Sets the STACKTRACE like the given value

Parameters:
aFlag - The STACKTRACE to set / unset.

isTRACE

public static boolean isTRACE()
Gets the current TRACE flag

Returns:
Returns the TRACE.

setTRACE

public static void setTRACE(boolean aFlag)
Sets the TRACE flag like the given value

Parameters:
aFlag - The TRACE to set / unset.

getLogFile

public static java.io.PrintWriter getLogFile()
Get the Logfile

Returns:
Returns the logFile.

setLogFile

public static java.io.PrintWriter setLogFile(java.io.PrintWriter aLogFile)
Sets the Logfile

Parameters:
aLogFile - The logFile to set. *
Returns:
The logfile to write into