Debug.defineSwitch

Overview | Methods | This Package | All Packages

Debug.defineSwitch

Defines a new debug switch.

Syntax

public static void defineSwitch( String name, String description )

Parameters

name

The name of the switch to define.

description

A string that describes what the switch does.

Remarks

A switch is a debugging tool that allows you to dynamically switch logic bits in and out of code. For example, you may have logic in your code that prints information every time part of your application paints so you can see when and why it is painting. However, you probably don't want to see an endless stream of text displayed all the time. You can use switches to add your special logic but keep it from being invoked unless you need it. You can dynamically switch logic on and off without recompiling, which can reduce development time.

You typically define a switch only once. To define a switch, add a call to Debug.defineSwitch in your class initializer:

import com.ms.wfc.util.Debug;
public class Class1 {
   // Static initializer
   static {
      Debug.defineSwitch("MYSWITCH", "Description of my switch.");
   }
}

This creates the switch when your class loads. To conditionally print information to debug output when MYSWITCH is set, use code such as:

Debug.printlnIf("MYSWITCH", "Print important debugging information here.");

A switch can be set either from the registry or from an environment variable. To set a switch from the registry, type the switch name as a non-zero DWORD value under the key HKEY_CURRENT_USER\Software\Microsoft\WFC\DebugSwitches. To set a switch from the environment, set an environment variable named WFCD_switch name to either 1 or Y.

Switches are set to false in versions of your product that do not have the DEBUG conditional compile switch set.

See Also   getSwitch