swpchat.util
Class Diag

java.lang.Object
  |
  +--swpchat.util.Diag

public class Diag
extends java.lang.Object

A class that prints diagnostic (debugging or error) messages in an informative, flexible and dynamic way.

Method names are rather short as they shouldn't take up too much space in the client source code.


Field Summary
static java.lang.String CLS
          The fully qualified class name.
private static java.lang.String DefaultDiagFileName
          The default name of the configurations file, it is used if the System Property PKDiagFileName is not set.
private static DiagLog diagLog
           
private static java.lang.String diagLogFileName
           
private static DiagProps diagProps
           
static int EXHIBITIONIST
          Details that will hardly ever be of interest, except in voodo debugging circumstances.
private static java.util.GregorianCalendar gregorianCalendar
           
static int INTERNAL_ERROR
          Internal problems that just may get fixed.
static int PACKAGE_ENTRY_EXIT
          Entry and exit of package visible methods (without modifier).
private static java.lang.String PKDiagFileName
          The name of the property that stores the configurations file.
static int PRIVATE_ENTRY_EXIT
          Entry and exit of private methods.
static int PROTECTED_ENTRY_EXIT
          Entry and exit of protected methods.
static int PUBLIC_ENTRY_EXIT
          Entry and exit of publically visible methods.
private static boolean showdbgmessages
           
static int STRANGE
          Close to a warning, things that should not happen: Exceptions that are definitively not expected, unreachable default clauses etc.
static int TALKATIVE
          Begins to strain the reader, talks also about things working just as expected.
static int VERBOSE
          Things that just *might* be of interest, such as major control structures.
private static boolean writeinlog
           
 
Constructor Summary
private Diag()
          A Private constructor to prevent instantiation.
 
Method Summary
static void blink(java.lang.String message, java.lang.String location, int level)
          Print an extremely short message, no line of its own.
static void dbg(java.lang.String message, java.lang.String location, int level)
          Print the debugging message, if debugging is enabled for the function, class, or some ancestor package at the appropriate level.
static void debugMessagesOff()
          Stop issuing debug messages alltogether.
static void debugMessagesOn()
          Issue debug messages as specified by the location and level.
static void err(java.lang.String message, java.lang.String location)
          Print an error message.
private static java.lang.String getConfigFileName(java.lang.String fileName, java.lang.String defaultFileName)
          get the path of the config file with the given name
static void msg(java.lang.String message)
          Print the log message.
static void notImplemented(java.lang.String location)
          Issue a message that this method is not implemented yet.
static void reload()
          Reloads the properties.
static void setConfigFileName(java.lang.String configFileName)
          saves the config file name in PKDiagFileName
static void writeDebugMessagesOff()
          Stop writeing debug messages in log-file
static void writeDebugMessagesOn()
          Writeing debug messages in log-file as specified by the location and level.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

PKDiagFileName

private static java.lang.String PKDiagFileName
The name of the property that stores the configurations file.

DefaultDiagFileName

private static java.lang.String DefaultDiagFileName
The default name of the configurations file, it is used if the System Property PKDiagFileName is not set.

diagProps

private static DiagProps diagProps

diagLogFileName

private static java.lang.String diagLogFileName

diagLog

private static DiagLog diagLog

gregorianCalendar

private static java.util.GregorianCalendar gregorianCalendar

showdbgmessages

private static boolean showdbgmessages

writeinlog

private static boolean writeinlog

STRANGE

public static int STRANGE
Close to a warning, things that should not happen: Exceptions that are definitively not expected, unreachable default clauses etc.

INTERNAL_ERROR

public static int INTERNAL_ERROR
Internal problems that just may get fixed. TAUs (Technically advanced users) may want to run PRODUCT on with this debugging level to diagnose setup problems.

PUBLIC_ENTRY_EXIT

public static int PUBLIC_ENTRY_EXIT
Entry and exit of publically visible methods.

PACKAGE_ENTRY_EXIT

public static int PACKAGE_ENTRY_EXIT
Entry and exit of package visible methods (without modifier).

VERBOSE

public static int VERBOSE
Things that just *might* be of interest, such as major control structures.

PROTECTED_ENTRY_EXIT

