Holger's Java API

## com.antelmann
Class Debug

    java.lang.Object
      com.antelmann.Debug

    public final class Debug

extends Object

provides globally accessible methods and variables for convenient debugging

Author:
  Holger Antelmann
See Also:
  `Monitor`

Nested Class Summary
`static class` `Debug.FileExceptionHandler` can be used to conveniently write all exceptions to a file.

Field Summary
`static Thread.UncaughtExceptionHandler` `dialogExceptionHandler` can be used to display a dialog for uncaught exceptions.
`static boolean` `enabled` false by default
`static MyFile` `file` a MyFile object that is initially null
`static Logger` `logger` the logger is initialized as a plain empty logger ignoring occurring exceptions in writers
`static Monitor` `monitor` monitor is initialized with new Monitor()
`static Stopwatch` `stopwatch` initialized as non-running

Method Summary
`static void` `addSystemErrFile(File file, boolean append)`
`static void` `addSystemOutFile(File file, boolean append)`
`static TimerTask` `createMemoryLogTimer()`
`static void` `dumpAllStacks()`
`static int` `dumpHeap(File file)`
`static void` `dumpSettings()` prints all settings to the console.
`static void` `dumpStack()`
`static void` `dumpStack(Thread t)`

`static

`<T> T`

`

`find(Throwable t, Class<T> exceptionType)`
looks if any exception in the getCause()-path is an instance of the given type and if so returns it - otherwise null is returned

`static String` `getAllStackTracesAsString()`
`static String` `getFieldDetailsAsString(Object obj)`
`static int` `getProcessID()`
`static String` `getSettingsAsString()` provides a String containing application settings, system settings, environment settings, L&Fs and memory info.
`static String` `getStackTraceAsString()` excludes the call to this method and beyond in the stack trace
`static String` `getStackTraceAsString(StackTraceElement[] stack, boolean reversed)`
`static String` `getStackTraceAsString(Thread t)`
`static boolean` `isDevEnv()` returns true only if the system can determine that the JVM runs on a special development environment where possibly some testing options ought to be enabled
`static boolean` `isTesting()`
`static String` `memoryString()`
`static boolean` `printToFile(Throwable t, File file, boolean append)` returns true only if operation was successful
`static File` `printToTempFile(Throwable t)` returns the name of the temp file the Throwable was written to or null if the write attempt was unsuccessful.
`static void` `say(Object txt)` just for test debugging; prints the text along w/ the word debug on the console (to distinguish from standard System.out.println() in the source code)
`static void` `setSystemErr(File file, boolean append)`
`static void` `setSystemOut(File file, boolean append)`
`static void` `setTesting(boolean flag)`
`static void` `show(Component parent, Object message)` displays a debug message in a modal dialog
`static void` `show(Object message)` displays a debug message in a modal dialog
`static JMainFrame` `showMemoryGauge()` pops up a JMemoryGauge in a simple JMainFrame
`static String` `stackTraceAsString(Throwable t)`
`static String` `stackTraceAsString(Throwable tw, Thread td)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### dialogExceptionHandler

    public static final Thread.UncaughtExceptionHandler dialogExceptionHandler

  can be used to display a dialog for uncaught exceptions.

  See Also:
    `Thread.setDefaultUncaughtExceptionHandler(Thread.UncaughtExceptionHandler)`, `Thread.setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler)`

### monitor

    public static final Monitor monitor

  monitor is initialized with new Monitor()

### enabled

    public static volatile boolean enabled

  false by default

### logger

    public static final Logger logger

  the logger is initialized as a plain empty logger ignoring occurring exceptions in writers

### stopwatch

    public static final Stopwatch stopwatch

  initialized as non-running

### file

    public static volatile MyFile file

  a MyFile object that is initially null

Method Detail

### isTesting

    public static boolean isTesting()

### setTesting

    public static void setTesting(boolean flag)

### isDevEnv

    public static boolean isDevEnv()

  returns true only if the system can determine that the JVM runs on a special development environment where possibly some testing options ought to be enabled

### createMemoryLogTimer

    public static TimerTask createMemoryLogTimer()

### getFieldDetailsAsString

    public static String getFieldDetailsAsString(Object obj)

### memoryString

    public static String memoryString()

### showMemoryGauge

    public static JMainFrame showMemoryGauge()

  pops up a JMemoryGauge in a simple JMainFrame

  See Also:
    `JMemoryGauge`

### find

    public static <T> T find(Throwable t,
                             Class<T> exceptionType)

  looks if any exception in the getCause()-path is an instance of the given type and if so returns it - otherwise null is returned

### show

    public static void show(Object message)

  displays a debug message in a modal dialog

### show

    public static void show(Component parent,
                            Object message)

  displays a debug message in a modal dialog

### stackTraceAsString

    public static String stackTraceAsString(Throwable t)

### stackTraceAsString

    public static String stackTraceAsString(Throwable tw,
                                            Thread td)

### printToTempFile

    public static File printToTempFile(Throwable t)

  returns the name of the temp file the Throwable was written to or null if the write attempt was unsuccessful.

### printToFile

    public static boolean printToFile(Throwable t,
                                      File file,
                                      boolean append)

  returns true only if operation was successful

### getSettingsAsString

    public static String getSettingsAsString()

  provides a String containing application settings, system settings, environment settings, L&Fs and memory info.

  See Also:
    `Settings`, `System.getProperties()`, `System.getenv()`

### dumpSettings

    public static void dumpSettings()

  prints all settings to the console. The output is sorted by property name. System variables may be overwritten by system properties may be overwritten by application settings in this map.

### getStackTraceAsString

    public static String getStackTraceAsString()

  excludes the call to this method and beyond in the stack trace

### getStackTraceAsString

    public static String getStackTraceAsString(StackTraceElement[] stack,
                                               boolean reversed)

### getStackTraceAsString

    public static String getStackTraceAsString(Thread t)

### getAllStackTracesAsString

    public static String getAllStackTracesAsString()

### dumpStack

    public static void dumpStack()

### dumpAllStacks

    public static void dumpAllStacks()

### dumpStack

    public static void dumpStack(Thread t)

### getProcessID

    public static int getProcessID()

### dumpHeap

    @Todo
    public static int dumpHeap(File file)
                        throws IOException,
                               InterruptedException

  Throws:
    `IOException`
    `InterruptedException`

### addSystemErrFile

    public static void addSystemErrFile(File file,
                                        boolean append)
                                 throws FileNotFoundException

  Throws:
    `FileNotFoundException`

### addSystemOutFile

    public static void addSystemOutFile(File file,
                                        boolean append)
                                 throws FileNotFoundException

  Throws:
    `FileNotFoundException`

### setSystemErr

    public static void setSystemErr(File file,
                                    boolean append)
                             throws FileNotFoundException

  Throws:
    `FileNotFoundException`

### setSystemOut

    public static void setSystemOut(File file,
                                    boolean append)
                             throws FileNotFoundException

  Throws:
    `FileNotFoundException`

### say

    public static void say(Object txt)

  just for test debugging; prints the text along w/ the word debug on the console (to distinguish from standard System.out.println() in the source code)

(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads