Debug Capture Mechanism
Debug Class Model
Configuring Debug Capturing Properties
The file that contains the configuration information
is Windchill\codebase\debug.properties. The file contains descriptions
for the syntax of entries and examples of each. The types of configuration
entries are as follows:
-
System Debug Switch - Governs the ability of debug flags to be activated
and has three valid settings:
-
Debug capturing is off for everything, regardless of other configuration
settings.
-
Debug capturing is on, but only for entries defined in the configuration
file.
-
Debug capturing is on, and entries can be dynamically activated programmatically.
-
Groups Definitions – Enable debug configuration for groups of packages
and classes.
-
Log File Definitions – Enable log files for specific pre-defined groups.
-
Expectation is that default log file will be overridden by the startup
of each application.
-
Debug Capturing Definitions – Enable debug capturing for specific classes,
class hierarchies, packages, package hierarchies, and groups.
-
Note: Qualifier only works for specifications where the target is a class.
Initializing a Class to use Debug Capturing
public class SomeClass {
public
static final boolean DEBUG = DebugProperties.isDebugOn( CLASSNAME );
private
static final DebugWriter LOG = ( DEBUG ? DebugProperties.getWriter( CLASSNAME ) : null
);
...
Capturing TRACE Information
public void step1( String[]
args ) {
//##begin
step1%3945723701D4.body preserve=yes
if ( DEBUG && DebugProperties.isTrace(
this ) ) {
Object[] dargs = { args };
LOG.enter( CLASSNAME, "step1(String[])",
dargs );
}
step2()
if ( DEBUG && DebugProperties.isTrace(
this ) )
LOG.exit( CLASSNAME , " step1(String[])"
);
//##end step1%3945723701D4.body
}
public boolean step2() {
//##begin
step2%3945729A030D.body preserve=yes
if (
DEBUG&&
DebugProperties.isTrace( this ) )
LOG.enter( CLASSNAME, "step2()" );
boolean
retVal = step3( 3, this ) != null;
if (
DEBUG
&& DebugProperties.isTrace( this ) )
LOG.exit( CLASSNAME , "step2()", retVal
);
return
retVal;
//##end
step2%3945729A030D.body
}
public Object step3( int primitive,
Object object ) {
//##begin
step3%3945726A038A.body preserve=yes
if (
DEBUG
&& DebugProperties.isTrace( this ) ) {
Object[] dargs = { new Integer( primitive ), object };
LOG.enter( CLASSNAME, "step3(int,Object)",
dargs );
}
Object
retVal = object;
if (
DEBUG
&& DebugProperties.isTrace( this ) )
LOG.exit( CLASSNAME, "step3(int,Object)",
retVal );
return
retVal;
//##end
step3%3945726A038A.body
}
Capturing Other Debug Information
//##begin
testData%39457382002E.body preserve=yes
if (
DEBUG && DebugProperties.isData( this
) )
LOG.identify( this ); // report the identity
of an object
if (
DEBUG && DebugProperties.isData( this
) )
LOG.dump( this ); // report the
complete state of an object
//##end
testData%39457382002E.body
}
public void testException()
{
//##begin
testException%39457304035B.body preserve=yes
Throwable
thown = new WTRuntimeException( "Test brief runtime exception report" );
if (
DEBUG && DebugProperties.isException( this
) )
LOG.exception( thown );
thown
= new WTException( RESOURCE, wt.util.utilResource.MALFORMED_MIME, null
);
if (
DEBUG && DebugProperties.isException( this
) )
LOG.exception( thown );
//##end
testException%39457304035B.body
}
public void testStackTrace()
{
//##begin
testStackTrace%3945739F034B.body preserve=yes
if (
DEBUG && DebugProperties.isStackTrace(
this ) )
LOG.printStackTrace( "Test printStackTrace"
);
//##end
testStackTrace%3945739F034B.body
}
public void testReport() {
//##begin
testReport%394573880280.body preserve=yes
if (
DEBUG && DebugProperties.isReport( this
) )
LOG.report( "Test general report API."
);
//##end
testReport%394573880280.body
}
Adjusting Debug Configuration On
The Fly
public void setConfig1() {
DebugProperties.setFlag(
DebugFlag.TRACE, CLASSNAME, DebugType.CLASS, "", true );
}
public void setConfig2() {
DebugProperties.setFlag(
DebugFlag.DATA, CLASSNAME, DebugType.CLASS, "", true );
DebugProperties.setFlag(
DebugFlag.EXCEPTION, "wt.util", DebugType.PACKAGE, "", true );
DebugProperties.setFlag(
DebugFlag.REPORT, "wt.util", DebugType.PACKAGE_HIERARCHY, "", true );
DebugProperties.setFlag(
DebugFlag.STACK_TRACE, "<<subsystem>>util", DebugType.GROUP, "",
true );
}
public void setConfig3() {
// set all flags on, with one call
DebugProperties.setFlag(
DebugFlag.ALL, CLASSNAME, DebugType.CLASS, "", true );
}