hl7parse
logging.h
Go to the documentation of this file.
1 
6 #pragma once
7 
9 #define LEVEL_FATAL 1
10 
11 #define LEVEL_CRITICAL 2
12 
13 #define LEVEL_ERROR 3
14 
15 #define LEVEL_WARNING 4
16 
17 #define LEVEL_NOTICE 5
18 
19 #define LEVEL_INFO 6
20 
21 #define LEVEL_DEBUG 7
22 
23 #define LEVEL_TRACE 8
24 
25 #ifndef PRODUCTION
26 
31  #define log_fatal(fmt, ...) \
32  logprint("%s %s:%d " fmt "\n", \
33  logtime(), __FUNCTION__, __LINE__, ##__VA_ARGS__)
34 
39  #define log_critical(fmt, ...) \
40  logprint("%s %s:%d " fmt "\n", \
41  logtime(), __FUNCTION__, __LINE__, ##__VA_ARGS__)
42 
47  #define log_error(fmt, ...) \
48  logprint("%s %s:%d " fmt "\n", \
49  logtime(), __FUNCTION__, __LINE__, ##__VA_ARGS__)
50 
56  #define log_warning(fmt, ...) if (loglevel >= LEVEL_WARNING) \
57  logprint("%s %s:%d " fmt "\n", logtime(), __FUNCTION__, \
58  __LINE__, ##__VA_ARGS__)
59 
64  #define log_notice(fmt, ...) if (loglevel >= LEVEL_NOTICE) \
65  logprint("%s %s:%d " fmt "\n", logtime(), __FUNCTION__, \
66  __LINE__, ##__VA_ARGS__)
67 
72  #define log_info(fmt, ...) if (loglevel >= LEVEL_INFO) \
73  logprint("%s %s:%d " fmt "\n", logtime(), __FUNCTION__, \
74  __LINE__, ##__VA_ARGS__)
75 
80  #define log_debug(fmt, ...) if (loglevel >= LEVEL_DEBUG) \
81  logprint("%s %s:%d " fmt "\n", logtime(), __FUNCTION__, \
82  __LINE__, ##__VA_ARGS__)
83 
88  #define log_trace(fmt, ...) if (loglevel >= LEVEL_TRACE) \
89  logprint("%s %s:%d " fmt "\n", logtime(), __FUNCTION__, \
90  __LINE__, ##__VA_ARGS__)
91 
92 #else
93 
94  #define log_fatal(fmt, ...) ;
95  #define log_critical(fmt, ...) ;
96  #define log_error(fmt, ...) ;
97  #define log_warning(fmt, ...) ;
98  #define log_notice(fmt, ...) ;
99  #define log_info(fmt, ...) ;
100  #define log_debug(fmt, ...) ;
101  #define log_trace(fmt, ...) ;
102 
103 #endif
104 
105 
106 #ifdef __cplusplus
107 extern "C" {
108 #endif
109 
115 extern const int loglevel;
116 
125 void logprint(const char *fmt, ...);
126 
132 const char *logtime(void);
133 
134 #ifdef __cplusplus
135 }
136 #endif
void logprint(const char *fmt,...)
log function
Definition: logging.c:13
const int loglevel
global log level
Definition: 7compose.c:15
const char * logtime(void)
create timestamp
Definition: logging.c:21