1 #ifndef NOTCURSES_LOGGING
2 #define NOTCURSES_LOGGING
3 
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7 
8 void nclog(const char* fmt, ...) __attribute__ ((format (printf, 1, 2)));
9 
10 // logging
11 extern int loglevel;
12 
13 #define logpanic(fmt, ...) do{ \
14   if(loglevel >= NCLOGLEVEL_PANIC){ \
15     nclog("%s:%d:" fmt, __func__, __LINE__, ##__VA_ARGS__); } \
16   } while(0);
17 
18 #define logfatal(fmt, ...) do{ \
19   if(loglevel >= NCLOGLEVEL_FATAL){ \
20     nclog("%s:%d:" fmt, __func__, __LINE__, ##__VA_ARGS__); } \
21   } while(0);
22 
23 #define logerror(fmt, ...) do{ \
24   if(loglevel >= NCLOGLEVEL_ERROR){ \
25     nclog("%s:%d:" fmt, __func__, __LINE__, ##__VA_ARGS__); } \
26   } while(0);
27 
28 #define logwarn(fmt, ...) do{ \
29   if(loglevel >= NCLOGLEVEL_WARNING){ \
30     nclog("%s:%d:" fmt, __func__, __LINE__, ##__VA_ARGS__); } \
31   } while(0);
32 
33 #define loginfo(fmt, ...) do{ \
34   if(loglevel >= NCLOGLEVEL_INFO){ \
35     nclog("%s:%d:" fmt, __func__, __LINE__, ##__VA_ARGS__); } \
36   } while(0);
37 
38 #define logverbose(fmt, ...) do{ \
39   if(loglevel >= NCLOGLEVEL_VERBOSE){ \
40     nclog("%s:%d:" fmt, __func__, __LINE__, ##__VA_ARGS__); } \
41   } while(0);
42 
43 #define logdebug(fmt, ...) do{ \
44   if(loglevel >= NCLOGLEVEL_DEBUG){ \
45     nclog("%s:%d:" fmt, __func__, __LINE__, ##__VA_ARGS__); } \
46   } while(0);
47 
48 #define logtrace(fmt, ...) do{ \
49   if(loglevel >= NCLOGLEVEL_TRACE){ \
50     nclog("%s:%d:" fmt, __func__, __LINE__, ##__VA_ARGS__); } \
51   } while(0);
52 
53 #ifdef __cplusplus
54 }
55 #endif
56 
57 #endif
58