Refactor logging core into multiple functions, support multi-line logging
[nobug.git] / doc / dumpexample.txt
blob96577b91790b86b37e904b8b01244ef858718e65
1 PARA How to use the DUMP facilities;;
3 [source,c]
4 -------------------------------------------------------
5 struct STRUCTNAME
7   int INTEGER_MEMBER;
8   char * STRING_MEMBER;
9   struct STRUCTNAME* next;
11 -------------------------------------------------------
13 then you define a function like:
15 [source,c]
16 -------------------------------------------------------
17 void
18 nobug_STRUCTNAME_dump (const struct STRUCTNAME* self,
19                        const int depth,
20                        const char* file,
21                        const int line,
22                        const char* func)
24   // check for self != NULL and that the depth
25   // limit did not exceed in recursive datastructures
26   if (self && depth)
27   {
28     // use DUMP_LOG not LOG to print the data
29     DUMP_LOG("STRUCTNAME %p: int is %d, string is %s", self,
30                              self->INTEGER_MEMBER,
31                              self->STRING_MEMBER);
32     // now recurse with decremented depth
33     nobug_STRUCTNAME_dump (self->next, depth-1, file, line, func);
34   }
36 -------------------------------------------------------
38 now you can use the DUMP() macros within the code
40 [source,c]
41 -------------------------------------------------------
42 example()
44   struct STRUCTNAME foo;
45   init(&foo);
46   DUMP (my_flag, STRUCTNAME, &foo, 2);
48 -------------------------------------------------------