de.fho.jump.pirol.utilities.debugOutput
Class GenericDebugLogger

java.lang.Object
  extended by de.fho.jump.pirol.utilities.debugOutput.GenericDebugLogger

public final class GenericDebugLogger
extends java.lang.Object

Class to handle debugging outputs. It is a singleton and keeps track of local debug settings and personal log levels. Configuration changes should not be done at runtime, but in the properties file ("debugging.properties") in the "[HOME]/.OpenJump_PIROL/config" directory. This file will be created when the logger is used the first time and filled with default values. For information on these values, please see commenting in the java source code.

Version:
$Rev: 1664 $
Author:
Ole Rahn, Stefan Ostermann

FH Osnabrück - University of Applied Sciences Osnabrück,
Project: PIROL (2005),
Subproject: Daten- und Wissensmanagement
See Also:
de.fho.jump.pirol.utilities.PirolPlugInSettings, PersonalLogger

Field Summary
protected  boolean eclipseFriendlyOutput
          format the output string so that eclipse supports jumping into the correct file and line number when clicking on the output.
protected static java.lang.String KEY_ECLIPSEFRIENDLYOUTPUT
           
protected static java.lang.String KEY_LOGLEVEL
           
protected static java.lang.String KEY_PRINTFILEANDLINE
           
protected static java.lang.String KEY_PRINTNEWLINEFIRST
           
protected static java.lang.String KEY_PRINTSHORTCLASSNAMES
           
protected static java.lang.String KEY_PRINTTIMESTAMPS
           
protected static java.lang.String KEY_PRINTUSERNAMES
           
protected static java.lang.String KEY_USELOGFILE
           
protected  java.io.File logFile
           
protected  int logLevel
          The logLevel specifies which kinds of messages will be put out.
protected  boolean printFileAndLine
          wether or not to print file name and line number in code
protected  boolean printNewLineFirst
          print additional line break before output of new messages?
protected  boolean printShortClassNames
          print short class names instead of class name plus the whole package path?
protected  boolean printTimeStamp
          wether or not to print time stamps in the messages
protected  boolean printUserNames
          print user names with every message?
protected  PropertiesHandler properties
           
protected static java.lang.String propertiesFile
           
static int SEVERITY_DEBUG
          Constant logLevel for debugging purposes.
static int SEVERITY_ERROR
          Constant logLevel for an error that may invalidate the current results occured.
static int SEVERITY_MINORERROR
          Constant logLevel for an error that won't have influence on the results occured.
static int SEVERITY_SEVEREERROR
          Constant logLevel for an error that may invalidate the current and future results or may crash the VM, etc..
static int SEVERITY_WARNING
          Constant logLevel for something that might not be good happened.
protected static java.lang.String[] severityLevels
           
protected  java.io.PrintStream stdErr
           
protected  java.io.PrintStream stdOut
           
protected  boolean useLogFile
          use a log file instead of printing messages to the console?
 
Method Summary
protected  java.lang.String getCallerString(java.lang.Throwable t)
           
 int getLogLevel()
           
 java.lang.String getPropertiesFile()
           
 boolean isPrintFileAndLine()
           
 boolean isPrintNewLineFirst()
           
 boolean isPrintTimeStamp()
           
protected  void loadProperties()
          load local configuration file, to check if there are saved directorties for debugging outputs.
protected  void printDebug(java.lang.String user, java.lang.String message)
           
protected  void printError(java.lang.String user, java.lang.String message)
           
protected  void printMessage(java.lang.String user, int severity, java.lang.String message)
           
protected  void printMinorError(java.lang.String user, java.lang.String message)
           
protected  void printSevereError(java.lang.String user, java.lang.String message)
           
protected  void printWarning(java.lang.String user, java.lang.String message)
           
 void setErrorStream(java.io.PrintStream err)
          Set the stream, where messages with a loglevel >= SEVERITY_MINORERROR are put out.
 void setLogLevel(int logLevel)
           
 void setOutputStream(java.io.PrintStream out)
          Set the stream, where messages with a loglevel < SEVERITY_MINORERROR are put out.
protected  boolean showMessagesOfUser(java.lang.String user)
          check if the properties contain information on how to treat messages from this user
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

properties

protected PropertiesHandler properties

propertiesFile

protected static final java.lang.String propertiesFile
See Also:
Constant Field Values

logLevel

