Coverage Report

Created: 2025-07-11 06:28

/src/opensips/dprint.h
Line
Count
Source (jump to first uncovered line)
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 3
109
110
0
#define STDERR_CONSUMER_NAME "stderror"
111
0
#define SYSLOG_CONSUMER_NAME "syslog"
112
0
#define EVENT_CONSUMER_NAME  "event"
113
114
#define LOG_PLAIN_NAME    "plain_text"
115
#define LOG_JSON_NAME     "json"
116
#define LOG_JSON_CEE_NAME "json_cee"
117
118
enum log_format {
119
  LOG_FORMAT_PLAIN,
120
  LOG_FORMAT_JSON,
121
  LOG_FORMAT_JSON_CEE
122
};
123
124
/* vars:*/
125
126
extern int *log_level;
127
extern char *log_prefix;
128
extern int log_stdout;
129
extern int stderr_enabled, syslog_enabled;
130
extern int log_event_enabled;
131
extern int log_facility;
132
extern char* log_name;
133
extern char ctime_buf[];
134
extern enum log_format stderr_log_format, syslog_log_format;
135
extern int log_event_level_filter;
136
extern int log_json_buf_size;
137
extern int log_msg_buf_size;
138
139
extern str log_cee_hostname;
140
141
/*
142
 * must be called after init_multi_proc_support()
143
 * must be called once for each OpenSIPS process
144
 */
145
int init_log_level(void);
146
147
/* must be called once, before the "pt" process table is freed */
148
void cleanup_log_level(void);
149
150
int init_log_cons_shm_table(void);
151
void cleanup_log_cons_shm_table(void);
152
153
int init_log_json_buf(int realloc);
154
int init_log_msg_buf(int realloc);
155
156
int init_log_cee_hostname(void);
157
158
int init_log_event_cons();
159
int set_log_event_cons_cfg_state(void);
160
void distroy_log_event_cons();
161
162
int set_log_consumer_mute_state(str *name, int state);
163
int get_log_consumer_mute_state(str *name, int *state);
164
165
int set_log_consumer_level_filter(str *name, int level);
166
int get_log_consumer_level_filter(str *name, int *level_filter);
167
168
int parse_log_format(str *format);
169
int dp_my_pid(void);
170
171
void stderr_dprint_tmp(char *format, ...);
172
173
void dprint(int log_level, int facility, const char *module, const char *func,
174
  char *stderr_fmt, char *syslog_fmt, char *format, ...)
175
  __attribute__ ((__format__ (__printf__, 5, 8)));
176
177
int str2facility(char *s);
178
179
void __set_proc_log_level(int proc_idx, int level);
180
181
void __set_proc_default_log_level(int proc_idx, int level);
182
183
/* set the current and default log levels for all OpenSIPS processes */
184
void set_global_log_level(int level);
185
186
/* set the log level of the current process */
187
void set_proc_log_level(int level);
188
189
/* changes the logging level to the default value for the current process */
190
void reset_proc_log_level(void);
191
192
/* suppress the E_CORE_LOG event for new logs (useful when handling the event
193
 * itself in an event consumer) */
