jap
Class JAPDebug

java.lang.Object
  extended by java.util.Observable
      extended by jap.JAPDebug
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener, Log

public final class JAPDebug
extends java.util.Observable
implements java.awt.event.ActionListener, Log

This class serves as a debugging interface. It provides different debug types and levels for the output of debug messages.

The debug level can be set with JAPDebug.setDebuglevel(int level).

The debug type can be set with JAPDebug.setDebugType(int type).

To output a debug message use JAPDebug.out(int level, int type, String txt) This is a Singleton!


Field Summary
private static java.text.SimpleDateFormat dateFormatter
           
private static JAPDebug debug
           
private static boolean m_bConsole
           
private  int m_debugLevel
           
private  int m_debugType
           
private static JAPDialog m_frameConsole
           
private static javax.swing.JTextArea m_textareaConsole
           
private  java.awt.event.WindowAdapter m_winAdapter
           
private static boolean ms_bFile
           
private static FileLog ms_FileLog
           
private static java.lang.String ms_strFileName
           
 
Constructor Summary
private JAPDebug()
           
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
           
 void finalize()
           
static JAPDebug getInstance()
           
static java.lang.String getLogFilename()
          Returns the Filename log output goes to or null if logging to a File is disabled.
 int getLogLevel()
          Get the current debug level.
 int getLogType()
          Get the current debug type.
 void internal_showConsole(boolean b, java.awt.Component parent)
           
static boolean isLogToFile()
           
static boolean isShowConsole()
           
 void log(int level, int type, java.lang.String txt)
          Output a debug message.
private  void saveLog()
           
 void setLogLevel(int level)
          Set the debugging level you would like to output.
static void setLogToFile(java.lang.String strFilename)
          Enables or disables log output to a File.
 void setLogType(int type)
          Set the debugging type you like to output.
static void showConsole(boolean b, java.awt.Component parent)
          Shows or hiddes a Debug-Console-Window
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_debugType

private int m_debugType

m_debugLevel

private int m_debugLevel

m_textareaConsole

private static javax.swing.JTextArea m_textareaConsole

m_frameConsole

private static JAPDialog m_frameConsole

m_bConsole

private static boolean m_bConsole

ms_bFile

private static volatile boolean ms_bFile

ms_strFileName

private static java.lang.String ms_strFileName

ms_FileLog

private static FileLog ms_FileLog

debug

private static JAPDebug debug

dateFormatter

private static java.text.SimpleDateFormat dateFormatter

m_winAdapter

private java.awt.event.WindowAdapter m_winAdapter
Constructor Detail

JAPDebug

private JAPDebug()
Method Detail

finalize

public void finalize()
Overrides:
finalize in class java.lang.Object

getInstance

public static JAPDebug getInstance()

log

public void log(int level,
                int type,
                java.lang.String txt)
Output a debug message.

Specified by:
log in interface Log
Parameters:
level - The level of the debugging message (EMERG,ALERT,CRIT,ERR,WARNING,NOTICE,INFO,DEBUG)
type - The type of the debugging message (GUI, NET, THREAD, MISC)
txt - The message itself

setLogType

public void setLogType(int type)
Set the debugging type you like to output. To activate more than one type you simly add the types like this setDebugType(JAPDebug.GUI+JAPDebug.NET).

Specified by:
setLogType in interface Log
Parameters:
type - The debug type (NUL, GUI, NET, THREAD, MISC)

getLogType

public int getLogType()
Get the current debug type.

Specified by:
getLogType in interface Log

setLogLevel

public void setLogLevel(int level)
Set the debugging level you would like to output. The possible parameters are (EMERG, ALERT, EXCEPTION, ERR, WARNING, NOTICE, INFO, DEBUG). DEBUG means output all messages, EMERG means only emergency messages.

Specified by:
setLogLevel in interface Log
Parameters:
level - The debug level (EMERG, ALERT, EXCEPTION, ERR, WARNING, NOTICE, INFO, DEBUG)

getLogLevel

public int getLogLevel()
Get the current debug level.

Specified by:
getLogLevel in interface Log

showConsole

public static void showConsole(boolean b,
                               java.awt.Component parent)
Shows or hiddes a Debug-Console-Window

Parameters:
b - set true to show the debug console or false to hidde them
parent - the parent frame of the debug console

setLogToFile

public static void setLogToFile(java.lang.String strFilename)
Enables or disables log output to a File.

Parameters:
strFilename - the Filename the logoutput should go to, if null (or the empty String "") log to file is disabled.

isShowConsole

public static boolean isShowConsole()

isLogToFile

public static boolean isLogToFile()

getLogFilename

public static java.lang.String getLogFilename()
Returns the Filename log output goes to or null if logging to a File is disabled.


internal_showConsole

public void internal_showConsole(boolean b,
                                 java.awt.Component parent)

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Specified by:
actionPerformed in interface java.awt.event.ActionListener

saveLog

private void saveLog()