diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-06-14 19:39:12 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-06-14 19:39:12 +0000 |
commit | f0424318479863edeed2a6a128e6d1ac926966e3 (patch) | |
tree | 4fd144260e58c9a66d331fc81b46473723452479 /main | |
parent | c8ca7d2f263f5161ce1b29ec2c9de835131fc950 (diff) |
Add a massive set of changes for converting to use the ast_debug() macro.
(issue #9957, patches from mvanbaak, caio1982, critch, and dimas)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@69327 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r-- | main/acl.c | 6 | ||||
-rw-r--r-- | main/adsistub.c | 3 | ||||
-rw-r--r-- | main/app.c | 39 | ||||
-rw-r--r-- | main/asterisk.c | 3 | ||||
-rw-r--r-- | main/callerid.c | 21 | ||||
-rw-r--r-- | main/cdr.c | 15 | ||||
-rw-r--r-- | main/channel.c | 223 | ||||
-rw-r--r-- | main/config.c | 9 | ||||
-rw-r--r-- | main/db.c | 6 | ||||
-rw-r--r-- | main/devicestate.c | 15 | ||||
-rw-r--r-- | main/dial.c | 4 | ||||
-rw-r--r-- | main/dns.c | 3 | ||||
-rw-r--r-- | main/dsp.c | 9 | ||||
-rw-r--r-- | main/enum.c | 17 | ||||
-rw-r--r-- | main/file.c | 6 | ||||
-rw-r--r-- | main/frame.c | 6 |
16 files changed, 137 insertions, 248 deletions
diff --git a/main/acl.c b/main/acl.c index 3a88c3c1a..74d0c096d 100644 --- a/main/acl.c +++ b/main/acl.c @@ -197,8 +197,7 @@ struct ast_ha *ast_append_ha(char *sense, char *stuff, struct ast_ha *path, int ret = ha; } } - if (option_debug) - ast_log(LOG_DEBUG, "%s/%s appended to acl for peer\n", stuff, nm); + ast_debug(1, "%s/%s appended to acl for peer\n", stuff, nm); return ret; } @@ -212,8 +211,7 @@ int ast_apply_ha(struct ast_ha *ha, struct sockaddr_in *sin) /* DEBUG */ ast_copy_string(iabuf, ast_inet_ntoa(sin->sin_addr), sizeof(iabuf)); ast_copy_string(iabuf2, ast_inet_ntoa(ha->netaddr), sizeof(iabuf2)); - if (option_debug) - ast_log(LOG_DEBUG, "##### Testing %s with %s\n", iabuf, iabuf2); + ast_debug(1, "##### Testing %s with %s\n", iabuf, iabuf2); /* For each rule, if this address and the netmask = the net address apply the current rule */ if ((sin->sin_addr.s_addr & ha->netmask.s_addr) == ha->netaddr.s_addr) diff --git a/main/adsistub.c b/main/adsistub.c index d92e54288..38eaa0efc 100644 --- a/main/adsistub.c +++ b/main/adsistub.c @@ -43,8 +43,7 @@ int (*func_name)(__VA_ARGS__) = \ #define build_stub(func_name,...) \ static int stub_##func_name(__VA_ARGS__) \ { \ - if (option_debug > 4) \ - ast_log(LOG_DEBUG, "ADSI support not loaded!\n"); \ + ast_debug(5, "ADSI support not loaded!\n"); \ return -1; \ } \ \ diff --git a/main/app.c b/main/app.c index a81831385..53c0d1f0f 100644 --- a/main/app.c +++ b/main/app.c @@ -472,8 +472,7 @@ int ast_control_streamfile(struct ast_channel *chan, const char *file, /* We go at next loop if we got the restart char */ if (restart && strchr(restart, res)) { - if (option_debug) - ast_log(LOG_DEBUG, "we'll restart the stream here at next loop\n"); + ast_debug(1, "we'll restart the stream here at next loop\n"); pause_restart_point = 0; continue; } @@ -581,8 +580,7 @@ static int __ast_play_and_record(struct ast_channel *chan, const char *playfile, return -1; } - if (option_debug) - ast_log(LOG_DEBUG,"play_and_record: %s, %s, '%s'\n", playfile ? playfile : "<None>", recordfile, fmt); + ast_debug(1, "play_and_record: %s, %s, '%s'\n", playfile ? playfile : "<None>", recordfile, fmt); snprintf(comment, sizeof(comment), "Playing %s, Recording to: %s on %s\n", playfile ? playfile : "<None>", recordfile, chan->name); if (playfile || beep) { @@ -603,8 +601,7 @@ static int __ast_play_and_record(struct ast_channel *chan, const char *playfile, stringp = fmts; strsep(&stringp, "|"); - if (option_debug) - ast_log(LOG_DEBUG, "Recording Formats: sfmts=%s\n", fmts); + ast_debug(1, "Recording Formats: sfmts=%s\n", fmts); sfmt[0] = ast_strdupa(fmts); while ((fmt = strsep(&stringp, "|"))) { @@ -659,8 +656,7 @@ static int __ast_play_and_record(struct ast_channel *chan, const char *playfile, for (;;) { res = ast_waitfor(chan, 2000); if (!res) { - if (option_debug) - ast_log(LOG_DEBUG, "One waitfor failed, trying another\n"); + ast_debug(1, "One waitfor failed, trying another\n"); /* Try one more time in case of masq */ res = ast_waitfor(chan, 2000); if (!res) { @@ -1071,8 +1067,7 @@ enum AST_LOCK_RESULT ast_lock_path(const char *path) ast_log(LOG_WARNING, "Failed to lock path '%s': %s\n", path, strerror(errno)); return AST_LOCK_TIMEOUT; } else { - if (option_debug) - ast_log(LOG_DEBUG, "Locked path '%s'\n", path); + ast_debug(1, "Locked path '%s'\n", path); return AST_LOCK_SUCCESS; } } @@ -1092,8 +1087,7 @@ int ast_unlock_path(const char *path) if ((res = unlink(s))) ast_log(LOG_ERROR, "Could not unlock path '%s': %s\n", path, strerror(errno)); else { - if (option_debug) - ast_log(LOG_DEBUG, "Unlocked path '%s'\n", path); + ast_debug(1, "Unlocked path '%s'\n", path); } return res; @@ -1324,8 +1318,7 @@ static int ast_ivr_menu_run_internal(struct ast_channel *chan, struct ast_ivr_me while (menu->options[pos].option) { if (!strcasecmp(menu->options[pos].option, exten)) { res = ivr_dispatch(chan, menu->options + pos, exten, cbdata); - if (option_debug) - ast_log(LOG_DEBUG, "IVR Dispatch of '%s' (pos %d) yields %d\n", exten, pos, res); + ast_debug(1, "IVR Dispatch of '%s' (pos %d) yields %d\n", exten, pos, res); if (res < 0) break; else if (res & RES_UPONE) @@ -1341,8 +1334,7 @@ static int ast_ivr_menu_run_internal(struct ast_channel *chan, struct ast_ivr_me if (!maxretries) maxretries = 3; if ((maxretries > 0) && (retries >= maxretries)) { - if (option_debug) - ast_log(LOG_DEBUG, "Max retries %d exceeded\n", maxretries); + ast_debug(1, "Max retries %d exceeded\n", maxretries); return -2; } else { if (option_exists(menu, "g") > -1) @@ -1353,28 +1345,24 @@ static int ast_ivr_menu_run_internal(struct ast_channel *chan, struct ast_ivr_me pos = 0; continue; } else if (res && strchr(AST_DIGIT_ANY, res)) { - if (option_debug) - ast_log(LOG_DEBUG, "Got start of extension, %c\n", res); + ast_debug(1, "Got start of extension, %c\n", res); exten[1] = '\0'; exten[0] = res; if ((res = read_newoption(chan, menu, exten, sizeof(exten)))) break; if (option_exists(menu, exten) < 0) { if (option_exists(menu, "i")) { - if (option_debug) - ast_log(LOG_DEBUG, "Invalid extension entered, going to 'i'!\n"); + ast_debug(1, "Invalid extension entered, going to 'i'!\n"); strcpy(exten, "i"); pos = 0; continue; } else { - if (option_debug) - ast_log(LOG_DEBUG, "Aborting on invalid entry, with no 'i' option!\n"); + ast_debug(1, "Aborting on invalid entry, with no 'i' option!\n"); res = -2; break; } } else { - if (option_debug) - ast_log(LOG_DEBUG, "New existing extension: %s\n", exten); + ast_debug(1, "New existing extension: %s\n", exten); pos = 0; continue; } @@ -1382,8 +1370,7 @@ static int ast_ivr_menu_run_internal(struct ast_channel *chan, struct ast_ivr_me } pos++; } - if (option_debug) - ast_log(LOG_DEBUG, "Stopping option '%s', res is %d\n", exten, res); + ast_debug(1, "Stopping option '%s', res is %d\n", exten, res); pos = 0; if (!strcasecmp(exten, "s")) strcpy(exten, "g"); diff --git a/main/asterisk.c b/main/asterisk.c index 7a65e47bc..4f5ada9b0 100644 --- a/main/asterisk.c +++ b/main/asterisk.c @@ -1266,8 +1266,7 @@ static void quit_handler(int num, int nice, int safeshutdown, int restart) /* Called on exit */ if (option_verbose && ast_opt_console) ast_verbose("Asterisk %s ending (%d).\n", ast_active_channels() ? "uncleanly" : "cleanly", num); - if (option_debug) - ast_log(LOG_DEBUG, "Asterisk ending (%d).\n", num); + ast_debug(1, "Asterisk ending (%d).\n", num); manager_event(EVENT_FLAG_SYSTEM, "Shutdown", "Shutdown: %s\r\nRestart: %s\r\n", ast_active_channels() ? "Uncleanly" : "Cleanly", restart ? "True" : "False"); if (ast_socket > -1) { pthread_cancel(lthread); diff --git a/main/callerid.c b/main/callerid.c index c870a462f..55e20d3da 100644 --- a/main/callerid.c +++ b/main/callerid.c @@ -180,7 +180,7 @@ void callerid_get_dtmf(char *cidstring, char *number, int *flags) number[0] = 0; if (strlen(cidstring) < 2) { - ast_log(LOG_DEBUG, "No cid detected\n"); + ast_debug(1, "No cid detected\n"); *flags = CID_UNKNOWN_NUMBER; return; } @@ -194,7 +194,7 @@ void callerid_get_dtmf(char *cidstring, char *number, int *flags) else if (code == 10) *flags = CID_PRIVATE_NUMBER; else - ast_log(LOG_DEBUG, "Unknown DTMF code %d\n", code); + ast_debug(1, "Unknown DTMF code %d\n", code); } else if (cidstring[0] == 'D' && cidstring[2] == '#') { /* .DK special code */ if (cidstring[1] == '1') @@ -209,7 +209,7 @@ void callerid_get_dtmf(char *cidstring, char *number, int *flags) if (isdigit(cidstring[i])) number[i-1] = cidstring[i]; else - ast_log(LOG_DEBUG, "Unknown CID digit '%c'\n", + ast_debug(1, "Unknown CID digit '%c'\n", cidstring[i]); } number[i-1] = 0; @@ -226,8 +226,7 @@ void callerid_get_dtmf(char *cidstring, char *number, int *flags) } number[i] = 0; } else { - if (option_debug) - ast_log(LOG_DEBUG, "Unknown CID protocol, start digit '%c'\n", cidstring[0]); + ast_debug(1, "Unknown CID protocol, start digit '%c'\n", cidstring[0]); *flags = CID_UNKNOWN_NUMBER; } } @@ -420,8 +419,7 @@ int callerid_feed_jp(struct callerid_state *cid, unsigned char *ubuf, int len, i case 0x06: /* short dial number */ case 0x07: /* reserved */ default: /* reserved */ - if (option_debug > 1) - ast_log(LOG_DEBUG, "cid info:#1=%X\n", cid->rawdata[x]); + ast_debug(2, "cid info:#1=%X\n", cid->rawdata[x]); break ; } x++; @@ -437,8 +435,7 @@ int callerid_feed_jp(struct callerid_state *cid, unsigned char *ubuf, int len, i case 0x09: /* private dial plan */ case 0x05: /* reserved */ default: /* reserved */ - if (option_debug > 1) - ast_log(LOG_DEBUG, "cid info:#2=%X\n", cid->rawdata[x]); + ast_debug(2, "cid info:#2=%X\n", cid->rawdata[x]); break ; } x++; @@ -453,8 +450,7 @@ int callerid_feed_jp(struct callerid_state *cid, unsigned char *ubuf, int len, i case 'C': /* pay phone */ case 'S': /* service congested */ cid->flags |= CID_UNKNOWN_NUMBER; - if (option_debug > 1) - ast_log(LOG_DEBUG, "no cid reason:%c\n",cid->rawdata[x]); + ast_debug(2, "no cid reason:%c\n",cid->rawdata[x]); break ; } x++; @@ -495,8 +491,7 @@ int callerid_feed_jp(struct callerid_state *cid, unsigned char *ubuf, int len, i case 0x09: /* private dial plan */ case 0x05: /* reserved */ default: /* reserved */ - if (option_debug > 1) - ast_log(LOG_DEBUG, "did info:#2=%X\n", cid->rawdata[x]); + ast_debug(2, "did info:#2=%X\n", cid->rawdata[x]); break ; } x++; diff --git a/main/cdr.c b/main/cdr.c index 76b5cfc1c..6614604eb 100644 --- a/main/cdr.c +++ b/main/cdr.c @@ -1049,16 +1049,14 @@ void ast_cdr_submit_batch(int shutdown) /* if configured, spawn a new thread to post these CDRs, also try to save as much as possible if we are shutting down safely */ if (batchscheduleronly || shutdown) { - if (option_debug) - ast_log(LOG_DEBUG, "CDR single-threaded batch processing begins now\n"); + ast_debug(1, "CDR single-threaded batch processing begins now\n"); do_batch_backend_process(oldbatchitems); } else { if (ast_pthread_create_detached_background(&batch_post_thread, NULL, do_batch_backend_process, oldbatchitems)) { ast_log(LOG_WARNING, "CDR processing thread could not detach, now trying in this thread\n"); do_batch_backend_process(oldbatchitems); } else { - if (option_debug) - ast_log(LOG_DEBUG, "CDR multi-threaded batch processing begins now\n"); + ast_debug(1, "CDR multi-threaded batch processing begins now\n"); } } } @@ -1095,8 +1093,7 @@ void ast_cdr_detach(struct ast_cdr *cdr) /* maybe they disabled CDR stuff completely, so just drop it */ if (!enabled) { - if (option_debug) - ast_log(LOG_DEBUG, "Dropping CDR !\n"); + ast_debug(1, "Dropping CDR !\n"); ast_set_flag(cdr, AST_CDR_FLAG_POST_DISABLED); ast_cdr_free(cdr); return; @@ -1110,8 +1107,7 @@ void ast_cdr_detach(struct ast_cdr *cdr) } /* otherwise, each CDR gets put into a batch list (at the end) */ - if (option_debug) - ast_log(LOG_DEBUG, "CDR detaching from this thread\n"); + ast_debug(1, "CDR detaching from this thread\n"); /* we'll need a new tail for every CDR */ if (!(newtail = ast_calloc(1, sizeof(*newtail)))) { @@ -1161,8 +1157,7 @@ static void *do_cdr(void *data) ast_cond_timedwait(&cdr_pending_cond, &cdr_pending_lock, &timeout); numevents = ast_sched_runq(sched); ast_mutex_unlock(&cdr_pending_lock); - if (option_debug > 1) - ast_log(LOG_DEBUG, "Processed %d scheduled CDR batches from the run queue\n", numevents); + ast_debug(2, "Processed %d scheduled CDR batches from the run queue\n", numevents); } return NULL; diff --git a/main/channel.c b/main/channel.c index dc99dfda9..86e4a92b9 100644 --- a/main/channel.c +++ b/main/channel.c @@ -433,8 +433,7 @@ int ast_channel_register(const struct ast_channel_tech *tech) chan->tech = tech; AST_LIST_INSERT_HEAD(&backends, chan, list); - if (option_debug) - ast_log(LOG_DEBUG, "Registered handler for '%s' (%s)\n", chan->tech->type, chan->tech->description); + ast_debug(1, "Registered handler for '%s' (%s)\n", chan->tech->type, chan->tech->description); if (option_verbose > 1) ast_verbose(VERBOSE_PREFIX_2 "Registered channel type '%s' (%s)\n", chan->tech->type, @@ -449,8 +448,7 @@ void ast_channel_unregister(const struct ast_channel_tech *tech) { struct chanlist *chan; - if (option_debug) - ast_log(LOG_DEBUG, "Unregistering channel type '%s'\n", tech->type); + ast_debug(1, "Unregistering channel type '%s'\n", tech->type); AST_RWLIST_WRLOCK(&channels); @@ -827,8 +825,7 @@ int ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin) ast_log(LOG_WARNING, "Exceptionally long queue length queuing to %s\n", chan->name); CRASH; } else { - if (option_debug) - ast_log(LOG_DEBUG, "Dropping voice to exceptionally long queue on %s\n", chan->name); + ast_debug(1, "Dropping voice to exceptionally long queue on %s\n", chan->name); ast_frfree(f); ast_channel_unlock(chan); return 0; @@ -974,14 +971,12 @@ static struct ast_channel *channel_find_locked(const struct ast_channel *prev, /* this is slightly unsafe, as we _should_ hold the lock to access c->name */ done = c == NULL || ast_channel_trylock(c) == 0; if (!done) { - if (option_debug) - ast_log(LOG_DEBUG, "Avoiding %s for channel '%p'\n", msg, c); + ast_debug(1, "Avoiding %s for channel '%p'\n", msg, c); if (retries == 9) { /* We are about to fail due to a deadlock, so report this * while we still have the list lock. */ - if (option_debug) - ast_log(LOG_DEBUG, "Failure, could not lock '%p' after %d retries!\n", c, retries); + ast_debug(1, "Failure, could not lock '%p' after %d retries!\n", c, retries); /* As we have deadlocked, we will skip this channel and * see if there is another match. * NOTE: No point doing this for a full-name match, @@ -1329,9 +1324,8 @@ int ast_channel_spy_add(struct ast_channel *chan, struct ast_channel_spy *spy) ast_clear_flag(spy, CHANSPY_TRIGGER_WRITE); } - if (option_debug) - ast_log(LOG_DEBUG, "Spy %s added to channel %s\n", - spy->type, chan->name); + ast_debug(1, "Spy %s added to channel %s\n", + spy->type, chan->name); return 0; } @@ -1366,8 +1360,7 @@ static void spy_detach(struct ast_channel_spy *spy, struct ast_channel *chan) } /* Print it out while we still have a lock so the structure can't go away (if signalled above) */ - if (option_debug) - ast_log(LOG_DEBUG, "Spy %s removed from channel %s\n", spy->type, chan->name); + ast_debug(1, "Spy %s removed from channel %s\n", spy->type, chan->name); ast_mutex_unlock(&spy->lock); @@ -1461,8 +1454,7 @@ static void detach_spies(struct ast_channel *chan) /*! \brief Softly hangup a channel, don't lock */ int ast_softhangup_nolock(struct ast_channel *chan, int cause) { - if (option_debug) - ast_log(LOG_DEBUG, "Soft-Hanging up channel '%s'\n", chan->name); + ast_debug(1, "Soft-Hanging up channel '%s'\n", chan->name); /* Inform channel driver that we need to be hung up, if it cares */ chan->_softhangup |= cause; ast_queue_frame(chan, &ast_null_frame); @@ -1512,8 +1504,7 @@ static void queue_frame_to_spies(struct ast_channel *chan, struct ast_frame *f, trans->path = NULL; } if (!trans->path) { - if (option_debug) - ast_log(LOG_DEBUG, "Building translator from %s to SLINEAR for spies on channel %s\n", + ast_debug(1, "Building translator from %s to SLINEAR for spies on channel %s\n", ast_getformatname(f->subclass), chan->name); if ((trans->path = ast_translator_build_path(AST_FORMAT_SLINEAR, f->subclass)) == NULL) { ast_log(LOG_WARNING, "Cannot build a path from %s to %s\n", @@ -1552,30 +1543,26 @@ static void queue_frame_to_spies(struct ast_channel *chan, struct ast_frame *f, if (dir == SPY_WRITE) { ast_set_flag(spy, CHANSPY_TRIGGER_WRITE); ast_clear_flag(spy, CHANSPY_TRIGGER_READ); - if (option_debug) - ast_log(LOG_DEBUG, "Switching spy '%s' on '%s' to write-trigger mode\n", - spy->type, chan->name); + ast_debug(1, "Switching spy '%s' on '%s' to write-trigger mode\n", + spy->type, chan->name); } break; case CHANSPY_TRIGGER_WRITE: if (dir == SPY_READ) { ast_set_flag(spy, CHANSPY_TRIGGER_READ); ast_clear_flag(spy, CHANSPY_TRIGGER_WRITE); - if (option_debug) - ast_log(LOG_DEBUG, "Switching spy '%s' on '%s' to read-trigger mode\n", - spy->type, chan->name); + ast_debug(1, "Switching spy '%s' on '%s' to read-trigger mode\n", + spy->type, chan->name); } break; } - if (option_debug) - ast_log(LOG_DEBUG, "Triggering queue flush for spy '%s' on '%s'\n", - spy->type, chan->name); + ast_debug(1, "Triggering queue flush for spy '%s' on '%s'\n", + spy->type, chan->name); ast_set_flag(spy, CHANSPY_TRIGGER_FLUSH); ast_cond_signal(&spy->trigger); } else { - if (option_debug) - ast_log(LOG_DEBUG, "Spy '%s' on channel '%s' %s queue too long, dropping frames\n", - spy->type, chan->name, (dir == SPY_READ) ? "read" : "write"); + ast_debug(1, "Spy '%s' on channel '%s' %s queue too long, dropping frames\n", + spy->type, chan->name, (dir == SPY_READ) ? "read" : "write"); while (queue->samples > SPY_QUEUE_SAMPLE_LIMIT) { struct ast_frame *drop = AST_LIST_REMOVE_HEAD(&queue->list, frame_list); queue->samples -= drop->samples; @@ -1675,13 +1662,11 @@ int ast_hangup(struct ast_channel *chan) CRASH; } if (!ast_test_flag(chan, AST_FLAG_ZOMBIE)) { - if (option_debug) - ast_log(LOG_DEBUG, "Hanging up channel '%s'\n", chan->name); + ast_debug(1, "Hanging up channel '%s'\n", chan->name); if (chan->tech->hangup) res = chan->tech->hangup(chan); } else { - if (option_debug) - ast_log(LOG_DEBUG, "Hanging up zombie '%s'\n", chan->name); + ast_debug(1, "Hanging up zombie '%s'\n", chan->name); } ast_channel_unlock(chan); @@ -1774,8 +1759,7 @@ static int generator_force(void *data) res = generate(chan, tmp, 0, 160); chan->generatordata = tmp; if (res) { - if (option_debug) - ast_log(LOG_DEBUG, "Auto-deactivating generator\n"); + ast_debug(1, "Auto-deactivating generator\n"); ast_deactivate_generator(chan); } return 0; @@ -1994,8 +1978,7 @@ int ast_settimeout(struct ast_channel *c, int samples, int (*func)(void *data), samples = 0; data = 0; } - if (option_debug) - ast_log(LOG_DEBUG, "Scheduling timer at %d sample intervals\n", samples); + ast_debug(1, "Scheduling timer at %d sample intervals\n", samples); res = ioctl(c->timingfd, ZT_TIMERCONFIG, &samples); c->timingfunc = func; c->timingdata = data; @@ -2219,13 +2202,11 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) case AST_FRAME_CONTROL: if (f->subclass == AST_CONTROL_ANSWER) { if (!ast_test_flag(chan, AST_FLAG_OUTGOING)) { - if (option_debug) - ast_log(LOG_DEBUG, "Ignoring answer on an inbound call!\n"); + ast_debug(1, "Ignoring answer on an inbound call!\n"); ast_frfree(f); f = &ast_null_frame; } else if (prestate == AST_STATE_UP) { - if (option_debug) - ast_log(LOG_DEBUG, "Dropping duplicate answer!\n"); + ast_debug(1, "Dropping duplicate answer!\n"); ast_frfree(f); f = &ast_null_frame; } else { @@ -2398,8 +2379,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) int res; if (chan->timingfunc) { - if (option_debug > 1) - ast_log(LOG_DEBUG, "Generator got voice, switching to phase locked mode\n"); + ast_debug(2, "Generator got voice, switching to phase locked mode\n"); ast_settimeout(chan, 0, NULL, NULL); } @@ -2407,15 +2387,13 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio) res = chan->generator->generate(chan, tmp, f->datalen, f->samples); chan->generatordata = tmp; if (res) { - if (option_debug > 1) - ast_log(LOG_DEBUG, "Auto-deactivating generator\n"); + ast_debug(2, "Auto-deactivating generator\n"); ast_deactivate_generator(chan); } } else if (f->frametype == AST_FRAME_CNG) { if (chan->generator && !chan->timingfunc && (chan->timingfd > -1)) { - if (option_debug > 1) - ast_log(LOG_DEBUG, "Generator got CNG, switching to timed mode\n"); + ast_debug(2, "Generator got CNG, switching to timed mode\n"); ast_settimeout(chan, 160, generator_force, chan); } } @@ -2450,8 +2428,7 @@ done: int ast_internal_timing_enabled(struct ast_channel *chan) { int ret = ast_opt_internal_timing && chan->timingfd > -1; - if (option_debug > 4) - ast_log(LOG_DEBUG, "Internal timing is %s (option_internal_timing=%d chan->timingfd=%d)\n", ret? "enabled": "disabled", ast_opt_internal_timing, chan->timingfd); + ast_debug(5, "Internal timing is %s (option_internal_timing=%d chan->timingfd=%d)\n", ret? "enabled": "disabled", ast_opt_internal_timing, chan->timingfd); return ret; } @@ -2504,8 +2481,7 @@ int ast_indicate_data(struct ast_channel *chan, int condition, const void *data, break; } if (ts && ts->data[0]) { - if (option_debug) - ast_log(LOG_DEBUG, "Driver for channel '%s' does not support indication %d, emulating it\n", chan->name, condition); + ast_debug(1, "Driver for channel '%s' does not support indication %d, emulating it\n", chan->name, condition); ast_playtones_start(chan,0,ts->data, 1); res = 0; } else if (condition == AST_CONTROL_PROGRESS) { @@ -2618,8 +2594,7 @@ int ast_senddigit_begin(struct ast_channel *chan, char digit) ast_playtones_start(chan, 0, dtmf_tones[15], 0); else { /* not handled */ - if (option_debug) - ast_log(LOG_DEBUG, "Unable to generate DTMF tone '%c' for '%s'\n", digit, chan->name); + ast_debug(1, "Unable to generate DTMF tone '%c' for '%s'\n", digit, chan->name); } return 0; @@ -2655,8 +2630,7 @@ int ast_prod(struct ast_channel *chan) /* Send an empty audio frame to get things moving */ if (chan->_state != AST_STATE_UP) { - if (option_debug) - ast_log(LOG_DEBUG, "Prodding channel '%s'\n", chan->name); + ast_debug(1, "Prodding channel '%s'\n", chan->name); a.subclass = chan->rawwriteformat; a.data = nothing + AST_FRIENDLY_OFFSET; a.src = "ast_prod"; @@ -2931,9 +2905,8 @@ static int set_format(struct ast_channel *chan, int fmt, int *rawformat, int *fo /* writing */ *trans = ast_translator_build_path(*rawformat, *format); ast_channel_unlock(chan); - if (option_debug) - ast_log(LOG_DEBUG, "Set channel %s to %s format %s\n", chan->name, - direction ? "write" : "read", ast_getformatname(fmt)); + ast_debug(1, "Set channel %s to %s format %s\n", chan->name, + direction ? "write" : "read", ast_getformatname(fmt)); return 0; } @@ -3332,9 +3305,8 @@ int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clo return -1; } - if (option_debug) - ast_log(LOG_DEBUG, "Planning to masquerade channel %s into the structure of %s\n", - clone->name, original->name); + ast_debug(1, "Planning to masquerade channel %s into the structure of %s\n", + clone->name, original->name); if (original->masq) { ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n", original->masq->name, original->name); @@ -3346,8 +3318,7 @@ int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clo clone->masqr = original; ast_queue_frame(original, &ast_null_frame); ast_queue_frame(clone, &ast_null_frame); - if (option_debug) - ast_log(LOG_DEBUG, "Done planning to masquerade channel %s into the structure of %s\n", clone->name, original->name); + ast_debug(1, "Done planning to masquerade channel %s into the structure of %s\n", clone->name, original->name); res = 0; } @@ -3386,21 +3357,18 @@ void ast_channel_inherit_variables(const struct ast_channel *parent, struct ast_ newvar = ast_var_assign(&varname[1], ast_var_value(current)); if (newvar) { AST_LIST_INSERT_TAIL(&child->varshead, newvar, entries); - if (option_debug) - ast_log(LOG_DEBUG, "Copying soft-transferable variable %s.\n", ast_var_name(newvar)); + ast_debug(1, "Copying soft-transferable variable %s.\n", ast_var_name(newvar)); } break; case 2: newvar = ast_var_assign(ast_var_full_name(current), ast_var_value(current)); if (newvar) { AST_LIST_INSERT_TAIL(&child->varshead, newvar, entries); - if (option_debug) - ast_log(LOG_DEBUG, "Copying hard-transferable variable %s.\n", ast_var_name(newvar)); + ast_debug(1, "Copying hard-transferable variable %s.\n", ast_var_name(newvar)); } break; default: - if (option_debug) - ast_log(LOG_DEBUG, "Not copying variable %s.\n", ast_var_name(current)); + ast_debug(1, "Not copying variable %s.\n", ast_var_name(current)); break; } } @@ -3448,9 +3416,8 @@ int ast_do_masquerade(struct ast_channel *original) char masqn[100]; char zombn[100]; - if (option_debug > 3) - ast_log(LOG_DEBUG, "Actually Masquerading %s(%d) into the structure of %s(%d)\n", - clone->name, clone->_state, original->name, original->_state); + ast_debug(4, "Actually Masquerading %s(%d) into the structure of %s(%d)\n", + clone->name, clone->_state, original->name, original->_state); manager_event(EVENT_FLAG_CALL, "Masquerade", "Clone: %s\r\nCloneState: %s\r\nOriginal: %s\r\nOriginalState: %s\r\n", clone->name, ast_state2str(clone->_state), original->name, ast_state2str(original->_state)); @@ -3463,8 +3430,7 @@ int ast_do_masquerade(struct ast_channel *original) /* We need the clone's lock, too */ ast_channel_lock(clone); - if (option_debug > 1) - ast_log(LOG_DEBUG, "Got clone lock for masquerade on '%s' at %p\n", clone->name, &clone->lock); + ast_debug(2, "Got clone lock for masquerade on '%s' at %p\n", clone->name, &clone->lock); /* Having remembered the original read/write formats, we turn off any translation on either one */ @@ -3665,8 +3631,7 @@ int ast_do_masquerade(struct ast_channel *original) /* Copy the music class */ ast_string_field_set(original, musicclass, clone->musicclass); - if (option_debug) - ast_log(LOG_DEBUG, "Putting channel %s in %d/%d formats\n", original->name, wformat, rformat); + ast_debug(1, "Putting channel %s in %d/%d formats\n", original->name, wformat, rformat); /* Okay. Last thing is to let the channel driver know about all this mess, so he can fix up everything as best as possible */ @@ -3686,8 +3651,7 @@ int ast_do_masquerade(struct ast_channel *original) a zombie so nothing tries to touch it. If it's already been marked as a zombie, then free it now (since it already is considered invalid). */ if (ast_test_flag(clone, AST_FLAG_ZOMBIE)) { - if (option_debug) - ast_log(LOG_DEBUG, "Destroying channel clone '%s'\n", clone->name); + ast_debug(1, "Destroying channel clone '%s'\n", clone->name); ast_channel_unlock(clone); manager_event(EVENT_FLAG_CALL, "Hangup", "Channel: %s\r\n" @@ -3701,8 +3665,7 @@ int ast_do_masquerade(struct ast_channel *original) ); ast_channel_free(clone); } else { - if (option_debug) - ast_log(LOG_DEBUG, "Released clone lock on '%s'\n", clone->name); + ast_debug(1, "Released clone lock on '%s'\n", clone->name); ast_set_flag(clone, AST_FLAG_ZOMBIE); ast_queue_frame(clone, &ast_null_frame); ast_channel_unlock(clone); @@ -3711,8 +3674,7 @@ int ast_do_masquerade(struct ast_channel *original) /* Signal any blocker */ if (ast_test_flag(original, AST_FLAG_BLOCKING)) pthread_kill(original->blocker, SIGURG); - if (option_debug) - ast_log(LOG_DEBUG, "Done Masquerading %s (%d)\n", original->name, original->_state); + ast_debug(1, "Done Masquerading %s (%d)\n", original->name, original->_state); return 0; } @@ -3893,8 +3855,7 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct if (!f) { *fo = NULL; *rc = who; - if (option_debug) - ast_log(LOG_DEBUG, "Didn't get a frame from channel: %s\n",who->name); + ast_debug(1, "Didn't get a frame from channel: %s\n",who->name); break; } @@ -3916,8 +3877,7 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct *fo = f; *rc = who; bridge_exit = 1; - if (option_debug) - ast_log(LOG_DEBUG, "Got a FRAME_CONTROL (%d) frame on channel %s\n", f->subclass, who->name); + ast_debug(1, "Got a FRAME_CONTROL (%d) frame on channel %s\n", f->subclass, who->name); break; } if (bridge_exit) @@ -3939,10 +3899,9 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct f->frametype == AST_FRAME_DTMF_BEGIN)) { *fo = f; *rc = who; - if (option_debug) - ast_log(LOG_DEBUG, "Got DTMF %s on channel (%s)\n", - f->frametype == AST_FRAME_DTMF_END ? "end" : "begin", - who->name); + ast_debug(1, "Got DTMF %s on channel (%s)\n", + f->frametype == AST_FRAME_DTMF_END ? "end" : "begin", + who->name); break; } /* Write immediately frames, not passed through jb */ @@ -4110,8 +4069,7 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha c1->_softhangup = 0; c0->_bridge = c1; c1->_bridge = c0; - if (option_debug) - ast_log(LOG_DEBUG, "Unbridge signal received. Ending native bridge.\n"); + ast_debug(1, "Unbridge signal received. Ending native bridge.\n"); continue; } @@ -4122,13 +4080,12 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha if (who) *rc = who; res = 0; - if (option_debug) - ast_log(LOG_DEBUG, "Bridge stops because we're zombie or need a soft hangup: c0=%s, c1=%s, flags: %s,%s,%s,%s\n", - c0->name, c1->name, - ast_test_flag(c0, AST_FLAG_ZOMBIE) ? "Yes" : "No", - ast_check_hangup(c0) ? "Yes" : "No", - ast_test_flag(c1, AST_FLAG_ZOMBIE) ? "Yes" : "No", - ast_check_hangup(c1) ? "Yes" : "No"); + ast_debug(1, "Bridge stops because we're zombie or need a soft hangup: c0=%s, c1=%s, flags: %s,%s,%s,%s\n", + c0->name, c1->name, + ast_test_flag(c0, AST_FLAG_ZOMBIE) ? "Yes" : "No", + ast_check_hangup(c0) ? "Yes" : "No", + ast_test_flag(c1, AST_FLAG_ZOMBIE) ? "Yes" : "No", + ast_check_hangup(c1) ? "Yes" : "No"); break; } @@ -4151,8 +4108,7 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha "CallerID1: %s\r\n" "CallerID2: %s\r\n", c0->name, c1->name, c0->uniqueid, c1->uniqueid, c0->cid.cid_num, c1->cid.cid_num); - if (option_debug) - ast_log(LOG_DEBUG, "Returning from native bridge, channels: %s, %s\n", c0->name, c1->name); + ast_debug(1, "Returning from native bridge, channels: %s, %s\n", c0->name, c1->name); ast_clear_flag(c0, AST_FLAG_NBRIDGE); ast_clear_flag(c1, AST_FLAG_NBRIDGE); @@ -4221,8 +4177,7 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha "CallerID1: %s\r\n" "CallerID2: %s\r\n", c0->name, c1->name, c0->uniqueid, c1->uniqueid, c0->cid.cid_num, c1->cid.cid_num); - if (option_debug) - ast_log(LOG_DEBUG, "Bridge stops bridging channels %s and %s\n", c0->name, c1->name); + ast_debug(1, "Bridge stops bridging channels %s and %s\n", c0->name, c1->name); return res; } @@ -4694,8 +4649,7 @@ struct ast_silence_generator *ast_channel_start_silence_generator(struct ast_cha ast_activate_generator(chan, &silence_generator, state); - if (option_debug) - ast_log(LOG_DEBUG, "Started silence generator on '%s'\n", chan->name); + ast_debug(1, "Started silence generator on '%s'\n", chan->name); return state; } @@ -4707,8 +4661,7 @@ void ast_channel_stop_silence_generator(struct ast_channel *chan, struct ast_sil ast_deactivate_generator(chan); - if (option_debug) - ast_log(LOG_DEBUG, "Stopped silence generator on '%s'\n", chan->name); + ast_debug(1, "Stopped silence generator on '%s'\n", chan->name); if (ast_set_write_format(chan, state->old_write_format) < 0) ast_log(LOG_ERROR, "Could not return write format to its original state\n"); @@ -4743,12 +4696,10 @@ const char *channelreloadreason2txt(enum channelreloadreason reason) int ast_channel_unlock(struct ast_channel *chan) { int res = 0; - if (option_debug > 2) - ast_log(LOG_DEBUG, "::::==== Unlocking AST channel %s\n", chan->name); + ast_debug(3, "::::==== Unlocking AST channel %s\n", chan->name); if (!chan) { - if (option_debug) - ast_log(LOG_DEBUG, "::::==== Unlocking non-existing channel \n"); + ast_debug(1, "::::==== Unlocking non-existing channel \n"); return 0; } @@ -4758,21 +4709,17 @@ int ast_channel_unlock(struct ast_channel *chan) #ifdef DEBUG_THREADS int count = 0; if ((count = chan->lock.reentrancy)) - if (option_debug) - ast_log(LOG_DEBUG, ":::=== Still have %d locks (recursive)\n", count); + ast_debug(3, ":::=== Still have %d locks (recursive)\n", count); #endif if (!res) - if (option_debug) - ast_log(LOG_DEBUG, "::::==== Channel %s was unlocked\n", chan->name); + ast_debug(3, "::::==== Channel %s was unlocked\n", chan->name); if (res == EINVAL) { - if (option_debug) - ast_log(LOG_DEBUG, "::::==== Channel %s had no lock by this thread. Failed unlocking\n", chan->name); + ast_debug(3, "::::==== Channel %s had no lock by this thread. Failed unlocking\n", chan->name); } } if (res == EPERM) { /* We had no lock, so okay any way*/ - if (option_debug > 3) - ast_log(LOG_DEBUG, "::::==== Channel %s was not locked at all \n", chan->name); + ast_debug(4, "::::==== Channel %s was not locked at all \n", chan->name); res = 0; } return res; @@ -4784,8 +4731,7 @@ int ast_channel_lock(struct ast_channel *chan) { int res; - if (option_debug > 3) - ast_log(LOG_DEBUG, "====:::: Locking AST channel %s\n", chan->name); + ast_debug(4, "====:::: Locking AST channel %s\n", chan->name); res = ast_mutex_lock(&chan->lock); @@ -4793,20 +4739,16 @@ int ast_channel_lock(struct ast_channel *chan) #ifdef DEBUG_THREADS int count = 0; if ((count = chan->lock.reentrancy)) - if (option_debug) - ast_log(LOG_DEBUG, ":::=== Now have %d locks (recursive)\n", count); + ast_debug(4, ":::=== Now have %d locks (recursive)\n", count); #endif if (!res) - if (option_debug) - ast_log(LOG_DEBUG, "::::==== Channel %s was locked\n", chan->name); + ast_debug(4, "::::==== Channel %s was locked\n", chan->name); if (res == EDEADLK) { /* We had no lock, so okey any way */ - if (option_debug > 3) - ast_log(LOG_DEBUG, "::::==== Channel %s was not locked by us. Lock would cause deadlock.\n", chan->name); + ast_debug(4, "::::==== Channel %s was not locked by us. Lock would cause deadlock.\n", chan->name); } if (res == EINVAL) { - if (option_debug > 3) - ast_log(LOG_DEBUG, "::::==== Channel %s lock failed. No mutex.\n", chan->name); + ast_debug(4, "::::==== Channel %s lock failed. No mutex.\n", chan->name); } } return res; @@ -4818,8 +4760,7 @@ int ast_channel_trylock(struct ast_channel *chan) { int res; - if (option_debug > 2) - ast_log(LOG_DEBUG, "====:::: Trying to lock AST channel %s\n", chan->name); + ast_debug(3, "====:::: Trying to lock AST channel %s\n", chan->name); res = ast_mutex_trylock(&chan->lock); @@ -4827,24 +4768,20 @@ int ast_channel_trylock(struct ast_channel *chan) #ifdef DEBUG_THREADS int count = 0; if ((count = chan->lock.reentrancy)) - if (option_debug) - ast_log(LOG_DEBUG, ":::=== Now have %d locks (recursive)\n", count); + ast_debug(3, ":::=== Now have %d locks (recursive)\n", count); #endif if (!res) - if (option_debug) - ast_log(LOG_DEBUG, "::::==== Channel %s was locked\n", chan->name); + ast_debug(3, "::::==== Channel %s was locked\n", chan->name); if (res == EBUSY) { /* We failed to lock */ - if (option_debug > 2) - ast_log(LOG_DEBUG, "::::==== Channel %s failed to lock. Not waiting around...\n", chan->name); + ast_debug(3, "::::==== Channel %s failed to lock. Not waiting around...\n", chan->name); } if (res == EDEADLK) { /* We had no lock, so okey any way*/ - if (option_debug > 2) - ast_log(LOG_DEBUG, "::::==== Channel %s was not locked. Lock would cause deadlock.\n", chan->name); + ast_debug(3, "::::==== Channel %s was not locked. Lock would cause deadlock.\n", chan->name); } - if (res == EINVAL && option_debug > 2) - ast_log(LOG_DEBUG, "::::==== Channel %s lock failed. No mutex.\n", chan->name); + if (res == EINVAL) + ast_debug(3, "::::==== Channel %s lock failed. No mutex.\n", chan->name); } return res; } diff --git a/main/config.c b/main/config.c index 54e899761..ad7138443 100644 --- a/main/config.c +++ b/main/config.c @@ -829,15 +829,13 @@ static struct ast_config *config_text_file_load(const char *database, const char fflush(stdout); } if (!(f = fopen(fn, "r"))) { - if (option_debug) - ast_log(LOG_DEBUG, "No file to parse: %s\n", fn); + ast_debug(1, "No file to parse: %s\n", fn); if (option_verbose > 1) ast_verbose( "Not found (%s)\n", strerror(errno)); continue; } count++; - if (option_debug) - ast_log(LOG_DEBUG, "Parsing %s\n", fn); + ast_debug(1, "Parsing %s\n", fn); if (option_verbose > 1) ast_verbose("Found\n"); while (!feof(f)) { @@ -1028,8 +1026,7 @@ int config_text_file_save(const char *configfile, const struct ast_config *cfg, if ((option_verbose > 1) && !option_debug) ast_verbose("Saved\n"); } else { - if (option_debug) - ast_log(LOG_DEBUG, "Unable to open for writing: %s\n", fn); + ast_debug(1, "Unable to open for writing: %s\n", fn); if (option_verbose > 1) ast_verbose(VERBOSE_PREFIX_2 "Unable to write (%s)", strerror(errno)); return -1; @@ -194,8 +194,7 @@ int ast_db_get(const char *family, const char *keys, char *value, int valuelen) /* Be sure to NULL terminate our data either way */ if (res) { - if (option_debug) - ast_log(LOG_DEBUG, "Unable to find key '%s' in family '%s'\n", keys, family); + ast_debug(1, "Unable to find key '%s' in family '%s'\n", keys, family); } else { #if 0 printf("Got value of size %d\n", data.size); @@ -234,8 +233,7 @@ int ast_db_del(const char *family, const char *keys) ast_mutex_unlock(&dblock); if (res) { - if (option_debug) - ast_log(LOG_DEBUG, "Unable to find key '%s' in family '%s'\n", keys, family); + ast_debug(1, "Unable to find key '%s' in family '%s'\n", keys, family); } return res; } diff --git a/main/devicestate.c b/main/devicestate.c index 2c30011b0..a233e5686 100644 --- a/main/devicestate.c +++ b/main/devicestate.c @@ -284,13 +284,11 @@ enum ast_device_state ast_device_state(const char *device) } if (provider) { - if (option_debug > 2) - ast_log(LOG_DEBUG, "Checking if I can find provider for \"%s\" - number: %s\n", provider, number); + ast_debug(3, "Checking if I can find provider for \"%s\" - number: %s\n", provider, number); return getproviderstate(provider, number); } - if (option_debug > 3) - ast_log(LOG_DEBUG, "No provider found, checking channel drivers for %s - %s\n", tech, number); + ast_debug(4, "No provider found, checking channel drivers for %s - %s\n", tech, number); if (!(chan_tech = ast_get_channel_tech(tech))) return AST_DEVICE_INVALID; @@ -359,8 +357,7 @@ static int getproviderstate(const char *provider, const char *address) AST_RWLIST_RDLOCK(&devstate_provs); AST_RWLIST_TRAVERSE(&devstate_provs, devprov, list) { - if (option_debug > 4) - ast_log(LOG_DEBUG, "Checking provider %s with %s\n", devprov->label, provider); + ast_debug(5, "Checking provider %s with %s\n", devprov->label, provider); if (!strcasecmp(devprov->label, provider)) { res = devprov->callback(address); @@ -380,8 +377,7 @@ static void do_state_change(const char *device) struct ast_event *event; state = ast_device_state(device); - if (option_debug > 2) - ast_log(LOG_DEBUG, "Changing state for %s - state %d (%s)\n", device, state, devstate2str(state)); + ast_debug(3, "Changing state for %s - state %d (%s)\n", device, state, devstate2str(state)); if (!(event = ast_event_new(AST_EVENT_DEVICE_STATE, AST_EVENT_IE_DEVICE, AST_EVENT_IE_PLTYPE_STR, device, @@ -401,8 +397,7 @@ static int __ast_device_state_changed_literal(char *buf) struct state_change *change; char *tmp = NULL; - if (option_debug > 2) - ast_log(LOG_DEBUG, "Notification of state change to be queued on device/channel %s\n", buf); + ast_debug(3, "Notification of state change to be queued on device/channel %s\n", buf); device = buf; diff --git a/main/dial.c b/main/dial.c index 8b804fdbb..de30419ba 100644 --- a/main/dial.c +++ b/main/dial.c @@ -576,13 +576,13 @@ enum ast_dial_result ast_dial_run(struct ast_dial *dial, struct ast_channel *cha /* Ensure required arguments are passed */ if (!dial || (!chan && !async)) { - ast_log(LOG_DEBUG, "invalid #1\n"); + ast_debug(1, "invalid #1\n"); return AST_DIAL_RESULT_INVALID; } /* If there are no channels to dial we can't very well try to dial them */ if (AST_LIST_EMPTY(&dial->channels)) { - ast_log(LOG_DEBUG, "invalid #2\n"); + ast_debug(1, "invalid #2\n"); return AST_DIAL_RESULT_INVALID; } diff --git a/main/dns.c b/main/dns.c index 52a4b8ddb..bb7827226 100644 --- a/main/dns.c +++ b/main/dns.c @@ -222,8 +222,7 @@ int ast_search_dns(void *context, ret = -1; } else if (ret == 0) { - if (option_debug) - ast_log(LOG_DEBUG, "No matches found in DNS for %s\n", dname); + ast_debug(1, "No matches found in DNS for %s\n", dname); ret = 0; } else diff --git a/main/dsp.c b/main/dsp.c index 9519c56cc..428873ebf 100644 --- a/main/dsp.c +++ b/main/dsp.c @@ -1323,8 +1323,7 @@ int ast_dsp_busydetect(struct ast_dsp *dsp) #ifndef BUSYDETECT_TONEONLY #if 1 if (res) { - if (option_debug) - ast_log(LOG_DEBUG, "ast_dsp_busydetect detected busy, avgtone: %d, avgsilence %d\n", avgtone, avgsilence); + ast_debug(1, "ast_dsp_busydetect detected busy, avgtone: %d, avgsilence %d\n", avgtone, avgsilence); } #endif #endif @@ -1460,8 +1459,7 @@ struct ast_frame *ast_dsp_process(struct ast_channel *chan, struct ast_dsp *dsp, memset(&dsp->f, 0, sizeof(dsp->f)); dsp->f.frametype = AST_FRAME_CONTROL; dsp->f.subclass = AST_CONTROL_BUSY; - if (option_debug) - ast_log(LOG_DEBUG, "Requesting Hangup because the busy tone was detected on channel %s\n", chan->name); + ast_debug(1, "Requesting Hangup because the busy tone was detected on channel %s\n", chan->name); return &dsp->f; } if ((dsp->features & DSP_FEATURE_DTMF_DETECT)) { @@ -1646,8 +1644,7 @@ void ast_dsp_set_busy_pattern(struct ast_dsp *dsp, int tonelength, int quietleng { dsp->busy_tonelength = tonelength; dsp->busy_quietlength = quietlength; - if (option_debug) - ast_log(LOG_DEBUG, "dsp busy pattern set to %d,%d\n", tonelength, quietlength); + ast_debug(1, "dsp busy pattern set to %d,%d\n", tonelength, quietlength); } void ast_dsp_digitreset(struct ast_dsp *dsp) diff --git a/main/enum.c b/main/enum.c index a860dcb4c..a54506045 100644 --- a/main/enum.c +++ b/main/enum.c @@ -169,9 +169,8 @@ static int parse_naptr(char *dst, int dstsize, char *tech, int techsize, unsigne return -1; } - if (option_debug > 2) /* Advanced NAPTR debugging */ - ast_log(LOG_DEBUG, "NAPTR input='%s', flags='%s', services='%s', regexp='%s', repl='%s'\n", - naptrinput, flags, services, regexp, repl); + ast_debug(3, "NAPTR input='%s', flags='%s', services='%s', regexp='%s', repl='%s'\n", + naptrinput, flags, services, regexp, repl); if (tolower(flags[0]) != 'u') { ast_log(LOG_WARNING, "NAPTR Flag must be 'U' or 'u'.\n"); @@ -403,7 +402,7 @@ int ast_get_enum(struct ast_channel *chan, const char *number, char *dst, int ds } } - ast_log(LOG_DEBUG, "ast_get_enum(): n='%s', tech='%s', suffix='%s', options='%d', record='%d'\n", + ast_debug(1, "ast_get_enum(): n='%s', tech='%s', suffix='%s', options='%d', record='%d'\n", number, tech, suffix, context->options, context->position); if (pos > 128) @@ -450,7 +449,7 @@ int ast_get_enum(struct ast_channel *chan, const char *number, char *dst, int ds if (suffix) { ast_copy_string(tmp + newpos, suffix, sizeof(tmp) - newpos); ret = ast_search_dns(context, tmp, C_IN, T_NAPTR, enum_callback); - ast_log(LOG_DEBUG, "ast_get_enum: ast_search_dns(%s) returned %d\n", tmp, ret); + ast_debug(1, "ast_get_enum: ast_search_dns(%s) returned %d\n", tmp, ret); } else { ret = -1; /* this is actually dead code since the demise of app_enum.c */ for (;;) { @@ -469,15 +468,14 @@ int ast_get_enum(struct ast_channel *chan, const char *number, char *dst, int ds ast_copy_string(tmp + newpos, s->toplev, sizeof(tmp) - newpos); ret = ast_search_dns(&context, tmp, C_IN, T_NAPTR, enum_callback); - ast_log(LOG_DEBUG, "ast_get_enum: ast_search_dns(%s) returned %d\n", tmp, ret); + ast_debug(1, "ast_get_enum: ast_search_dns(%s) returned %d\n", tmp, ret); if (ret > 0) break; } } if (ret < 0) { - if (option_debug) - ast_log(LOG_DEBUG, "No such number found: %s (%s)\n", tmp, strerror(errno)); + ast_debug(1, "No such number found: %s (%s)\n", tmp, strerror(errno)); strcpy(dst, "0"); ret = 0; } @@ -589,8 +587,7 @@ int ast_get_txt(struct ast_channel *chan, const char *number, char *dst, int dst break; } if (ret < 0) { - if (option_debug > 1) - ast_log(LOG_DEBUG, "No such number found in ENUM: %s (%s)\n", tmp, strerror(errno)); + ast_debug(2, "No such number found in ENUM: %s (%s)\n", tmp, strerror(errno)); ret = 0; } if (chan) diff --git a/main/file.c b/main/file.c index f315bfcd2..cd5e2e435 100644 --- a/main/file.c +++ b/main/file.c @@ -155,8 +155,7 @@ int ast_writestream(struct ast_filestream *fs, struct ast_frame *f) if (!fs->vfs && fs->filename) { const char *type = ast_getformatname(f->subclass & ~0x1); fs->vfs = ast_writefile(fs->filename, type, NULL, fs->flags, 0, fs->mode); - if (option_debug) - ast_log(LOG_DEBUG, "Opened video output file\n"); + ast_debug(1, "Opened video output file\n"); } if (fs->vfs) return ast_writestream(fs->vfs, f); @@ -788,8 +787,7 @@ int ast_streamfile(struct ast_channel *chan, const char *filename, const char *p if (fs) vfs = ast_openvstream(chan, filename, preflang); if (vfs) { - if (option_debug) - ast_log(LOG_DEBUG, "Ooh, found a video stream, too, format %s\n", ast_getformatname(vfs->fmt->format)); + ast_debug(1, "Ooh, found a video stream, too, format %s\n", ast_getformatname(vfs->fmt->format)); } if (fs){ if (ast_applystream(chan, fs)) diff --git a/main/frame.c b/main/frame.c index 57a8b0b33..c5a9e82eb 100644 --- a/main/frame.c +++ b/main/frame.c @@ -1153,8 +1153,7 @@ int ast_codec_choose(struct ast_codec_pref *pref, int formats, int find_best) if (ret & AST_FORMAT_AUDIO_MASK) return ret; - if (option_debug > 3) - ast_log(LOG_DEBUG, "Could not find preferred codec - %s\n", find_best ? "Going for the best codec" : "Returning zero codec"); + ast_debug(4, "Could not find preferred codec - %s\n", find_best ? "Going for the best codec" : "Returning zero codec"); return find_best ? ast_best_codec(formats) : 0; } @@ -1170,8 +1169,7 @@ int ast_parse_allow_disallow(struct ast_codec_pref *pref, int *mask, const char framems = 0; if ((psize = strrchr(this, ':'))) { *psize++ = '\0'; - if (option_debug) - ast_log(LOG_DEBUG,"Packetization for codec: %s is %s\n", this, psize); + ast_debug(1, "Packetization for codec: %s is %s\n", this, psize); framems = atoi(psize); if (framems < 0) { framems = 0; |