194
void suppress_proc_log_event(void);
195
196
void reset_proc_log_event(void);
197
198
static inline char* dp_time(void)
199
0
{
200
0
  time_t ltime;
201
202
0
  time(&ltime);
203
0
  ctime_r( &ltime, ctime_buf);
204
0
  ctime_buf[19] = 0; /* remove year*/
205
206
0
  return ctime_buf+4;  /* remove name of day*/
207
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: 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: tcp_passfd.c:dp_time
Unexecuted instantiation: shm_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: mem.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: 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: status_report.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: 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
208
209
static inline const char *dp_log_level_str(int log_level)
210
0
{
211
0
  const char *level_str;
212
213
0
  switch (log_level) {
214
0
  case L_ALERT:
215
0
    level_str = DP_ALERT_STR;
216
0
    break;
217
0
  case L_CRIT:
218
0
    level_str = DP_CRIT_STR;
219
0
    break;
220
0
  case L_ERR:
221
0
    level_str = DP_ERR_STR;
222
0
    break;
223
0
  case L_WARN:
224
0
    level_str = DP_WARN_STR;
225
0
    break;
226
0
  case L_NOTICE:
227
0
    level_str = DP_NOTICE_STR;
228
0
    break;
229
0
  case L_INFO:
230
0
    level_str = DP_INFO_STR;
231
0
    break;
232
0
  case L_DBG:
233
0
  default:
234
0
    level_str = DP_DBG_STR;
235
0
  }
236
237
0
  return level_str;
238
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: 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: tcp_passfd.c:dp_log_level_str
Unexecuted instantiation: shm_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: mem.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: 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: status_report.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: 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
239
240
32.2k
#define is_printable(_level)  (((int)(*log_level)) >= ((int)(_level)))
241
242
#if defined __GNUC__
243
0
  #define __DP_FUNC  __FUNCTION__
244
#elif defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
245
  #define __DP_FUNC  __func__
246
#else
247
  #define __DP_FUNC  ((__const char *) 0)
248
#endif
249
250
251
#ifdef NO_LOG
252
253
  #ifdef __SUNPRO_C
254
    #define LM_GEN2(facility, lev, ...)
255
    #define LM_GEN1(lev, ...)
256
    #define LM_GEN(lev, ...)
257
    #define LM_ALERT( ...)
258
    #define LM_CRIT( ...)
259
    #define LM_ERR( ...)
260
    #define LM_WARN( ...)
261
    #define LM_NOTICE( ...)
262
    #define LM_INFO( ...)
263
    #define LM_DBG( ...)
264
  #else
265
    #define LM_GEN2(facility, lev, fmt, args...)
266
    #define LM_GEN1(lev, fmt, args...)
267
    #define LM_GEN(lev, fmt, args...)
268
    #define LM_ALERT(fmt, args...)
269
    #define LM_CRIT(fmt, args...)
270
    #define LM_ERR(fmt, args...)
271
    #define LM_WARN(fmt, args...)
272
    #define LM_NOTICE(fmt, args...)
273
    #define LM_INFO(fmt, args...)
274
    #define LM_DBG(fmt, args...)
275
  #endif
276
277
#else /* NO_LOG */
278
279
  #ifdef __SUNPRO_C
280
    #define LOG_PREFIX_UTIL2(_n) #_n
281
    #define LOG_PREFIX_UTIL(_n)  LOG_PREFIX_UTIL2(_n)
282
    #define LOG_PREFIX  LOG_PREFIX_UTIL(MOD_NAME) ": "
283
284
    #define stderr_dprint_tmp_err(fmt, ...) \
285
        stderr_dprint_tmp(DP_ERR_PREFIX LOG_PREFIX fmt __VA_ARGS__)
286
287
    #define MY_DPRINT(_log_level, _log_facility, _stderr_prefix, \
288
          _syslog_prefix, _fmt, ...) \
289
        dprint(_log_level, _log_facility, \
290
          LOG_PREFIX_UTIL(MOD_NAME), NULL, \
291
          _stderr_prefix LOG_PREFIX _fmt, \
292
          "%s" _prefix LOG_PREFIX _fmt, \
293
          _fmt, \
294
          dp_time(), dp_my_pid(), log_prefix __VA_ARGS__ ) \
295
296
    #define LM_GEN(_lev, fmt, ...) \
297
      do { \
298
        if (is_printable(_lev)){ \
299
          switch(_lev){ \
300
          case L_CRIT: \
301
            MY_DPRINT(L_CRIT, log_facility, DP_CRIT_PREFIX, \
302
              DP_CRIT_TEXT, fmt __VA_ARGS__); \
303
            break; \
304
          case L_ALERT: \
305
            MY_DPRINT(L_ALERT, log_facility, DP_ALERT_PREFIX, \
306
              DP_ALERT_TEXT, fmt __VA_ARGS__); \
307
            break; \
308
          case L_ERR: \
309
            MY_DPRINT(L_ERR, log_facility, DP_ERR_PREFIX, \
310
              DP_ERR_TEXT, fmt __VA_ARGS__); \
311
            break; \
312
          case L_WARN: \
313
            MY_DPRINT(L_WARN, log_facility, DP_WARN_PREFIX, \
314
              DP_WARN_TEXT, fmt __VA_ARGS__); \
315
            break; \
316
          case L_NOTICE: \
317
            MY_DPRINT(L_NOTICE, log_facility, DP_NOTICE_PREFIX, \
318
              DP_NOTICE_TEXT, fmt __VA_ARGS__); \
319
            break; \
320
          case L_INFO: \
321
            MY_DPRINT(L_INFO, log_facility, DP_INFO_PREFIX, \
322
              DP_INFO_TEXT, fmt __VA_ARGS__); \
323
            break; \
324
          case L_DBG: \
325
            MY_DPRINT(L_DBG, log_facility, DP_DBG_PREFIX, \
326
              DP_DBG_TEXT, fmt __VA_ARGS__); \
327
            break; \
328
          default: \
329
            if (_lev > L_DBG) \
330
              MY_DPRINT(L_DBG, log_facility, DP_DBG_PREFIX, \
331
              DP_DBG_TEXT, fmt __VA_ARGS__); \
332
            break; \
333
          } \
334
        } \
335
      }while(0)
336
337
    #define LM_GEN1(_lev, ...) \
338
      LM_GEN2( log_facility, _lev, __VA_ARGS__)
339
340
    #define LM_GEN2( _facility, _lev, fmt, ...) \
341
      do { \
342
        if (is_printable(_lev)){ \
343
          switch(_lev){ \
344
          case L_CRIT: \
345
            dprint(_lev, _facility, NULL, NULL, \
346
              DP_CRIT_PREFIX fmt, "%s" DP_CRIT_TEXT fmt, fmt, \
347
              dp_time(), dp_my_pid(), log_prefix __VA_ARGS__) \
348
            break; \
349
          case L_ALERT: \
350
            dprint(_lev, _facility, NULL, NULL, \
351
              DP_ALERT_PREFIX fmt, "%s" DP_ALERT_TEXT fmt, fmt, \
352
              dp_time(), dp_my_pid(), log_prefix __VA_ARGS__) \
353
            break; \
354
          case L_ERR: \
355
            dprint(_lev, _facility, NULL, NULL, \
356
              DP_ERR_PREFIX fmt, "%s" DP_ERR_TEXT fmt, fmt, \
357
              dp_time(), dp_my_pid(), log_prefix __VA_ARGS__) \
358
            break; \
359
          case L_WARN: \
360
            dprint(_lev, _facility, NULL, NULL, \
361
              DP_WARN_PREFIX fmt, "%s" DP_WARN_TEXT fmt, fmt, \
362
              dp_time(), dp_my_pid(), log_prefix __VA_ARGS__) \
363
            break; \
364
          case L_NOTICE: \
365
            dprint(_lev, _facility, NULL, NULL, \
366
              DP_NOTICE_PREFIX fmt, "%s" DP_NOTICE_TEXT fmt, fmt, \
367
              dp_time(), dp_my_pid(), log_prefix __VA_ARGS__) \
368
            break; \
369
          case L_INFO: \
370
            dprint(_lev, _facility, NULL, NULL, \
371
              DP_INFO_PREFIX fmt, "%s" DP_INFO_TEXT fmt, fmt, \
372
              dp_time(), dp_my_pid(), log_prefix __VA_ARGS__) \
373
            break; \
374
          case L_DBG: \
375
            dprint(_lev, _facility, NULL, NULL, \
376
              DP_DBG_PREFIX fmt, "%s" DP_DBG_TEXT fmt, fmt, \
377
              dp_time(), dp_my_pid(), log_prefix __VA_ARGS__) \
378
            break; \
379
          default: \
380
            if (_lev > L_DBG) \
381
              dprint(_lev, _facility, NULL, NULL, \
382
                DP_DBG_PREFIX fmt, "%s" DP_DBG_TEXT fmt, fmt, \
383
                dp_time(), dp_my_pid(), log_prefix __VA_ARGS__) \
384
            break; \
385
          } \
386
        } \
387
      }while(0)
388
389
    #define LM_ALERT( fmt, ...) \
390
      do { \
391
        if (is_printable(L_ALERT)) \
392
          MY_DPRINT(L_ALERT, log_facility, DP_ALERT_PREFIX, \
393
            DP_ALERT_TEXT, fmt __VA_ARGS__); \
394
      }while(0)
395
396
    #define LM_CRIT( fmt, ...) \
397
      do { \
398
        if (is_printable(L_CRIT)) \
399
          MY_DPRINT(L_CRIT, log_facility, DP_CRIT_PREFIX, \
400
            DP_CRIT_TEXT, fmt __VA_ARGS__); \
401
      }while(0)
402
403
    #define LM_ERR( fmt, ...) \
404
      do { \
405
        if (is_printable(L_ERR)) \
406
          MY_DPRINT(L_ERR, log_facility, DP_ERR_PREFIX, \
407
            DP_ERR_TEXT, fmt __VA_ARGS__); \
408
      }while(0)
409
410
    #define LM_WARN( fmt, ...) \
411
      do { \
412
        if (is_printable(L_WARN)) \
413
          MY_DPRINT(L_WARN, log_facility, DP_WARN_PREFIX, \
414
            DP_WARN_TEXT, fmt __VA_ARGS__); \
415
      }while(0)
416
417
    #define LM_NOTICE( fmt, ...) \
418
      do { \
419
        if (is_printable(L_NOTICE)) \
420
          MY_DPRINT(L_NOTICE, log_facility, DP_NOTICE_PREFIX, \
421
            DP_NOTICE_TEXT, fmt __VA_ARGS__); \
422
      }while(0)
423
424
    #define LM_INFO( fmt, ...) \
425
      do { \
426
        if (is_printable(L_INFO)) \
427
          MY_DPRINT(L_INFO, log_facility, DP_INFO_PREFIX, \
428
            DP_INFO_TEXT, fmt __VA_ARGS__); \
429
      }while(0)
430
431
    #ifdef NO_DEBUG
432
      #define LM_DBG( fmt, ...)
433
    #else
434
      #define LM_DBG( fmt, ...) \
435
        do { \
436
          if (is_printable(L_DBG)) \
437
            MY_DPRINT(L_DBG, log_facility, DP_DBG_PREFIX, \
438
              DP_DBG_TEXT, fmt __VA_ARGS__); \
439
        }while(0)
440
    #endif /*NO_DEBUG*/
441
442
  #else /*SUN_PRO_C*/
443
444
0
    #define LOG_PREFIX_UTIL2(_n) #_n
445
0
    #define LOG_PREFIX_UTIL(_n)  LOG_PREFIX_UTIL2(_n)
446
    #define LOG_PREFIX  LOG_PREFIX_UTIL(MOD_NAME) ":%s: "
447
448
    #define stderr_dprint_tmp_err(_fmt, args...) \
449
0
        stderr_dprint_tmp(DP_ERR_PREFIX LOG_PREFIX _fmt, \
450
0
        dp_time(), dp_my_pid(), log_prefix, __DP_FUNC, ## args) \
451
452
    #define MY_DPRINT(_log_level, _log_facility, _stderr_prefix, \
453
          _syslog_prefix, _fmt, args...) \
454
0
        dprint(_log_level, _log_facility, \
455
0
          LOG_PREFIX_UTIL(MOD_NAME), __DP_FUNC, \
456
0
          _stderr_prefix LOG_PREFIX _fmt, \
457
0
          (char *)"%s" _syslog_prefix LOG_PREFIX _fmt, \
458
0
          (char *)_fmt, \
459
0
          dp_time(), dp_my_pid(), log_prefix, __DP_FUNC, ## args) \
460
461
    #define LM_GEN(_lev, fmt, args...) \
462
      do { \
463
        if (is_printable(_lev)){ \
464
          switch(_lev){ \
465
          case L_CRIT: \
466
            MY_DPRINT(L_CRIT, log_facility, DP_CRIT_PREFIX, \
467
              DP_CRIT_TEXT, fmt, ##args); \
468
            break; \
469
          case L_ALERT: \
470
            MY_DPRINT(L_ALERT, log_facility, DP_ALERT_PREFIX, \
471
              DP_ALERT_TEXT, fmt, ##args); \
472
            break; \
473
          case L_ERR: \
474
            MY_DPRINT(L_ERR, log_facility, DP_ERR_PREFIX, \
475
              DP_ERR_TEXT, fmt, ##args); \
476
            break; \
477
          case L_WARN: \
478
            MY_DPRINT(L_WARN, log_facility, DP_WARN_PREFIX, \
479
              DP_WARN_TEXT, fmt, ##args); \
480
            break; \
481
          case L_NOTICE: \
482
            MY_DPRINT(L_NOTICE, log_facility, DP_NOTICE_PREFIX, \
483
              DP_NOTICE_TEXT, fmt, ##args); \
484
            break; \
485
          case L_INFO: \
486
            MY_DPRINT(L_INFO, log_facility, DP_INFO_PREFIX, \
487
              DP_INFO_TEXT, fmt, ##args); \
488
            break; \
489
          case L_DBG: \
490
            MY_DPRINT(L_DBG, log_facility, DP_DBG_PREFIX, \
491
              DP_DBG_TEXT, fmt, ##args); \
492
            break; \
493
          default: \
494
            if (_lev > L_DBG) \
495
              MY_DPRINT(L_DBG, log_facility, DP_DBG_PREFIX, \
496
                DP_DBG_TEXT, fmt, ##args); \
497
            break; \
498
          } \
499
        } \
500
      }while(0)
501
502
    #define LM_GEN1(_lev, args...) \
503
0
      LM_GEN2( log_facility, _lev, ##args)
504
505
    #define LM_GEN2( _facility, _lev, fmt, args...) \
506
0
      do { \
507
0
        if (is_printable(_lev)){ \
508
0
          switch(_lev){ \
509
0
          case L_CRIT: \
510
0
            dprint(_lev, _facility, NULL, NULL, \
511
0
              DP_CRIT_PREFIX fmt, "%s" DP_CRIT_TEXT fmt, fmt, \
512
0
              dp_time(), dp_my_pid(), log_prefix, ## args); \
513
0
            break; \
514
0
          case L_ALERT: \
515
0
            dprint(_lev, _facility, NULL, NULL, \
516
0
              DP_ALERT_PREFIX fmt, "%s" DP_ALERT_TEXT fmt, fmt, \
517
0
              dp_time(), dp_my_pid(), log_prefix, ## args); \
518
0
            break; \
519
0
          case L_ERR: \
520
0
            dprint(_lev, _facility, NULL, NULL, \
521
0
              DP_ERR_PREFIX fmt, "%s" DP_ERR_TEXT fmt, fmt, \
522
0
              dp_time(), dp_my_pid(), log_prefix, ## args); \
523
0
            break; \
524
0
          case L_WARN: \
525
0
            dprint(_lev, _facility, NULL, NULL, \
526
0
              DP_WARN_PREFIX fmt, "%s" DP_WARN_TEXT fmt, fmt, \
527
0
              dp_time(), dp_my_pid(), log_prefix, ## args); \
528
0
            break; \
529
0
          case L_NOTICE: \
530
0
            dprint(_lev, _facility, NULL, NULL, \
531
0
              DP_NOTICE_PREFIX fmt, "%s" DP_NOTICE_TEXT fmt, fmt, \
532
0
              dp_time(), dp_my_pid(), log_prefix, ## args); \
533
0
            break; \
534
0
          case L_INFO: \
535
0
            dprint(_lev, _facility, NULL, NULL, \
536
0
              DP_INFO_PREFIX fmt, "%s" DP_INFO_TEXT fmt, fmt, \
537
0
              dp_time(), dp_my_pid(), log_prefix, ## args); \
538
0
            break; \
539
0
          case L_DBG: \
540
0
            dprint(_lev, _facility, NULL, NULL, \
541
0
              DP_DBG_PREFIX fmt, "%s" DP_DBG_TEXT fmt, fmt, \
542
0
              dp_time(), dp_my_pid(), log_prefix, ## args); \
543
0
            break; \
544
0
          default: \
545
0
            if (_lev > L_DBG) \
546
0
              dprint(_lev, _facility, NULL, NULL, \
547
0
              DP_DBG_PREFIX fmt, "%s" DP_DBG_TEXT fmt, fmt, \
548
0
              dp_time(), dp_my_pid(), log_prefix, ## args); \
549
0
            break; \
550
0
          } \
551
0
        } \
552
0
      }while(0)
553
554
    #define LM_ALERT( fmt, args...) \
555
0
      do { \
556
0
        if (is_printable(L_ALERT)) \
557
0
          MY_DPRINT(L_ALERT, log_facility, DP_ALERT_PREFIX, \
558
0
            DP_ALERT_TEXT, fmt, ##args); \
559
0
      }while(0)
560
561
    #define LM_CRIT( fmt, args...) \
562
0
      do { \
563
0
        if (is_printable(L_CRIT)) \
564
0
          MY_DPRINT(L_CRIT, log_facility, DP_CRIT_PREFIX, \
565
0
            DP_CRIT_TEXT, fmt, ##args); \
566
0
      }while(0)
567
568
    #define LM_ERR( fmt, args...) \
569
0
      do { \
570
0
        if (is_printable(L_ERR)) \
571
0
          MY_DPRINT(L_ERR, log_facility, DP_ERR_PREFIX, \
572
0
            DP_ERR_TEXT, fmt, ##args); \
573
0
      }while(0)
574
575
    #define LM_WARN( fmt, args...) \
576
0
      do { \
577
0
        if (is_printable(L_WARN)) \
578
0
          MY_DPRINT(L_WARN, log_facility, DP_WARN_PREFIX, \
579
0
            DP_WARN_TEXT, fmt, ##args); \
580
0
      }while(0)
581
582
    #define LM_NOTICE( fmt, args...) \
583
0
      do { \
584
0
        if (is_printable(L_NOTICE)) \
585
0
          MY_DPRINT(L_NOTICE, log_facility, DP_NOTICE_PREFIX, \
586
0
            DP_NOTICE_TEXT, fmt, ##args); \
587
0
      }while(0)
588
589
    #define LM_INFO( fmt, args...) \
590
0
      do { \
591
0
        if (is_printable(L_INFO)) \
592
0
          MY_DPRINT(L_INFO, log_facility, DP_INFO_PREFIX, \
593
0
            DP_INFO_TEXT, fmt, ##args); \
594
0
      }while(0)
595
596
    #ifdef NO_DEBUG
597
      #define LM_DBG( fmt, args...)
598
    #else
599
      #define LM_DBG( fmt, args...) \
600
32.2k
        do { \
601
32.2k
          if (is_printable(L_DBG)) \
602
32.2k
            MY_DPRINT(L_DBG, log_facility, DP_DBG_PREFIX, \
603
32.2k
              DP_DBG_TEXT, fmt, ##args); \
604
32.2k
        }while(0)
605
    #endif /*NO_DEBUG*/
606
  #endif /*SUN_PRO_C*/
607
#endif
608
609
#define LM_BUG(format, args...) \
610
0
  do { \
611
0
    LM_CRIT("\n>>> " format"\nIt seems you have hit a programming bug.\n" \
612
0
        "Please help us make OpenSIPS better by reporting it at " \
613
0
        "https://github.com/OpenSIPS/opensips/issues\n\n", ##args); \
614
0
  } while (0)
615
616
#define CASE_PRINTENUM(em) \
617
0
  CASE_FPRINTENUM(stdout, em)
618
#define CASE_FPRINTENUM(file, em) \
619
0
        case em: printf(# em "\n"); break
620
621
#endif /* ifndef dprint_h */