Debugging

Top  Previous  Next

A user program can dynamically manage the XVSAM log, by defining the XvsamFdbg external variable. XVSAM writes the call information and the error messages in xvsamFdbg stream, if the value of xvsamFdbg differs from NULL. It uses the variable xvsamLdbg to establish the level of debugging information: 0 - no log printing, 15 - maximum level of debugging information.

For example the program:

external FILE *xvsamFdbg;
external int xvsamLdbg ;
main () {
    xvsamFdbg = fopen (“xvsam.log”, “w”);
    xvsamLdbg=10;
    xvsamapi (...);
}

writes the Xvsam6 log information in the file xvsam.log with a debugging level of 10 - average information logging level for diagnose -.

User debugging function

xvsam6 calls the function xvsamSdbg (if it’s value isn’t equal to NULL) any time it needs to print some debug information. The user can substitute the internal debug function with its own one. For example :

#include <stdarg.h>
extern void (*xvsamSdbg)(int, char *, int, char *, char *, ...);
static void my_debug(int, char *, int, char *, char, ...);
main ()
{
  xvsamSdbg = my_debug;    /* change the debug print
                              function for my one    */
  xvsamapi (...);
}
static void my_debug (int  lev,
                     char *file,
                     int  line,
                     char *id,
                     char *format,
                     ...)
{
  va_list   marker;
  if (level > 5) return ;
  if (file != NULL) printf("%s:%d:", file, line);
  if (id != NULL) printf("%s: ", id) ;
  va_start(marker, format) ;
  vfprintf(stdout, format, marker) ;
  va_end(marker) ;
  fflush(stdout);