public static int PROTECTED_ENTRY_EXIT
Entry and exit of protected methods.

TALKATIVE

public static int TALKATIVE
Begins to strain the reader, talks also about things working just as expected.

PRIVATE_ENTRY_EXIT

public static int PRIVATE_ENTRY_EXIT
Entry and exit of private methods.

EXHIBITIONIST

public static int EXHIBITIONIST
Details that will hardly ever be of interest, except in voodo debugging circumstances.

CLS

public static final java.lang.String CLS
The fully qualified class name.
Constructor Detail

Diag

private Diag()
A Private constructor to prevent instantiation.
Method Detail

msg

public static void msg(java.lang.String message)
Print the log message. Log messages are issued during normal operation to inform about major state changes, such as successful logins. As the user can not suppress these messages double check wether dbg isn't a better choice.
Parameters:
message - The message to show to the user.

dbg

public static void dbg(java.lang.String message,
                       java.lang.String location,
                       int level)
Print the debugging message, if debugging is enabled for the function, class, or some ancestor package at the appropriate level. Debugging messages are issued to support in tracing faulty code and may be turned on or off.
Parameters:
message - The message to show to the user.
location - The location of the call in the code. This is also written to the log.

This is a string containing the complete methodname followed by paramter types in paranthesis, e. g. "util.Diag.dbg(String,String,int)". The most specific entry in the internal database is matched against this string. The example is matched by: util.Diag.dbg(String,String,int), util.Diag.dbg, util.Diag, util and, if none of the others is found, the root entry. util.Diag.dbg() does not match the example.

level - The level of this message. The message is shown iff the debuglevel defined for the most specific location entry is equal to or larger than this value. Expect a message with a level of 0 to be printed always. (Although someone could define a negative level for a location)

blink

public static void blink(java.lang.String message,
                         java.lang.String location,
                         int level)
Print an extremely short message, no line of its own. Intended for things like "Reading stream: (a)(b)(c)". location and level are included for filtering, not for output.
Parameters:
message - The message to show to the user.
location - The location of the call in the code. This is a string containing the complete methodname followed by parameter types in paranthesis, e. g. "util.Diag.dbg(String,String,int)". The most specific entry in the internal database is matched against this string. The example is matched by: util.Diag.dbg(String,String,int), util.Diag.dbg, util.Diag, util and, if none of the others is found, the root entry. util.Diag.dbg() does not match the example.

level - The level of this message. The message is shown iff the debuglevel defined for the most specific location entry is equal to or larger than this value. Expect a message with a level of 0 to be printed always. (Although someone could define a negative level for a location)

err

public static void err(java.lang.String message,
                       java.lang.String location)
Print an error message. Error messages are generated for abnormal conditions and cannot be masked out. This method is intended for command-line error messages for `knowledgeable' users.
Parameters:
message - The message to show to the user.
location - Where did the error occur. This is a string containing the complete methodname followed by paramter types in paranthesis, e. g. "util.Diag.dbg(String,String, int)".

notImplemented

public static void notImplemented(java.lang.String location)
Issue a message that this method is not implemented yet.
Parameters:
location - This is a string containing the complete methodname followed by paramter types in paranthesis, e. g. "util.Diag.dbg(String,String,int),".

debugMessagesOff

public static void debugMessagesOff()
Stop issuing debug messages alltogether. Calling this has no effect to msg and err!

debugMessagesOn

public static void debugMessagesOn()
Issue debug messages as specified by the location and level.

writeDebugMessagesOff

public static void writeDebugMessagesOff()
Stop writeing debug messages in log-file

writeDebugMessagesOn

public static void writeDebugMessagesOn()
Writeing debug messages in log-file as specified by the location and level.

reload

public static void reload()
Reloads the properties.

getConfigFileName

private static java.lang.String getConfigFileName(java.lang.String fileName,
                                                  java.lang.String defaultFileName)
get the path of the config file with the given name
Parameters:
String - fileName
String - defaultFileName
Returns:
the path specified in the System property

setConfigFileName

public static void setConfigFileName(java.lang.String configFileName)
saves the config file name in PKDiagFileName
Parameters:
configFileName - the String specifying the name of the config file, that is just the filename without directory.