4 * Copyright (C) 2001-2003 FhG Fokus
6 * This file is part of ser, a free SIP server.
8 * ser is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version
13 * For a license to use the ser software under conditions
14 * other than those described here, or to purchase support for this
15 * software, please contact iptel.org by e-mail at the following addresses:
18 * ser is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
48 extern int log_stderr;
49 extern int log_facility;
50 extern volatile int dprint_crit; /* protection against "simultaneous"
51 printing from signal handlers */
54 #define DPRINT_NON_CRIT (1)
55 #define DPRINT_CRIT_ENTER
56 #define DPRINT_CRIT_EXIT
58 #define DPRINT_NON_CRIT (dprint_crit==0)
59 #define DPRINT_CRIT_ENTER (dprint_crit++)
60 #define DPRINT_CRIT_EXIT (dprint_crit--)
64 /* priority at which we log */
65 #define DPRINT_PRIO LOG_DEBUG
68 void dprint (char* format, ...);
70 int str2facility(char *s);
72 /* C >= 99 has __func__, older gcc versions have __FUNCTION__ */
73 #if __STDC_VERSION__ < 199901L
75 # define _FUNC_NAME_ __FUNCTION__
77 # define _FUNC_NAME_ ""
80 # define _FUNC_NAME_ __func__
85 #define CT2STR(l) XCT2STR(l)
87 #define LOC_INFO __FILE__ ":" CT2STR(__LINE__) ": "
95 #define DPrint(fmt, args...)
99 #define DPrint( ...) \
101 if ((cfg_get(core, core_cfg, debug)>=DPRINT_LEV) && DPRINT_NON_CRIT){ \
104 dprint (__VA_ARGS__); \
106 syslog(DPRINT_LEV|log_facility, __VA_ARGS__); \
112 #define DPrint(fmt,args...) \
114 if ((cfg_get(core, core_cfg, debug)>=DPRINT_LEV) && DPRINT_NON_CRIT){ \
117 dprint (fmt, ## args); \
119 syslog(DPRINT_LEV|log_facility, fmt, ## args); \
134 #define LOG(lev, ...)
136 #define LOG(lev, fmt, args...)
140 #define LOG(lev, ...) \
142 if ((cfg_get(core, core_cfg, debug)>=(lev)) && DPRINT_NON_CRIT){ \
144 if (log_stderr) dprint (__VA_ARGS__); \
148 syslog(LOG_CRIT|log_facility, __VA_ARGS__); \
151 syslog(LOG_ALERT|log_facility, __VA_ARGS__); \
154 syslog(LOG_ERR|log_facility, __VA_ARGS__); \
157 syslog(LOG_WARNING|log_facility, __VA_ARGS__);\
160 syslog(LOG_NOTICE|log_facility, __VA_ARGS__); \
163 syslog(LOG_INFO|log_facility, __VA_ARGS__); \
166 syslog(LOG_DEBUG|log_facility, __VA_ARGS__); \
174 #define LOG(lev, fmt, args...) \
176 if ((cfg_get(core, core_cfg, debug)>=(lev)) && DPRINT_NON_CRIT){ \
178 if (log_stderr) dprint (fmt, ## args); \
182 syslog(LOG_CRIT|log_facility, fmt, ##args); \
185 syslog(LOG_ALERT|log_facility, fmt, ##args); \
188 syslog(LOG_ERR|log_facility, fmt, ##args); \
191 syslog(LOG_WARNING|log_facility, fmt, ##args);\
194 syslog(LOG_NOTICE|log_facility, fmt, ##args); \
197 syslog(LOG_INFO|log_facility, fmt, ##args); \
200 syslog(LOG_DEBUG|log_facility, fmt, ##args); \
215 #define DBG(fmt, args...)
219 #define DBG(...) LOG(L_DBG, __VA_ARGS__)
221 #define DBG(fmt, args...) LOG(L_DBG, fmt, ## args)
226 #define DEBUG(...) DBG("DEBUG: " LOC_INFO __VA_ARGS__)
227 #define ERR(...) LOG(L_ERR, "ERROR: " LOC_INFO __VA_ARGS__)
228 #define WARN(...) LOG(L_WARN, "WARNING: " LOC_INFO __VA_ARGS__)
229 #define INFO(...) LOG(L_INFO, "INFO: " LOC_INFO __VA_ARGS__)
230 #define BUG(...) LOG(L_CRIT, "BUG: " LOC_INFO __VA_ARGS__)
232 #define DEBUG(fmt, args...) DBG("DEBUG: " LOC_INFO fmt, ## args)
233 #define ERR(fmt, args...) LOG(L_ERR, "ERROR: " LOC_INFO fmt, ## args)
234 #define WARN(fmt, args...) LOG(L_WARN, "WARN: " LOC_INFO fmt, ## args)
235 #define INFO(fmt, args...) LOG(L_INFO, "INFO: " LOC_INFO fmt, ## args)
236 #define BUG(fmt, args...) LOG(L_CRIT, "BUG: " LOC_INFO fmt, ## args)
240 #endif /* ifndef dprint_h */