summaryrefslogtreecommitdiff
path: root/include/chilldebug.h
blob: 010687afac45e4db7bdf6c10b5b4956344c2f745 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef DEBUGCHILL_H
#define DEBUGCHILL_H

#include <libgen.h>
#include <string.h>
#include <stdlib.h>

#ifndef NDEBUG // means that CMAKE_BUILD_TYPE=Debug
#define DEBUGCHILL
#endif
// This thing below potentially create leaks
#define FILENAME basename(strdup(__FILE__))

#ifdef DEBUGCHILL 
#define CHILL_DEBUG_PRINT(format,args...) fprintf(stderr,"%15s | %15s | LN%-4d:\t" format,FILENAME,__FUNCTION__, \
        __LINE__, ##args )
#define CHILL_DEBUG_BEGIN   { \
                                fprintf(stderr,"=========\t%15s, %15s, LN%-4d\t=========\n",FILENAME,__FUNCTION__,__LINE__);
#define CHILL_DEBUG_END     fprintf(stderr,"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n");}
#else
#define CHILL_DEBUG_PRINT(format,args...) do {} while(0) /* Don't do anything  */
#define CHILL_DEBUG_BEGIN   while(0) {
#define CHILL_DEBUG_END     }
#endif

// TODO below should be substituted by some error throwing? to be more consistent with cpp style
#define CHILL_ERROR(format,args...) fprintf(stderr,"ERROR:\t%s, %s, LN%d:\t" format,FILENAME,__FUNCTION__, \
        __LINE__, ##args )


#endif