diff options
author | mogorman <mogorman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-10-03 15:53:07 +0000 |
---|---|---|
committer | mogorman <mogorman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-10-03 15:53:07 +0000 |
commit | 4a1aaf52ae4189e660ad57ba69253f54603a2beb (patch) | |
tree | 27a80e26cf8f6ea1728ab5b2b8cc7573fd9f7cdc /main | |
parent | 1bd1494da59a95dce73628aafc4ba892036b82b2 (diff) |
bug #8076 check option_debug before printing to debug channel.
patch provided in bugnote, with minor changes.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@44253 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r-- | main/app.c | 42 | ||||
-rw-r--r-- | main/channel.c | 118 | ||||
-rw-r--r-- | main/db.c | 9 | ||||
-rw-r--r-- | main/dns.c | 4 | ||||
-rw-r--r-- | main/dsp.c | 13 | ||||
-rw-r--r-- | main/enum.c | 3 | ||||
-rw-r--r-- | main/file.c | 9 | ||||
-rw-r--r-- | main/http.c | 3 | ||||
-rw-r--r-- | main/loader.c | 3 | ||||
-rw-r--r-- | main/logger.c | 9 | ||||
-rw-r--r-- | main/manager.c | 18 | ||||
-rw-r--r-- | main/pbx.c | 33 | ||||
-rw-r--r-- | main/rtp.c | 36 | ||||
-rw-r--r-- | main/say.c | 92 | ||||
-rw-r--r-- | main/sched.c | 32 | ||||
-rw-r--r-- | main/udptl.c | 37 |
16 files changed, 298 insertions, 163 deletions
diff --git a/main/app.c b/main/app.c index b6a7f73a9..20620a62f 100644 --- a/main/app.c +++ b/main/app.c @@ -416,7 +416,8 @@ 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)) { - ast_log(LOG_DEBUG, "we'll restart the stream here at next loop\n"); + if (option_debug) + ast_log(LOG_DEBUG, "we'll restart the stream here at next loop\n"); pause_restart_point = 0; continue; } @@ -508,7 +509,8 @@ static int __ast_play_and_record(struct ast_channel *chan, const char *playfile, return -1; } - ast_log(LOG_DEBUG,"play_and_record: %s, %s, '%s'\n", playfile ? playfile : "<None>", recordfile, fmt); + if (option_debug) + ast_log(LOG_DEBUG,"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) { @@ -529,7 +531,8 @@ static int __ast_play_and_record(struct ast_channel *chan, const char *playfile, stringp = fmts; strsep(&stringp, "|"); - ast_log(LOG_DEBUG, "Recording Formats: sfmts=%s\n", fmts); + if (option_debug) + ast_log(LOG_DEBUG, "Recording Formats: sfmts=%s\n", fmts); sfmt[0] = ast_strdupa(fmts); while ((fmt = strsep(&stringp, "|"))) { @@ -584,7 +587,8 @@ static int __ast_play_and_record(struct ast_channel *chan, const char *playfile, for (;;) { res = ast_waitfor(chan, 2000); if (!res) { - ast_log(LOG_DEBUG, "One waitfor failed, trying another\n"); + if (option_debug) + ast_log(LOG_DEBUG, "One waitfor failed, trying another\n"); /* Try one more time in case of masq */ res = ast_waitfor(chan, 2000); if (!res) { @@ -931,7 +935,8 @@ 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 { - ast_log(LOG_DEBUG, "Locked path '%s'\n", path); + if (option_debug) + ast_log(LOG_DEBUG, "Locked path '%s'\n", path); return AST_LOCK_SUCCESS; } } @@ -950,8 +955,10 @@ 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 - ast_log(LOG_DEBUG, "Unlocked path '%s'\n", path); + else { + if (option_debug) + ast_log(LOG_DEBUG, "Unlocked path '%s'\n", path); + } return res; } @@ -1181,7 +1188,8 @@ 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); - ast_log(LOG_DEBUG, "IVR Dispatch of '%s' (pos %d) yields %d\n", exten, pos, res); + if (option_debug) + ast_log(LOG_DEBUG, "IVR Dispatch of '%s' (pos %d) yields %d\n", exten, pos, res); if (res < 0) break; else if (res & RES_UPONE) @@ -1197,7 +1205,8 @@ static int ast_ivr_menu_run_internal(struct ast_channel *chan, struct ast_ivr_me if (!maxretries) maxretries = 3; if ((maxretries > 0) && (retries >= maxretries)) { - ast_log(LOG_DEBUG, "Max retries %d exceeded\n", maxretries); + if (option_debug) + ast_log(LOG_DEBUG, "Max retries %d exceeded\n", maxretries); return -2; } else { if (option_exists(menu, "g") > -1) @@ -1208,24 +1217,28 @@ 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)) { - ast_log(LOG_DEBUG, "Got start of extension, %c\n", res); + if (option_debug) + ast_log(LOG_DEBUG, "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")) { - ast_log(LOG_DEBUG, "Invalid extension entered, going to 'i'!\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Invalid extension entered, going to 'i'!\n"); strcpy(exten, "i"); pos = 0; continue; } else { - ast_log(LOG_DEBUG, "Aborting on invalid entry, with no 'i' option!\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Aborting on invalid entry, with no 'i' option!\n"); res = -2; break; } } else { - ast_log(LOG_DEBUG, "New existing extension: %s\n", exten); + if (option_debug) + ast_log(LOG_DEBUG, "New existing extension: %s\n", exten); pos = 0; continue; } @@ -1233,7 +1246,8 @@ static int ast_ivr_menu_run_internal(struct ast_channel *chan, struct ast_ivr_me } pos++; } - ast_log(LOG_DEBUG, "Stopping option '%s', res is %d\n", exten, res); + if (option_debug) + ast_log(LOG_DEBUG, "Stopping option '%s', res is %d\n", exten, res); pos = 0; if (!strcasecmp(exten, "s")) strcpy(exten, "g"); diff --git a/main/channel.c b/main/channel.c index 6a5ecaef1..c1e3c0a58 100644 --- a/main/channel.c +++ b/main/channel.c @@ -745,7 +745,8 @@ 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 { - ast_log(LOG_DEBUG, "Dropping voice to exceptionally long queue on %s\n", chan->name); + if (option_debug) + ast_log(LOG_DEBUG, "Dropping voice to exceptionally long queue on %s\n", chan->name); ast_frfree(f); ast_channel_unlock(chan); return 0; @@ -881,8 +882,10 @@ static struct ast_channel *channel_find_locked(const struct ast_channel *prev, /* exit if chan not found or mutex acquired successfully */ /* this is slightly unsafe, as we _should_ hold the lock to access c->name */ done = c == NULL || ast_channel_trylock(c) == 0; - if (!done) - ast_log(LOG_DEBUG, "Avoiding %s for channel '%p'\n", msg, c); + if (!done) { + if (option_debug) + ast_log(LOG_DEBUG, "Avoiding %s for channel '%p'\n", msg, c); + } AST_LIST_UNLOCK(&channels); if (done) return c; @@ -892,8 +895,9 @@ static struct ast_channel *channel_find_locked(const struct ast_channel *prev, * c is surely not null, but we don't have the lock so cannot * access c->name */ - ast_log(LOG_DEBUG, "Failure, could not lock '%p' after %d retries!\n", - c, retries); + if (option_debug) + ast_log(LOG_DEBUG, "Failure, could not lock '%p' after %d retries!\n", + c, retries); return NULL; } @@ -1202,8 +1206,9 @@ int ast_channel_spy_add(struct ast_channel *chan, struct ast_channel_spy *spy) ast_clear_flag(spy, CHANSPY_TRIGGER_WRITE); } - ast_log(LOG_DEBUG, "Spy %s added to channel %s\n", - spy->type, chan->name); + if (option_debug) + ast_log(LOG_DEBUG, "Spy %s added to channel %s\n", + spy->type, chan->name); return 0; } @@ -1238,7 +1243,8 @@ 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) */ - ast_log(LOG_DEBUG, "Spy %s removed from channel %s\n", spy->type, chan->name); + if (option_debug) + ast_log(LOG_DEBUG, "Spy %s removed from channel %s\n", spy->type, chan->name); ast_mutex_unlock(&spy->lock); @@ -1383,8 +1389,9 @@ static void queue_frame_to_spies(struct ast_channel *chan, struct ast_frame *f, trans->path = NULL; } if (!trans->path) { - ast_log(LOG_DEBUG, "Building translator from %s to SLINEAR for spies on channel %s\n", - ast_getformatname(f->subclass), chan->name); + if (option_debug) + ast_log(LOG_DEBUG, "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", ast_getformatname(f->subclass), ast_getformatname(AST_FORMAT_SLINEAR)); @@ -1628,7 +1635,8 @@ static int generator_force(void *data) res = generate(chan, tmp, 0, 160); chan->generatordata = tmp; if (res) { - ast_log(LOG_DEBUG, "Auto-deactivating generator\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Auto-deactivating generator\n"); ast_deactivate_generator(chan); } return 0; @@ -1847,7 +1855,8 @@ int ast_settimeout(struct ast_channel *c, int samples, int (*func)(void *data), samples = 0; data = 0; } - ast_log(LOG_DEBUG, "Scheduling timer at %d sample intervals\n", samples); + if (option_debug) + ast_log(LOG_DEBUG, "Scheduling timer at %d sample intervals\n", samples); res = ioctl(c->timingfd, ZT_TIMERCONFIG, &samples); c->timingfunc = func; c->timingdata = data; @@ -2052,11 +2061,13 @@ 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)) { - ast_log(LOG_DEBUG, "Ignoring answer on an inbound call!\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Ignoring answer on an inbound call!\n"); ast_frfree(f); f = &ast_null_frame; } else if (prestate == AST_STATE_UP) { - ast_log(LOG_DEBUG, "Dropping duplicate answer!\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Dropping duplicate answer!\n"); ast_frfree(f); f = &ast_null_frame; } else { @@ -2266,7 +2277,8 @@ int ast_indicate_data(struct ast_channel *chan, int condition, const void *data, break; } if (ts && ts->data[0]) { - ast_log(LOG_DEBUG, "Driver for channel '%s' does not support indication %d, emulating it\n", chan->name, condition); + if (option_debug) + ast_log(LOG_DEBUG, "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) { @@ -2379,7 +2391,8 @@ int ast_senddigit_begin(struct ast_channel *chan, char digit) ast_playtones_start(chan, 0, dtmf_tones[15], 0); else { /* not handled */ - ast_log(LOG_DEBUG, "Unable to generate DTMF tone '%c' for '%s'\n", digit, chan->name); + if (option_debug) + ast_log(LOG_DEBUG, "Unable to generate DTMF tone '%c' for '%s'\n", digit, chan->name); } } @@ -2415,7 +2428,8 @@ int ast_prod(struct ast_channel *chan) /* Send an empty audio frame to get things moving */ if (chan->_state != AST_STATE_UP) { - ast_log(LOG_DEBUG, "Prodding channel '%s'\n", chan->name); + if (option_debug) + ast_log(LOG_DEBUG, "Prodding channel '%s'\n", chan->name); a.subclass = chan->rawwriteformat; a.data = nothing + AST_FRIENDLY_OFFSET; a.src = "ast_prod"; @@ -3066,8 +3080,9 @@ int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clo return -1; } - ast_log(LOG_DEBUG, "Planning to masquerade channel %s into the structure of %s\n", - clone->name, original->name); + if (option_debug) + ast_log(LOG_DEBUG, "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); @@ -3079,7 +3094,8 @@ 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); - ast_log(LOG_DEBUG, "Done planning to masquerade channel %s into the structure of %s\n", clone->name, original->name); + if (option_debug) + ast_log(LOG_DEBUG, "Done planning to masquerade channel %s into the structure of %s\n", clone->name, original->name); res = 0; } @@ -3438,7 +3454,8 @@ int ast_do_masquerade(struct ast_channel *original) ); ast_channel_free(clone); } else { - ast_log(LOG_DEBUG, "Released clone lock on '%s'\n", clone->name); + if (option_debug) + ast_log(LOG_DEBUG, "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); @@ -3625,7 +3642,8 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct if (!f) { *fo = NULL; *rc = who; - ast_log(LOG_DEBUG, "Didn't get a frame from channel: %s\n",who->name); + if (option_debug) + ast_log(LOG_DEBUG, "Didn't get a frame from channel: %s\n",who->name); break; } @@ -3647,7 +3665,8 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct *fo = f; *rc = who; bridge_exit = 1; - ast_log(LOG_DEBUG, "Got a FRAME_CONTROL (%d) frame on channel %s\n", f->subclass, who->name); + if (option_debug) + ast_log(LOG_DEBUG, "Got a FRAME_CONTROL (%d) frame on channel %s\n", f->subclass, who->name); break; } if (bridge_exit) @@ -3669,9 +3688,10 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct f->frametype == AST_FRAME_DTMF_BEGIN)) { *fo = f; *rc = who; - ast_log(LOG_DEBUG, "Got DTMF %s on channel (%s)\n", - f->frametype == AST_FRAME_DTMF_END ? "end" : "begin", - who->name); + if (option_debug) + ast_log(LOG_DEBUG, "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 */ @@ -3831,7 +3851,8 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha c1->_softhangup = 0; c0->_bridge = c1; c1->_bridge = c0; - ast_log(LOG_DEBUG, "Unbridge signal received. Ending native bridge.\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Unbridge signal received. Ending native bridge.\n"); continue; } @@ -3842,12 +3863,13 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha if (who) *rc = who; res = 0; - 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"); + 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"); break; } @@ -3870,7 +3892,8 @@ 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); - ast_log(LOG_DEBUG, "Returning from native bridge, channels: %s, %s\n", c0->name, c1->name); + if (option_debug) + ast_log(LOG_DEBUG, "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); @@ -3936,7 +3959,8 @@ 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); - ast_log(LOG_DEBUG, "Bridge stops bridging channels %s and %s\n", c0->name, c1->name); + if (option_debug) + ast_log(LOG_DEBUG, "Bridge stops bridging channels %s and %s\n", c0->name, c1->name); return res; } @@ -4461,7 +4485,8 @@ int ast_channel_unlock(struct ast_channel *chan) ast_log(LOG_DEBUG, "::::==== Unlocking AST channel %s\n", chan->name); if (!chan) { - ast_log(LOG_DEBUG, "::::==== Unlocking non-existing channel \n"); + if (option_debug) + ast_log(LOG_DEBUG, "::::==== Unlocking non-existing channel \n"); return 0; } @@ -4479,12 +4504,15 @@ int ast_channel_unlock(struct ast_channel *chan) #else if ((count = chan->lock.__data.__count)) #endif - ast_log(LOG_DEBUG, ":::=== Still have %d locks (recursive)\n", count); + if (option_debug) + ast_log(LOG_DEBUG, ":::=== Still have %d locks (recursive)\n", count); #endif if (!res) - ast_log(LOG_DEBUG, "::::==== Channel %s was unlocked\n", chan->name); + if (option_debug) + ast_log(LOG_DEBUG, "::::==== Channel %s was unlocked\n", chan->name); if (res == EINVAL) { - ast_log(LOG_DEBUG, "::::==== Channel %s had no lock by this thread. Failed unlocking\n", chan->name); + if (option_debug) + ast_log(LOG_DEBUG, "::::==== Channel %s had no lock by this thread. Failed unlocking\n", chan->name); } } if (res == EPERM) { @@ -4515,10 +4543,12 @@ int ast_channel_lock(struct ast_channel *chan) #else if ((count = chan->lock.__data.__count)) #endif - ast_log(LOG_DEBUG, ":::=== Now have %d locks (recursive)\n", count); + if (option_debug) + ast_log(LOG_DEBUG, ":::=== Now have %d locks (recursive)\n", count); #endif if (!res) - ast_log(LOG_DEBUG, "::::==== Channel %s was locked\n", chan->name); + if (option_debug) + ast_log(LOG_DEBUG, "::::==== Channel %s was locked\n", chan->name); if (res == EDEADLK) { /* We had no lock, so okey any way */ if (option_debug > 3) @@ -4551,10 +4581,12 @@ int ast_channel_trylock(struct ast_channel *chan) #else if ((count = chan->lock.__data.__count)) #endif - ast_log(LOG_DEBUG, ":::=== Now have %d locks (recursive)\n", count); + if (option_debug) + ast_log(LOG_DEBUG, ":::=== Now have %d locks (recursive)\n", count); #endif if (!res) - ast_log(LOG_DEBUG, "::::==== Channel %s was locked\n", chan->name); + if (option_debug) + ast_log(LOG_DEBUG, "::::==== Channel %s was locked\n", chan->name); if (res == EBUSY) { /* We failed to lock */ if (option_debug > 2) @@ -194,7 +194,8 @@ 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) { - ast_log(LOG_DEBUG, "Unable to find key '%s' in family '%s'\n", keys, family); + if (option_debug) + ast_log(LOG_DEBUG, "Unable to find key '%s' in family '%s'\n", keys, family); } else { #if 0 printf("Got value of size %d\n", data.size); @@ -233,8 +234,10 @@ int ast_db_del(const char *family, const char *keys) ast_mutex_unlock(&dblock); - if (res) - ast_log(LOG_DEBUG, "Unable to find key '%s' in family '%s'\n", keys, family); + if (res) { + if (option_debug) + ast_log(LOG_DEBUG, "Unable to find key '%s' in family '%s'\n", keys, family); + } return res; } diff --git a/main/dns.c b/main/dns.c index 3599de2c5..ff7dde745 100644 --- a/main/dns.c +++ b/main/dns.c @@ -44,6 +44,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/channel.h" #include "asterisk/dns.h" #include "asterisk/endian.h" +#include "asterisk/options.h" #define MAX_SIZE 4096 @@ -209,7 +210,8 @@ int ast_search_dns(void *context, ret = -1; } else if (ret == 0) { - ast_log(LOG_DEBUG, "No matches found in DNS for %s\n", dname); + if (option_debug) + ast_log(LOG_DEBUG, "No matches found in DNS for %s\n", dname); ret = 0; } else diff --git a/main/dsp.c b/main/dsp.c index 2992031b4..12ffaaf42 100644 --- a/main/dsp.c +++ b/main/dsp.c @@ -59,6 +59,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/ulaw.h" #include "asterisk/alaw.h" #include "asterisk/utils.h" +#include "asterisk/options.h" /*! Number of goertzels for progress detect */ enum gsamp_size { @@ -1335,8 +1336,10 @@ int ast_dsp_busydetect(struct ast_dsp *dsp) } #endif #if 1 - if (res) - ast_log(LOG_DEBUG, "ast_dsp_busydetect detected busy, avgtone: %d, avgsilence %d\n", avgtone, avgsilence); + if (res) { + if (option_debug) + ast_log(LOG_DEBUG, "ast_dsp_busydetect detected busy, avgtone: %d, avgsilence %d\n", avgtone, avgsilence); + } #endif return res; } @@ -1470,7 +1473,8 @@ 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; - ast_log(LOG_DEBUG, "Requesting Hangup because the busy tone was detected on channel %s\n", chan->name); + if (option_debug) + ast_log(LOG_DEBUG, "Requesting Hangup because the busy tone was detected on channel %s\n", chan->name); return &dsp->f; } if ((dsp->features & DSP_FEATURE_DTMF_DETECT)) { @@ -1655,7 +1659,8 @@ void ast_dsp_set_busy_pattern(struct ast_dsp *dsp, int tonelength, int quietleng { dsp->busy_tonelength = tonelength; dsp->busy_quietlength = quietlength; - ast_log(LOG_DEBUG, "dsp busy pattern set to %d,%d\n", tonelength, quietlength); + if (option_debug) + ast_log(LOG_DEBUG, "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 fff932f2f..a9392019d 100644 --- a/main/enum.c +++ b/main/enum.c @@ -486,7 +486,8 @@ int ast_get_enum(struct ast_channel *chan, const char *number, char *dst, int ds break; } if (ret < 0) { - ast_log(LOG_DEBUG, "No such number found: %s (%s)\n", tmp, strerror(errno)); + if (option_debug) + ast_log(LOG_DEBUG, "No such number found: %s (%s)\n", tmp, strerror(errno)); strcpy(dst, "0"); ret = 0; } diff --git a/main/file.c b/main/file.c index f8ca9afeb..412bb0f3f 100644 --- a/main/file.c +++ b/main/file.c @@ -156,7 +156,8 @@ 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); - ast_log(LOG_DEBUG, "Opened video output file\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Opened video output file\n"); } if (fs->vfs) return ast_writestream(fs->vfs, f); @@ -785,8 +786,10 @@ int ast_streamfile(struct ast_channel *chan, const char *filename, const char *p fs = ast_openstream(chan, filename, preflang); if (fs) vfs = ast_openvstream(chan, filename, preflang); - if (vfs) - ast_log(LOG_DEBUG, "Ooh, found a video stream, too, format %s\n", ast_getformatname(vfs->fmt->format)); + if (vfs) { + if (option_debug) + ast_log(LOG_DEBUG, "Ooh, found a video stream, too, format %s\n", ast_getformatname(vfs->fmt->format)); + } if (fs){ if (ast_applystream(chan, fs)) return -1; diff --git a/main/http.c b/main/http.c index a59d7a58b..a1cd73a91 100644 --- a/main/http.c +++ b/main/http.c @@ -544,7 +544,8 @@ static void http_server_start(struct sockaddr_in *sin) /* Do nothing if nothing has changed */ if (!memcmp(&oldsin, sin, sizeof(oldsin))) { - ast_log(LOG_DEBUG, "Nothing changed in http\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Nothing changed in http\n"); return; } diff --git a/main/loader.c b/main/loader.c index 23aec019a..8b149f2d7 100644 --- a/main/loader.c +++ b/main/loader.c @@ -250,7 +250,8 @@ static int printdigest(const unsigned char *d) for (pos = 0, x = 0; x < 16; x++) pos += sprintf(buf + pos, " %02x", *d++); - ast_log(LOG_DEBUG, "Unexpected signature:%s\n", buf); + if (option_debug) + ast_log(LOG_DEBUG, "Unexpected signature:%s\n", buf); return 0; } diff --git a/main/logger.c b/main/logger.c index 29c4cf48b..a8e5c3700 100644 --- a/main/logger.c +++ b/main/logger.c @@ -840,13 +840,16 @@ void ast_backtrace(void) if ((addresses = ast_calloc(MAX_BACKTRACE_FRAMES, sizeof(*addresses)))) { count = backtrace(addresses, MAX_BACKTRACE_FRAMES); if ((strings = backtrace_symbols(addresses, count))) { - ast_log(LOG_DEBUG, "Got %d backtrace record%c\n", count, count != 1 ? 's' : ' '); + if (option_debug) + ast_log(LOG_DEBUG, "Got %d backtrace record%c\n", count, count != 1 ? 's' : ' '); for (i=0; i < count ; i++) { - ast_log(LOG_DEBUG, "#%d: [%08X] %s\n", i, (unsigned int)addresses[i], strings[i]); + if (option_debug) + ast_log(LOG_DEBUG, "#%d: [%08X] %s\n", i, (unsigned int)addresses[i], strings[i]); } free(strings); } else { - ast_log(LOG_DEBUG, "Could not allocate memory for backtrace\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Could not allocate memory for backtrace\n"); } free(addresses); } diff --git a/main/manager.c b/main/manager.c index 674ae30ec..8e368bf0b 100644 --- a/main/manager.c +++ b/main/manager.c @@ -1193,7 +1193,8 @@ static int action_waitevent(struct mansession *s, struct message *m) "\r\n", idText); s->waiting_thread = AST_PTHREADT_NULL; } else { - ast_log(LOG_DEBUG, "Abandoning event request!\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Abandoning event request!\n"); } ast_mutex_unlock(&s->__lock); return 0; @@ -1906,7 +1907,8 @@ static int process_message(struct mansession *s, struct message *m) int ret = 0; ast_copy_string(action, astman_get_header(m, "Action"), sizeof(action)); - ast_log( LOG_DEBUG, "Manager received command '%s'\n", action ); + if (option_debug) + ast_log(LOG_DEBUG, "Manager received command '%s'\n", action); if (ast_strlen_zero(action)) { astman_send_error(s, m, "Missing action in request"); @@ -2498,10 +2500,12 @@ static char *generic_http_callback(int format, struct sockaddr_in *requestor, co ast_mutex_lock(&s->__lock); if (s->needdestroy) { if (s->inuse == 1) { - ast_log(LOG_DEBUG, "Need destroy, doing it now!\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Need destroy, doing it now!\n"); blastaway = 1; } else { - ast_log(LOG_DEBUG, "Need destroy, but can't do it yet!\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Need destroy, but can't do it yet!\n"); if (s->waiting_thread != AST_PTHREADT_NULL) pthread_kill(s->waiting_thread, SIGURG); s->inuse--; @@ -2700,8 +2704,10 @@ int init_manager(void) user->write = ast_strdup(var->value); } else if (!strcasecmp(var->name, "displayconnects") ) user->displayconnects = ast_true(var->value); - else - ast_log(LOG_DEBUG, "%s is an unknown option.\n", var->name); + else { + if (option_debug) + ast_log(LOG_DEBUG, "%s is an unknown option.\n", var->name); + } var = var->next; } } diff --git a/main/pbx.c b/main/pbx.c index 6f6127d4a..d3fb389da 100644 --- a/main/pbx.c +++ b/main/pbx.c @@ -1529,8 +1529,8 @@ static void pbx_substitute_variables_helper_full(struct ast_channel *c, struct v if (isfunction) { /* Evaluate function */ cp4 = ast_func_read(c, vars, workspace, VAR_BUF_SIZE) ? NULL : workspace; - - ast_log(LOG_DEBUG, "Function result is '%s'\n", cp4 ? cp4 : "(null)"); + if (option_debug) + ast_log(LOG_DEBUG, "Function result is '%s'\n", cp4 ? cp4 : "(null)"); } else { /* Retrieve variable value */ pbx_retrieve_variable(c, vars, &cp4, workspace, VAR_BUF_SIZE, headp); @@ -1597,7 +1597,8 @@ static void pbx_substitute_variables_helper_full(struct ast_channel *c, struct v length = ast_expr(vars, cp2, count); if (length) { - ast_log(LOG_DEBUG, "Expression result is '%s'\n", cp2); + if (option_debug) + ast_log(LOG_DEBUG, "Expression result is '%s'\n", cp2); count -= length; cp2 += length; } @@ -1678,7 +1679,8 @@ static int pbx_extension_helper(struct ast_channel *c, struct ast_context *con, if (option_debug) { char atmp[80]; char atmp2[EXT_DATA_SIZE+100]; - ast_log(LOG_DEBUG, "Launching '%s'\n", app->name); + if (option_debug) + ast_log(LOG_DEBUG, "Launching '%s'\n", app->name); snprintf(atmp, sizeof(atmp), "STACK-%s-%s-%d", context, exten, priority); snprintf(atmp2, sizeof(atmp2), "%s(\"%s\", \"%s\") %s", app->name, c->name, passdata, "in new stack"); @@ -1735,7 +1737,8 @@ static int pbx_extension_helper(struct ast_channel *c, struct ast_context *con, ast_log(LOG_NOTICE, "No such label '%s' in extension '%s' in context '%s'\n", label, exten, context); break; default: - ast_log(LOG_DEBUG, "Shouldn't happen!\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Shouldn't happen!\n"); } return (matching_action) ? 0 : -1; @@ -2259,7 +2262,8 @@ static int __ast_pbx_run(struct ast_channel *c) if ((res = ast_spawn_extension(c, c->context, c->exten, c->priority, c->cid.cid_num))) { /* Something bad happened, or a hangup has been requested. */ if (strchr("0123456789ABCDEF*#", res)) { - ast_log(LOG_DEBUG, "Oooh, got something to jump out with ('%c')!\n", res); + if (option_debug) + ast_log(LOG_DEBUG, "Oooh, got something to jump out with ('%c')!\n", res); pos = 0; dst_exten[pos++] = digit = res; dst_exten[pos] = '\0'; @@ -2294,8 +2298,9 @@ static int __ast_pbx_run(struct ast_channel *c) c->whentohangup = 0; c->_softhangup &= ~AST_SOFTHANGUP_TIMEOUT; } else if (c->_softhangup) { - ast_log(LOG_DEBUG, "Extension %s, priority %d returned normally even though call was hung up\n", - c->exten, c->priority); + if (option_debug) + ast_log(LOG_DEBUG, "Extension %s, priority %d returned normally even though call was hung up\n", + c->exten, c->priority); error = 1; break; } @@ -3623,7 +3628,8 @@ void ast_merge_contexts_and_delete(struct ast_context **extcontexts, const char tmp = *extcontexts; if (registrar) { /* XXX remove previous contexts from same registrar */ - ast_log(LOG_DEBUG, "must remove any reg %s\n", registrar); + if (option_debug) + ast_log(LOG_DEBUG, "must remove any reg %s\n", registrar); __ast_context_destroy(NULL,registrar); while (tmp) { lasttmp = tmp; @@ -4959,7 +4965,8 @@ void __ast_context_destroy(struct ast_context *con, const char *registrar) for (tmp = contexts; tmp; ) { struct ast_context *next; /* next starting point */ for (; tmp; tmpl = tmp, tmp = tmp->next) { - ast_log(LOG_DEBUG, "check ctx %s %s\n", tmp->name, tmp->registrar); + if (option_debug) + ast_log(LOG_DEBUG, "check ctx %s %s\n", tmp->name, tmp->registrar); if ( (!registrar || !strcasecmp(registrar, tmp->registrar)) && (!con || !strcasecmp(tmp->name, con->name)) ) break; /* found it */ @@ -4967,7 +4974,8 @@ void __ast_context_destroy(struct ast_context *con, const char *registrar) if (!tmp) /* not found, we are done */ break; ast_mutex_lock(&tmp->lock); - ast_log(LOG_DEBUG, "delete ctx %s %s\n", tmp->name, tmp->registrar); + if (option_debug) + ast_log(LOG_DEBUG, "delete ctx %s %s\n", tmp->name, tmp->registrar); next = tmp->next; if (tmpl) tmpl->next = next; @@ -5639,7 +5647,8 @@ static int pbx_builtin_gotoif(struct ast_channel *chan, void *data) branch = pbx_checkcondition(condition) ? branch1 : branch2; if (ast_strlen_zero(branch)) { - ast_log(LOG_DEBUG, "Not taking any branch\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Not taking any branch\n"); return 0; } diff --git a/main/rtp.c b/main/rtp.c index c93887581..e45f5bc27 100644 --- a/main/rtp.c +++ b/main/rtp.c @@ -1019,12 +1019,18 @@ static int bridge_p2p_rtcp_write(struct ast_rtp *rtp, unsigned int *rtcpheader, /* Send the data out */ res = sendto(bridged->rtcp->s, (void *)rtcpheader, len, 0, (struct sockaddr *)&bridged->rtcp->them, sizeof(bridged->rtcp->them)); if (res < 0) { - if (!bridged->nat || (bridged->nat && (ast_test_flag(bridged, FLAG_NAT_ACTIVE) == FLAG_NAT_ACTIVE))) - ast_log(LOG_DEBUG, "RTCP Transmission error of packet to %s:%d: %s\n", ast_inet_ntoa(bridged->rtcp->them.sin_addr), ntohs(bridged->rtcp->them.sin_port), strerror(errno)); - else if ((((ast_test_flag(bridged, FLAG_NAT_ACTIVE) == FLAG_NAT_INACTIVE) || rtpdebug)) && (option_debug || rtpdebug)) - ast_log(LOG_DEBUG, "RTCP NAT: Can't write RTCP to private address %s:%d, waiting for other end to send first...\n", ast_inet_ntoa(bridged->rtcp->them.sin_addr), ntohs(bridged->rtcp->them.sin_port)); - } else if (rtp_debug_test_addr(&bridged->rtcp->them)) - ast_verbose("Sent RTCP P2P packet to %s:%d (len %-6.6u)\n", ast_inet_ntoa(bridged->rtcp->them.sin_addr), ntohs(bridged->rtcp->them.sin_port), len); + if (!bridged->nat || (bridged->nat && (ast_test_flag(bridged, FLAG_NAT_ACTIVE) == FLAG_NAT_ACTIVE))) { + if (option_debug) + ast_log(LOG_DEBUG, "RTCP Transmission error of packet to %s:%d: %s\n", ast_inet_ntoa(bridged->rtcp->them.sin_addr), ntohs(bridged->rtcp->them.sin_port), strerror(errno)); + } + else if ((((ast_test_flag(bridged, FLAG_NAT_ACTIVE) == FLAG_NAT_INACTIVE) || rtpdebug)) && (option_debug || rtpdebug)) { + if (option_debug) + ast_log(LOG_DEBUG, "RTCP NAT: Can't write RTCP to private address %s:%d, waiting for other end to send first...\n", ast_inet_ntoa(bridged->rtcp->them.sin_addr), ntohs(bridged->rtcp->them.sin_port)); + } + } else if (rtp_debug_test_addr(&bridged->rtcp->them)) { + if (option_verbose) + ast_verbose("Sent RTCP P2P packet to %s:%d (len %-6.6u)\n", ast_inet_ntoa(bridged->rtcp->them.sin_addr), ntohs(bridged->rtcp->them.sin_port), len); + } return 0; } @@ -1069,7 +1075,8 @@ static int bridge_p2p_rtp_write(struct ast_rtp *rtp, unsigned int *rtpheader, in res = sendto(bridged->s, (void *)rtpheader, len, 0, (struct sockaddr *)&bridged->them, sizeof(bridged->them)); if (res < 0) { if (!bridged->nat || (bridged->nat && (ast_test_flag(bridged, FLAG_NAT_ACTIVE) == FLAG_NAT_ACTIVE))) { - ast_log(LOG_DEBUG, "RTP Transmission error of packet to %s:%d: %s\n", ast_inet_ntoa(bridged->them.sin_addr), ntohs(bridged->them.sin_port), strerror(errno)); + if (option_debug) + ast_log(LOG_DEBUG, "RTP Transmission error of packet to %s:%d: %s\n", ast_inet_ntoa(bridged->them.sin_addr), ntohs(bridged->them.sin_port), strerror(errno)); } else if (((ast_test_flag(bridged, FLAG_NAT_ACTIVE) == FLAG_NAT_INACTIVE) || rtpdebug) && !ast_test_flag(bridged, FLAG_NAT_INACTIVE_NOWARN)) { if (option_debug || rtpdebug) ast_log(LOG_DEBUG, "RTP NAT: Can't write RTP to private address %s:%d, waiting for other end to send audio...\n", ast_inet_ntoa(bridged->them.sin_addr), ntohs(bridged->them.sin_port)); @@ -2517,7 +2524,8 @@ static int ast_rtp_raw_write(struct ast_rtp *rtp, struct ast_frame *f, int codec res = sendto(rtp->s, (void *)rtpheader, f->datalen + hdrlen, 0, (struct sockaddr *)&rtp->them, sizeof(rtp->them)); if (res <0) { if (!rtp->nat || (rtp->nat && (ast_test_flag(rtp, FLAG_NAT_ACTIVE) == FLAG_NAT_ACTIVE))) { - ast_log(LOG_DEBUG, "RTP Transmission error of packet %d to %s:%d: %s\n", rtp->seqno, ast_inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port), strerror(errno)); + if (option_debug) + ast_log(LOG_DEBUG, "RTP Transmission error of packet %d to %s:%d: %s\n", rtp->seqno, ast_inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port), strerror(errno)); } else if (((ast_test_flag(rtp, FLAG_NAT_ACTIVE) == FLAG_NAT_INACTIVE) || rtpdebug) && !ast_test_flag(rtp, FLAG_NAT_INACTIVE_NOWARN)) { /* Only give this error message once if we are not RTP debugging */ if (option_debug || rtpdebug) @@ -2715,7 +2723,8 @@ static enum ast_bridge_result bridge_native_loop(struct ast_channel *c0, struct if ((c0->tech_pvt != pvt0) || (c1->tech_pvt != pvt1) || (c0->masq || c0->masqr || c1->masq || c1->masqr)) { - ast_log(LOG_DEBUG, "Oooh, something is weird, backing out\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Oooh, something is weird, backing out\n"); if (c0->tech_pvt == pvt0) if (pr0->set_rtp_peer(c0, NULL, NULL, 0, 0)) ast_log(LOG_WARNING, "Channel '%s' failed to break RTP bridge\n", c0->name); @@ -2806,7 +2815,8 @@ static enum ast_bridge_result bridge_native_loop(struct ast_channel *c0, struct } else { *fo = fr; *rc = who; - ast_log(LOG_DEBUG, "Got a FRAME_CONTROL (%d) frame on channel %s\n", fr->subclass, who->name); + if (option_debug) + ast_log(LOG_DEBUG, "Got a FRAME_CONTROL (%d) frame on channel %s\n", fr->subclass, who->name); return AST_BRIDGE_COMPLETE; } } else { @@ -2967,7 +2977,8 @@ static enum ast_bridge_result bridge_p2p_loop(struct ast_channel *c0, struct ast if ((c0->tech_pvt != pvt0) || (c1->tech_pvt != pvt1) || (c0->masq || c0->masqr || c1->masq || c1->masqr)) { - ast_log(LOG_DEBUG, "Oooh, something is weird, backing out\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Oooh, something is weird, backing out\n"); res = AST_BRIDGE_RETRY; break; } @@ -3033,7 +3044,8 @@ static enum ast_bridge_result bridge_p2p_loop(struct ast_channel *c0, struct ast } else { *fo = fr; *rc = who; - ast_log(LOG_DEBUG, "Got a FRAME_CONTROL (%d) frame on channel %s\n", fr->subclass, who->name); + if (option_debug) + ast_log(LOG_DEBUG, "Got a FRAME_CONTROL (%d) frame on channel %s\n", fr->subclass, who->name); res = AST_BRIDGE_COMPLETE; break; } diff --git a/main/say.c b/main/say.c index 623a3425d..45f67dc9e 100644 --- a/main/say.c +++ b/main/say.c @@ -476,7 +476,8 @@ static int ast_say_number_full_en(struct ast_channel *chan, int num, const char num = num % 1000000; snprintf(fn, sizeof(fn), "digits/million"); } else { - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + if (option_debug) + ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); res = -1; } } @@ -705,7 +706,8 @@ static int ast_say_number_full_da(struct ast_channel *chan, int num, const char snprintf(fn, sizeof(fn), "digits/millions"); num = num % 1000000; } else { - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + if (option_debug) + ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); res = -1; } } @@ -840,7 +842,8 @@ static int ast_say_number_full_de(struct ast_channel *chan, int num, const char snprintf(fn, sizeof(fn), "digits/milliards"); } } else { - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + if (option_debug) + ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); res = -1; } if (!res) { @@ -925,7 +928,8 @@ static int ast_say_number_full_en_GB(struct ast_channel *chan, int num, const ch if (num && num < 100) playa++; } else { - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + if (option_debug) + ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); res = -1; } @@ -1026,7 +1030,8 @@ static int ast_say_number_full_es(struct ast_channel *chan, int num, const char } num = num % 1000000; } else { - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + if (option_debug) + ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); res = -1; } } @@ -1122,7 +1127,8 @@ static int ast_say_number_full_fr(struct ast_channel *chan, int num, const char snprintf(fn, sizeof(fn), "digits/million"); num = num % 1000000; } else { - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + if (option_debug) + ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); res = -1; } if (!res) { @@ -1268,7 +1274,8 @@ static int ast_say_number_full_he(struct ast_channel *chan, int num, snprintf(fn, sizeof(fn), "digits/million"); num = num % 1000000; } else { - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + if (option_debug) + ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); res = -1; } if (!res) { @@ -1418,7 +1425,8 @@ static int ast_say_number_full_it(struct ast_channel *chan, int num, const char else snprintf(fn, sizeof(fn), "digits/millions"); } else { - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + if (option_debug) + ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); res = -1; } } @@ -1494,7 +1502,8 @@ static int ast_say_number_full_nl(struct ast_channel *chan, int num, const char num = num % 1000000; snprintf(fn, sizeof(fn), "digits/million"); } else { - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + if (option_debug) + ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); res = -1; } } @@ -1589,7 +1598,8 @@ static int ast_say_number_full_no(struct ast_channel *chan, int num, const char if (num && num < 100) playa++; } else { - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + if (option_debug) + ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); res = -1; } @@ -1640,7 +1650,8 @@ static void pl_odtworz_plik(struct ast_channel *chan, const char *language, int { char file_name[255] = "digits/"; strcat(file_name, fn); - ast_log(LOG_DEBUG, "Trying to play: %s\n", file_name); + if (option_debug) + ast_log(LOG_DEBUG, "Trying to play: %s\n", file_name); if (!ast_streamfile(chan, file_name, language)) { if ((audiofd > -1) && (ctrlfd > -1)) ast_waitstream_full(chan, ints, audiofd, ctrlfd); @@ -2049,7 +2060,8 @@ static int ast_say_number_full_se(struct ast_channel *chan, int num, const char num = num % 1000000; snprintf(fn, sizeof(fn), "digits/million"); } else { - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + if (option_debug) + ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); res = -1; } } @@ -2114,7 +2126,8 @@ static int ast_say_number_full_tw(struct ast_channel *chan, int num, const char num = num % 1000000; snprintf(fn, sizeof(fn), "digits/million"); } else { - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + if (option_debug) + ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); res = -1; } } @@ -2223,8 +2236,9 @@ static int ast_say_number_full_ru(struct ast_channel *chan, int num, const char } num %= 1000000; } else { - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); - res = -1; + if (option_debug) + ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + res = -1; } if (!res) { if (!ast_streamfile(chan, fn, language)) { @@ -2337,7 +2351,8 @@ static int ast_say_enumeration_full_en(struct ast_channel *chan, int num, const snprintf(fn, sizeof(fn), "digits/h-last"); num = 0; } else { - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + if (option_debug) + ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); res = -1; } @@ -2490,7 +2505,8 @@ static int ast_say_enumeration_full_da(struct ast_channel *chan, int num, const snprintf(fn, sizeof(fn), "digits/h-last%s", gender); num = 0; } else { - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + if (option_debug) + ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); res = -1; } @@ -2653,7 +2669,8 @@ static int ast_say_enumeration_full_de(struct ast_channel *chan, int num, const snprintf(fn, sizeof(fn), "digits/h-last%s", gender); num = 0; } else { - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + if (option_debug) + ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); res = -1; } @@ -2955,7 +2972,8 @@ int ast_say_date_with_format_en(struct ast_channel *chan, time_t time, const cha ast_localtime(&time,&tm,timezone); for (offset=0 ; format[offset] != '\0' ; offset++) { - ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); + if (option_debug) + ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); switch (format[offset]) { /* NOTE: if you add more options here, please try to be consistent with strftime(3) */ case '\'': @@ -3197,7 +3215,8 @@ int ast_say_date_with_format_da(struct ast_channel *chan, time_t time, const cha ast_localtime(&time,&tm,timezone); for (offset=0 ; format[offset] != '\0' ; offset++) { - ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); + if (option_debug) + ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); switch (format[offset]) { /* NOTE: if you add more options here, please try to be consistent with strftime(3) */ case '\'': @@ -3402,7 +3421,8 @@ int ast_say_date_with_format_de(struct ast_channel *chan, time_t time, const cha ast_localtime(&time,&tm,timezone); for (offset=0 ; format[offset] != '\0' ; offset++) { - ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); + if (option_debug) + ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); switch (format[offset]) { /* NOTE: if you add more options here, please try to be consistent with strftime(3) */ case '\'': @@ -3632,7 +3652,8 @@ int ast_say_date_with_format_he(struct ast_channel *chan, time_t time, ast_localtime(&time,&tm,timezone); for (offset=0 ; format[offset] != '\0' ; offset++) { - ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); + if (option_debug) + ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); switch (format[offset]) { /* NOTE: if you add more options here, please try to be consistent with strftime(3) */ case '\'': @@ -3814,7 +3835,8 @@ int ast_say_date_with_format_es(struct ast_channel *chan, time_t time, const cha ast_localtime(&time,&tm,timezone); for (offset=0 ; format[offset] != '\0' ; offset++) { - ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); + if (option_debug) + ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); switch (format[offset]) { /* NOTE: if you add more options here, please try to be consistent with strftime(3) */ case '\'': @@ -4006,7 +4028,8 @@ int ast_say_date_with_format_fr(struct ast_channel *chan, time_t time, const cha ast_localtime(&time,&tm,timezone); for (offset=0 ; format[offset] != '\0' ; offset++) { - ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); + if (option_debug) + ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); switch (format[offset]) { /* NOTE: if you add more options here, please try to be consistent with strftime(3) */ case '\'': @@ -4204,7 +4227,8 @@ int ast_say_date_with_format_it(struct ast_channel *chan, time_t time, const cha ast_localtime(&time,&tm,timezone); for (offset=0 ; format[offset] != '\0' ; offset++) { - ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); + if (option_debug) + ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); switch (format[offset]) { /* NOTE: if you add more options here, please try to be consistent with strftime(3) */ case '\'': @@ -4437,7 +4461,8 @@ int ast_say_date_with_format_nl(struct ast_channel *chan, time_t time, const cha ast_localtime(&time,&tm,timezone); for (offset=0 ; format[offset] != '\0' ; offset++) { - ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); + if (option_debug) + ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); switch (format[offset]) { /* NOTE: if you add more options here, please try to be consistent with strftime(3) */ case '\'': @@ -4668,7 +4693,8 @@ int ast_say_date_with_format_pl(struct ast_channel *chan, time_t thetime, const for (offset = 0 ; format[offset] != '\0' ; offset++) { int remainder; - ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); + if (option_debug) + ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); switch (format[offset]) { /* NOTE: if you add more options here, please try to be consistent with strftime(3) */ case '\'': @@ -4886,7 +4912,8 @@ int ast_say_date_with_format_pt(struct ast_channel *chan, time_t time, const cha ast_localtime(&time,&tm,timezone); for (offset=0 ; format[offset] != '\0' ; offset++) { - ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); + if (option_debug) + ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); switch (format[offset]) { /* NOTE: if you add more options here, please try to be consistent with strftime(3) */ case '\'': @@ -5109,7 +5136,8 @@ int ast_say_date_with_format_tw(struct ast_channel *chan, time_t time, const cha ast_localtime(&time,&tm,timezone); for (offset=0 ; format[offset] != '\0' ; offset++) { - ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); + if (option_debug) + ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); switch (format[offset]) { /* NOTE: if you add more options here, please try to be consistent with strftime(3) */ case '\'': @@ -6076,7 +6104,8 @@ static int ast_say_number_full_gr(struct ast_channel *chan, int num, const char num = num % 1000000; snprintf(fn, sizeof(fn), "digits/millions"); } else { - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + if (option_debug) + ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); res = -1; } } @@ -6240,7 +6269,8 @@ static int ast_say_date_with_format_gr(struct ast_channel *chan, time_t time, co ast_localtime(&time,&tm,timezone); for (offset=0 ; format[offset] != '\0' ; offset++) { - ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); + if (option_debug) + ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format); switch (format[offset]) { /* NOTE: if you add more options here, please try to be consistent with strftime(3) */ case '\'': diff --git a/main/sched.c b/main/sched.c index 30b0af243..5fc0ef9ed 100644 --- a/main/sched.c +++ b/main/sched.c @@ -201,7 +201,8 @@ static int sched_settime(struct timeval *tv, int when) *tv = now; *tv = ast_tvadd(*tv, ast_samp2tv(when, 1000)); if (ast_tvcmp(*tv, now) < 0) { - ast_log(LOG_DEBUG, "Request to schedule in the past?!?!\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Request to schedule in the past?!?!\n"); *tv = now; } return 0; @@ -296,26 +297,29 @@ void ast_sched_dump(const struct sched_context *con) struct sched *q; struct timeval tv = ast_tvnow(); #ifdef SCHED_MAX_CACHE - ast_log(LOG_DEBUG, "Asterisk Schedule Dump (%d in Q, %d Total, %d Cache)\n", con->schedcnt, con->eventcnt - 1, con->schedccnt); + if (option_debug) + ast_log(LOG_DEBUG, "Asterisk Schedule Dump (%d in Q, %d Total, %d Cache)\n", con->schedcnt, con->eventcnt - 1, con->schedccnt); #else - ast_log(LOG_DEBUG, "Asterisk Schedule Dump (%d in Q, %d Total)\n", con->schedcnt, con->eventcnt - 1); + if (option_debug) + ast_log(LOG_DEBUG, "Asterisk Schedule Dump (%d in Q, %d Total)\n", con->schedcnt, con->eventcnt - 1); #endif + if (option_debug) { ast_log(LOG_DEBUG, "=============================================================\n"); ast_log(LOG_DEBUG, "|ID Callback Data Time (sec:ms) |\n"); ast_log(LOG_DEBUG, "+-----+-----------------+-----------------+-----------------+\n"); - AST_LIST_TRAVERSE(&con->schedq, q, list) { - struct timeval delta = ast_tvsub(q->when, tv); - - ast_log(LOG_DEBUG, "|%.4d | %-15p | %-15p | %.6ld : %.6ld |\n", - q->id, - q->callback, - q->data, - delta.tv_sec, - (long int)delta.tv_usec); + AST_LIST_TRAVERSE(&con->schedq, q, list) { + struct timeval delta = ast_tvsub(q->when, tv); + + ast_log(LOG_DEBUG, "|%.4d | %-15p | %-15p | %.6ld : %.6ld |\n", + q->id, + q->callback, + q->data, + delta.tv_sec, + (long int)delta.tv_usec); + } + ast_log(LOG_DEBUG, "=============================================================\n"); } - ast_log(LOG_DEBUG, "=============================================================\n"); - } /*! \brief diff --git a/main/udptl.c b/main/udptl.c index 72f316f7e..1e0e518cc 100644 --- a/main/udptl.c +++ b/main/udptl.c @@ -664,13 +664,15 @@ struct ast_frame *ast_udptl_read(struct ast_udptl *udptl) if ((udptl->them.sin_addr.s_addr != sin.sin_addr.s_addr) || (udptl->them.sin_port != sin.sin_port)) { memcpy(&udptl->them, &sin, sizeof(udptl->them)); - ast_log(LOG_DEBUG, "UDPTL NAT: Using address %s:%d\n", ast_inet_ntoa(udptl->them.sin_addr), ntohs(udptl->them.sin_port)); + if (option_debug) + ast_log(LOG_DEBUG, "UDPTL NAT: Using address %s:%d\n", ast_inet_ntoa(udptl->them.sin_addr), ntohs(udptl->them.sin_port)); } } if (udptl_debug_test_addr(&sin)) { - ast_verbose("Got UDPTL packet from %s:%d (type %d, seq %d, len %d)\n", - ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), 0, seqno, res); + if (option_verbose) + ast_verbose("Got UDPTL packet from %s:%d (type %d, seq %d, len %d)\n", + ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), 0, seqno, res); } #if 0 printf("Got UDPTL packet from %s:%d (seq %d, len = %d)\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), seqno, res); @@ -1035,7 +1037,8 @@ int ast_udptl_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, if ((c0->tech_pvt != pvt0) || (c1->tech_pvt != pvt1) || (c0->masq || c0->masqr || c1->masq || c1->masqr)) { - ast_log(LOG_DEBUG, "Oooh, something is weird, backing out\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Oooh, something is weird, backing out\n"); /* Tell it to try again later */ return -3; } @@ -1043,22 +1046,27 @@ int ast_udptl_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, ast_udptl_get_peer(p1, &t1); ast_udptl_get_peer(p0, &t0); if (inaddrcmp(&t1, &ac1)) { - ast_log(LOG_DEBUG, "Oooh, '%s' changed end address to %s:%d\n", - c1->name, ast_inet_ntoa(t1.sin_addr), ntohs(t1.sin_port)); - ast_log(LOG_DEBUG, "Oooh, '%s' was %s:%d\n", - c1->name, ast_inet_ntoa(ac1.sin_addr), ntohs(ac1.sin_port)); + if (option_debug) { + ast_log(LOG_DEBUG, "Oooh, '%s' changed end address to %s:%d\n", + c1->name, ast_inet_ntoa(t1.sin_addr), ntohs(t1.sin_port)); + ast_log(LOG_DEBUG, "Oooh, '%s' was %s:%d\n", + c1->name, ast_inet_ntoa(ac1.sin_addr), ntohs(ac1.sin_port)); + } memcpy(&ac1, &t1, sizeof(ac1)); } if (inaddrcmp(&t0, &ac0)) { - ast_log(LOG_DEBUG, "Oooh, '%s' changed end address to %s:%d\n", - c0->name, ast_inet_ntoa(t0.sin_addr), ntohs(t0.sin_port)); - ast_log(LOG_DEBUG, "Oooh, '%s' was %s:%d\n", - c0->name, ast_inet_ntoa(ac0.sin_addr), ntohs(ac0.sin_port)); + if (option_debug) { + ast_log(LOG_DEBUG, "Oooh, '%s' changed end address to %s:%d\n", + c0->name, ast_inet_ntoa(t0.sin_addr), ntohs(t0.sin_port)); + ast_log(LOG_DEBUG, "Oooh, '%s' was %s:%d\n", + c0->name, ast_inet_ntoa(ac0.sin_addr), ntohs(ac0.sin_port)); + } memcpy(&ac0, &t0, sizeof(ac0)); } who = ast_waitfor_n(cs, 2, &to); if (!who) { - ast_log(LOG_DEBUG, "Ooh, empty read...\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Ooh, empty read...\n"); /* check for hangup / whentohangup */ if (ast_check_hangup(c0) || ast_check_hangup(c1)) break; @@ -1068,7 +1076,8 @@ int ast_udptl_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, if (!f) { *fo = f; *rc = who; - ast_log(LOG_DEBUG, "Oooh, got a %s\n", f ? "digit" : "hangup"); + if (option_debug) + ast_log(LOG_DEBUG, "Oooh, got a %s\n", f ? "digit" : "hangup"); /* That's all we needed */ return 0; } else { |