summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorCorey Farrell <git@cfware.com>2018-03-07 15:36:17 -0500
committerCorey Farrell <git@cfware.com>2018-03-07 16:03:01 -0600
commitc8a521b6c804d66abb367783dba75eecb16889a2 (patch)
treecd017f42216be9712f6b38cacffd8d6a67484844 /main
parent9040057db38dbc3d8181a5405d13ed8c8083d438 (diff)
Replace direct checks of option_debug with DEBUG_ATLEAST macro.
Checking option_debug directly is incorrect as it ignores file/module specific debug settings. This system-wide change replaces nearly all direct checks for option_debug with the DEBUG_ATLEAST macro. Change-Id: Ic342d4799a945dbc40ac085ac142681094a4ebf0
Diffstat (limited to 'main')
-rw-r--r--main/callerid.c2
-rw-r--r--main/config.c4
-rw-r--r--main/netsock2.c8
-rw-r--r--main/pbx.c10
-rw-r--r--main/sched.c35
5 files changed, 30 insertions, 29 deletions
diff --git a/main/callerid.c b/main/callerid.c
index d6f8575fb..6c4e5cf04 100644
--- a/main/callerid.c
+++ b/main/callerid.c
@@ -501,7 +501,7 @@ int callerid_feed_jp(struct callerid_state *cid, unsigned char *ubuf, int len, s
case 0x06: /* short dial number */
case 0x07: /* reserved */
default: /* reserved */
- if (option_debug > 1)
+ if (DEBUG_ATLEAST(2))
ast_log(LOG_NOTICE, "did info:#1=%X\n", (unsigned)cid->rawdata[x]);
break ;
}
diff --git a/main/config.c b/main/config.c
index 8107fce04..38192ed25 100644
--- a/main/config.c
+++ b/main/config.c
@@ -2785,9 +2785,7 @@ int ast_config_text_file_save2(const char *configfile, const struct ast_config *
}
cat = cat->next;
}
- if (!option_debug) {
- ast_verb(2, "Saving '%s': saved\n", fn);
- }
+ ast_verb(2, "Saving '%s': saved\n", fn);
} else {
ast_debug(1, "Unable to open for writing: %s\n", fn);
ast_verb(2, "Unable to write '%s' (%s)\n", fn, strerror(errno));
diff --git a/main/netsock2.c b/main/netsock2.c
index ef74ab92b..fedbd94a0 100644
--- a/main/netsock2.c
+++ b/main/netsock2.c
@@ -443,7 +443,7 @@ uint16_t _ast_sockaddr_port(const struct ast_sockaddr *addr, const char *file, i
&& addr->ss.ss_family == AF_INET6) {
return ntohs(((struct sockaddr_in6 *)&addr->ss)->sin6_port);
}
- if (option_debug >= 1) {
+ if (DEBUG_ATLEAST(1)) {
ast_log(__LOG_DEBUG, file, line, func, "Not an IPv4 nor IPv6 address, cannot get port.\n");
}
return 0;
@@ -461,7 +461,7 @@ void _ast_sockaddr_set_port(struct ast_sockaddr *addr, uint16_t port, const char
} else if (addr->len == sizeof(struct sockaddr_in6)
&& addr->ss.ss_family == AF_INET6) {
((struct sockaddr_in6 *)&addr->ss)->sin6_port = htons(port);
- } else if (option_debug >= 1) {
+ } else if (DEBUG_ATLEAST(1)) {
ast_log(__LOG_DEBUG, file, line, func,
"Not an IPv4 nor IPv6 address, cannot set port.\n");
}
@@ -657,7 +657,7 @@ int _ast_sockaddr_to_sin(const struct ast_sockaddr *addr,
return 0;
}
- if (addr->ss.ss_family != AF_INET && option_debug >= 1) {
+ if (addr->ss.ss_family != AF_INET && DEBUG_ATLEAST(1)) {
ast_log(__LOG_DEBUG, file, line, func, "Address family is not AF_INET\n");
}
@@ -670,7 +670,7 @@ void _ast_sockaddr_from_sin(struct ast_sockaddr *addr, const struct sockaddr_in
{
memcpy(&addr->ss, sin, sizeof(*sin));
- if (addr->ss.ss_family != AF_INET && option_debug >= 1) {
+ if (addr->ss.ss_family != AF_INET && DEBUG_ATLEAST(1)) {
ast_log(__LOG_DEBUG, file, line, func, "Address family is not AF_INET\n");
}
diff --git a/main/pbx.c b/main/pbx.c
index 942c15c05..70e72fe43 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -7508,13 +7508,13 @@ static int ast_add_extension2_lockopt(struct ast_context *con,
ast_add_hint(tmp);
}
}
- if (option_debug) {
+ if (DEBUG_ATLEAST(1)) {
if (tmp->matchcid == AST_EXT_MATCHCID_ON) {
- ast_debug(1, "Added extension '%s' priority %d (CID match '%s') to %s (%p)\n",
- tmp->name, tmp->priority, tmp->cidmatch_display, con->name, con);
+ ast_log(LOG_DEBUG, "Added extension '%s' priority %d (CID match '%s') to %s (%p)\n",
+ tmp->name, tmp->priority, tmp->cidmatch_display, con->name, con);
} else {
- ast_debug(1, "Added extension '%s' priority %d to %s (%p)\n",
- tmp->name, tmp->priority, con->name, con);
+ ast_log(LOG_DEBUG, "Added extension '%s' priority %d to %s (%p)\n",
+ tmp->name, tmp->priority, con->name, con);
}
}
diff --git a/main/sched.c b/main/sched.c
index a4ca260c6..d8afc74e6 100644
--- a/main/sched.c
+++ b/main/sched.c
@@ -31,10 +31,7 @@
#include "asterisk.h"
#ifdef DEBUG_SCHEDULER
-#define DEBUG(a) do { \
- if (option_debug) \
- DEBUG_M(a) \
- } while (0)
+#define DEBUG(a) a
#else
#define DEBUG(a)
#endif
@@ -548,8 +545,7 @@ int ast_sched_add_variable(struct ast_sched_context *con, int when, ast_sched_cb
}
#ifdef DUMP_SCHEDULER
/* Dump contents of the context while we have the lock so nothing gets screwed up by accident. */
- if (option_debug)
- ast_sched_dump(con);
+ ast_sched_dump(con);
#endif
if (con->sched_thread) {
ast_cond_signal(&con->sched_thread->cond);
@@ -649,8 +645,7 @@ int _ast_sched_del(struct ast_sched_context *con, int id, const char *file, int
#ifdef DUMP_SCHEDULER
/* Dump contents of the context while we have the lock so nothing gets screwed up by accident. */
- if (option_debug)
- ast_sched_dump(con);
+ ast_sched_dump(con);
#endif
if (con->sched_thread) {
ast_cond_signal(&con->sched_thread->cond);
@@ -711,25 +706,33 @@ void ast_sched_report(struct ast_sched_context *con, struct ast_str **buf, struc
void ast_sched_dump(struct ast_sched_context *con)
{
struct sched *q;
- struct timeval when = ast_tvnow();
+ struct timeval when;
int x;
size_t heap_size;
+
+ if (!DEBUG_ATLEAST(1)) {
+ return;
+ }
+
+ when = ast_tvnow();
#ifdef SCHED_MAX_CACHE
- ast_debug(1, "Asterisk Schedule Dump (%zu in Q, %u Total, %u Cache, %u high-water)\n", ast_heap_size(con->sched_heap), con->eventcnt - 1, con->schedccnt, con->highwater);
+ ast_log(LOG_DEBUG, "Asterisk Schedule Dump (%zu in Q, %u Total, %u Cache, %u high-water)\n",
+ ast_heap_size(con->sched_heap), con->eventcnt - 1, con->schedccnt, con->highwater);
#else
- ast_debug(1, "Asterisk Schedule Dump (%zu in Q, %u Total, %u high-water)\n", ast_heap_size(con->sched_heap), con->eventcnt - 1, con->highwater);
+ ast_log(LOG_DEBUG, "Asterisk Schedule Dump (%zu in Q, %u Total, %u high-water)\n",
+ ast_heap_size(con->sched_heap), con->eventcnt - 1, con->highwater);
#endif
- ast_debug(1, "=============================================================\n");
- ast_debug(1, "|ID Callback Data Time (sec:ms) |\n");
- ast_debug(1, "+-----+-----------------+-----------------+-----------------+\n");
+ ast_log(LOG_DEBUG, "=============================================================\n");
+ ast_log(LOG_DEBUG, "|ID Callback Data Time (sec:ms) |\n");
+ ast_log(LOG_DEBUG, "+-----+-----------------+-----------------+-----------------+\n");
ast_mutex_lock(&con->lock);
heap_size = ast_heap_size(con->sched_heap);
for (x = 1; x <= heap_size; x++) {
struct timeval delta;
q = ast_heap_peek(con->sched_heap, x);
delta = ast_tvsub(q->when, when);
- ast_debug(1, "|%.4d | %-15p | %-15p | %.6ld : %.6ld |\n",
+ ast_log(LOG_DEBUG, "|%.4d | %-15p | %-15p | %.6ld : %.6ld |\n",
q->sched_id->id,
q->callback,
q->data,
@@ -737,7 +740,7 @@ void ast_sched_dump(struct ast_sched_context *con)
(long int)delta.tv_usec);
}
ast_mutex_unlock(&con->lock);
- ast_debug(1, "=============================================================\n");
+ ast_log(LOG_DEBUG, "=============================================================\n");
}
/*! \brief