class ScDebug

This Class provides Debug possibilities. More...

Definition#include <scdebug.h>
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods


Detailed Description

This Class provides Debug possibilities.

At the moment the method doDebug writes its data, if debuglev (set by method setDebugLevel) is higher or equal then the first Argument of doDebug.

The user may set a combination of SYSLOG or STDOUT debugging. For this the setDebugMode method has to be called after creating the class.

Note !! The debugmode may be switched into different combinations during runtime.

In case of using scdebug (linking -luvdebug), the application has always to create a class scdebug (whether it is used or not). You may want to do that in your main file. The following piece of example code shows how to implement that straight forward.

The next paragraph shows, how to initialise Debugging


    #include 

    ScDebug *qwdebug;

    void main ( int argc, char *argv[] )
    {
      ScDebug *qwdebug   = new ScDebug();
      // set DebugLevel to 5 and use standard printmode and debugmode
      qwdebug->setDebugLevel( 5 );
      ...
    }

Here comes the example of a DebugMessage (in your code)


    #include 
    extern ScDebug *qwdebug;

    qwdebug->doDebug( 4, "%s[%d] : main(%d, %p) : start\n",
                          __FILE__, __LINE__, argc, argv );

The result is shown on stdout (fflushed) and looks like


    yourProgramName[203] : main ( 3, 0x80334450 ) : start

It is generally a good idea to switch the debuglevel of your program using a config file entry or program arguments. I am using -d level as program arguments normally.

int  dLevel ( )

dLevel

return the actual DebugLevel

Returns: : the actual debuglevel

void  setDebugLevel ( int dlev = 0 )

setDebugLevel

sets the actual debuglevel, which defines the limit, where debugging is stopped. All messages above debuglevel are not printed out.

dlev : the new debuglevel

void  setDebugPrintMode ( int mode = 0 )

setDebugPrintMode

sets the actual printmode actual printmodes are


    #define DBGFULLLINE 0 // print the full line transferd by program
    #define DBGBASENAME 1 // strip the leading path from filename

mode : the new printmode

void  setDebugMode ( int mode = 1 )

setDebugMode

sets the actual debugmode actual printmodes are


    #define DBGSTDOUT   0x01 // print to stdout
    #define DBGSYSLOG   0x02 // print to syslog

both values ar OR combinable. Note, that if no value is set (0x00) no debugging will take place. Nevertheless, the scdebug instance has to be instantiated.

mode : the new debugmode

void  doDebug ( int lev, const char *format, ... )

doDebug

writes a debug message to stdout, if lev is below debuglev.

lev : the debuglevel of the actual message format, ... : the format string (printf-compatible) and parameters

 ScDebug ()

ScDebug

constructor

 ~ScDebug ()

~ScDebug

destructor