TPLOGDUMPDIFF

TPLOGDUMPDIFF

NAME
SYNOPSIS
DESCRIPTION
RETURN VALUE
ERRORS
EXAMPLE
BUGS
SEE ALSO
COPYING

NAME

tplogdumpdiff − print the hex−dump differences of two buffers to log file

SYNOPSIS

#include <ndebug.h>

void tplogdumpdiff(int lev, char *comment, void *ptr1, void *ptr2, int len);

or

#define TP_DUMP_DIFF(lev,comment,ptr,ptr2,len)

Link with −lnstd −lpthread −lrt −lm

DESCRIPTION

Function compares two memory areas by given pointers ptr and ptr2. The hex dump is generate and output is written to current logger (either process based, thread based or request based). The tplogdumpdiff() basically is wrapper for TP_LOGDUMP_DIFF. For C/C++ programs it is recommended to use macro version. lev is debug level from 1 (log_always) .. 5 (log_debug). Comment is title line of the dump. ptr and ptr2 are pointer to memory blocks to compare. len is number of bytes in each array to compare.

Log levels are following (from ndebug.h):

• log_always 1

• log_error 2

• log_warn 3

• log_info 4

• log_debug 5

RETURN VALUE

N/A

ERRORS

N/A

EXAMPLE

Code dumpdifftest.c

#include <ndebug.h>

int main (int argc, char **argv)
{
char arr1[32];
char arr2[32];
int i;

for (i=0; i<sizeof(arr1); i++)
{
arr1[i]=(char)(65+i);
arr2[i]=(char)(66+i);
}

tplogdumpdiff(log_debug, "Compare two arrays", arr1, arr2, sizeof(arr1));

TP_DUMP_DIFF(5, "Compare two arrays (TP_DUMP version)", arr1, arr2, sizeof(arr1));

return 0;
}

Sample run:

$ cc dumpdifftest.c −lnstd −lpthread −lrt −lm −I /include
$ ./a.out
t:USER:5:10865:000:20160928:095506583:/tplog.c:0437:Compare two arrays
< 0000 41 42 43 44 45 46 47 48 49 4a 4b 4c