Implement logfile and daemon mode.
[dss.git] / log.h
1
2 /** debug loglevel, gets really noisy */
3 #define DEBUG 1
4 /** still noisy, but won't fill your disk */
5 #define INFO  2
6 /** normal, but significant event */
7 #define NOTICE 3
8 /** unexpected event that can be handled */
9 #define WARNING 4
10 /** unhandled error condition */
11 #define ERROR 5
12 /** system might be unreliable */
13 #define CRIT 6
14 /** last message before exit */
15 #define EMERG 7
16
17 /** Log messages with lower priority than that will not be compiled in. */
18 #define COMPILE_TIME_LOGLEVEL 0
19
20 /** \cond */
21 #if DEBUG > COMPILE_TIME_LOGLEVEL
22 #define DSS_DEBUG_LOG(f,...) dss_log(DEBUG, "%s: " f, __FUNCTION__, ## __VA_ARGS__)
23 #else
24 #define DSS_DEBUG_LOG(...) do {;} while (0)
25 #endif
26
27 #if INFO > COMPILE_TIME_LOGLEVEL
28 #define DSS_INFO_LOG(f,...) dss_log(INFO, "%s: " f, __FUNCTION__, ## __VA_ARGS__)
29 #else
30 #define DSS_INFO_LOG(...) do {;} while (0)
31 #endif
32
33 #if NOTICE > COMPILE_TIME_LOGLEVEL
34 #define DSS_NOTICE_LOG(f,...) dss_log(NOTICE, "%s: " f, __FUNCTION__, ## __VA_ARGS__)
35 #else
36 #define DSS_NOTICE_LOG(...) do {;} while (0)
37 #endif
38
39 #if WARNING > COMPILE_TIME_LOGLEVEL
40 #define DSS_WARNING_LOG(f,...) dss_log(WARNING, "%s: " f, __FUNCTION__, ##  __VA_ARGS__)
41 #else
42 #define DSS_WARNING_LOG(...) do {;} while (0)
43 #endif
44
45 #if ERROR > COMPILE_TIME_LOGLEVEL
46 #define DSS_ERROR_LOG(f,...) dss_log(ERROR, "%s: " f, __FUNCTION__, ## __VA_ARGS__)
47 #else
48 #define DSS_ERROR_LOG(...) do {;} while (0)
49 #endif
50
51 #if CRIT > COMPILE_TIME_LOGLEVEL
52 #define DSS_CRIT_LOG(f,...) dss_log(CRIT, "%s: " f, __FUNCTION__, ## __VA_ARGS__)
53 #else
54 #define DSS_CRIT_LOG(...) do {;} while (0)
55 #endif
56
57 #if EMERG > COMPILE_TIME_LOGLEVEL
58 #define DSS_EMERG_LOG(f,...) dss_log(EMERG, "%s: " f, __FUNCTION__, ## __VA_ARGS__)
59 #else
60 #define DSS_EMERG_LOG(...)
61 #endif