# BRCM_VERSION=3
[bcm963xx.git] / userapps / opensource / udhcp / debug.h
1 #ifndef _DEBUG_H
2 #define _DEBUG_H
3
4 #include <stdio.h>
5 #ifdef SYSLOG
6 #include <syslog.h>
7 #endif
8
9 #define debug 0
10
11 #ifdef SYSLOG
12 # define LOG(level, str, args...) if (debug)do { printf(str, ## args); \
13                                 printf("\n"); \
14                                 syslog(level, str, ## args); } while(0)
15 # define OPEN_LOG(name) openlog(name, 0, 0)
16 #define CLOSE_LOG() closelog()
17 #else
18 # define LOG_EMERG      "EMERGENCY!"
19 # define LOG_ALERT      "ALERT!"
20 # define LOG_CRIT       "critical!"
21 # define LOG_WARNING    "warning"
22 # define LOG_ERR        "error"
23 # define LOG_INFO       "info"
24 # define LOG_DEBUG      "debug"
25 # define LOG(level, str, args...) if (debug) do { printf("%s, ", level); \
26                                 printf(str, ## args); \
27                                 printf("\n"); } while(0)
28 # define OPEN_LOG(name) do {;} while(0)
29 #define CLOSE_LOG() do {;} while(0)
30 #endif
31
32 #ifdef DEBUG
33 # undef DEBUG
34 # define DEBUG(level, str, args...) LOG(level, str, ## args)
35 # define DEBUGGING
36 #else
37 # define DEBUG(level, str, args...) do {;} while(0)
38 #endif
39
40 #endif