Line | Count | Source |
1 | | /* |
2 | | * Copyright (C) 2001-2003 FhG Fokus |
3 | | * |
4 | | * This file is part of opensips, a free SIP server. |
5 | | * |
6 | | * opensips 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 | | * opensips 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 | | /*! |
23 | | * \file |
24 | | * \brief OpenSIPS Debug console print functions |
25 | | * \see syslog.h |
26 | | */ |
27 | | |
28 | | |
29 | | /*! \page DebugLogFunction Description of the logging functions: |
30 | | * |
31 | | * A) macros to log on a predefine log level, with a standard prefix |
32 | | * such as: "time [pid] level:module:function: <my-msg>" |
33 | | * LM_ALERT( fmt, ....) |
34 | | * LM_CRIT( fmt, ....) |
35 | | * LM_ERR( fmt, ...) |
36 | | * LM_WARN( fmt, ...) |
37 | | * LM_NOTICE( fmt, ...) |
38 | | * LM_INFO( fmt, ...) |
39 | | * LM_DBG( fmt, ...) |
40 | | * |
41 | | * B) macros for generic logging |
42 | | * LM_GEN( log_level, fmt, ...) - same standard prefix as above |
43 | | * |
44 | | * LM_GEN1( log_level, fmt, ....) - no additional info added |
45 | | * LM_GEN2( log_facility, log_level, fmt, ...) |
46 | | */ |
47 | | |
48 | | |
49 | | |
50 | | #ifndef dprint_h |
51 | | #define dprint_h |
52 | | |
53 | | #include <syslog.h> |
54 | | #include <time.h> |
55 | | #include <stdarg.h> |
56 | | |
57 | | #include "str.h" |
58 | | |
59 | 0 | #define L_ALERT -3 /*!< Alert level */ |
60 | 2 | #define L_CRIT -2 /*!< Critical level */ |
61 | 0 | #define L_ERR -1 /*!< Error level */ |
62 | 0 | #define L_WARN 1 /*!< Warning level */ |
63 | 0 | #define L_NOTICE 2 /*!< Notice level */ |
64 | 0 | #define L_INFO 3 /*!< Info level */ |
65 | 0 | #define L_DBG 4 /*!< Debug level */ |
66 | | |
67 | | |
68 | | #ifdef __SUNPRO_C |
69 | | #define DP_PREFIX |
70 | | #else |
71 | 0 | #define DP_PREFIX (char *)"%s [%d] " |
72 | | #endif |
73 | | |
74 | 0 | #define DP_ALERT_STR "ALERT" |
75 | 0 | #define DP_CRIT_STR "CRITICAL" |
76 | 0 | #define DP_ERR_STR "ERROR" |
77 | 0 | #define DP_WARN_STR "WARNING" |
78 | 0 | #define DP_NOTICE_STR "NOTICE" |
79 | 0 | #define DP_INFO_STR "INFO" |
80 | 0 | #define DP_DBG_STR "DBG" |
81 | | |
82 | 0 | #define DP_ALERT_TEXT DP_ALERT_STR ":" |
83 | 0 | #define DP_CRIT_TEXT DP_CRIT_STR ":" |
84 | 0 | #define DP_ERR_TEXT DP_ERR_STR ":" |
85 | 0 | #define DP_WARN_TEXT DP_WARN_STR ":" |
86 | 0 | #define DP_NOTICE_TEXT DP_NOTICE_STR ":" |
87 | 0 | #define DP_INFO_TEXT DP_INFO_STR ":" |
88 | 0 | #define DP_DBG_TEXT DP_DBG_STR ":" |
89 | | |
90 | 0 | #define DP_ALERT_PREFIX DP_PREFIX "%s" DP_ALERT_TEXT |
91 | 0 | #define DP_CRIT_PREFIX DP_PREFIX "%s" DP_CRIT_TEXT |
92 | 0 | #define DP_ERR_PREFIX DP_PREFIX "%s" DP_ERR_TEXT |
93 | 0 | #define DP_WARN_PREFIX DP_PREFIX "%s" DP_WARN_TEXT |
94 | 0 | #define DP_NOTICE_PREFIX DP_PREFIX "%s" DP_NOTICE_TEXT |
95 | 0 | #define DP_INFO_PREFIX DP_PREFIX "%s" DP_INFO_TEXT |
96 | 0 | #define DP_DBG_PREFIX DP_PREFIX "%s" DP_DBG_TEXT |
97 | | |
98 | | #define DPRINT_LEV L_ERR |
99 | | |
100 | | #ifndef MOD_NAME |
101 | | #define MOD_NAME core |
102 | | #endif |
103 | | |
104 | | #ifndef NO_DEBUG |
105 | | #undef NO_LOG |
106 | | #endif |
107 | | |
108 | 0 | #define MAX_LOG_CONS_NO 4 |
109 | | |
110 | 0 | #define STDERR_CONSUMER_NAME "stderror" |
111 | 0 | #define SYSLOG_CONSUMER_NAME "syslog" |
112 | 0 | #define EVENT_CONSUMER_NAME "event" |
113 | | #define OTEL_CONSUMER_NAME "opentelemetry" |
114 | | |
115 | | #define LOG_PLAIN_NAME "plain_text" |
116 | | #define LOG_JSON_NAME "json" |
117 | | #define LOG_JSON_CEE_NAME "json_cee" |
118 | | |
119 | | enum log_format { |
120 | | LOG_FORMAT_PLAIN, |
121 | | LOG_FORMAT_JSON, |
122 | | LOG_FORMAT_JSON_CEE |
123 | | }; |
124 | | |
125 | | /* vars:*/ |
126 | | |
127 | | extern int *log_level; |
128 | | extern char *log_prefix; |
129 | | extern int log_stdout; |
130 | | extern int stderr_enabled, syslog_enabled; |
131 | | extern int log_event_enabled; |
132 | | extern int log_facility; |
133 | | extern char* log_name; |
134 | | extern char ctime_buf[]; |
135 | | extern enum log_format stderr_log_format, syslog_log_format; |
136 | | extern int log_event_level_filter; |
137 | | extern int log_json_buf_size; |
138 | | extern int log_msg_buf_size; |
139 | | |
140 | | extern str log_cee_hostname; |
141 | | |
142 | | /* |
143 | | * must be called after init_multi_proc_support() |
144 | | * must be called once for each OpenSIPS process |
145 | | */ |
146 | | int init_log_level(void); |
147 | | |
148 | | /* must be called once, before the "pt" process table is freed */ |
149 | | void cleanup_log_level(void); |
150 | | |
151 | | int init_log_cons_shm_table(void); |
152 | | void cleanup_log_cons_shm_table(void); |
153 | | |
154 | | int init_log_json_buf(int realloc); |
155 | | int init_log_msg_buf(int realloc); |
156 | | |
157 | | int init_log_cee_hostname(void); |
158 | | |
159 | | int init_log_event_cons(); |
160 | | int set_log_event_cons_cfg_state(void); |
161 | | void distroy_log_event_cons(); |
162 | | |
163 | | int set_log_consumer_mute_state(str *name, int state); |
164 | | int get_log_consumer_mute_state(str *name, int *state); |
165 | | |
166 | | int set_log_consumer_level_filter(str *name, int level); |
167 | | int get_log_consumer_level_filter(str *name, int *level_filter); |
168 | | |
169 | | int parse_log_format(str *format); |
170 | | int dp_my_pid(void); |
171 | | |
172 | | void stderr_dprint_tmp(char *format, ...); |
173 | | |
174 | | void dprint(int log_level, int facility, const char *module, const char *func, |
175 | | char *stderr_fmt, char *syslog_fmt, char *format, ...) |
176 | | __attribute__ ((__format__ (__printf__, 5, 8))); |
177 | | |
178 | | int str2facility(char *s); |
179 | | |
180 | | void __set_proc_log_level(int proc_idx, int level); |
181 | | |
182 | | void __set_proc_default_log_level(int proc_idx, int level); |
183 | | |
184 | | /* set the current and default log levels for all OpenSIPS processes */ |
185 | | void set_global_log_level(int level); |
186 | | |
187 | | /* set the log level of the current process */ |
188 | | void set_proc_log_level(int level); |
189 | | |
190 | | /* changes the logging level to the default value for the current process */ |
191 | | void reset_proc_log_level(void); |
192 | | |
193 | | /* suppress the E_CORE_LOG event for new logs (useful when handling the event |
194 | | * itself in an event consumer) */ |
195 | | void suppress_proc_log_event(void); |
196 | | |
197 | | void reset_proc_log_event(void); |
198 | | |
199 | | static inline char* dp_time(void) |
200 | 0 | { |
201 | 0 | time_t ltime; |
202 | |
|
203 | 0 | time(<ime); |
204 | 0 | ctime_r( <ime, ctime_buf); |
205 | 0 | ctime_buf[19] = 0; /* remove year*/ |
206 | |
|
207 | 0 | return ctime_buf+4; /* remove name of day*/ |
208 | 0 | } Unexecuted instantiation: fuzz_csv_parser.c:dp_time Unexecuted instantiation: csv.c:dp_time Unexecuted instantiation: context.c:dp_time Unexecuted instantiation: dprint.c:dp_time Unexecuted instantiation: pt.c:dp_time Unexecuted instantiation: ut.c:dp_time Unexecuted instantiation: statistics.c:dp_time Unexecuted instantiation: route.c:dp_time Unexecuted instantiation: globals.c:dp_time Unexecuted instantiation: ipc.c:dp_time Unexecuted instantiation: core_stats.c:dp_time Unexecuted instantiation: route_struct.c:dp_time Unexecuted instantiation: dset.c:dp_time Unexecuted instantiation: pt_load.c:dp_time Unexecuted instantiation: sr_module.c:dp_time Unexecuted instantiation: action.c:dp_time Unexecuted instantiation: db_insertq.c:dp_time Unexecuted instantiation: db.c:dp_time Unexecuted instantiation: proto_tcp.c:dp_time Unexecuted instantiation: proto_udp.c:dp_time Unexecuted instantiation: net_tcp_proc.c:dp_time Unexecuted instantiation: proxy_protocol.c:dp_time Unexecuted instantiation: net_tcp.c:dp_time Unexecuted instantiation: tcp_common.c:dp_time Unexecuted instantiation: net_udp.c:dp_time Unexecuted instantiation: tcp_conn_profile.c:dp_time Unexecuted instantiation: trans_trace.c:dp_time Unexecuted instantiation: net_tcp_report.c:dp_time Unexecuted instantiation: shm_mem.c:dp_time Unexecuted instantiation: thread_mem.c:dp_time Unexecuted instantiation: f_parallel_malloc.c:dp_time Unexecuted instantiation: common.c:dp_time Unexecuted instantiation: q_malloc.c:dp_time Unexecuted instantiation: rpm_mem.c:dp_time Unexecuted instantiation: cond.c:dp_time Unexecuted instantiation: mi.c:dp_time Unexecuted instantiation: item.c:dp_time Unexecuted instantiation: fmt.c:dp_time Unexecuted instantiation: msg_parser.c:dp_time Unexecuted instantiation: parse_uri.c:dp_time Unexecuted instantiation: parse_fline.c:dp_time Unexecuted instantiation: parse_methods.c:dp_time Unexecuted instantiation: parse_hname2.c:dp_time Unexecuted instantiation: parse_content.c:dp_time Unexecuted instantiation: hf.c:dp_time Unexecuted instantiation: parse_to.c:dp_time Unexecuted instantiation: parse_via.c:dp_time Unexecuted instantiation: event_interface.c:dp_time Unexecuted instantiation: evi_params.c:dp_time Unexecuted instantiation: receive.c:dp_time Unexecuted instantiation: error.c:dp_time Unexecuted instantiation: script_cb.c:dp_time Unexecuted instantiation: errinfo.c:dp_time Unexecuted instantiation: ip_addr.c:dp_time Unexecuted instantiation: data_lump_rpl.c:dp_time Unexecuted instantiation: async.c:dp_time Unexecuted instantiation: daemonize.c:dp_time Unexecuted instantiation: timer.c:dp_time Unexecuted instantiation: trace_api.c:dp_time Unexecuted instantiation: mod_fix.c:dp_time Unexecuted instantiation: reactor.c:dp_time Unexecuted instantiation: strcommon.c:dp_time Unexecuted instantiation: forward.c:dp_time Unexecuted instantiation: xlog.c:dp_time Unexecuted instantiation: blacklists.c:dp_time Unexecuted instantiation: msg_callbacks.c:dp_time Unexecuted instantiation: route_trace.c:dp_time Unexecuted instantiation: usr_avp.c:dp_time Unexecuted instantiation: sl_cb.c:dp_time Unexecuted instantiation: sdp_ops.c:dp_time Unexecuted instantiation: resolve.c:dp_time Unexecuted instantiation: io_wait.c:dp_time Unexecuted instantiation: transformations.c:dp_time Unexecuted instantiation: pvar.c:dp_time Unexecuted instantiation: sr_module_deps.c:dp_time Unexecuted instantiation: cfg_reload.c:dp_time Unexecuted instantiation: socket_info.c:dp_time Unexecuted instantiation: tsend.c:dp_time Unexecuted instantiation: time_rec.c:dp_time Unexecuted instantiation: data_lump.c:dp_time Unexecuted instantiation: map.c:dp_time Unexecuted instantiation: script_var.c:dp_time Unexecuted instantiation: pt_scaling.c:dp_time Unexecuted instantiation: name_alias.c:dp_time Unexecuted instantiation: signals.c:dp_time Unexecuted instantiation: flags.c:dp_time Unexecuted instantiation: db_pool.c:dp_time Unexecuted instantiation: db_id.c:dp_time Unexecuted instantiation: trans.c:dp_time Unexecuted instantiation: cJSON.c:dp_time Unexecuted instantiation: sdp.c:dp_time Unexecuted instantiation: sdp_helpr_funcs.c:dp_time Unexecuted instantiation: digest_parser.c:dp_time Unexecuted instantiation: param_parser.c:dp_time Unexecuted instantiation: digest.c:dp_time Unexecuted instantiation: parse_contact.c:dp_time Unexecuted instantiation: contact.c:dp_time Unexecuted instantiation: parse_body.c:dp_time Unexecuted instantiation: parse_cseq.c:dp_time Unexecuted instantiation: parse_security.c:dp_time Unexecuted instantiation: parse_call_info.c:dp_time Unexecuted instantiation: parse_event.c:dp_time Unexecuted instantiation: parse_disposition.c:dp_time Unexecuted instantiation: parse_authenticate.c:dp_time Unexecuted instantiation: parser_f.c:dp_time Unexecuted instantiation: parse_rpid.c:dp_time Unexecuted instantiation: parse_ppi.c:dp_time Unexecuted instantiation: parse_fcaps.c:dp_time Unexecuted instantiation: parse_sst.c:dp_time Unexecuted instantiation: parse_rr.c:dp_time Unexecuted instantiation: parse_param.c:dp_time Unexecuted instantiation: parse_diversion.c:dp_time Unexecuted instantiation: parse_nameaddr.c:dp_time Unexecuted instantiation: parse_expires.c:dp_time Unexecuted instantiation: parse_refer_to.c:dp_time Unexecuted instantiation: parse_from.c:dp_time Unexecuted instantiation: parse_pai.c:dp_time Unexecuted instantiation: evi_transport.c:dp_time Unexecuted instantiation: msg_translator.c:dp_time Unexecuted instantiation: md5utils.c:dp_time Unexecuted instantiation: cfg.tab.c:dp_time Unexecuted instantiation: modparam.c:dp_time Unexecuted instantiation: crc.c:dp_time Unexecuted instantiation: re.c:dp_time Unexecuted instantiation: lex.yy.c:dp_time Unexecuted instantiation: cfg_pp.c:dp_time Unexecuted instantiation: proxy.c:dp_time Unexecuted instantiation: shutdown.c:dp_time Unexecuted instantiation: status_report.c:dp_time Unexecuted instantiation: cmds.c:dp_time Unexecuted instantiation: core_cmds.c:dp_time Unexecuted instantiation: serialize.c:dp_time Unexecuted instantiation: cachedb.c:dp_time Unexecuted instantiation: cachedb_pool.c:dp_time Unexecuted instantiation: cachedb_id.c:dp_time |
209 | | |
210 | | static inline const char *dp_log_level_str(int log_level) |
211 | 0 | { |
212 | 0 | const char *level_str; |
213 | |
|
214 | 0 | switch (log_level) { |
215 | 0 | case L_ALERT: |
216 | 0 | level_str = DP_ALERT_STR; |
217 | 0 | break; |
218 | 0 | case L_CRIT: |
219 | 0 | level_str = DP_CRIT_STR; |
220 | 0 | break; |
221 | 0 | case L_ERR: |
222 | 0 | level_str = DP_ERR_STR; |
223 | 0 | break; |
224 | 0 | case L_WARN: |
225 | 0 | level_str = DP_WARN_STR; |
226 | 0 | break; |
227 | 0 | case L_NOTICE: |
228 | 0 | level_str = DP_NOTICE_STR; |
229 | 0 | break; |
230 | 0 | case L_INFO: |
231 | 0 | level_str = DP_INFO_STR; |
232 | 0 | break; |
233 | 0 | case L_DBG: |
234 | 0 | default: |
235 | 0 | level_str = DP_DBG_STR; |
236 | 0 | } |
237 | | |
238 | 0 | return level_str; |
239 | 0 | } Unexecuted instantiation: fuzz_csv_parser.c:dp_log_level_str Unexecuted instantiation: csv.c:dp_log_level_str Unexecuted instantiation: context.c:dp_log_level_str Unexecuted instantiation: dprint.c:dp_log_level_str Unexecuted instantiation: pt.c:dp_log_level_str Unexecuted instantiation: ut.c:dp_log_level_str Unexecuted instantiation: statistics.c:dp_log_level_str Unexecuted instantiation: route.c:dp_log_level_str Unexecuted instantiation: globals.c:dp_log_level_str Unexecuted instantiation: ipc.c:dp_log_level_str Unexecuted instantiation: core_stats.c:dp_log_level_str Unexecuted instantiation: route_struct.c:dp_log_level_str Unexecuted instantiation: dset.c:dp_log_level_str Unexecuted instantiation: pt_load.c:dp_log_level_str Unexecuted instantiation: sr_module.c:dp_log_level_str Unexecuted instantiation: action.c:dp_log_level_str Unexecuted instantiation: db_insertq.c:dp_log_level_str Unexecuted instantiation: db.c:dp_log_level_str Unexecuted instantiation: proto_tcp.c:dp_log_level_str Unexecuted instantiation: proto_udp.c:dp_log_level_str Unexecuted instantiation: net_tcp_proc.c:dp_log_level_str Unexecuted instantiation: proxy_protocol.c:dp_log_level_str Unexecuted instantiation: net_tcp.c:dp_log_level_str Unexecuted instantiation: tcp_common.c:dp_log_level_str Unexecuted instantiation: net_udp.c:dp_log_level_str Unexecuted instantiation: tcp_conn_profile.c:dp_log_level_str Unexecuted instantiation: trans_trace.c:dp_log_level_str Unexecuted instantiation: net_tcp_report.c:dp_log_level_str Unexecuted instantiation: shm_mem.c:dp_log_level_str Unexecuted instantiation: thread_mem.c:dp_log_level_str Unexecuted instantiation: f_parallel_malloc.c:dp_log_level_str Unexecuted instantiation: common.c:dp_log_level_str Unexecuted instantiation: q_malloc.c:dp_log_level_str Unexecuted instantiation: rpm_mem.c:dp_log_level_str Unexecuted instantiation: cond.c:dp_log_level_str Unexecuted instantiation: mi.c:dp_log_level_str Unexecuted instantiation: item.c:dp_log_level_str Unexecuted instantiation: fmt.c:dp_log_level_str Unexecuted instantiation: msg_parser.c:dp_log_level_str Unexecuted instantiation: parse_uri.c:dp_log_level_str Unexecuted instantiation: parse_fline.c:dp_log_level_str Unexecuted instantiation: parse_methods.c:dp_log_level_str Unexecuted instantiation: parse_hname2.c:dp_log_level_str Unexecuted instantiation: parse_content.c:dp_log_level_str Unexecuted instantiation: hf.c:dp_log_level_str Unexecuted instantiation: parse_to.c:dp_log_level_str Unexecuted instantiation: parse_via.c:dp_log_level_str Unexecuted instantiation: event_interface.c:dp_log_level_str Unexecuted instantiation: evi_params.c:dp_log_level_str Unexecuted instantiation: receive.c:dp_log_level_str Unexecuted instantiation: error.c:dp_log_level_str Unexecuted instantiation: script_cb.c:dp_log_level_str Unexecuted instantiation: errinfo.c:dp_log_level_str Unexecuted instantiation: ip_addr.c:dp_log_level_str Unexecuted instantiation: data_lump_rpl.c:dp_log_level_str Unexecuted instantiation: async.c:dp_log_level_str Unexecuted instantiation: daemonize.c:dp_log_level_str Unexecuted instantiation: timer.c:dp_log_level_str Unexecuted instantiation: trace_api.c:dp_log_level_str Unexecuted instantiation: mod_fix.c:dp_log_level_str Unexecuted instantiation: reactor.c:dp_log_level_str Unexecuted instantiation: strcommon.c:dp_log_level_str Unexecuted instantiation: forward.c:dp_log_level_str Unexecuted instantiation: xlog.c:dp_log_level_str Unexecuted instantiation: blacklists.c:dp_log_level_str Unexecuted instantiation: msg_callbacks.c:dp_log_level_str Unexecuted instantiation: route_trace.c:dp_log_level_str Unexecuted instantiation: usr_avp.c:dp_log_level_str Unexecuted instantiation: sl_cb.c:dp_log_level_str Unexecuted instantiation: sdp_ops.c:dp_log_level_str Unexecuted instantiation: resolve.c:dp_log_level_str Unexecuted instantiation: io_wait.c:dp_log_level_str Unexecuted instantiation: transformations.c:dp_log_level_str Unexecuted instantiation: pvar.c:dp_log_level_str Unexecuted instantiation: sr_module_deps.c:dp_log_level_str Unexecuted instantiation: cfg_reload.c:dp_log_level_str Unexecuted instantiation: socket_info.c:dp_log_level_str Unexecuted instantiation: tsend.c:dp_log_level_str Unexecuted instantiation: time_rec.c:dp_log_level_str Unexecuted instantiation: data_lump.c:dp_log_level_str Unexecuted instantiation: map.c:dp_log_level_str Unexecuted instantiation: script_var.c:dp_log_level_str Unexecuted instantiation: pt_scaling.c:dp_log_level_str Unexecuted instantiation: name_alias.c:dp_log_level_str Unexecuted instantiation: signals.c:dp_log_level_str Unexecuted instantiation: flags.c:dp_log_level_str Unexecuted instantiation: db_pool.c:dp_log_level_str Unexecuted instantiation: db_id.c:dp_log_level_str Unexecuted instantiation: trans.c:dp_log_level_str Unexecuted instantiation: cJSON.c:dp_log_level_str Unexecuted instantiation: sdp.c:dp_log_level_str Unexecuted instantiation: sdp_helpr_funcs.c:dp_log_level_str Unexecuted instantiation: digest_parser.c:dp_log_level_str Unexecuted instantiation: param_parser.c:dp_log_level_str Unexecuted instantiation: digest.c:dp_log_level_str Unexecuted instantiation: parse_contact.c:dp_log_level_str Unexecuted instantiation: contact.c:dp_log_level_str Unexecuted instantiation: parse_body.c:dp_log_level_str Unexecuted instantiation: parse_cseq.c:dp_log_level_str Unexecuted instantiation: parse_security.c:dp_log_level_str Unexecuted instantiation: parse_call_info.c:dp_log_level_str Unexecuted instantiation: parse_event.c:dp_log_level_str Unexecuted instantiation: parse_disposition.c:dp_log_level_str Unexecuted instantiation: parse_authenticate.c:dp_log_level_str Unexecuted instantiation: parser_f.c:dp_log_level_str Unexecuted instantiation: parse_rpid.c:dp_log_level_str Unexecuted instantiation: parse_ppi.c:dp_log_level_str Unexecuted instantiation: parse_fcaps.c:dp_log_level_str Unexecuted instantiation: parse_sst.c:dp_log_level_str Unexecuted instantiation: parse_rr.c:dp_log_level_str Unexecuted instantiation: parse_param.c:dp_log_level_str Unexecuted instantiation: parse_diversion.c:dp_log_level_str Unexecuted instantiation: parse_nameaddr.c:dp_log_level_str Unexecuted instantiation: parse_expires.c:dp_log_level_str Unexecuted instantiation: parse_refer_to.c:dp_log_level_str Unexecuted instantiation: parse_from.c:dp_log_level_str Unexecuted instantiation: parse_pai.c:dp_log_level_str Unexecuted instantiation: evi_transport.c:dp_log_level_str Unexecuted instantiation: msg_translator.c:dp_log_level_str Unexecuted instantiation: md5utils.c:dp_log_level_str Unexecuted instantiation: cfg.tab.c:dp_log_level_str Unexecuted instantiation: modparam.c:dp_log_level_str Unexecuted instantiation: crc.c:dp_log_level_str Unexecuted instantiation: re.c:dp_log_level_str Unexecuted instantiation: lex.yy.c:dp_log_level_str Unexecuted instantiation: cfg_pp.c:dp_log_level_str Unexecuted instantiation: proxy.c:dp_log_level_str Unexecuted instantiation: shutdown.c:dp_log_level_str Unexecuted instantiation: status_report.c:dp_log_level_str Unexecuted instantiation: cmds.c:dp_log_level_str Unexecuted instantiation: core_cmds.c:dp_log_level_str Unexecuted instantiation: serialize.c:dp_log_level_str Unexecuted instantiation: cachedb.c:dp_log_level_str Unexecuted instantiation: cachedb_pool.c:dp_log_level_str Unexecuted instantiation: cachedb_id.c:dp_log_level_str |
240 | | |
241 | 113 | #define is_printable(_level) (((int)(*log_level)) >= ((int)(_level))) |
242 | | |
243 | | #if defined __GNUC__ |
244 | 0 | #define __DP_FUNC __FUNCTION__ |
245 | | #elif defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L |
246 | | #define __DP_FUNC __func__ |
247 | | #else |
248 | | #define __DP_FUNC ((__const char *) 0) |
249 | | #endif |
250 | | |
251 | | |
252 | | #ifdef NO_LOG |
253 | | |
254 | | #ifdef __SUNPRO_C |
255 | | #define LM_GEN2(facility, lev, ...) |
256 | | #define LM_GEN1(lev, ...) |
257 | | #define LM_GEN(lev, ...) |
258 | | #define LM_ALERT( ...) |
259 | | #define LM_CRIT( ...) |
260 | | #define LM_ERR( ...) |
261 | | #define LM_WARN( ...) |
262 | | #define LM_NOTICE( ...) |
263 | | #define LM_INFO( ...) |
264 | | #define LM_DBG( ...) |
265 | | #else |
266 | | #define LM_GEN2(facility, lev, fmt, args...) |
267 | | #define LM_GEN1(lev, fmt, args...) |
268 | | #define LM_GEN(lev, fmt, args...) |
269 | | #define LM_ALERT(fmt, args...) |
270 | | #define LM_CRIT(fmt, args...) |
271 | | #define LM_ERR(fmt, args...) |
272 | | #define LM_WARN(fmt, args...) |
273 | | #define LM_NOTICE(fmt, args...) |
274 | | #define LM_INFO(fmt, args...) |
275 | | #define LM_DBG(fmt, args...) |
276 | | #endif |
277 | | |
278 | | #else /* NO_LOG */ |
279 | | |
280 | | #ifdef __SUNPRO_C |
281 | | #define LOG_PREFIX_UTIL2(_n) #_n |
282 | | #define LOG_PREFIX_UTIL(_n) LOG_PREFIX_UTIL2(_n) |
283 | | #define LOG_PREFIX LOG_PREFIX_UTIL(MOD_NAME) ": " |
284 | | |
285 | | #define stderr_dprint_tmp_err(fmt, ...) \ |
286 | | stderr_dprint_tmp(DP_ERR_PREFIX LOG_PREFIX fmt __VA_ARGS__) |
287 | | |
288 | | #define MY_DPRINT(_log_level, _log_facility, _stderr_prefix, \ |
289 | | _syslog_prefix, _fmt, ...) \ |
290 | | dprint(_log_level, _log_facility, \ |
291 | | LOG_PREFIX_UTIL(MOD_NAME), NULL, \ |
292 | | _stderr_prefix LOG_PREFIX _fmt, \ |
293 | | "%s" _prefix LOG_PREFIX _fmt, \ |
294 | | _fmt, \ |
295 | | dp_time(), dp_my_pid(), log_prefix __VA_ARGS__ ) \ |
296 | | |
297 | | #define LM_GEN(_lev, fmt, ...) \ |
298 | | do { \ |
299 | | if (is_printable(_lev)){ \ |
300 | | switch(_lev){ \ |
301 | | case L_CRIT: \ |
302 | | MY_DPRINT(L_CRIT, log_facility, DP_CRIT_PREFIX, \ |
303 | | DP_CRIT_TEXT, fmt __VA_ARGS__); \ |
304 | | break; \ |
305 | | case L_ALERT: \ |
306 | | MY_DPRINT(L_ALERT, log_facility, DP_ALERT_PREFIX, \ |
307 | | DP_ALERT_TEXT, fmt __VA_ARGS__); \ |
308 | | break; \ |
309 | | case L_ERR: \ |
310 | | MY_DPRINT(L_ERR, log_facility, DP_ERR_PREFIX, \ |
311 | | DP_ERR_TEXT, fmt __VA_ARGS__); \ |
312 | | break; \ |
313 | | case L_WARN: \ |
314 | | MY_DPRINT(L_WARN, log_facility, DP_WARN_PREFIX, \ |
315 | | DP_WARN_TEXT, fmt __VA_ARGS__); \ |
316 | | break; \ |
317 | | case L_NOTICE: \ |
318 | | MY_DPRINT(L_NOTICE, log_facility, DP_NOTICE_PREFIX, \ |
319 | | DP_NOTICE_TEXT, fmt __VA_ARGS__); \ |
320 | | break; \ |
321 | | case L_INFO: \ |
322 | | MY_DPRINT(L_INFO, log_facility, DP_INFO_PREFIX, \ |
323 | | DP_INFO_TEXT, fmt __VA_ARGS__); \ |
324 | | break; \ |
325 | | case L_DBG: \ |
326 | | MY_DPRINT(L_DBG, log_facility, DP_DBG_PREFIX, \ |
327 | | DP_DBG_TEXT, fmt __VA_ARGS__); \ |
328 | | break; \ |
329 | | default: \ |
330 | | if (_lev > L_DBG) \ |
331 | | MY_DPRINT(L_DBG, log_facility, DP_DBG_PREFIX, \ |
332 | | DP_DBG_TEXT, fmt __VA_ARGS__); \ |
333 | | break; \ |
334 | | } \ |
335 | | } \ |
336 | | }while(0) |
337 | | |
338 | | #define LM_GEN1(_lev, ...) \ |
339 | | LM_GEN2( log_facility, _lev, __VA_ARGS__) |
340 | | |
341 | | #define LM_GEN2( _facility, _lev, fmt, ...) \ |
342 | | do { \ |
343 | | if (is_printable(_lev)){ \ |
344 | | switch(_lev){ \ |
345 | | case L_CRIT: \ |
346 | | dprint(_lev, _facility, NULL, NULL, \ |
347 | | DP_CRIT_PREFIX fmt, "%s" DP_CRIT_TEXT fmt, fmt, \ |
348 | | dp_time(), dp_my_pid(), log_prefix __VA_ARGS__) \ |
349 | | break; \ |
350 | | case L_ALERT: \ |
351 | | dprint(_lev, _facility, NULL, NULL, \ |
352 | | DP_ALERT_PREFIX fmt, "%s" DP_ALERT_TEXT fmt, fmt, \ |
353 | | dp_time(), dp_my_pid(), log_prefix __VA_ARGS__) \ |
354 | | break; \ |
355 | | case L_ERR: \ |
356 | | dprint(_lev, _facility, NULL, NULL, \ |
357 | | DP_ERR_PREFIX fmt, "%s" DP_ERR_TEXT fmt, fmt, \ |
358 | | dp_time(), dp_my_pid(), log_prefix __VA_ARGS__) \ |
359 | | break; \ |
360 | | case L_WARN: \ |
361 | | dprint(_lev, _facility, NULL, NULL, \ |
362 | | DP_WARN_PREFIX fmt, "%s" DP_WARN_TEXT fmt, fmt, \ |
363 | | dp_time(), dp_my_pid(), log_prefix __VA_ARGS__) \ |
364 | | break; \ |
365 | | case L_NOTICE: \ |
366 | | dprint(_lev, _facility, NULL, NULL, \ |
367 | | DP_NOTICE_PREFIX fmt, "%s" DP_NOTICE_TEXT fmt, fmt, \ |
368 | | dp_time(), dp_my_pid(), log_prefix __VA_ARGS__) \ |
369 | | break; \ |
370 | | case L_INFO: \ |
371 | | dprint(_lev, _facility, NULL, NULL, \ |
372 | | DP_INFO_PREFIX fmt, "%s" DP_INFO_TEXT fmt, fmt, \ |
373 | | dp_time(), dp_my_pid(), log_prefix __VA_ARGS__) \ |
374 | | break; \ |
375 | | case L_DBG: \ |
376 | | dprint(_lev, _facility, NULL, NULL, \ |
377 | | DP_DBG_PREFIX fmt, "%s" DP_DBG_TEXT fmt, fmt, \ |
378 | | dp_time(), dp_my_pid(), log_prefix __VA_ARGS__) \ |
379 | | break; \ |
380 | | default: \ |
381 | | if (_lev > L_DBG) \ |
382 | | dprint(_lev, _facility, NULL, NULL, \ |
383 | | DP_DBG_PREFIX fmt, "%s" DP_DBG_TEXT fmt, fmt, \ |
384 | | dp_time(), dp_my_pid(), log_prefix __VA_ARGS__) \ |
385 | | break; \ |
386 | | } \ |
387 | | } \ |
388 | | }while(0) |
389 | | |
390 | | #define LM_ALERT( fmt, ...) \ |
391 | | do { \ |
392 | | if (is_printable(L_ALERT)) \ |
393 | | MY_DPRINT(L_ALERT, log_facility, DP_ALERT_PREFIX, \ |
394 | | DP_ALERT_TEXT, fmt __VA_ARGS__); \ |
395 | | }while(0) |
396 | | |
397 | | #define LM_CRIT( fmt, ...) \ |
398 | | do { \ |
399 | | if (is_printable(L_CRIT)) \ |
400 | | MY_DPRINT(L_CRIT, log_facility, DP_CRIT_PREFIX, \ |
401 | | DP_CRIT_TEXT, fmt __VA_ARGS__); \ |
402 | | }while(0) |
403 | | |
404 | | #define LM_ERR( fmt, ...) \ |
405 | | do { \ |
406 | | if (is_printable(L_ERR)) \ |
407 | | MY_DPRINT(L_ERR, log_facility, DP_ERR_PREFIX, \ |
408 | | DP_ERR_TEXT, fmt __VA_ARGS__); \ |
409 | | }while(0) |
410 | | |
411 | | #define LM_WARN( fmt, ...) \ |
412 | | do { \ |
413 | | if (is_printable(L_WARN)) \ |
414 | | MY_DPRINT(L_WARN, log_facility, DP_WARN_PREFIX, \ |
415 | | DP_WARN_TEXT, fmt __VA_ARGS__); \ |
416 | | }while(0) |
417 | | |
418 | | #define LM_NOTICE( fmt, ...) \ |
419 | | do { \ |
420 | | if (is_printable(L_NOTICE)) \ |
421 | | MY_DPRINT(L_NOTICE, log_facility, DP_NOTICE_PREFIX, \ |
422 | | DP_NOTICE_TEXT, fmt __VA_ARGS__); \ |
423 | | }while(0) |
424 | | |
425 | | #define LM_INFO( fmt, ...) \ |
426 | | do { \ |
427 | | if (is_printable(L_INFO)) \ |
428 | | MY_DPRINT(L_INFO, log_facility, DP_INFO_PREFIX, \ |
429 | | DP_INFO_TEXT, fmt __VA_ARGS__); \ |
430 | | }while(0) |
431 | | |
432 | | #ifdef NO_DEBUG |
433 | | #define LM_DBG( fmt, ...) |
434 | | #else |
435 | | #define LM_DBG( fmt, ...) \ |
436 | | do { \ |
437 | | if (is_printable(L_DBG)) \ |
438 | | MY_DPRINT(L_DBG, log_facility, DP_DBG_PREFIX, \ |
439 | | DP_DBG_TEXT, fmt __VA_ARGS__); \ |
440 | | }while(0) |
441 | | #endif /*NO_DEBUG*/ |
442 | | |
443 | | #else /*SUN_PRO_C*/ |
444 | | |
445 | 0 | #define LOG_PREFIX_UTIL2(_n) #_n |
446 | 0 | #define LOG_PREFIX_UTIL(_n) LOG_PREFIX_UTIL2(_n) |
447 | | #define LOG_PREFIX LOG_PREFIX_UTIL(MOD_NAME) ":%s: " |
448 | | |
449 | | #define stderr_dprint_tmp_err(_fmt, args...) \ |
450 | 0 | stderr_dprint_tmp(DP_ERR_PREFIX LOG_PREFIX _fmt, \ |
451 | 0 | dp_time(), dp_my_pid(), log_prefix, __DP_FUNC, ## args) \ |
452 | | |
453 | | #define MY_DPRINT(_log_level, _log_facility, _stderr_prefix, \ |
454 | | _syslog_prefix, _fmt, args...) \ |
455 | 0 | dprint(_log_level, _log_facility, \ |
456 | 0 | LOG_PREFIX_UTIL(MOD_NAME), __DP_FUNC, \ |
457 | 0 | _stderr_prefix LOG_PREFIX _fmt, \ |
458 | 0 | (char *)"%s" _syslog_prefix LOG_PREFIX _fmt, \ |
459 | 0 | (char *)_fmt, \ |
460 | 0 | dp_time(), dp_my_pid(), log_prefix, __DP_FUNC, ## args) \ |
461 | | |
462 | | #define LM_GEN(_lev, fmt, args...) \ |
463 | | do { \ |
464 | | if (is_printable(_lev)){ \ |
465 | | switch(_lev){ \ |
466 | | case L_CRIT: \ |
467 | | MY_DPRINT(L_CRIT, log_facility, DP_CRIT_PREFIX, \ |
468 | | DP_CRIT_TEXT, fmt, ##args); \ |
469 | | break; \ |
470 | | case L_ALERT: \ |
471 | | MY_DPRINT(L_ALERT, log_facility, DP_ALERT_PREFIX, \ |
472 | | DP_ALERT_TEXT, fmt, ##args); \ |
473 | | break; \ |
474 | | case L_ERR: \ |
475 | | MY_DPRINT(L_ERR, log_facility, DP_ERR_PREFIX, \ |
476 | | DP_ERR_TEXT, fmt, ##args); \ |
477 | | break; \ |
478 | | case L_WARN: \ |
479 | | MY_DPRINT(L_WARN, log_facility, DP_WARN_PREFIX, \ |
480 | | DP_WARN_TEXT, fmt, ##args); \ |
481 | | break; \ |
482 | | case L_NOTICE: \ |
483 | | MY_DPRINT(L_NOTICE, log_facility, DP_NOTICE_PREFIX, \ |
484 | | DP_NOTICE_TEXT, fmt, ##args); \ |
485 | | break; \ |
486 | | case L_INFO: \ |
487 | | MY_DPRINT(L_INFO, log_facility, DP_INFO_PREFIX, \ |
488 | | DP_INFO_TEXT, fmt, ##args); \ |
489 | | break; \ |
490 | | case L_DBG: \ |
491 | | MY_DPRINT(L_DBG, log_facility, DP_DBG_PREFIX, \ |
492 | | DP_DBG_TEXT, fmt, ##args); \ |
493 | | break; \ |
494 | | default: \ |
495 | | if (_lev > L_DBG) \ |
496 | | MY_DPRINT(L_DBG, log_facility, DP_DBG_PREFIX, \ |
497 | | DP_DBG_TEXT, fmt, ##args); \ |
498 | | break; \ |
499 | | } \ |
500 | | } \ |
501 | | }while(0) |
502 | | |
503 | | #define LM_GEN1(_lev, args...) \ |
504 | 0 | LM_GEN2( log_facility, _lev, ##args) |
505 | | |
506 | | #define LM_GEN2( _facility, _lev, fmt, args...) \ |
507 | 0 | do { \ |
508 | 0 | if (is_printable(_lev)){ \ |
509 | 0 | switch(_lev){ \ |
510 | 0 | case L_CRIT: \ |
511 | 0 | dprint(_lev, _facility, NULL, NULL, \ |
512 | 0 | DP_CRIT_PREFIX fmt, "%s" DP_CRIT_TEXT fmt, fmt, \ |
513 | 0 | dp_time(), dp_my_pid(), log_prefix, ## args); \ |
514 | 0 | break; \ |
515 | 0 | case L_ALERT: \ |
516 | 0 | dprint(_lev, _facility, NULL, NULL, \ |
517 | 0 | DP_ALERT_PREFIX fmt, "%s" DP_ALERT_TEXT fmt, fmt, \ |
518 | 0 | dp_time(), dp_my_pid(), log_prefix, ## args); \ |
519 | 0 | break; \ |
520 | 0 | case L_ERR: \ |
521 | 0 | dprint(_lev, _facility, NULL, NULL, \ |
522 | 0 | DP_ERR_PREFIX fmt, "%s" DP_ERR_TEXT fmt, fmt, \ |
523 | 0 | dp_time(), dp_my_pid(), log_prefix, ## args); \ |
524 | 0 | break; \ |
525 | 0 | case L_WARN: \ |
526 | 0 | dprint(_lev, _facility, NULL, NULL, \ |
527 | 0 | DP_WARN_PREFIX fmt, "%s" DP_WARN_TEXT fmt, fmt, \ |
528 | 0 | dp_time(), dp_my_pid(), log_prefix, ## args); \ |
529 | 0 | break; \ |
530 | 0 | case L_NOTICE: \ |
531 | 0 | dprint(_lev, _facility, NULL, NULL, \ |
532 | 0 | DP_NOTICE_PREFIX fmt, "%s" DP_NOTICE_TEXT fmt, fmt, \ |
533 | 0 | dp_time(), dp_my_pid(), log_prefix, ## args); \ |
534 | 0 | break; \ |
535 | 0 | case L_INFO: \ |
536 | 0 | dprint(_lev, _facility, NULL, NULL, \ |
537 | 0 | DP_INFO_PREFIX fmt, "%s" DP_INFO_TEXT fmt, fmt, \ |
538 | 0 | dp_time(), dp_my_pid(), log_prefix, ## args); \ |
539 | 0 | break; \ |
540 | 0 | case L_DBG: \ |
541 | 0 | dprint(_lev, _facility, NULL, NULL, \ |
542 | 0 | DP_DBG_PREFIX fmt, "%s" DP_DBG_TEXT fmt, fmt, \ |
543 | 0 | dp_time(), dp_my_pid(), log_prefix, ## args); \ |
544 | 0 | break; \ |
545 | 0 | default: \ |
546 | 0 | if (_lev > L_DBG) \ |
547 | 0 | dprint(_lev, _facility, NULL, NULL, \ |
548 | 0 | DP_DBG_PREFIX fmt, "%s" DP_DBG_TEXT fmt, fmt, \ |
549 | 0 | dp_time(), dp_my_pid(), log_prefix, ## args); \ |
550 | 0 | break; \ |
551 | 0 | } \ |
552 | 0 | } \ |
553 | 0 | }while(0) |
554 | | |
555 | | #define LM_ALERT( fmt, args...) \ |
556 | 0 | do { \ |
557 | 0 | if (is_printable(L_ALERT)) \ |
558 | 0 | MY_DPRINT(L_ALERT, log_facility, DP_ALERT_PREFIX, \ |
559 | 0 | DP_ALERT_TEXT, fmt, ##args); \ |
560 | 0 | }while(0) |
561 | | |
562 | | #define LM_CRIT( fmt, args...) \ |
563 | 0 | do { \ |
564 | 0 | if (is_printable(L_CRIT)) \ |
565 | 0 | MY_DPRINT(L_CRIT, log_facility, DP_CRIT_PREFIX, \ |
566 | 0 | DP_CRIT_TEXT, fmt, ##args); \ |
567 | 0 | }while(0) |
568 | | |
569 | | #define LM_ERR( fmt, args...) \ |
570 | 0 | do { \ |
571 | 0 | if (is_printable(L_ERR)) \ |
572 | 0 | MY_DPRINT(L_ERR, log_facility, DP_ERR_PREFIX, \ |
573 | 0 | DP_ERR_TEXT, fmt, ##args); \ |
574 | 0 | }while(0) |
575 | | |
576 | | #define LM_WARN( fmt, args...) \ |
577 | 0 | do { \ |
578 | 0 | if (is_printable(L_WARN)) \ |
579 | 0 | MY_DPRINT(L_WARN, log_facility, DP_WARN_PREFIX, \ |
580 | 0 | DP_WARN_TEXT, fmt, ##args); \ |
581 | 0 | }while(0) |
582 | | |
583 | | #define LM_NOTICE( fmt, args...) \ |
584 | 0 | do { \ |
585 | 0 | if (is_printable(L_NOTICE)) \ |
586 | 0 | MY_DPRINT(L_NOTICE, log_facility, DP_NOTICE_PREFIX, \ |
587 | 0 | DP_NOTICE_TEXT, fmt, ##args); \ |
588 | 0 | }while(0) |
589 | | |
590 | | #define LM_INFO( fmt, args...) \ |
591 | 0 | do { \ |
592 | 0 | if (is_printable(L_INFO)) \ |
593 | 0 | MY_DPRINT(L_INFO, log_facility, DP_INFO_PREFIX, \ |
594 | 0 | DP_INFO_TEXT, fmt, ##args); \ |
595 | 0 | }while(0) |
596 | | |
597 | | #ifdef NO_DEBUG |
598 | | #define LM_DBG( fmt, args...) |
599 | | #else |
600 | | #define LM_DBG( fmt, args...) \ |
601 | 113 | do { \ |
602 | 113 | if (is_printable(L_DBG)) \ |
603 | 113 | MY_DPRINT(L_DBG, log_facility, DP_DBG_PREFIX, \ |
604 | 113 | DP_DBG_TEXT, fmt, ##args); \ |
605 | 113 | }while(0) |
606 | | #endif /*NO_DEBUG*/ |
607 | | #endif /*SUN_PRO_C*/ |
608 | | #endif |
609 | | |
610 | | #define LM_BUG(format, args...) \ |
611 | 0 | do { \ |
612 | 0 | LM_CRIT("\n>>> " format"\nIt seems you have hit a programming bug.\n" \ |
613 | 0 | "Please help us make OpenSIPS better by reporting it at " \ |
614 | 0 | "https://github.com/OpenSIPS/opensips/issues\n\n", ##args); \ |
615 | 0 | } while (0) |
616 | | |
617 | | #define CASE_PRINTENUM(em) \ |
618 | 0 | CASE_FPRINTENUM(stdout, em) |
619 | | #define CASE_FPRINTENUM(file, em) \ |
620 | 0 | case em: printf(# em "\n"); break |
621 | | |
622 | | #endif /* ifndef dprint_h */ |