Perforce

com.perforce.api
Class Debug

java.lang.Object
  |
  +--com.perforce.api.Debug

public final class Debug
extends Object

Utility class used for debugging. The level of debugging determines the amount of debugging information that is generated. The process using this class for debugging should ensure that it sets the debugging level appropriately.

Version:
$Date: 2002/08/05 $ $Revision: #6 $
Author:
David Markley

Field Summary
static int ERROR
          Only error messages are displayed.
static int LOG_NONE
          Debugging output is discarded entirely.
static int LOG_ONLY
          Debugging output is sent only to the EventLog.
static int LOG_SPLIT
          Debugging output is sent to standard out and to the EventLog.
static int NONE
          No debug messages are displayed.
static int NOTICE
          Error, warning, and notice messages are displayed.
static int VERBOSE
          Error, warning, notice, and verbose messages are displayed.
static int WARNING
          Error and warning messages are displayed.
 
Constructor Summary
Debug()
           
 
Method Summary
static void error(String msg)
          Displays an error message for debugging.
static int getDebugLevel()
          Returns the current debug level.
static EventLog getEventLog()
          Returns the current EventLog in use.
static String getLevelName(int level)
          Returns the name associated with the specified level.
static int getLogLevel()
          Returns the current logging level.
static boolean getShowThread()
          Returns the state of showing threads in degugging output.
static void notify(String msg)
          Displays a notice message for debugging.
static void notify(String msg, String[] arry)
          Displays a notice message for debugging.
static void out(int level, String msg)
          Writes the message to the debugging output.
static void out(int level, String msg, String[] arry)
          Writes the message and associated array of Strings to the debugging output.
static void out(int level, Throwable t)
          Writes the message associated with the Throwable to the debugging output.
static void out(String format, int level, Throwable t)
          Writes the formatted message associated with the Throwable to the debugging output.
static void setDebugLevel(int l)
          Sets the debug level for the application.
static void setEventLog(EventLog elog)
          Sets the EventLog that debugging output should be sent to.
static void setLogLevel(int log_level)
          Sets the logging level.
static void setLogLevel(String level)
          Sets the logging level.
static void setProperties(Properties props)
          Sets the logging level from the supplied Properties.
static void setShowThread(boolean show)
          If set true, the thread number is included in all debugging output.
static void verbose(String msg)
          Displays a verbose message for debugging.
static void verbose(String msg, String[] arry)
          Displays a verbose message for debugging.
static void warn(String msg)
          Displays a warning message for debugging.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ERROR

public static final int ERROR
Only error messages are displayed.

LOG_NONE

public static final int LOG_NONE
Debugging output is discarded entirely.

LOG_ONLY

public static final int LOG_ONLY
Debugging output is sent only to the EventLog.

LOG_SPLIT

public static final int LOG_SPLIT
Debugging output is sent to standard out and to the EventLog.

NONE

public static final int NONE
No debug messages are displayed.

NOTICE

public static final int NOTICE
Error, warning, and notice messages are displayed.

VERBOSE

public static final int VERBOSE
Error, warning, notice, and verbose messages are displayed.

WARNING

public static final int WARNING
Error and warning messages are displayed.
Constructor Detail

Debug

public Debug()
Method Detail

error

public static void error(String msg)
Displays an error message for debugging. If the debugging level is set below ERROR, then no message is displayed.
Parameters:
msg - The debugging error message.

getDebugLevel

public static int getDebugLevel()
Returns the current debug level.
See Also:
setDebugLevel(int)

getEventLog

public static EventLog getEventLog()
Returns the current EventLog in use.

getLevelName

public static String getLevelName(int level)
Returns the name associated with the specified level.
See Also:
setDebugLevel(int)

getLogLevel

public static int getLogLevel()
Returns the current logging level.

getShowThread

public static boolean getShowThread()
Returns the state of showing threads in degugging output.

notify

public static void notify(String msg)
Displays a notice message for debugging. If the debugging level is set below NOTICE, then no message is displayed.
Parameters:
msg - The debugging notice message.

notify

public static void notify(String msg,
                          String[] arry)
Displays a notice message for debugging. If the debugging level is set below NOTICE, then no message is displayed.
Parameters:
msg - The debugging notice message.
arry - Array containing useful debug information.

out

public static void out(int level,
                       String msg)
Writes the message to the debugging output.
Parameters:
level - Debugging level to associate with the message.
msg - Debugging message.

out

public static void out(int level,
                       String msg,
                       String[] arry)
Writes the message and associated array of Strings to the debugging output. The message will be followed by all the elements in the arry.
Parameters:
level - Debugging level to associate with the message.
msg - Debugging message.
arry - Array of strings to be sent to the debugging output.

out

public static void out(int level,
                       Throwable t)
Writes the message associated with the Throwable to the debugging output.
Parameters:
level - Debugging level to associate with the message.
t - Throwable that contains the message.

out

public static void out(String format,
                       int level,
                       Throwable t)
Writes the formatted message associated with the Throwable to the debugging output. The message will be placed in the string generated wherever the '{0}' attribute is placed.
Parameters:
format - Format to use for the debugging output.
level - Debugging level to associate with the message.
t - Throwable that contains the message.
See Also:
java.text.MessageFormat

setDebugLevel

public static void setDebugLevel(int l)
Sets the debug level for the application. If this is 0, no debug information is generated.
Parameters:
l - The level of debugging to use.
See Also:
NONE, ERROR, WARNING, NOTICE, VERBOSE

setEventLog

public static void setEventLog(EventLog elog)
Sets the EventLog that debugging output should be sent to.
Parameters:
elog - EventLog to use.

setLogLevel

public static void setLogLevel(int log_level)
Sets the logging level. This determines where the debugging output will be sent. Valid values are: LOG_SPLIT, LOG_ONLY, and LOG_NONE. The default is LOG_ONLY.

If the log level is set to LOG_NONE, then the debug level is automatically set to NONE.


setLogLevel

public static void setLogLevel(String level)
Sets the logging level. This determines where the debugging output will be sent. Valid values are "none", "only", or "split". The default is "only". The default value will be set, if the String does not match.

setProperties

public static void setProperties(Properties props)
Sets the logging level from the supplied Properties. This looks for the "p4.log_level" property with the value of either "none", "split", or "only".

setShowThread

public static void setShowThread(boolean show)
If set true, the thread number is included in all debugging output.

verbose

public static void verbose(String msg)
Displays a verbose message for debugging. If the debugging level is set below VERBOSE, then no message is displayed.
Parameters:
msg - The debugging notice message.

verbose

public static void verbose(String msg,
                           String[] arry)
Displays a verbose message for debugging. If the debugging level is set below VERBOSE, then no message is displayed.
Parameters:
msg - The debugging notice message.
arry - Array containing useful debug information.

warn

public static void warn(String msg)
Displays a warning message for debugging. If the debugging level is set below WARNING, then no message is displayed.
Parameters:
msg - The debugging warning message.

Perforce

Copyright © 2001, Perforce Software, All rights reserved.