New Debugging

From OPeNDAP Documentation
⧼opendap2-jumptonavigation⧽

For example:

besctl start -d "bes.debug,all"

This will dump all debug statements to the file bes.debug in the same directory from where you started the BES.

And adding debug statements to your code is easy.

 BESDEBUG( "<context>", "I am here" << endl )

The first parameter to this macro is the context of debugging. For example, if you are debugging the netcdf_handler you would use "nc" as the context. In the BES there is the bes context, ppt for the transport context, server for the server specific context, cmdln for the bescmdln specific debugging. After the context you can add anything that would be accepted by ostream. And, all BES classes are inherited from a single class, BESObj. This class has a method on it that allows you to dump the contents of that object to an ostream. All classes generated by the besCreateModule script also implement this dump method. For example, using the example hello world module provided in the BES source tree:

void
SayResponseHandler::dump( ostream &strm ) const
{
    strm << BESIndent::LMarg << "SayResponseHandler::dump - ("
			     << (void *)this << ")" << endl ;
    BESIndent::Indent() ;
    BESResponseHandler::dump( strm ) ;
    BESIndent::UnIndent() ;
}

In order to dump an object all you have to do is:

SayResponseHandler *handler = new SayResponseHandler( "say" ) ;
BESDEBUG( "handler = " << *handler << endl )

In your Module class you should register your context, so that when -h is specified to beslistener you can see all context available for debugging. To register, in your Module class in the initialize method simply add the following line:

BESDebug::Register( "<context>" ) ;

where context is your component name (nc for netcdf_handler, ff for freeform_handler, etc...)