]> git.ipfire.org Git - thirdparty/squid.git/blob - compat/debug.h
Merge from trunk
[thirdparty/squid.git] / compat / debug.h
1 #ifndef SQUID_CONFIG_H
2 #include "config.h"
3 #endif
4
5 #ifndef COMPAT_DEBUG_H
6 #define COMPAT_DEBUG_H
7
8 /*
9 * A debug method for use of external helpers and tools.
10 * It shunts the debug messages down stderr for logging by Squid
11 * or display to the user instead of corrupting the stdout data stream.
12 */
13
14 #if HAVE_STDIO_H
15 #include <stdio.h>
16 #endif
17 #if HAVE_UNISTD_H
18 #include <unistd.h>
19 #endif
20
21 /* Debugging stuff */
22
23 /* the macro overload style is really a gcc-ism */
24 #ifdef __GNUC__
25
26 SQUIDCEXTERN int debug_enabled;
27
28 #define debug(X...) \
29 if (debug_enabled) { \
30 fprintf(stderr, "%s(%d): pid=%ld :", __FILE__, __LINE__, (long)getpid() ); \
31 fprintf(stderr,X); \
32 }
33
34 #else /* __GNUC__ */
35
36 /* TODO: non-GCC compilers can't do the above macro define yet. */
37 inline void
38 debug(char *format,...)
39 {
40 ; // nothing to do.
41 }
42 #endif
43
44
45 #endif /* COMPAT_DEBUG_H */