- new folder src/ to hold the source code for main project applications
- main.c is in src/
- all core files are subfolder are in src/core/
- modules are in src/modules/
- libs are in src/lib/
- application Makefiles are in src/
- application binary is built in src/ (src/kamailio)
1 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,426 +0,0 @@ |
1 |
-/* |
|
2 |
- * Copyright (C) 2001-2003 FhG Fokus |
|
3 |
- * |
|
4 |
- * This file is part of Kamailio, a free SIP server. |
|
5 |
- * |
|
6 |
- * Kamailio is free software; you can redistribute it and/or modify |
|
7 |
- * it under the terms of the GNU General Public License as published by |
|
8 |
- * the Free Software Foundation; either version 2 of the License, or |
|
9 |
- * (at your option) any later version |
|
10 |
- * |
|
11 |
- * Kamailio is distributed in the hope that it will be useful, |
|
12 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
- * GNU General Public License for more details. |
|
15 |
- * |
|
16 |
- * You should have received a copy of the GNU General Public License |
|
17 |
- * along with this program; if not, write to the Free Software |
|
18 |
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
19 |
- */ |
|
20 |
- |
|
21 |
-/** |
|
22 |
- * @file |
|
23 |
- * @brief Kamailio core :: debug printing |
|
24 |
- * @ingroup core |
|
25 |
- * Module: @ref core |
|
26 |
- */ |
|
27 |
- |
|
28 |
-#ifndef dprint_h |
|
29 |
-#define dprint_h |
|
30 |
- |
|
31 |
-#include <assert.h> |
|
32 |
-#include <syslog.h> |
|
33 |
-#include <stdio.h> /* stderr, fprintf() */ |
|
34 |
- |
|
35 |
-#include "compiler_opt.h" |
|
36 |
-#include "cfg_core.h" |
|
37 |
- |
|
38 |
- |
|
39 |
-/** if defined the function name will also be logged. */ |
|
40 |
-#ifdef NO_LOG_FUNC_NAME |
|
41 |
-# undef LOG_FUNC_NAME |
|
42 |
-#else |
|
43 |
-/* by default log the function name */ |
|
44 |
-# define LOG_FUNC_NAME |
|
45 |
-#endif /* NO_LOG_FUNC_NAME */ |
|
46 |
- |
|
47 |
-/* C >= 99 has __func__, older gcc versions have __FUNCTION__ */ |
|
48 |
-#if __STDC_VERSION__ < 199901L |
|
49 |
-# if __GNUC__ >= 2 |
|
50 |
-# define _FUNC_NAME_ __FUNCTION__ |
|
51 |
-# else |
|
52 |
-# define _FUNC_NAME_ "" |
|
53 |
-# undef LOG_FUNC_NAME |
|
54 |
-# endif |
|
55 |
-#else |
|
56 |
-# define _FUNC_NAME_ __func__ |
|
57 |
-#endif |
|
58 |
- |
|
59 |
-#ifdef NO_DEBUG |
|
60 |
-# ifdef MOD_NAME |
|
61 |
-# define LOC_INFO MOD_NAME ": " |
|
62 |
-# define LOG_MNAME MOD_NAME |
|
63 |
-# else |
|
64 |
-# define LOC_INFO "<core>: " |
|
65 |
-# define LOG_MNAME "core" |
|
66 |
-# endif |
|
67 |
-#else |
|
68 |
-# define XCT2STR(i) #i |
|
69 |
-# define CT2STR(l) XCT2STR(l) |
|
70 |
-# |
|
71 |
-# ifdef MOD_NAME |
|
72 |
-# define LOC_INFO MOD_NAME " [" __FILE__ ":" CT2STR(__LINE__) "]: " |
|
73 |
-# define LOG_MNAME MOD_NAME |
|
74 |
-# else |
|
75 |
-# define LOC_INFO "<core> [" __FILE__ ":" CT2STR(__LINE__) "]: " |
|
76 |
-# define LOG_MNAME "core" |
|
77 |
-# endif |
|
78 |
-# |
|
79 |
-# ifdef NO_LOG |
|
80 |
-# undef NO_LOG |
|
81 |
-# endif |
|
82 |
-#endif /* NO_DEBUG */ |
|
83 |
- |
|
84 |
-#define LOG_MNAME_LEN (sizeof(LOG_MNAME)-1) |
|
85 |
- |
|
86 |
-/* |
|
87 |
- * Log levels |
|
88 |
- */ |
|
89 |
-#define L_NPRL -6 /* (L_MIN-1) to skip printing level prefix */ |
|
90 |
-#define L_MIN -5 |
|
91 |
-#define L_ALERT -5 |
|
92 |
-#define L_BUG -4 |
|
93 |
-#define L_CRIT2 -3 /* like L_CRIT, but adds prefix */ |
|
94 |
-#define L_CRIT -2 /* no prefix added */ |
|
95 |
-#define L_ERR -1 |
|
96 |
-#define L_WARN 0 |
|
97 |
-#define L_NOTICE 1 |
|
98 |
-#define L_INFO 2 |
|
99 |
-#define L_DBG 3 |
|
100 |
-#define L_MAX 3 |
|
101 |
-#define L_OFFSET 42 /* needs to be added and then substracted |
|
102 |
- because L_WARN may be confused with NULL pointer |
|
103 |
- (e.g. fixup_dbg_sip_msg) */ |
|
104 |
- |
|
105 |
-/** @brief This is the facility value used to indicate that the caller of the macro |
|
106 |
- * did not override the facility. Value 0 (the defaul) is LOG_KERN on Linux |
|
107 |
- */ |
|
108 |
-#define DEFAULT_FACILITY 0 |
|
109 |
- |
|
110 |
-#define LOG_LEVEL2NAME(level) (log_level_info[(level) - (L_ALERT)].name) |
|
111 |
-#define LOG2SYSLOG_LEVEL(level) \ |
|
112 |
- (log_level_info[(level) - (L_ALERT)].syslog_level) |
|
113 |
- |
|
114 |
- |
|
115 |
-/** @brief my_pid(), process_no are from pt.h but we cannot \#include it here |
|
116 |
- because of circular dependencies */ |
|
117 |
-extern int process_no; |
|
118 |
-extern int my_pid(void); |
|
119 |
- |
|
120 |
-/** @brief non-zero if logging to stderr instead to the syslog */ |
|
121 |
-extern int log_stderr; |
|
122 |
- |
|
123 |
-extern int log_color; |
|
124 |
-extern char *log_prefix_fmt; |
|
125 |
-extern str *log_prefix_val; |
|
126 |
-extern int log_prefix_mode; |
|
127 |
-extern char *_km_log_engine_type; |
|
128 |
-extern char *_km_log_engine_data; |
|
129 |
- |
|
130 |
-typedef void (*km_log_f)(int, const char *, ...); |
|
131 |
-extern km_log_f _km_log_func; |
|
132 |
- |
|
133 |
-void km_log_func_set(km_log_f f); |
|
134 |
- |
|
135 |
-/** @brief maps log levels to their string name and corresponding syslog level */ |
|
136 |
- |
|
137 |
-struct log_level_info { |
|
138 |
- char *name; |
|
139 |
- int syslog_level; |
|
140 |
-}; |
|
141 |
- |
|
142 |
-/** @brief per process debug level handling */ |
|
143 |
-int get_debug_level(char *mname, int mnlen); |
|
144 |
-int get_debug_facility(char *mname, int mnlen); |
|
145 |
-void set_local_debug_level(int level); |
|
146 |
-void set_local_debug_facility(int facility); |
|
147 |
-void reset_local_debug_level(void); |
|
148 |
-void reset_local_debug_facility(void); |
|
149 |
-typedef int (*get_module_debug_level_f)(char *mname, int mnlen, int *mlevel); |
|
150 |
-typedef int (*get_module_debug_facility_f)(char *mname, int mnlen, int *mfacility); |
|
151 |
-void set_module_debug_level_cb(get_module_debug_level_f f); |
|
152 |
-void set_module_debug_facility_cb(get_module_debug_facility_f f); |
|
153 |
- |
|
154 |
-#define is_printable(level) (get_debug_level(LOG_MNAME, LOG_MNAME_LEN)>=(level)) |
|
155 |
-extern struct log_level_info log_level_info[]; |
|
156 |
-extern char *log_name; |
|
157 |
- |
|
158 |
-#ifndef NO_SIG_DEBUG |
|
159 |
-/** @brief protection against "simultaneous" printing from signal handlers */ |
|
160 |
-extern volatile int dprint_crit; |
|
161 |
-#endif |
|
162 |
- |
|
163 |
-int str2facility(char *s); |
|
164 |
-char* facility2str(int fl, int *len); |
|
165 |
- |
|
166 |
-int log_facility_fixup(void *handle, str *gname, str *name, void **val); |
|
167 |
- |
|
168 |
-void dprint_color(int level); |
|
169 |
-void dprint_color_reset(void); |
|
170 |
-void dprint_color_update(int level, char f, char b); |
|
171 |
-void dprint_init_colors(void); |
|
172 |
-void dprint_term_color(char f, char b, str *obuf); |
|
173 |
- |
|
174 |
-void log_prefix_init(void); |
|
175 |
- |
|
176 |
-/** @brief |
|
177 |
- * General logging macros |
|
178 |
- * |
|
179 |
- * LOG_(level, prefix, fmt, ...) prints "printf"-formatted log message to |
|
180 |
- * stderr (if `log_stderr' is non-zero) or to syslog. Note that `fmt' must |
|
181 |
- * be constant. `prefix' is added to the beginning of the message. |
|
182 |
- * |
|
183 |
- * LOG(level, fmt, ...) is same as LOG_() with LOC_INFO prefix. |
|
184 |
- */ |
|
185 |
-#ifdef NO_LOG |
|
186 |
- |
|
187 |
-# ifdef __SUNPRO_C |
|
188 |
-# define LOG__(facility, level, lname, prefix, ...) |
|
189 |
-# define LOG_(facility, level, prefix, ...) |
|
190 |
-# define LOG(level, fmt, ...) |
|
191 |
-# define LOG_FC(facility, level, ...) |
|
192 |
-# define LOG_LN(level, lname, ...) |
|
193 |
-# else |
|
194 |
-# define LOG__(facility, level, lname, prefix, fmt, args...) |
|
195 |
-# define LOG_(facility, level, prefix, fmt, args...) |
|
196 |
-# define LOG(level, fmt, args...) |
|
197 |
-# define LOG_FC(facility, level, fmt, args...) |
|
198 |
-# define LOG_LN(level, lname, fmt, args...) |
|
199 |
-# endif |
|
200 |
- |
|
201 |
-#else |
|
202 |
- |
|
203 |
-# ifdef NO_SIG_DEBUG |
|
204 |
-# define DPRINT_NON_CRIT (1) |
|
205 |
-# define DPRINT_CRIT_ENTER |
|
206 |
-# define DPRINT_CRIT_EXIT |
|
207 |
-# else |
|
208 |
-# define DPRINT_NON_CRIT (dprint_crit==0) |
|
209 |
-# define DPRINT_CRIT_ENTER (dprint_crit++) |
|
210 |
-# define DPRINT_CRIT_EXIT (dprint_crit--) |
|
211 |
-# endif |
|
212 |
- |
|
213 |
-# ifdef __SUNPRO_C |
|
214 |
-# define LOG__(facility, level, lname, prefix, fmt, ...) \ |
|
215 |
- do { \ |
|
216 |
- if (get_debug_level(LOG_MNAME, LOG_MNAME_LEN) >= (level) && \ |
|
217 |
- DPRINT_NON_CRIT) { \ |
|
218 |
- int __llevel; \ |
|
219 |
- __llevel = ((level)<L_ALERT)?L_ALERT:(((level)>L_DBG)?L_DBG:level); \ |
|
220 |
- DPRINT_CRIT_ENTER; \ |
|
221 |
- if (unlikely(log_stderr)) { \ |
|
222 |
- if (unlikely(log_color)) dprint_color(__llevel); \ |
|
223 |
- if(unlikely(log_prefix_val)) { \ |
|
224 |
- fprintf(stderr, "%.*s%2d(%d) %s: %s" fmt, \ |
|
225 |
- log_prefix_val->len, log_prefix_val->s, \ |
|
226 |
- process_no, my_pid(), \ |
|
227 |
- (lname)?(lname):LOG_LEVEL2NAME(__llevel), \ |
|
228 |
- (prefix) , __VA_ARGS__);\ |
|
229 |
- } else { \ |
|
230 |
- fprintf(stderr, "%2d(%d) %s: %s" fmt, \ |
|
231 |
- process_no, my_pid(), \ |
|
232 |
- (lname)?(lname):LOG_LEVEL2NAME(__llevel), \ |
|
233 |
- (prefix) , __VA_ARGS__);\ |
|
234 |
- } \ |
|
235 |
- if (unlikely(log_color)) dprint_color_reset(); \ |
|
236 |
- } else { \ |
|
237 |
- if(unlikely(log_prefix_val)) { \ |
|
238 |
- _km_log_func(LOG2SYSLOG_LEVEL(__llevel) |\ |
|
239 |
- (((facility) != DEFAULT_FACILITY) ? \ |
|
240 |
- (facility) : \ |
|
241 |
- get_debug_facility(LOG_MNAME, LOG_MNAME_LEN)), \ |
|
242 |
- "%.*s%s: %s" fmt,\ |
|
243 |
- log_prefix_val->len, log_prefix_val->s, \ |
|
244 |
- (lname)?(lname):LOG_LEVEL2NAME(__llevel),\ |
|
245 |
- (prefix) , __VA_ARGS__); \ |
|
246 |
- } else { \ |
|
247 |
- _km_log_func(LOG2SYSLOG_LEVEL(__llevel) |\ |
|
248 |
- (((facility) != DEFAULT_FACILITY) ? \ |
|
249 |
- (facility) : \ |
|
250 |
- get_debug_facility(LOG_MNAME, LOG_MNAME_LEN)), \ |
|
251 |
- "%s: %s" fmt,\ |
|
252 |
- (lname)?(lname):LOG_LEVEL2NAME(__llevel),\ |
|
253 |
- (prefix) , __VA_ARGS__); \ |
|
254 |
- } \ |
|
255 |
- } \ |
|
256 |
- DPRINT_CRIT_EXIT; \ |
|
257 |
- } \ |
|
258 |
- } while(0) |
|
259 |
- |
|
260 |
-# define LOG_(facility, level, ...) \ |
|
261 |
- LOG__(facility, level, NULL, __VA_ARGS__, NULL) |
|
262 |
- |
|
263 |
-# ifdef LOG_FUNC_NAME |
|
264 |
-# define LOG(level, ...) \ |
|
265 |
- _LOG(level, __VA_ARGS__, NULL) |
|
266 |
-# define _LOG(level, fmt, ...) \ |
|
267 |
- LOG_(DEFAULT_FACILITY, (level), LOC_INFO, "%s(): " fmt,\ |
|
268 |
- _FUNC_NAME_, __VA_ARGS__) |
|
269 |
- |
|
270 |
-# define LOG_FC(facility, level, ...) \ |
|
271 |
- _LOG_FC(facility, level, __VA_ARGS__, NULL) |
|
272 |
-# define _LOG_FC(facility, level, fmt, ...) \ |
|
273 |
- LOG_((facility), (level), LOC_INFO, "%s(): " fmt , _FUNC_NAME_, __VA_ARGS__) |
|
274 |
- |
|
275 |
-# define LOG_LN(level, lname, ...) \ |
|
276 |
- _LOG_LN(level, lname, __VA_ARGS__, NULL) |
|
277 |
-# define _LOG_LN(level, lname, fmt, ...) \ |
|
278 |
- LOG__(DEFAULT_FACILITY, (level), (lname), LOC_INFO, "%s(): " fmt,\ |
|
279 |
- _FUNC_NAME_, __VA_ARGS__) |
|
280 |
- |
|
281 |
-# else /* LOG_FUNC_NAME */ |
|
282 |
-# define LOG(level, ...) \ |
|
283 |
- LOG_(DEFAULT_FACILITY, (level), LOC_INFO, __VA_ARGS__, NULL) |
|
284 |
-# define LOG_FC(facility, level, ...) \ |
|
285 |
- LOG_((facility), (level), LOC_INFO, __VA_ARGS__, NULL) |
|
286 |
-# define LOG_LN(level, lname, ...) \ |
|
287 |
- LOG__(DEFAULT_FACILITY, (level), (lname), LOC_INFO, __VA_ARGS__, NULL) |
|
288 |
- |
|
289 |
-# endif /* LOG_FUNC_NAME */ |
|
290 |
- |
|
291 |
-# else /* ! __SUNPRO_C */ |
|
292 |
-# define LOG__(facility, level, lname, prefix, fmt, args...) \ |
|
293 |
- do { \ |
|
294 |
- if (get_debug_level(LOG_MNAME, LOG_MNAME_LEN) >= (level) && \ |
|
295 |
- DPRINT_NON_CRIT) { \ |
|
296 |
- int __llevel; \ |
|
297 |
- __llevel = ((level)<L_ALERT)?L_ALERT:(((level)>L_DBG)?L_DBG:level); \ |
|
298 |
- DPRINT_CRIT_ENTER; \ |
|
299 |
- if (unlikely(log_stderr)) { \ |
|
300 |
- if (unlikely(log_color)) dprint_color(__llevel); \ |
|
301 |
- if(unlikely(log_prefix_val)) { \ |
|
302 |
- fprintf(stderr, "%.*s%2d(%d) %s: %s" fmt, \ |
|
303 |
- log_prefix_val->len, log_prefix_val->s, \ |
|
304 |
- process_no, my_pid(), \ |
|
305 |
- (lname)?(lname):LOG_LEVEL2NAME(__llevel), \ |
|
306 |
- (prefix) , ## args);\ |
|
307 |
- } else { \ |
|
308 |
- fprintf(stderr, "%2d(%d) %s: %s" fmt, \ |
|
309 |
- process_no, my_pid(), \ |
|
310 |
- (lname)?(lname):LOG_LEVEL2NAME(__llevel), \ |
|
311 |
- (prefix) , ## args);\ |
|
312 |
- } \ |
|
313 |
- if (unlikely(log_color)) dprint_color_reset(); \ |
|
314 |
- } else { \ |
|
315 |
- if(unlikely(log_prefix_val)) { \ |
|
316 |
- _km_log_func(LOG2SYSLOG_LEVEL(__llevel) |\ |
|
317 |
- (((facility) != DEFAULT_FACILITY) ? \ |
|
318 |
- (facility) : \ |
|
319 |
- get_debug_facility(LOG_MNAME, LOG_MNAME_LEN)), \ |
|
320 |
- "%.*s%s: %s" fmt,\ |
|
321 |
- log_prefix_val->len, log_prefix_val->s, \ |
|
322 |
- (lname)?(lname):LOG_LEVEL2NAME(__llevel),\ |
|
323 |
- (prefix) , ## args); \ |
|
324 |
- } else { \ |
|
325 |
- _km_log_func(LOG2SYSLOG_LEVEL(__llevel) |\ |
|
326 |
- (((facility) != DEFAULT_FACILITY) ? \ |
|
327 |
- (facility) : \ |
|
328 |
- get_debug_facility(LOG_MNAME, LOG_MNAME_LEN)), \ |
|
329 |
- "%s: %s" fmt,\ |
|
330 |
- (lname)?(lname):LOG_LEVEL2NAME(__llevel),\ |
|
331 |
- (prefix) , ## args); \ |
|
332 |
- } \ |
|
333 |
- } \ |
|
334 |
- DPRINT_CRIT_EXIT; \ |
|
335 |
- } \ |
|
336 |
- } while(0) |
|
337 |
- |
|
338 |
-# define LOG_(facility, level, prefix, fmt, args...) \ |
|
339 |
- LOG__(facility, level, NULL, prefix, fmt, ## args) |
|
340 |
- |
|
341 |
-# ifdef LOG_FUNC_NAME |
|
342 |
-# define LOG(level, fmt, args...) \ |
|
343 |
- LOG_(DEFAULT_FACILITY, (level), LOC_INFO, "%s(): " fmt ,\ |
|
344 |
- _FUNC_NAME_, ## args) |
|
345 |
- |
|
346 |
-# define LOG_FC(facility, level, fmt, args...) \ |
|
347 |
- LOG_((facility), (level), LOC_INFO, "%s(): " fmt , _FUNC_NAME_, ## args) |
|
348 |
- |
|
349 |
-# define LOG_LN(level, lname, fmt, args...) \ |
|
350 |
- LOG__(DEFAULT_FACILITY, (level), (lname), LOC_INFO, "%s(): " fmt ,\ |
|
351 |
- _FUNC_NAME_, ## args) |
|
352 |
- |
|
353 |
-# else /* LOG_FUNC_NAME */ |
|
354 |
-# define LOG(level, fmt, args...) \ |
|
355 |
- LOG_(DEFAULT_FACILITY, (level), LOC_INFO, fmt , ## args) |
|
356 |
-# define LOG_FC(facility, level, fmt, args...) \ |
|
357 |
- LOG_((facility), (level), LOC_INFO, fmt , ## args) |
|
358 |
-# define LOG_LN(level, lname, fmt, args...) \ |
|
359 |
- LOG__(DEFAULT_FACILITY, (level), (lname), LOC_INFO, fmt , ## args) |
|
360 |
- |
|
361 |
-# endif /* LOG_FUNC_NAME */ |
|
362 |
-# endif /* __SUNPRO_C */ |
|
363 |
-#endif /* NO_LOG */ |
|
364 |
- |
|
365 |
- |
|
366 |
-/** @name SimpleLog |
|
367 |
- * Simplier, prefered logging macros for constant log level |
|
368 |
- */ |
|
369 |
-/*@ { */ |
|
370 |
-#ifdef __SUNPRO_C |
|
371 |
-# define NPRL(...) LOG(L_NPRL, __VA_ARGS__) |
|
372 |
-# define ALERT(...) LOG(L_ALERT, __VA_ARGS__) |
|
373 |
-# define BUG(...) LOG(L_BUG, __VA_ARGS__) |
|
374 |
-# define ERR(...) LOG(L_ERR, __VA_ARGS__) |
|
375 |
-# define WARN(...) LOG(L_WARN, __VA_ARGS__) |
|
376 |
-# define NOTICE(...) LOG(L_NOTICE, __VA_ARGS__) |
|
377 |
-# define INFO(...) LOG(L_INFO, __VA_ARGS__) |
|
378 |
-# define CRIT(...) LOG(L_CRIT2, __VA_ARGS__) |
|
379 |
- |
|
380 |
-# ifdef NO_DEBUG |
|
381 |
-# define DBG(...) |
|
382 |
-# else |
|
383 |
-# define DBG(...) LOG(L_DBG, __VA_ARGS__) |
|
384 |
-# endif |
|
385 |
-/*@ } */ |
|
386 |
- |
|
387 |
-/* obsolete, do not use */ |
|
388 |
-# define DEBUG(...) DBG(__VA_ARGS__) |
|
389 |
- |
|
390 |
-#else /* ! __SUNPRO_C */ |
|
391 |
-# define NPRL(fmt, args...) LOG(L_NPRL, fmt , ## args) |
|
392 |
-# define ALERT(fmt, args...) LOG(L_ALERT, fmt , ## args) |
|
393 |
-# define BUG(fmt, args...) LOG(L_BUG, fmt , ## args) |
|
394 |
-# define ERR(fmt, args...) LOG(L_ERR, fmt , ## args) |
|
395 |
-# define WARN(fmt, args...) LOG(L_WARN, fmt , ## args) |
|
396 |
-# define NOTICE(fmt, args...) LOG(L_NOTICE, fmt , ## args) |
|
397 |
-# define INFO(fmt, args...) LOG(L_INFO, fmt , ## args) |
|
398 |
-# define CRIT(fmt, args...) LOG(L_CRIT2, fmt , ## args) |
|
399 |
- |
|
400 |
-# ifdef NO_DEBUG |
|
401 |
-# define DBG(fmt, args...) |
|
402 |
-# else |
|
403 |
-# define DBG(fmt, args...) LOG(L_DBG, fmt , ## args) |
|
404 |
-# endif |
|
405 |
- |
|
406 |
-/* obsolete, do not use */ |
|
407 |
-# define DEBUG(fmt, args...) DBG(fmt , ## args) |
|
408 |
- |
|
409 |
-#endif /* __SUNPRO_C */ |
|
410 |
- |
|
411 |
- |
|
412 |
-/* kamailio/openser compatibility */ |
|
413 |
- |
|
414 |
-#define LM_GEN1 LOG |
|
415 |
-#define LM_GEN2 LOG_FC |
|
416 |
-#define LM_NPRL NPRL |
|
417 |
-#define LM_ALERT ALERT |
|
418 |
-#define LM_CRIT CRIT |
|
419 |
-#define LM_BUG BUG |
|
420 |
-#define LM_ERR ERR |
|
421 |
-#define LM_WARN WARN |
|
422 |
-#define LM_NOTICE NOTICE |
|
423 |
-#define LM_INFO INFO |
|
424 |
-#define LM_DBG DEBUG |
|
425 |
- |
|
426 |
-#endif /* !dprint_h */ |
... | ... |
@@ -401,11 +401,11 @@ void log_prefix_init(void); |
401 | 401 |
# define DBG(fmt, args...) |
402 | 402 |
# else |
403 | 403 |
# define DBG(fmt, args...) LOG(L_DBG, fmt , ## args) |
404 |
-# endif |
|
404 |
+# endif |
|
405 | 405 |
|
406 | 406 |
/* obsolete, do not use */ |
407 | 407 |
# define DEBUG(fmt, args...) DBG(fmt , ## args) |
408 |
- |
|
408 |
+ |
|
409 | 409 |
#endif /* __SUNPRO_C */ |
410 | 410 |
|
411 | 411 |
|
... | ... |
@@ -416,6 +416,7 @@ void log_prefix_init(void); |
416 | 416 |
#define LM_NPRL NPRL |
417 | 417 |
#define LM_ALERT ALERT |
418 | 418 |
#define LM_CRIT CRIT |
419 |
+#define LM_BUG BUG |
|
419 | 420 |
#define LM_ERR ERR |
420 | 421 |
#define LM_WARN WARN |
421 | 422 |
#define LM_NOTICE NOTICE |
... | ... |
@@ -185,11 +185,11 @@ void log_prefix_init(void); |
185 | 185 |
#ifdef NO_LOG |
186 | 186 |
|
187 | 187 |
# ifdef __SUNPRO_C |
188 |
-# define LOG__(facility, level, lname, prefix, fmt, ...) |
|
189 |
-# define LOG_(facility, level, prefix, fmt, ...) |
|
188 |
+# define LOG__(facility, level, lname, prefix, ...) |
|
189 |
+# define LOG_(facility, level, prefix, ...) |
|
190 | 190 |
# define LOG(level, fmt, ...) |
191 |
-# define LOG_FC(facility, level, fmt, ...) |
|
192 |
-# define LOG_LN(level, lname, fmt, ...) |
|
191 |
+# define LOG_FC(facility, level, ...) |
|
192 |
+# define LOG_LN(level, lname, ...) |
|
193 | 193 |
# else |
194 | 194 |
# define LOG__(facility, level, lname, prefix, fmt, args...) |
195 | 195 |
# define LOG_(facility, level, prefix, fmt, args...) |
... | ... |
@@ -213,78 +213,78 @@ void log_prefix_init(void); |
213 | 213 |
# ifdef __SUNPRO_C |
214 | 214 |
# define LOG__(facility, level, lname, prefix, fmt, ...) \ |
215 | 215 |
do { \ |
216 |
- if (unlikely(get_debug_level(LOG_MNAME, LOG_MNAME_LEN) >= (level) && \ |
|
217 |
- DPRINT_NON_CRIT)) { \ |
|
216 |
+ if (get_debug_level(LOG_MNAME, LOG_MNAME_LEN) >= (level) && \ |
|
217 |
+ DPRINT_NON_CRIT) { \ |
|
218 |
+ int __llevel; \ |
|
219 |
+ __llevel = ((level)<L_ALERT)?L_ALERT:(((level)>L_DBG)?L_DBG:level); \ |
|
218 | 220 |
DPRINT_CRIT_ENTER; \ |
219 |
- if (likely(((level) >= L_ALERT) && ((level) <= L_DBG))){ \ |
|
220 |
- if (unlikely(log_stderr)) { \ |
|
221 |
- if (unlikely(log_color)) dprint_color(level); \ |
|
222 |
- fprintf(stderr, "%2d(%d) %s: %s" fmt, \ |
|
223 |
- process_no, my_pid(), \ |
|
224 |
- (lname)?(lname):LOG_LEVEL2NAME(level), (prefix), \ |
|
225 |
- __VA_ARGS__); \ |
|
226 |
- if (unlikely(log_color)) dprint_color_reset(); \ |
|
221 |
+ if (unlikely(log_stderr)) { \ |
|
222 |
+ if (unlikely(log_color)) dprint_color(__llevel); \ |
|
223 |
+ if(unlikely(log_prefix_val)) { \ |
|
224 |
+ fprintf(stderr, "%.*s%2d(%d) %s: %s" fmt, \ |
|
225 |
+ log_prefix_val->len, log_prefix_val->s, \ |
|
226 |
+ process_no, my_pid(), \ |
|
227 |
+ (lname)?(lname):LOG_LEVEL2NAME(__llevel), \ |
|
228 |
+ (prefix) , __VA_ARGS__);\ |
|
227 | 229 |
} else { \ |
228 |
- syslog(LOG2SYSLOG_LEVEL(level) | \ |
|
229 |
- (((facility) != DEFAULT_FACILITY) ? \ |
|
230 |
- (facility) : \ |
|
231 |
- get_debug_facility(LOG_MNAME, LOG_MNAME_LEN)), \ |
|
232 |
- "%s: %s" fmt, \ |
|
233 |
- (lname)?(lname):LOG_LEVEL2NAME(level),\ |
|
234 |
- (prefix), __VA_ARGS__); \ |
|
230 |
+ fprintf(stderr, "%2d(%d) %s: %s" fmt, \ |
|
231 |
+ process_no, my_pid(), \ |
|
232 |
+ (lname)?(lname):LOG_LEVEL2NAME(__llevel), \ |
|
233 |
+ (prefix) , __VA_ARGS__);\ |
|
235 | 234 |
} \ |
235 |
+ if (unlikely(log_color)) dprint_color_reset(); \ |
|
236 | 236 |
} else { \ |
237 |
- if (log_stderr) { \ |
|
238 |
- if (unlikely(log_color)) dprint_color(level); \ |
|
239 |
- fprintf(stderr, "%2d(%d) %s" fmt, \ |
|
240 |
- process_no, my_pid(), \ |
|
241 |
- (prefix), __VA_ARGS__); \ |
|
242 |
- if (unlikely(log_color)) dprint_color_reset(); \ |
|
237 |
+ if(unlikely(log_prefix_val)) { \ |
|
238 |
+ _km_log_func(LOG2SYSLOG_LEVEL(__llevel) |\ |
|
239 |
+ (((facility) != DEFAULT_FACILITY) ? \ |
|
240 |
+ (facility) : \ |
|
241 |
+ get_debug_facility(LOG_MNAME, LOG_MNAME_LEN)), \ |
|
242 |
+ "%.*s%s: %s" fmt,\ |
|
243 |
+ log_prefix_val->len, log_prefix_val->s, \ |
|
244 |
+ (lname)?(lname):LOG_LEVEL2NAME(__llevel),\ |
|
245 |
+ (prefix) , __VA_ARGS__); \ |
|
243 | 246 |
} else { \ |
244 |
- if ((level)<L_ALERT) \ |
|
245 |
- syslog(LOG2SYSLOG_LEVEL(L_ALERT) | \ |
|
246 |
- (((facility) != DEFAULT_FACILITY) ? \ |
|
247 |
- (facility) : \ |
|
248 |
- get_debug_facility(LOG_MNAME, LOG_MNAME_LEN)), \ |
|
249 |
- "%s" fmt, (prefix), __VA_ARGS__); \ |
|
250 |
- else \ |
|
251 |
- syslog(LOG2SYSLOG_LEVEL(L_DBG) | \ |
|
252 |
- (((facility) != DEFAULT_FACILITY) ? \ |
|
253 |
- (facility) : \ |
|
254 |
- get_debug_facility(LOG_MNAME, LOG_MNAME_LEN)), \ |
|
255 |
- "%s" fmt, (prefix), __VA_ARGS__); \ |
|
247 |
+ _km_log_func(LOG2SYSLOG_LEVEL(__llevel) |\ |
|
248 |
+ (((facility) != DEFAULT_FACILITY) ? \ |
|
249 |
+ (facility) : \ |
|
250 |
+ get_debug_facility(LOG_MNAME, LOG_MNAME_LEN)), \ |
|
251 |
+ "%s: %s" fmt,\ |
|
252 |
+ (lname)?(lname):LOG_LEVEL2NAME(__llevel),\ |
|
253 |
+ (prefix) , __VA_ARGS__); \ |
|
256 | 254 |
} \ |
257 | 255 |
} \ |
258 | 256 |
DPRINT_CRIT_EXIT; \ |
259 | 257 |
} \ |
260 | 258 |
} while(0) |
261 | 259 |
|
262 |
-# define LOG_(facility, level, lname, prefix, fmt, ...) \ |
|
263 |
- LOG__(facility, level, NULL, prefix, fmt, __VA_ARGS__) |
|
260 |
+# define LOG_(facility, level, ...) \ |
|
261 |
+ LOG__(facility, level, NULL, __VA_ARGS__, NULL) |
|
264 | 262 |
|
265 | 263 |
# ifdef LOG_FUNC_NAME |
266 |
-# define LOG(level, fmt, ...) \ |
|
264 |
+# define LOG(level, ...) \ |
|
265 |
+ _LOG(level, __VA_ARGS__, NULL) |
|
266 |
+# define _LOG(level, fmt, ...) \ |
|
267 | 267 |
LOG_(DEFAULT_FACILITY, (level), LOC_INFO, "%s(): " fmt,\ |
268 | 268 |
_FUNC_NAME_, __VA_ARGS__) |
269 | 269 |
|
270 |
-# define LOG_FC(facility, level, fmt, ...) \ |
|
271 |
- LOG_((facility), (level), LOC_INFO, "%s(): " fmt,\ |
|
272 |
- _FUNC_NAME_, __VA_ARGS__) |
|
270 |
+# define LOG_FC(facility, level, ...) \ |
|
271 |
+ _LOG_FC(facility, level, __VA_ARGS__, NULL) |
|
272 |
+# define _LOG_FC(facility, level, fmt, ...) \ |
|
273 |
+ LOG_((facility), (level), LOC_INFO, "%s(): " fmt , _FUNC_NAME_, __VA_ARGS__) |
|
273 | 274 |
|
274 |
-# define LOG_LN(level, lname, fmt, ...) \ |
|
275 |
+# define LOG_LN(level, lname, ...) \ |
|
276 |
+ _LOG_LN(level, lname, __VA_ARGS__, NULL) |
|
277 |
+# define _LOG_LN(level, lname, fmt, ...) \ |
|
275 | 278 |
LOG__(DEFAULT_FACILITY, (level), (lname), LOC_INFO, "%s(): " fmt,\ |
276 | 279 |
_FUNC_NAME_, __VA_ARGS__) |
277 | 280 |
|
278 | 281 |
# else /* LOG_FUNC_NAME */ |
279 |
- |
|
280 |
-# define LOG(level, fmt, ...) \ |
|
281 |
- LOG_(DEFAULT_FACILITY, (level), LOC_INFO, fmt, __VA_ARGS__) |
|
282 |
- |
|
283 |
-# define LOG_FC(facility, level, fmt, ...) \ |
|
284 |
- LOG_((facility), (level), LOC_INFO, fmt, __VA_ARGS__) |
|
285 |
- |
|
286 |
-# define LOG_LN(level, lname, fmt, ...) \ |
|
287 |
- LOG_(DEFAULT_FACILITY, (level), (lname), LOC_INFO, fmt, __VA_ARGS__) |
|
282 |
+# define LOG(level, ...) \ |
|
283 |
+ LOG_(DEFAULT_FACILITY, (level), LOC_INFO, __VA_ARGS__, NULL) |
|
284 |
+# define LOG_FC(facility, level, ...) \ |
|
285 |
+ LOG_((facility), (level), LOC_INFO, __VA_ARGS__, NULL) |
|
286 |
+# define LOG_LN(level, lname, ...) \ |
|
287 |
+ LOG__(DEFAULT_FACILITY, (level), (lname), LOC_INFO, __VA_ARGS__, NULL) |
|
288 | 288 |
|
289 | 289 |
# endif /* LOG_FUNC_NAME */ |
290 | 290 |
|
... | ... |
@@ -381,7 +381,7 @@ void log_prefix_init(void); |
381 | 381 |
# define DBG(...) |
382 | 382 |
# else |
383 | 383 |
# define DBG(...) LOG(L_DBG, __VA_ARGS__) |
384 |
-# endif |
|
384 |
+# endif |
|
385 | 385 |
/*@ } */ |
386 | 386 |
|
387 | 387 |
/* obsolete, do not use */ |
- if set to 0 (default), then log_prefix is evaluated when the sip
message is received and then reused (recommended if the log_prefix has
only variables that have same value for same message). This is the
current behaviour of log_prefix evaluation.
- if set to 1, then the log prefix is evaluated before/after each config
action (needs to be set when the log_prefix has variables that are
different based on the context of config execution, e.g., $cfg(line))
Add support to get the facility number given the facility string.
- this enables a module to replace all logging to syslog with another
logging mechanism
- it is not enabled when log_stderror=yes or the system is detected as
__SUNPRO_C
... | ... |
@@ -123,6 +123,13 @@ extern int log_stderr; |
123 | 123 |
extern int log_color; |
124 | 124 |
extern char *log_prefix_fmt; |
125 | 125 |
extern str *log_prefix_val; |
126 |
+extern char *_km_log_engine_type; |
|
127 |
+extern char *_km_log_engine_data; |
|
128 |
+ |
|
129 |
+typedef void (*km_log_f)(int, const char *, ...); |
|
130 |
+extern km_log_f _km_log_func; |
|
131 |
+ |
|
132 |
+void km_log_func_set(km_log_f f); |
|
126 | 133 |
|
127 | 134 |
/** @brief maps log levels to their string name and corresponding syslog level */ |
128 | 135 |
|
... | ... |
@@ -303,7 +310,7 @@ void log_prefix_init(void); |
303 | 310 |
if (unlikely(log_color)) dprint_color_reset(); \ |
304 | 311 |
} else { \ |
305 | 312 |
if(unlikely(log_prefix_val)) { \ |
306 |
- syslog(LOG2SYSLOG_LEVEL(__llevel) |\ |
|
313 |
+ _km_log_func(LOG2SYSLOG_LEVEL(__llevel) |\ |
|
307 | 314 |
(((facility) != DEFAULT_FACILITY) ? \ |
308 | 315 |
(facility) : \ |
309 | 316 |
get_debug_facility(LOG_MNAME, LOG_MNAME_LEN)), \ |
... | ... |
@@ -312,7 +319,7 @@ void log_prefix_init(void); |
312 | 319 |
(lname)?(lname):LOG_LEVEL2NAME(__llevel),\ |
313 | 320 |
(prefix) , ## args); \ |
314 | 321 |
} else { \ |
315 |
- syslog(LOG2SYSLOG_LEVEL(__llevel) |\ |
|
322 |
+ _km_log_func(LOG2SYSLOG_LEVEL(__llevel) |\ |
|
316 | 323 |
(((facility) != DEFAULT_FACILITY) ? \ |
317 | 324 |
(facility) : \ |
318 | 325 |
get_debug_facility(LOG_MNAME, LOG_MNAME_LEN)), \ |
Added a config function which prints how the sip message would look like
if it were to be sent out at that point in config. Displays how the message
looks after apllying all the lumps; but it is just printing, not actual
lump application. Updated doku.
... | ... |
@@ -98,6 +98,9 @@ |
98 | 98 |
#define L_INFO 2 |
99 | 99 |
#define L_DBG 3 |
100 | 100 |
#define L_MAX 3 |
101 |
+#define L_OFFSET 42 /* needs to be added and then substracted |
|
102 |
+ because L_WARN may be confused with NULL pointer |
|
103 |
+ (e.g. fixup_dbg_sip_msg) */ |
|
101 | 104 |
|
102 | 105 |
/** @brief This is the facility value used to indicate that the caller of the macro |
103 | 106 |
* did not override the facility. Value 0 (the defaul) is LOG_KERN on Linux |
Added two new debugger params which will support setting per module logging facility.
This is useful when one might want to change logging for a certain module to a different file.
mod_facility_mode (0/1) is used for enabling this. mod_facility (str) is used for
setting the facility.
... | ... |
@@ -130,10 +130,15 @@ struct log_level_info { |
130 | 130 |
|
131 | 131 |
/** @brief per process debug level handling */ |
132 | 132 |
int get_debug_level(char *mname, int mnlen); |
133 |
+int get_debug_facility(char *mname, int mnlen); |
|
133 | 134 |
void set_local_debug_level(int level); |
135 |
+void set_local_debug_facility(int facility); |
|
134 | 136 |
void reset_local_debug_level(void); |
137 |
+void reset_local_debug_facility(void); |
|
135 | 138 |
typedef int (*get_module_debug_level_f)(char *mname, int mnlen, int *mlevel); |
139 |
+typedef int (*get_module_debug_facility_f)(char *mname, int mnlen, int *mfacility); |
|
136 | 140 |
void set_module_debug_level_cb(get_module_debug_level_f f); |
141 |
+void set_module_debug_facility_cb(get_module_debug_facility_f f); |
|
137 | 142 |
|
138 | 143 |
#define is_printable(level) (get_debug_level(LOG_MNAME, LOG_MNAME_LEN)>=(level)) |
139 | 144 |
extern struct log_level_info log_level_info[]; |
... | ... |
@@ -141,7 +146,7 @@ extern char *log_name; |
141 | 146 |
|
142 | 147 |
#ifndef NO_SIG_DEBUG |
143 | 148 |
/** @brief protection against "simultaneous" printing from signal handlers */ |
144 |
-extern volatile int dprint_crit; |
|
149 |
+extern volatile int dprint_crit; |
|
145 | 150 |
#endif |
146 | 151 |
|
147 | 152 |
int str2facility(char *s); |
... | ... |
@@ -210,7 +215,7 @@ void log_prefix_init(void); |
210 | 215 |
syslog(LOG2SYSLOG_LEVEL(level) | \ |
211 | 216 |
(((facility) != DEFAULT_FACILITY) ? \ |
212 | 217 |
(facility) : \ |
213 |
- cfg_get(core, core_cfg, log_facility)), \ |
|
218 |
+ get_debug_facility(LOG_MNAME, LOG_MNAME_LEN)), \ |
|
214 | 219 |
"%s: %s" fmt, \ |
215 | 220 |
(lname)?(lname):LOG_LEVEL2NAME(level),\ |
216 | 221 |
(prefix), __VA_ARGS__); \ |
... | ... |
@@ -227,13 +232,13 @@ void log_prefix_init(void); |
227 | 232 |
syslog(LOG2SYSLOG_LEVEL(L_ALERT) | \ |
228 | 233 |
(((facility) != DEFAULT_FACILITY) ? \ |
229 | 234 |
(facility) : \ |
230 |
- cfg_get(core, core_cfg, log_facility)),\ |
|
235 |
+ get_debug_facility(LOG_MNAME, LOG_MNAME_LEN)), \ |
|
231 | 236 |
"%s" fmt, (prefix), __VA_ARGS__); \ |
232 | 237 |
else \ |
233 | 238 |
syslog(LOG2SYSLOG_LEVEL(L_DBG) | \ |
234 | 239 |
(((facility) != DEFAULT_FACILITY) ? \ |
235 | 240 |
(facility) : \ |
236 |
- cfg_get(core, core_cfg, log_facility)),\ |
|
241 |
+ get_debug_facility(LOG_MNAME, LOG_MNAME_LEN)), \ |
|
237 | 242 |
"%s" fmt, (prefix), __VA_ARGS__); \ |
238 | 243 |
} \ |
239 | 244 |
} \ |
... | ... |
@@ -298,7 +303,7 @@ void log_prefix_init(void); |
298 | 303 |
syslog(LOG2SYSLOG_LEVEL(__llevel) |\ |
299 | 304 |
(((facility) != DEFAULT_FACILITY) ? \ |
300 | 305 |
(facility) : \ |
301 |
- cfg_get(core, core_cfg, log_facility)), \ |
|
306 |
+ get_debug_facility(LOG_MNAME, LOG_MNAME_LEN)), \ |
|
302 | 307 |
"%.*s%s: %s" fmt,\ |
303 | 308 |
log_prefix_val->len, log_prefix_val->s, \ |
304 | 309 |
(lname)?(lname):LOG_LEVEL2NAME(__llevel),\ |
... | ... |
@@ -307,7 +312,7 @@ void log_prefix_init(void); |
307 | 312 |
syslog(LOG2SYSLOG_LEVEL(__llevel) |\ |
308 | 313 |
(((facility) != DEFAULT_FACILITY) ? \ |
309 | 314 |
(facility) : \ |
310 |
- cfg_get(core, core_cfg, log_facility)), \ |
|
315 |
+ get_debug_facility(LOG_MNAME, LOG_MNAME_LEN)), \ |
|
311 | 316 |
"%s: %s" fmt,\ |
312 | 317 |
(lname)?(lname):LOG_LEVEL2NAME(__llevel),\ |
313 | 318 |
(prefix) , ## args); \ |
... | ... |
@@ -1,14 +1,14 @@ |
1 | 1 |
/* |
2 | 2 |
* Copyright (C) 2001-2003 FhG Fokus |
3 | 3 |
* |
4 |
- * This file is part of ser, a free SIP server. |
|
4 |
+ * This file is part of Kamailio, a free SIP server. |
|
5 | 5 |
* |
6 |
- * ser is free software; you can redistribute it and/or modify |
|
6 |
+ * Kamailio is free software; you can redistribute it and/or modify |
|
7 | 7 |
* it under the terms of the GNU General Public License as published by |
8 | 8 |
* the Free Software Foundation; either version 2 of the License, or |
9 | 9 |
* (at your option) any later version |
10 | 10 |
* |
11 |
- * ser is distributed in the hope that it will be useful, |
|
11 |
+ * Kamailio is distributed in the hope that it will be useful, |
|
12 | 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | 14 |
* GNU General Public License for more details. |
- can be used to set what prefix to be printed for each log message
while processing a SIP message
- can contain variables
- example:
log_prefix="[$mt $hdr(CSeq) $ci]"
... | ... |
@@ -118,6 +118,8 @@ extern int my_pid(void); |
118 | 118 |
extern int log_stderr; |
119 | 119 |
|
120 | 120 |
extern int log_color; |
121 |
+extern char *log_prefix_fmt; |
|
122 |
+extern str *log_prefix_val; |
|
121 | 123 |
|
122 | 124 |
/** @brief maps log levels to their string name and corresponding syslog level */ |
123 | 125 |
|
... | ... |
@@ -151,6 +153,8 @@ void dprint_color_update(int level, char f, char b); |
151 | 153 |
void dprint_init_colors(void); |
152 | 154 |
void dprint_term_color(char f, char b, str *obuf); |
153 | 155 |
|
156 |
+void log_prefix_init(void); |
|
157 |
+ |
|
154 | 158 |
/** @brief |
155 | 159 |
* General logging macros |
156 | 160 |
* |
... | ... |
@@ -271,44 +275,42 @@ void dprint_term_color(char f, char b, str *obuf); |
271 | 275 |
do { \ |
272 | 276 |
if (get_debug_level(LOG_MNAME, LOG_MNAME_LEN) >= (level) && \ |
273 | 277 |
DPRINT_NON_CRIT) { \ |
278 |
+ int __llevel; \ |
|
279 |
+ __llevel = ((level)<L_ALERT)?L_ALERT:(((level)>L_DBG)?L_DBG:level); \ |
|
274 | 280 |
DPRINT_CRIT_ENTER; \ |
275 |
- if (likely(((level) >= L_ALERT) && ((level) <= L_DBG))){ \ |
|
276 |
- if (unlikely(log_stderr)) { \ |
|
277 |
- if (unlikely(log_color)) dprint_color(level); \ |
|
278 |
- fprintf(stderr, "%2d(%d) %s: %s" fmt, \ |
|
279 |
- process_no, my_pid(), \ |
|
280 |
- (lname)?(lname):LOG_LEVEL2NAME(level), \ |
|
281 |
- (prefix) , ## args);\ |
|
282 |
- if (unlikely(log_color)) dprint_color_reset(); \ |
|
281 |
+ if (unlikely(log_stderr)) { \ |
|
282 |
+ if (unlikely(log_color)) dprint_color(__llevel); \ |
|
283 |
+ if(unlikely(log_prefix_val)) { \ |
|
284 |
+ fprintf(stderr, "%.*s%2d(%d) %s: %s" fmt, \ |
|
285 |
+ log_prefix_val->len, log_prefix_val->s, \ |
|
286 |
+ process_no, my_pid(), \ |
|
287 |
+ (lname)?(lname):LOG_LEVEL2NAME(__llevel), \ |
|
288 |
+ (prefix) , ## args);\ |
|
283 | 289 |
} else { \ |
284 |
- syslog(LOG2SYSLOG_LEVEL(level) |\ |
|
285 |
- (((facility) != DEFAULT_FACILITY) ? \ |
|
286 |
- (facility) : \ |
|
287 |
- cfg_get(core, core_cfg, log_facility)), \ |
|
288 |
- "%s: %s" fmt,\ |
|
289 |
- (lname)?(lname):LOG_LEVEL2NAME(level),\ |
|
290 |
- (prefix) , ## args); \ |
|
290 |
+ fprintf(stderr, "%2d(%d) %s: %s" fmt, \ |
|
291 |
+ process_no, my_pid(), \ |
|
292 |
+ (lname)?(lname):LOG_LEVEL2NAME(__llevel), \ |
|
293 |
+ (prefix) , ## args);\ |
|
291 | 294 |
} \ |
295 |
+ if (unlikely(log_color)) dprint_color_reset(); \ |
|
292 | 296 |
} else { \ |
293 |
- if (log_stderr) { \ |
|
294 |
- if (unlikely(log_color)) dprint_color(level); \ |
|
295 |
- fprintf(stderr, "%2d(%d) %s" fmt, \ |
|
296 |
- process_no, my_pid(), \ |
|
297 |
- (prefix) , ## args); \ |
|
298 |
- if (unlikely(log_color)) dprint_color_reset(); \ |
|
297 |
+ if(unlikely(log_prefix_val)) { \ |
|
298 |
+ syslog(LOG2SYSLOG_LEVEL(__llevel) |\ |
|
299 |
+ (((facility) != DEFAULT_FACILITY) ? \ |
|
300 |
+ (facility) : \ |
|
301 |
+ cfg_get(core, core_cfg, log_facility)), \ |
|
302 |
+ "%.*s%s: %s" fmt,\ |
|
303 |
+ log_prefix_val->len, log_prefix_val->s, \ |
|
304 |
+ (lname)?(lname):LOG_LEVEL2NAME(__llevel),\ |
|
305 |
+ (prefix) , ## args); \ |
|
299 | 306 |
} else { \ |
300 |
- if ((level)<L_ALERT) \ |
|
301 |
- syslog(LOG2SYSLOG_LEVEL(L_ALERT) | \ |
|
302 |
- (((facility) != DEFAULT_FACILITY) ? \ |
|
303 |
- (facility) : \ |
|
304 |
- cfg_get(core, core_cfg, log_facility)),\ |
|
305 |
- "%s" fmt, (prefix) , ## args); \ |
|
306 |
- else \ |
|
307 |
- syslog(LOG2SYSLOG_LEVEL(L_DBG) | \ |
|
308 |
- (((facility) != DEFAULT_FACILITY) ? \ |
|
309 |
- (facility) : \ |
|
310 |
- cfg_get(core, core_cfg, log_facility)),\ |
|
311 |
- "%s" fmt, (prefix) , ## args); \ |
|
307 |
+ syslog(LOG2SYSLOG_LEVEL(__llevel) |\ |
|
308 |
+ (((facility) != DEFAULT_FACILITY) ? \ |
|
309 |
+ (facility) : \ |
|
310 |
+ cfg_get(core, core_cfg, log_facility)), \ |
|
311 |
+ "%s: %s" fmt,\ |
|
312 |
+ (lname)?(lname):LOG_LEVEL2NAME(__llevel),\ |
|
313 |
+ (prefix) , ## args); \ |
|
312 | 314 |
} \ |
313 | 315 |
} \ |
314 | 316 |
DPRINT_CRIT_EXIT; \ |
... | ... |
@@ -15,7 +15,7 @@ |
15 | 15 |
* |
16 | 16 |
* You should have received a copy of the GNU General Public License |
17 | 17 |
* along with this program; if not, write to the Free Software |
18 |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
18 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
19 | 19 |
*/ |
20 | 20 |
|
21 | 21 |
/** |
... | ... |
@@ -167,11 +167,13 @@ void dprint_term_color(char f, char b, str *obuf); |
167 | 167 |
# define LOG_(facility, level, prefix, fmt, ...) |
168 | 168 |
# define LOG(level, fmt, ...) |
169 | 169 |
# define LOG_FC(facility, level, fmt, ...) |
170 |
+# define LOG_LN(level, lname, fmt, ...) |
|
170 | 171 |
# else |
171 | 172 |
# define LOG__(facility, level, lname, prefix, fmt, args...) |
172 | 173 |
# define LOG_(facility, level, prefix, fmt, args...) |
173 | 174 |
# define LOG(level, fmt, args...) |
174 | 175 |
# define LOG_FC(facility, level, fmt, args...) |
176 |
+# define LOG_LN(level, lname, fmt, args...) |
|
175 | 177 |
# endif |
176 | 178 |
|
177 | 179 |
#else |
... | ... |
@@ -246,6 +248,11 @@ void dprint_term_color(char f, char b, str *obuf); |
246 | 248 |
# define LOG_FC(facility, level, fmt, ...) \ |
247 | 249 |
LOG_((facility), (level), LOC_INFO, "%s(): " fmt,\ |
248 | 250 |
_FUNC_NAME_, __VA_ARGS__) |
251 |
+ |
|
252 |
+# define LOG_LN(level, lname, fmt, ...) \ |
|
253 |
+ LOG__(DEFAULT_FACILITY, (level), (lname), LOC_INFO, "%s(): " fmt,\ |
|
254 |
+ _FUNC_NAME_, __VA_ARGS__) |
|
255 |
+ |
|
249 | 256 |
# else /* LOG_FUNC_NAME */ |
250 | 257 |
|
251 | 258 |
# define LOG(level, fmt, ...) \ |
... | ... |
@@ -254,6 +261,9 @@ void dprint_term_color(char f, char b, str *obuf); |
254 | 261 |
# define LOG_FC(facility, level, fmt, ...) \ |
255 | 262 |
LOG_((facility), (level), LOC_INFO, fmt, __VA_ARGS__) |
256 | 263 |
|
264 |
+# define LOG_LN(level, lname, fmt, ...) \ |
|
265 |
+ LOG_(DEFAULT_FACILITY, (level), (lname), LOC_INFO, fmt, __VA_ARGS__) |
|
266 |