com.perforce.api
Class Debug

java.lang.Object
  extended by com.perforce.api.Debug

public final class Debug
extends java.lang.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: 2001/11/05 $ $Revision: #1 $
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(java.lang.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 java.lang.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(java.lang.String msg)
          Displays a notice message for debugging.
static void notify(java.lang.String msg, java.lang.String[] arry)
          Displays a notice message for debugging.
static void out(int level, java.lang.String msg)
          Writes the message to the debugging output.
static void out(int level, java.lang.String msg, java.lang.String[] arry)
          Writes the message and associated array of Strings to the debugging output.
static void out(int level, java.lang.Throwable t)
          Writes the message associated with the Throwable to the debugging output.
static void out(java.lang.String format, int level, java.lang.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(java.lang.String level)
          Sets the logging level.
static void setProperties(java.util.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(java.lang.String msg)
          Displays a verbose message for debugging.
static void verbose(java.lang.String msg, java.lang.String[] arry)
          Displays a verbose message for debugging.
static void warn(java.lang.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

NONE

public static final int NONE
No debug messages are displayed.

See Also:
Constant Field Values

ERROR

public static final int ERROR
Only error messages are displayed.

See Also:
Constant Field Values

WARNING

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

See Also:
Constant Field Values

NOTICE

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

See Also:
Constant Field Values

VERBOSE

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

See Also:
Constant Field Values

LOG_NONE

public static final int LOG_NONE
Debugging output is discarded entirely.

See Also:
Constant Field Values

LOG_SPLIT

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

See Also:
Constant Field Values

LOG_ONLY

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

See Also:
Constant Field Values
Constructor Detail

Debug

public Debug()
Method Detail

getLevelName

public static java.lang.String getLevelName(int level)
Returns the name associated with the specified level.

See Also:
setDebugLevel(int)

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

getDebugLevel

public static int getDebugLevel()
Returns the current debug level.

See Also:
setDebugLevel(int)

setShowThread

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


getShowThread

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


setEventLog

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

Parameters:
elog - EventLog to use.

getEventLog

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


setLogLevel

public static void setLogLevel(java.lang.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(java.util.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".


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.


getLogLevel

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


error

public static void error(java.lang.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.

warn

public static void warn(java.lang.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.

notify

public static void notify(java.lang.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(java.lang.String msg,
                          java.lang.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.

verbose

public static void verbose(java.lang.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(java.lang.String msg,
                           java.lang.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.

out

public static void out(int level,
                       java.lang.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(java.lang.String format,
                       int level,
                       java.lang.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:
MessageFormat

out

public static void out(int level,
                       java.lang.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,
                       java.lang.String msg,
                       java.lang.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.


Copyright © 2009. All Rights Reserved.