Revert "ipc.c: Use ftok() instead of SuperFastHash."
[dss.git] / log.h
1 /*
2  * Copyright (C) 1997-2010 Andre Noll <maan@tuebingen.mpg.de>
3  *
4  * Licensed under the GPL v2. For licencing details see COPYING.
5  */
6
7 /** debug loglevel, gets really noisy */
8 #define DEBUG 1
9 /** still noisy, but won't fill your disk */
10 #define INFO  2
11 /** normal, but significant event */
12 #define NOTICE 3
13 /** unexpected event that can be handled */
14 #define WARNING 4
15 /** unhandled error condition */
16 #define ERROR 5
17 /** system might be unreliable */
18 #define CRIT 6
19 /** last message before exit */
20 #define EMERG 7
21
22 /** Log messages with lower priority than that will not be compiled in. */
23 #define COMPILE_TIME_LOGLEVEL 0
24
25 /** Not all compilers support __func__ or an equivalent. */
26 #if (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L) && !defined(__GNUC__)
27 # if defined(_MSC_VER) && _MSC_VER >= 1300
28 #  define __func__ __FUNCTION__
29 # else
30 #  define DSS_NO_FUNC_NAMES
31 #  define __func__ "<unknown>"
32 # endif
33 #endif
34
35 /** \cond */
36 #if DEBUG > COMPILE_TIME_LOGLEVEL
37 #define DSS_DEBUG_LOG(args) \
38         do { \
39                 dss_log_set_params(DEBUG, __FILE__, __LINE__, __func__); \
40                 dss_log args ; \
41         } while (0)
42 #else
43 #define DSS_DEBUG_LOG(args) do {;} while (0)
44 #endif
45
46 #if INFO > COMPILE_TIME_LOGLEVEL
47 #define DSS_INFO_LOG(args) \
48         do { \
49                 dss_log_set_params(INFO, __FILE__, __LINE__, __func__); \
50                 dss_log args ; \
51         } while (0)
52 #else
53 #define DSS_INFO_LOG(args) do {;} while (0)
54 #endif
55
56 #if NOTICE > COMPILE_TIME_LOGLEVEL
57 #define DSS_NOTICE_LOG(args) \
58         do { \
59                 dss_log_set_params(NOTICE, __FILE__, __LINE__, __func__); \
60                 dss_log args ; \
61         } while (0)
62 #else
63 #define DSS_NOTICE_LOG(args) do {;} while (0)
64 #endif
65
66 #if WARNING > COMPILE_TIME_LOGLEVEL
67 #define DSS_WARNING_LOG(args) \
68         do { \
69                 dss_log_set_params(WARNING, __FILE__, __LINE__, __func__); \
70                 dss_log args ; \
71         } while (0)
72 #else
73 #define DSS_WARNING_LOG(args) do {;} while (0)
74 #endif
75
76 #if ERROR > COMPILE_TIME_LOGLEVEL
77 #define DSS_ERROR_LOG(args) \
78         do { \
79                 dss_log_set_params(ERROR, __FILE__, __LINE__, __func__); \
80                 dss_log args ; \
81         } while (0)
82 #else
83 #define DSS_ERROR_LOG(args) do {;} while (0)
84 #endif
85
86 #if CRIT > COMPILE_TIME_LOGLEVEL
87 #define DSS_CRIT_LOG(args) \
88         do { \
89                 dss_log_set_params(CRIT, __FILE__, __LINE__, __func__); \
90                 dss_log args ; \
91         } while (0)
92 #else
93 #define DSS_CRIT_LOG(args) do {;} while (0)
94 #endif
95
96 #if EMERG > COMPILE_TIME_LOGLEVEL
97 #define DSS_EMERG_LOG(args) \
98         do { \
99                 dss_log_set_params(EMERG, __FILE__, __LINE__, __func__); \
100                 dss_log args ; \
101         } while (0)
102 #else
103 #define DSS_EMERG_LOG(args)
104 #endif