1 #ifndef LOG_H
2 #define LOG_H
3 
4 #include <stdio.h>
5 
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 
10 #ifdef DEBUG
11 # define debug logit
12 #else
13 # define debug fake_logit
14 #endif
15 
16 #ifndef NDEBUG
17 # define logit(format, ...) \
18 	internal_logit (__FILE__, __LINE__, __FUNCTION__, format, \
19 	## __VA_ARGS__)
20 #else
21 # define logit fake_logit
22 #endif
23 
24 #ifdef HAVE__ATTRIBUTE__
25 void internal_logit (const char *file, const int line, const char *function,
26 		const char *format, ...)
27 	__attribute__ ((format (printf, 4, 5)));
28 #else
29 void internal_logit (const char *file, const int line, const char *function,
30 		const char *format, ...);
31 #endif
32 
33 void fake_logit (const char *format, ...);
34 void log_init_stream (FILE *f, const char *fn);
35 void log_close ();
36 
37 #ifdef NDEBUG
38 #define log_signal(sig)
39 #else
40 void log_signal (int sig);
41 #endif
42 
43 #ifdef __cplusplus
44 }
45 #endif
46 
47 #endif
48