Listing 2: Controlling the Debug class from the command line, and setting default behavior

// Example of activating the package from the command line
int main(int argc, char *argv[]) {
   for(int i = 1;i < argc; i++) {
       ...
       if(!strncmp("-DEBUG",argv[i],6)) 
           Debug::specify(argv[i]);
       ...
   }
   Debug D("main");
   ...
   D.Dbg("A","Value of x is ",x);
   ...
   return 0;
} 

//Example of setting default behavior and
//possibly overriding it from the command line
int main(int argc, char *argv[]) {
       
    // No tracing, logging with keyword log
    Debug::specify("D:logt:");
    for(int i = 1;i < argc; i++) {
        ...
        if(!strncmp("-DEBUG",argv[i],6)) 
            Debug::specify(argv[i]);
        ...
    }
    Debug D("main");
    ...
    D.Dbg("A","Value of x is ",x);
    D.Dbg("log","Blah blah blah ",x);
    ...
    return 0;
}
— End of Listing —