protected int logLevel
The logLevel specifies which kinds of messages will be put out. A message will be put out, if its severity is greater or equal to the log level (or if the user's log messages are enabled)
 logLevel severity sheme:
 0  - debug             - just an output for debugging purposes
 1  - warning           - something that might not be good happened
 2  - minor error       - an error that won't have influence on the results occured
 3  - error             - an error that may invalidate the current results occured
 4  - severe error      - an error that may invalidate the current and future results or may crash the VM, etc. 
 


KEY_LOGLEVEL

protected static final java.lang.String KEY_LOGLEVEL
See Also:
Constant Field Values

SEVERITY_DEBUG

public static final int SEVERITY_DEBUG
Constant logLevel for debugging purposes.

See Also:
Constant Field Values

SEVERITY_WARNING

public static final int SEVERITY_WARNING
Constant logLevel for something that might not be good happened.

See Also:
Constant Field Values

SEVERITY_MINORERROR

public static final int SEVERITY_MINORERROR
Constant logLevel for an error that won't have influence on the results occured.

See Also:
Constant Field Values

SEVERITY_ERROR

public static final int SEVERITY_ERROR
Constant logLevel for an error that may invalidate the current results occured.

See Also:
Constant Field Values

SEVERITY_SEVEREERROR

public static final int SEVERITY_SEVEREERROR
Constant logLevel for an error that may invalidate the current and future results or may crash the VM, etc..

See Also:
Constant Field Values

severityLevels

protected static final java.lang.String[] severityLevels

eclipseFriendlyOutput

protected boolean eclipseFriendlyOutput
format the output string so that eclipse supports jumping into the correct file and line number when clicking on the output.


KEY_ECLIPSEFRIENDLYOUTPUT

protected static final java.lang.String KEY_ECLIPSEFRIENDLYOUTPUT
See Also:
Constant Field Values

printTimeStamp

protected boolean printTimeStamp
wether or not to print time stamps in the messages


KEY_PRINTTIMESTAMPS

protected static final java.lang.String KEY_PRINTTIMESTAMPS
See Also:
Constant Field Values

printFileAndLine

protected boolean printFileAndLine
wether or not to print file name and line number in code


KEY_PRINTFILEANDLINE

protected static final java.lang.String KEY_PRINTFILEANDLINE
See Also:
Constant Field Values

printNewLineFirst

protected boolean printNewLineFirst
print additional line break before output of new messages?


KEY_PRINTNEWLINEFIRST

protected static final java.lang.String KEY_PRINTNEWLINEFIRST
See Also:
Constant Field Values

printShortClassNames

protected boolean printShortClassNames
print short class names instead of class name plus the whole package path?


KEY_PRINTSHORTCLASSNAMES

protected static final java.lang.String KEY_PRINTSHORTCLASSNAMES
See Also:
Constant Field Values

printUserNames

protected boolean printUserNames
print user names with every message?


KEY_PRINTUSERNAMES

protected static final java.lang.String KEY_PRINTUSERNAMES
See Also:
Constant Field Values

stdOut

protected java.io.PrintStream stdOut

stdErr

protected java.io.PrintStream stdErr

logFile

protected java.io.File logFile

useLogFile

protected boolean useLogFile
use a log file instead of printing messages to the console?


KEY_USELOGFILE

protected static final java.lang.String KEY_USELOGFILE
See Also:
Constant Field Values
Method Detail

loadProperties

protected final void loadProperties()
                             throws java.io.IOException
load local configuration file, to check if there are saved directorties for debugging outputs.

Throws:
java.io.IOException - if the file with the given file name could not be accessed

showMessagesOfUser

protected final boolean showMessagesOfUser(java.lang.String user)
check if the properties contain information on how to treat messages from this user

Parameters:
user - user id to check
Returns:
true, if Properties contain information on this user that allow posting his/her messages

printMessage

protected final void printMessage(java.lang.String user,
                                  int severity,
                                  java.lang.String message)

getCallerString

protected final java.lang.String getCallerString(java.lang.Throwable t)

printDebug

protected final void printDebug(java.lang.String user,
                                java.lang.String message)

printWarning

protected final void printWarning(java.lang.String user,
                                  java.lang.String message)

printMinorError

protected final void printMinorError(java.lang.String user,
                                     java.lang.String message)

printError

protected final void printError(java.lang.String user,
                                java.lang.String message)

printSevereError

protected final void printSevereError(java.lang.String user,
                                      java.lang.String message)

getLogLevel

public final int getLogLevel()
Returns:
current log level

setLogLevel

public final void setLogLevel(int logLevel)
Parameters:
logLevel -

isPrintFileAndLine

public final boolean isPrintFileAndLine()
Returns:
true or false //TODO specify the return value

isPrintNewLineFirst

public final boolean isPrintNewLineFirst()
Returns:
true or false //TODO specify the return value

isPrintTimeStamp

public final boolean isPrintTimeStamp()
Returns:
true or false //TODO specify the return value

getPropertiesFile

public final java.lang.String getPropertiesFile()
Returns:
File name of the file where logger configuration is stored

setOutputStream

public final void setOutputStream(java.io.PrintStream out)
Set the stream, where messages with a loglevel < SEVERITY_MINORERROR are put out.

Parameters:
out - stream for debugging output

setErrorStream

public final void setErrorStream(java.io.PrintStream err)
Set the stream, where messages with a loglevel >= SEVERITY_MINORERROR are put out.

Parameters:
err - stream for debugging output