Commandline Parsing and Enabling

Top  Previous  Next

SEE SAMPLE SOURCE CODE FOR BETTER EXPLANATION

 

In order to make it easier for you to enable commandline configuration of logging functions, JrDebugLogger provides a helper commandline parser function.  When invoked it will scan the commandline for specific arguments and. if found, use them to enable or disable debugging; any arguments found will be removed from your argc and argv variables so that your program can parse the rest of the commandline arguments as per normal.

 

Invoke the commandline parser helper function from your main() function as follows:

JrDebug::GrabCommandlineDebugFile(int &argc,char **argv,bool disableifnofile=false, bool donthangeargcv=false)

 

The function returns true if debugging was enabled through the commandline.

 

int main(int argc, char *argv[])

{

 // automatically enable if -dbc or -dbf parameters on commandline; disable if not

 JrDebug::GrabCommandlineDebugFile(argc,argv,true);

}

 

Invoke like:

demo1.exe -dbo text;debugout.txt

 

Options:

-db                        enable debug logging

-dbc                        enable debug logging to stdout console

-dbo STYLE[:options][;FILENAME][;stdout][;sysout][;info]    send debug output to file (and/or stdout,sysout), optionally with info about where the debug file is being written

-dbb                        enable brief mode debug logging

-dbd                        disable debug logging

 


 

 

IMPORTANT NOTE:

 

You can also call a simpler commandline initialization function that doesn't use argc and argv:

 JrDebug::ParseCommandlineArgString("commandline args as one long string",fullpathofexe|NULL,bool &foundcommandlineargs);

 

ex:

 JrDebug::ParseCommandlineArgString("-dbo text;debugout.txt",NULL,false);