00001 #ifndef _DEBUG_H 00002 #define _DEBUG_H 00003 00004 #include "libbb_udhcp.h" 00005 00006 #include <stdio.h> 00007 #ifdef SYSLOG 00008 #include <syslog.h> 00009 #endif 00010 00011 00012 #ifdef SYSLOG 00013 # define LOG(level, str, args...) do { printf(str, ## args); \ 00014 printf("\n"); \ 00015 syslog(level, str, ## args); } while(0) 00016 # define OPEN_LOG(name) openlog(name, 0, 0) 00017 #define CLOSE_LOG() closelog() 00018 #else 00019 # define LOG_EMERG "EMERGENCY!" 00020 # define LOG_ALERT "ALERT!" 00021 # define LOG_CRIT "critical!" 00022 # define LOG_WARNING "warning" 00023 # define LOG_ERR "error" 00024 # define LOG_INFO "info" 00025 # define LOG_DEBUG "debug" 00026 # define LOG(level, str, args...) do { printf("%s, ", level); \ 00027 printf(str, ## args); \ 00028 printf("\n"); } while(0) 00029 # define OPEN_LOG(name) do {;} while(0) 00030 #define CLOSE_LOG() do {;} while(0) 00031 #endif 00032 00033 #ifdef DEBUG 00034 # undef DEBUG 00035 # define DEBUG(level, str, args...) LOG(level, str, ## args) 00036 # define DEBUGGING 00037 #else 00038 # define DEBUG(level, str, args...) do {;} while(0) 00039 #endif 00040 00041 #endif