Index: loader.c =================================================================== --- loader.c (revision 7745) +++ loader.c (working copy) @@ -87,6 +87,10 @@ int x; char buf[256]; char buf2[16]; + + if (!option_debug) + return 0; + snprintf(buf, sizeof(buf), "Unexpected signature:"); for (x=0; x<16; x++) { snprintf(buf2, sizeof(buf2), " %02x", *(d++)); Index: channel.c =================================================================== --- channel.c (revision 7745) +++ channel.c (working copy) @@ -626,7 +626,8 @@ 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_mutex_unlock(&chan->lock); return 0; @@ -760,7 +761,7 @@ /* exit if chan not found or mutex acquired successfully */ done = (c == NULL) || (ast_mutex_trylock(&c->lock) == 0); /* this is slightly unsafe, as we _should_ hold the lock to access c->name */ - if (!done && c) + if (option_debug && !done && c) ast_log(LOG_DEBUG, "Avoiding %s for '%s'\n", msg, c->name); ast_mutex_unlock(&chlock); if (done) @@ -980,8 +981,9 @@ 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; } @@ -1034,7 +1036,8 @@ ast_mutex_unlock(&spy->lock); - ast_log(LOG_DEBUG, "Spy %s removed from channel %s\n", + if (option_debug) + ast_log(LOG_DEBUG, "Spy %s removed from channel %s\n", spy->type, chan->name); if (AST_LIST_EMPTY(&chan->spies->list)) { @@ -1125,8 +1128,9 @@ 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)); @@ -1373,7 +1377,8 @@ 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; @@ -1680,7 +1685,8 @@ 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; @@ -1823,9 +1829,8 @@ data = chan->timingdata; ast_mutex_unlock(&chan->lock); if (func) { -#if 0 - ast_log(LOG_DEBUG, "Calling private function\n"); -#endif + if (option_debug > 3) + ast_log(LOG_DEBUG, "Calling private function\n"); func(data); } else { blah = 0; @@ -1928,7 +1933,8 @@ f = &null_frame; } else if ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_ANSWER)) { if (prestate == AST_STATE_UP) { - ast_log(LOG_DEBUG, "Dropping duplicate answer!\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Dropping duplicate answer!\n"); f = &null_frame; } /* Answer the CDR */ @@ -1945,7 +1951,8 @@ int (*generate)(struct ast_channel *chan, void *tmp, int datalen, int samples); if (chan->timingfunc) { - ast_log(LOG_DEBUG, "Generator got voice, switching to phase locked mode\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Generator got voice, switching to phase locked mode\n"); ast_settimeout(chan, 0, NULL, NULL); } tmp = chan->generatordata; @@ -1954,12 +1961,14 @@ res = generate(chan, tmp, f->datalen, f->samples); 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); } } else if (f && (f->frametype == AST_FRAME_CNG)) { if (chan->generator && !chan->timingfunc && (chan->timingfd > -1)) { - ast_log(LOG_DEBUG, "Generator got CNG, switching to zap timed mode\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Generator got CNG, switching to zap timed mode\n"); ast_settimeout(chan, 160, generator_force, chan); } } @@ -2014,7 +2023,8 @@ 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) { @@ -2125,7 +2135,7 @@ ast_playtones_start(chan, 0, dtmf_tones[14], 0); else if (digit == '#') ast_playtones_start(chan, 0, dtmf_tones[15], 0); - else { + else if (option_debug) { /* not handled */ ast_log(LOG_DEBUG, "Unable to generate DTMF tone '%c' for '%s'\n", digit, chan->name); } @@ -2145,7 +2155,8 @@ /* 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"; @@ -2734,8 +2745,9 @@ usleep(1); ast_mutex_lock(&original->lock); } - 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); @@ -2747,7 +2759,8 @@ clone->masqr = original; ast_queue_frame(original, &null); ast_queue_frame(clone, &null); - 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; } ast_mutex_unlock(&clone->lock); @@ -2873,7 +2886,8 @@ /* We need the clone's lock, too */ ast_mutex_lock(&clone->lock); - ast_log(LOG_DEBUG, "Got clone lock for masquerade on '%s' at %p\n", clone->name, &clone->lock); + if (option_debug) + ast_log(LOG_DEBUG, "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 */ @@ -3032,7 +3046,8 @@ /* Copy the music class */ ast_copy_string(original->musicclass, clone->musicclass, sizeof(original->musicclass)); - ast_log(LOG_DEBUG, "Putting channel %s in %d/%d formats\n", original->name, wformat, rformat); + if (option_debug) + ast_log(LOG_DEBUG, "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 */ @@ -3052,7 +3067,8 @@ 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)) { - ast_log(LOG_DEBUG, "Destroying channel clone '%s'\n", clone->name); + if (option_debug) + ast_log(LOG_DEBUG, "Destroying channel clone '%s'\n", clone->name); ast_mutex_unlock(&clone->lock); manager_event(EVENT_FLAG_CALL, "Hangup", "Channel: %s\r\n" @@ -3067,7 +3083,8 @@ ast_channel_free(clone); } else { struct ast_frame null_frame = { AST_FRAME_NULL, }; - 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, &null_frame); ast_mutex_unlock(&clone->lock); @@ -3076,7 +3093,8 @@ /* Signal any blocker */ if (ast_test_flag(original, AST_FLAG_BLOCKING)) pthread_kill(original->blocker, SIGURG); - ast_log(LOG_DEBUG, "Done Masquerading %s (%d)\n", original->name, original->_state); + if (option_debug) + ast_log(LOG_DEBUG, "Done Masquerading %s (%d)\n", original->name, original->_state); return 0; } @@ -3233,7 +3251,8 @@ res = AST_BRIDGE_RETRY; break; } - ast_log(LOG_DEBUG, "Nobody there, continuing...\n"); + if (option_debug > 1) + ast_log(LOG_DEBUG, "Nobody there, continuing...\n"); if (c0->_softhangup == AST_SOFTHANGUP_UNBRIDGE || c1->_softhangup == AST_SOFTHANGUP_UNBRIDGE) { if (c0->_softhangup == AST_SOFTHANGUP_UNBRIDGE) c0->_softhangup = 0; @@ -3249,7 +3268,8 @@ *fo = NULL; *rc = who; res = AST_BRIDGE_COMPLETE; - ast_log(LOG_DEBUG, "Didn't get a frame from channel: %s\n",who->name); + if (option_debug > 1) + ast_log(LOG_DEBUG, "Didn't get a frame from channel: %s\n",who->name); break; } @@ -3261,7 +3281,8 @@ *fo = f; *rc = who; res = AST_BRIDGE_COMPLETE; - ast_log(LOG_DEBUG, "Got a FRAME_CONTROL (%d) frame on channel %s\n", f->subclass, who->name); + if (option_debug > 1) + ast_log(LOG_DEBUG, "Got a FRAME_CONTROL (%d) frame on channel %s\n", f->subclass, who->name); break; } } @@ -3277,15 +3298,17 @@ *rc = who; *fo = f; res = AST_BRIDGE_COMPLETE; - ast_log(LOG_DEBUG, "Got DTMF on channel (%s)\n", who->name); + if (option_debug > 1) + ast_log(LOG_DEBUG, "Got DTMF on channel (%s)\n", who->name); break; } else { goto tackygoto; } } else { #if 0 - ast_log(LOG_DEBUG, "Read from %s\n", who->name); - if (who == last) + if (option_debug > 1) + ast_log(LOG_DEBUG, "Read from %s\n", who->name); + if (option_debug > 1 && who == last) ast_log(LOG_DEBUG, "Servicing channel %s twice in a row?\n", last->name); last = who; #endif @@ -3420,7 +3443,8 @@ c1->_softhangup = 0; c0->_bridge = c1; c1->_bridge = c0; - ast_log(LOG_DEBUG, "Unbridge signal received. Ending native bridge.\n"); + if (option_debug > 1) + ast_log(LOG_DEBUG, "Unbridge signal received. Ending native bridge.\n"); continue; } @@ -3431,12 +3455,13 @@ 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 > 1) + 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; } @@ -3459,7 +3484,8 @@ "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); @@ -3521,7 +3547,8 @@ "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; } Index: pbx/pbx_loopback.c =================================================================== --- pbx/pbx_loopback.c (revision 7745) +++ pbx/pbx_loopback.c (working copy) @@ -77,7 +77,7 @@ char *newpattern=NULL; \ loopback_helper(buf, sizeof(buf), exten, context, priority, data); \ loopback_subst(&newexten, &newcontext, &newpriority, &newpattern, buf); \ - ast_log(LOG_DEBUG, "Parsed into %s @ %s priority %d\n", newexten, newcontext, newpriority); \ + if (option_debug) ast_log(LOG_DEBUG, "Parsed into %s @ %s priority %d\n", newexten, newcontext, newpriority); \ if (!strcasecmp(newcontext, context)) return -1 Index: pbx/pbx_spool.c =================================================================== --- pbx/pbx_spool.c (revision 7745) +++ pbx/pbx_spool.c (working copy) @@ -313,7 +313,8 @@ if (o->retries <= o->maxretries) { if (o->callingpid && (o->callingpid == ast_mainpid)) { safe_append(o, time(NULL), "DelayedRetry"); - ast_log(LOG_DEBUG, "Delaying retry since we're currently running '%s'\n", o->fn); + if (option_debug) + ast_log(LOG_DEBUG, "Delaying retry since we're currently running '%s'\n", o->fn); } else { /* Increment retries */ o->retries++; Index: pbx/pbx_dundi.c =================================================================== --- pbx/pbx_dundi.c (revision 7745) +++ pbx/pbx_dundi.c (working copy) @@ -419,7 +419,8 @@ snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "eth%d", x); if (!ioctl(s, SIOCGIFHWADDR, &ifr)) { memcpy(&global_eid, ((unsigned char *)&ifr.ifr_hwaddr) + 2, sizeof(global_eid)); - ast_log(LOG_DEBUG, "Seeding global EID '%s' from '%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &global_eid), ifr.ifr_name); + if (option_debug) + ast_log(LOG_DEBUG, "Seeding global EID '%s' from '%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &global_eid), ifr.ifr_name); close(s); return; } @@ -439,7 +440,8 @@ memcpy( &(global_eid.eid), sdp->sdl_data + sdp->sdl_nlen, 6); - ast_log(LOG_DEBUG, "Seeding global EID '%s' from '%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &global_eid), ifap->ifa_name); + if (option_debug) + ast_log(LOG_DEBUG, "Seeding global EID '%s' from '%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &global_eid), ifap->ifa_name); freeifaddrs(ifap); return; } @@ -613,7 +615,8 @@ int max = 999999; int expiration = dundi_cache_time; - ast_log(LOG_DEBUG, "Whee, looking up '%s@%s' for '%s'\n", st->called_number, st->called_context, + if (option_debug) + ast_log(LOG_DEBUG, "Whee, looking up '%s@%s' for '%s'\n", st->called_number, st->called_context, st->eids[0] ? dundi_eid_to_str(eid_str, sizeof(eid_str), st->eids[0]) : "ourselves"); memset(&ied, 0, sizeof(ied)); memset(&dr, 0, sizeof(dr)); @@ -645,7 +648,8 @@ if (!ast_test_flag_nonstd(&hmd, DUNDI_HINT_DONT_ASK)) hmd.exten[0] = '\0'; if (ast_test_flag(st->trans, FLAG_DEAD)) { - ast_log(LOG_DEBUG, "Our transaction went away!\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Our transaction went away!\n"); st->trans->thread = 0; destroy_trans(st->trans, 0); } else { @@ -672,8 +676,9 @@ struct dundi_hint_metadata hmd; char eid_str[20]; - ast_log(LOG_DEBUG, "Whee, precaching '%s@%s' for '%s'\n", st->called_number, st->called_context, - st->eids[0] ? dundi_eid_to_str(eid_str, sizeof(eid_str), st->eids[0]) : "ourselves"); + if (option_debug) + ast_log(LOG_DEBUG, "Whee, precaching '%s@%s' for '%s'\n", st->called_number, st->called_context, + st->eids[0] ? dundi_eid_to_str(eid_str, sizeof(eid_str), st->eids[0]) : "ourselves"); memset(&ied, 0, sizeof(ied)); /* Now produce precache */ @@ -684,7 +689,8 @@ if (!ast_test_flag_nonstd(&hmd, DUNDI_HINT_DONT_ASK)) hmd.exten[0] = '\0'; if (ast_test_flag(st->trans, FLAG_DEAD)) { - ast_log(LOG_DEBUG, "Our transaction went away!\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Our transaction went away!\n"); st->trans->thread = 0; destroy_trans(st->trans, 0); } else { @@ -706,14 +712,16 @@ struct dundi_hint_metadata hmd; char eid_str[20]; int res; - ast_log(LOG_DEBUG, "Whee, looking up '%s@%s' for '%s'\n", st->called_number, st->called_context, - st->eids[0] ? dundi_eid_to_str(eid_str, sizeof(eid_str), st->eids[0]) : "ourselves"); + if (option_debug) + ast_log(LOG_DEBUG, "Whee, looking up '%s@%s' for '%s'\n", st->called_number, st->called_context, + st->eids[0] ? dundi_eid_to_str(eid_str, sizeof(eid_str), st->eids[0]) : "ourselves"); memset(&ied, 0, sizeof(ied)); memset(&dei, 0, sizeof(dei)); memset(&hmd, 0, sizeof(hmd)); if (!dundi_eid_cmp(&st->trans->us_eid, &st->reqeid)) { /* Ooh, it's us! */ - ast_log(LOG_DEBUG, "Neat, someone look for us!\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Neat, someone look for us!\n"); ast_copy_string(dei.orgunit, dept, sizeof(dei.orgunit)); ast_copy_string(dei.org, org, sizeof(dei.org)); ast_copy_string(dei.locality, locality, sizeof(dei.locality)); @@ -728,7 +736,8 @@ } ast_mutex_lock(&peerlock); if (ast_test_flag(st->trans, FLAG_DEAD)) { - ast_log(LOG_DEBUG, "Our transaction went away!\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Our transaction went away!\n"); st->trans->thread = 0; destroy_trans(st->trans, 0); } else { @@ -788,7 +797,8 @@ *st->eids[x-skipfirst] = *ies->eids[x]; s += sizeof(dundi_eid); } - ast_log(LOG_DEBUG, "Answering EID query for '%s@%s'!\n", dundi_eid_to_str(eid_str, sizeof(eid_str), ies->reqeid), ies->called_context); + if (option_debug) + ast_log(LOG_DEBUG, "Answering EID query for '%s@%s'!\n", dundi_eid_to_str(eid_str, sizeof(eid_str), ies->reqeid), ies->called_context); pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); trans->thread = 1; @@ -840,9 +850,11 @@ snprintf(data, sizeof(data), "%ld|", (long)(timeout)); ast_db_put("dundi/cache", key1, data); - ast_log(LOG_DEBUG, "Caching hint at '%s'\n", key1); + if (option_debug) + ast_log(LOG_DEBUG, "Caching hint at '%s'\n", key1); ast_db_put("dundi/cache", key2, data); - ast_log(LOG_DEBUG, "Caching hint at '%s'\n", key2); + if (option_debug) + ast_log(LOG_DEBUG, "Caching hint at '%s'\n", key2); return 0; } @@ -1019,7 +1031,8 @@ cur = cur->next; } st->nummaps = mapcount; - ast_log(LOG_DEBUG, "Forwarding precache for '%s@%s'!\n", ies->called_number, ies->called_context); + if (option_debug) + ast_log(LOG_DEBUG, "Forwarding precache for '%s@%s'!\n", ies->called_number, ies->called_context); pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); trans->thread = 1; @@ -1111,7 +1124,8 @@ cur = cur->next; } st->nummaps = mapcount; - ast_log(LOG_DEBUG, "Answering query for '%s@%s'!\n", ies->called_number, ies->called_context); + if (option_debug) + ast_log(LOG_DEBUG, "Answering query for '%s@%s'!\n", ies->called_number, ies->called_context); pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); trans->thread = 1; @@ -1152,7 +1166,8 @@ if (sscanf(ptr, "%d|%n", (int *)&timeout, &length) == 1) { expiration = timeout - now; if (expiration > 0) { - ast_log(LOG_DEBUG, "Found cache expiring in %d seconds!\n", (int)(timeout - now)); + if (option_debug) + ast_log(LOG_DEBUG, "Found cache expiring in %d seconds!\n", (int)(timeout - now)); ptr += length; while((sscanf(ptr, "%d/%d/%d/%n", &(flags.flags), &weight, &tech, &length) == 3)) { ptr += length; @@ -1165,8 +1180,9 @@ src++; } else src = ""; - ast_log(LOG_DEBUG, "Found cached answer '%s/%s' originally from '%s' with flags '%s' on behalf of '%s'\n", - tech2str(tech), ptr, src, dundi_flags2str(fs, sizeof(fs), flags.flags), eid_str_full); + if (option_debug) + ast_log(LOG_DEBUG, "Found cached answer '%s/%s' originally from '%s' with flags '%s' on behalf of '%s'\n", + tech2str(tech), ptr, src, dundi_flags2str(fs, sizeof(fs), flags.flags), eid_str_full); /* Make sure it's not already there */ for (z=0;zrespcount;z++) { if ((req->dr[z].techint == tech) && @@ -1287,7 +1303,8 @@ struct dundi_peer *peer = data; char eid_str[20]; /* Called with peerlock already held */ - ast_log(LOG_DEBUG, "Register expired for '%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &peer->eid)); + if (option_debug) + ast_log(LOG_DEBUG, "Register expired for '%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &peer->eid)); peer->registerexpire = -1; peer->lastms = 0; memset(&peer->addr, 0, sizeof(peer->addr)); @@ -1381,7 +1398,8 @@ *h = *ohdr; bytes = space - 6; if (uncompress(dst + 6, &bytes, decrypt_space, srclen) != Z_OK) { - ast_log(LOG_DEBUG, "Ouch, uncompress failed :(\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Ouch, uncompress failed :(\n"); return NULL; } /* Update length */ @@ -1407,7 +1425,8 @@ bytes = len; res = compress(compress_space, &bytes, pack->data + 6, pack->datalen - 6); if (res != Z_OK) { - ast_log(LOG_DEBUG, "Ouch, compression failed!\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Ouch, compression failed!\n"); return -1; } memset(&ied, 0, sizeof(ied)); @@ -1502,7 +1521,8 @@ return 0; } /* Decrypted, passes signature */ - ast_log(LOG_DEBUG, "Wow, new key combo passed signature and decrypt!\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Wow, new key combo passed signature and decrypt!\n"); memcpy(peer->rxenckey, newkey, 128); memcpy(peer->rxenckey + 128, newsig, 128); peer->them_keycrc32 = crc32(0L, peer->rxenckey, 128); @@ -1534,7 +1554,8 @@ return -1; /* Make a copy for parsing */ memcpy(bufcpy, hdr->ies, datalen); - ast_log(LOG_DEBUG, "Got canonical message %d (%d), %d bytes data%s\n", cmd, hdr->oseqno, datalen, final ? " (Final)" : ""); + if (option_debug) + ast_log(LOG_DEBUG, "Got canonical message %d (%d), %d bytes data%s\n", cmd, hdr->oseqno, datalen, final ? " (Final)" : ""); if (dundi_parse_ies(&ies, bufcpy, datalen) < 0) { ast_log(LOG_WARNING, "Failed to parse DUNDI information elements!\n"); return -1; @@ -1646,7 +1667,8 @@ /* A dialplan response, lets see what we got... */ if (ies.cause < 1) { /* Success of some sort */ - ast_log(LOG_DEBUG, "Looks like success of some sort (%d), %d answers\n", ies.cause, ies.anscount); + if (option_debug) + ast_log(LOG_DEBUG, "Looks like success of some sort (%d), %d answers\n", ies.cause, ies.anscount); if (ast_test_flag(trans, FLAG_ENCRYPT)) { authpass = encrypted; } else @@ -1730,7 +1752,8 @@ /* A dialplan response, lets see what we got... */ if (ies.cause < 1) { /* Success of some sort */ - ast_log(LOG_DEBUG, "Looks like success of some sort (%d)\n", ies.cause); + if (option_debug) + ast_log(LOG_DEBUG, "Looks like success of some sort (%d)\n", ies.cause); if (ast_test_flag(trans, FLAG_ENCRYPT)) { authpass = encrypted; } else @@ -1797,7 +1820,8 @@ dundi_send(trans, DUNDI_COMMAND_CANCEL, 0, 1, &ied); } } else { - ast_log(LOG_DEBUG, "Yay, we've registered as '%s' to '%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &trans->us_eid), + if (option_debug) + ast_log(LOG_DEBUG, "Yay, we've registered as '%s' to '%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &trans->us_eid), dundi_eid_to_str(eid_str2, sizeof(eid_str2), &trans->them_eid)); /* Close connection if not final */ if (!final) @@ -1880,7 +1904,7 @@ /* Carry back final flag */ hdr->cmdresp |= dhdr->cmdresp & 0x80; break; - } else + } else if (option_debug) ast_log(LOG_DEBUG, "Ouch, decrypt failed :(\n"); } } @@ -1975,7 +1999,8 @@ dundi_ack(trans, 0); } else { /* Out of window -- simply drop */ - ast_log(LOG_DEBUG, "Dropping packet out of window!\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Dropping packet out of window!\n"); } return 0; } @@ -3250,7 +3275,8 @@ transn = trans->next; trans->thread = 0; if (ast_test_flag(trans, FLAG_DEAD)) { - ast_log(LOG_DEBUG, "Our transaction went away!\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Our transaction went away!\n"); destroy_trans(trans, 0); } trans = transn; @@ -3341,10 +3367,12 @@ return 0; if (p->maxms && ((p->lastms < 0) || (p->lastms >= p->maxms))) return 0; - if (ast_strlen_zero(dr->number)) - ast_log(LOG_DEBUG, "Will query peer '%s' for '%s' (context '%s')\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &p->eid), dundi_eid_to_str(eid_str2, sizeof(eid_str2), &dr->query_eid), dr->dcontext); - else - ast_log(LOG_DEBUG, "Will query peer '%s' for '%s@%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &p->eid), dr->number, dr->dcontext); + if (option_debug) { + if (ast_strlen_zero(dr->number)) + ast_log(LOG_DEBUG, "Will query peer '%s' for '%s' (context '%s')\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &p->eid), dundi_eid_to_str(eid_str2, sizeof(eid_str2), &dr->query_eid), dr->dcontext); + else + ast_log(LOG_DEBUG, "Will query peer '%s' for '%s@%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &p->eid), dr->number, dr->dcontext); + } trans = create_transaction(p); if (!trans) return -1; @@ -3431,7 +3459,7 @@ if (!avoid[x] && (!blockempty || !dundi_eid_zero(&p->us_eid))) { /* Check for a matching or 0 cache entry */ append_transaction(dr, p, ttl, avoid); - } else + } else if (option_debug) ast_log(LOG_DEBUG, "Avoiding '%s' in transaction\n", dundi_eid_to_str(eid_str, sizeof(eid_str), avoid[x])); } } @@ -3467,8 +3495,9 @@ cur = cur->next; } if (!res) { - ast_log(LOG_DEBUG, "Registering request for '%s@%s' on behalf of '%s' crc '%08lx'\n", - dr->number, dr->dcontext, dundi_eid_to_str(eid_str, sizeof(eid_str), &dr->root_eid), dr->crc32); + if (option_debug) + ast_log(LOG_DEBUG, "Registering request for '%s@%s' on behalf of '%s' crc '%08lx'\n", + dr->number, dr->dcontext, dundi_eid_to_str(eid_str, sizeof(eid_str), &dr->root_eid), dr->crc32); /* Go ahead and link us in since nobody else is searching for this */ dr->next = requests; requests = dr; @@ -3574,15 +3603,17 @@ if (rooteid && !dundi_eid_cmp(&dr.root_eid, &pending->root_eid)) { /* This is on behalf of someone else. Go ahead and close this out since they'll get their answer anyway. */ - ast_log(LOG_DEBUG, "Oooh, duplicate request for '%s@%s' for '%s'\n", - dr.number,dr.dcontext,dundi_eid_to_str(eid_str, sizeof(eid_str), &dr.root_eid)); + if (option_debug) + ast_log(LOG_DEBUG, "Oooh, duplicate request for '%s@%s' for '%s'\n", + dr.number,dr.dcontext,dundi_eid_to_str(eid_str, sizeof(eid_str), &dr.root_eid)); close(dr.pfds[0]); close(dr.pfds[1]); return -2; } else { /* Wait for the cache to populate */ - ast_log(LOG_DEBUG, "Waiting for similar request for '%s@%s' for '%s'\n", - dr.number,dr.dcontext,dundi_eid_to_str(eid_str, sizeof(eid_str), &pending->root_eid)); + if (option_debug) + ast_log(LOG_DEBUG, "Waiting for similar request for '%s@%s' for '%s'\n", + dr.number,dr.dcontext,dundi_eid_to_str(eid_str, sizeof(eid_str), &pending->root_eid)); start = ast_tvnow(); while(check_request(pending) && (ast_tvdiff_ms(ast_tvnow(), start) < ttlms) && (!chan || !chan->_softhangup)) { /* XXX Would be nice to have a way to poll/select here XXX */ @@ -3621,7 +3652,7 @@ ms = 100; ast_waitfor_n_fd(dr.pfds, 1, &ms, NULL); } - if (chan && chan->_softhangup) + if (option_debug && chan && chan->_softhangup) ast_log(LOG_DEBUG, "Hrm, '%s' hungup before their query for %s@%s finished\n", chan->name, dr.number, dr.dcontext); cancel_request(&dr); unregister_request(&dr); @@ -3727,7 +3758,8 @@ int foundcache, skipped, ttlms, ms; if (!context) context = "e164"; - ast_log(LOG_DEBUG, "Precache internal (%s@%s)!\n", number, context); + if (option_debug) + ast_log(LOG_DEBUG, "Precache internal (%s@%s)!\n", number, context); ast_mutex_lock(&peerlock); nummaps = 0; @@ -4200,7 +4232,8 @@ char eid_str[20]; char eid_str2[20]; /* Called with peerlock already held */ - ast_log(LOG_DEBUG, "Register us as '%s' to '%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &peer->us_eid), dundi_eid_to_str(eid_str2, sizeof(eid_str2), &peer->eid)); + if (option_debug) + ast_log(LOG_DEBUG, "Register us as '%s' to '%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &peer->us_eid), dundi_eid_to_str(eid_str2, sizeof(eid_str2), &peer->eid)); peer->registerid = ast_sched_add(sched, default_expiration * 1000, do_register, data); /* Destroy old transaction if there is one */ if (peer->regtrans) Index: channels/iax2-provision.c =================================================================== --- channels/iax2-provision.c (revision 7745) +++ channels/iax2-provision.c (working copy) @@ -246,7 +246,7 @@ if (sscanf(tmp, "v%x", version) != 1) { if (strcmp(tmp, "u")) { ret = iax_provision_build(&ied, version, template, force); - if (ret) + if (option_debug && ret) ast_log(LOG_DEBUG, "Unable to create provisioning packet for '%s'\n", template); } else ret = -1; Index: channels/chan_iax2.c =================================================================== --- channels/chan_iax2.c (revision 7745) +++ channels/chan_iax2.c (working copy) @@ -1031,7 +1031,8 @@ ast_log(LOG_WARNING, "Unable to trunk call: Insufficient space\n"); return -1; } - ast_log(LOG_DEBUG, "Made call %d into trunk call %d\n", callno, x); + if (option_debug) + ast_log(LOG_DEBUG, "Made call %d into trunk call %d\n", callno, x); /* We move this call from a non-trunked to a trunked call */ update_max_trunk(); update_max_nontrunk(); Index: channels/chan_misdn.c =================================================================== --- channels/chan_misdn.c (revision 7745) +++ channels/chan_misdn.c (working copy) @@ -412,7 +412,8 @@ ast_playtones_start(chan,0,dtmf_tones[15], 0); else { /* not handled */ - ast_log(LOG_DEBUG, "Unable to handle DTMF tone '%c' for '%s'\n", digit, chan->name); + if (option_debug) + ast_log(LOG_DEBUG, "Unable to handle DTMF tone '%c' for '%s'\n", digit, chan->name); } @@ -1753,7 +1754,8 @@ release_lock; - ast_log(LOG_DEBUG, "misdn_hangup(%s)\n", ast->name); + if (option_debug) + ast_log(LOG_DEBUG, "misdn_hangup(%s)\n", ast->name); if (!p) { chan_misdn_log(3, 0, "misdn_hangup called, without chan_list obj.\n"); @@ -2030,7 +2032,8 @@ who = ast_waitfor_n(carr, 2, &to); if (!who) { - ast_log(LOG_DEBUG,"misdn_bridge: empty read\n"); + if (option_debug) + ast_log(LOG_DEBUG,"misdn_bridge: empty read\n"); continue; } f = ast_read(who); @@ -2418,7 +2421,8 @@ f = ast_dsp_process(tmp->ast, tmp->dsp, f2); if (f && (f->frametype == AST_FRAME_DTMF)) { - ast_log(LOG_DEBUG, "Detected inband DTMF digit: %c", f->subclass); + if (option_debug) + ast_log(LOG_DEBUG, "Detected inband DTMF digit: %c", f->subclass); if (f->subclass == 'f' && tmp->faxdetect) { /* Fax tone -- Handle and return NULL */ struct ast_channel *ast = tmp->ast; @@ -2434,9 +2438,9 @@ ast_log(LOG_WARNING, "Failed to async goto '%s' into fax of '%s'\n", ast->name, ast->context); } else ast_log(LOG_NOTICE, "Fax detected, but no fax extension ctx:%s exten:%s\n",ast->context, ast->exten); - } else + } else if (option_debug) ast_log(LOG_DEBUG, "Already in a fax extension, not redirecting\n"); - } else + } else if (option_debug) ast_log(LOG_DEBUG, "Fax already handled\n"); frame.frametype = AST_FRAME_NULL; frame.subclass = 0; @@ -3245,7 +3249,8 @@ if (bc->bframe_len > free) { - ast_log(LOG_DEBUG, "sbuf overflow!\n"); + if (option_debug > 1) + ast_log(LOG_DEBUG, "sbuf overflow!\n"); len=misdn_ibuf_freecount(bc->astbuf); if (len == 0) { Index: channels/chan_skinny.c =================================================================== --- channels/chan_skinny.c (revision 7745) +++ channels/chan_skinny.c (working copy) @@ -1761,7 +1761,8 @@ timeout = matchdigittimeout; } } else if (res == 0) { - ast_log(LOG_DEBUG, "Not enough digits (and no ambiguous match)...\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Not enough digits (and no ambiguous match)...\n"); transmit_tone(s, SKINNY_REORDER); ast_hangup(chan); return NULL; @@ -2005,10 +2006,11 @@ if (skinnydebug) { ast_verbose("skinny_hangup(%s) on %s@%s\n", ast->name, l->name, l->parent->name); } - if (!ast->tech_pvt) { - ast_log(LOG_DEBUG, "Asked to hangup channel not connected\n"); - return 0; - } + if (!ast->tech_pvt) { + if (option_debug) + ast_log(LOG_DEBUG, "Asked to hangup channel not connected\n"); + return 0; + } if (l->parent->registered) { if ((sub->parent->type = TYPE_LINE) && (sub->parent->hookstate == SKINNY_OFFHOOK)) { Index: channels/chan_alsa.c =================================================================== --- channels/chan_alsa.c (revision 7745) +++ channels/chan_alsa.c (working copy) @@ -355,7 +355,7 @@ if (err < 0) { ast_log(LOG_ERROR, "snd_pcm_open failed: %s\n", snd_strerror(err)); return NULL; - } else { + } else if (option_debug) { ast_log(LOG_DEBUG, "Opening device %s in %s mode\n", dev, (stream == SND_PCM_STREAM_CAPTURE) ? "read" : "write"); } @@ -387,7 +387,7 @@ err = snd_pcm_hw_params_set_period_size_near(handle, hwparams, &period_size, &direction); if (err < 0) { ast_log(LOG_ERROR, "period_size(%ld frames) is bad: %s\n", period_size, snd_strerror(err)); - } else { + } else if (option_debug) { ast_log(LOG_DEBUG, "Period size is %d\n", err); } @@ -395,7 +395,7 @@ err = snd_pcm_hw_params_set_buffer_size_near(handle, hwparams, &buffer_size); if (err < 0) { ast_log(LOG_WARNING, "Problem setting buffer size of %ld: %s\n", buffer_size, snd_strerror(err)); - } else { + } else if (option_debug) { ast_log(LOG_DEBUG, "Buffer size is set to %d frames\n", err); } @@ -467,12 +467,13 @@ ast_log(LOG_ERROR, "Unable to get a poll descriptors count, error is %s\n", snd_strerror(err)); } - if (err != 1) { + if (option_debug && err != 1) { ast_log(LOG_DEBUG, "Can't handle more than one device\n"); } snd_pcm_poll_descriptors(handle, &pfd, err); - ast_log(LOG_DEBUG, "Acquired fd %d from the poll descriptor\n", pfd.fd); + if (option_debug) + ast_log(LOG_DEBUG, "Acquired fd %d from the poll descriptor\n", pfd.fd); if (stream == SND_PCM_STREAM_CAPTURE) readdev = pfd.fd; Index: channels/chan_nbs.c =================================================================== --- channels/chan_nbs.c (revision 7745) +++ channels/chan_nbs.c (working copy) @@ -199,7 +199,8 @@ p->fr.delivery.tv_sec = 0; p->fr.delivery.tv_usec = 0; - ast_log(LOG_DEBUG, "Returning null frame on %s\n", ast->name); + if (option_debug) + ast_log(LOG_DEBUG, "Returning null frame on %s\n", ast->name); return &p->fr; } Index: channels/chan_mgcp.c =================================================================== --- channels/chan_mgcp.c (revision 7745) +++ channels/chan_mgcp.c (working copy) @@ -528,7 +528,8 @@ ast_log(LOG_WARNING, "Trying to unalloc the real channel %s@%s?!?\n", p->name, p->parent->name); return -1; } - ast_log(LOG_DEBUG, "Released sub %d of channel %s@%s\n", sub->id, p->name, p->parent->name); + if (option_debug) + ast_log(LOG_DEBUG, "Released sub %d of channel %s@%s\n", sub->id, p->name, p->parent->name); sub->owner = NULL; if (!ast_strlen_zero(sub->cxident)) { @@ -792,7 +793,7 @@ __mgcp_xmit(gw, msg->buf, msg->len); /* XXX Should schedule retransmission XXX */ /* SC - } else + } else if (option_debug) ast_log(LOG_DEBUG, "Deferring transmission of transaction %d\n", seqno); */ return 0; @@ -807,7 +808,8 @@ char iabuf[INET_ADDRSTRLEN]; ast_mutex_t *l; - ast_log(LOG_DEBUG, "Slow sequence is %d\n", p->slowsequence); + if (option_debug > 2) + ast_log(LOG_DEBUG, "Slow sequence is %d\n", p->slowsequence); if (p->slowsequence) { queue = &p->cmd_queue; l = &p->cmd_queue_lock; @@ -987,11 +989,13 @@ ast_log(LOG_DEBUG, "mgcp_hangup(%s)\n", ast->name); } if (!ast->tech_pvt) { - ast_log(LOG_DEBUG, "Asked to hangup channel not connected\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Asked to hangup channel not connected\n"); return 0; } if (strcmp(sub->magic, MGCP_SUBCHANNEL_MAGIC)) { - ast_log(LOG_DEBUG, "Invalid magic. MGCP subchannel freed up already.\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Invalid magic. MGCP subchannel freed up already.\n"); return 0; } ast_mutex_lock(&sub->lock); @@ -1225,7 +1229,8 @@ /* We already hold the channel lock */ if (f->frametype == AST_FRAME_VOICE) { if (f->subclass != sub->owner->nativeformats) { - ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass); + if (option_debug) + ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass); sub->owner->nativeformats = f->subclass; ast_set_read_format(sub->owner, sub->owner->readformat); ast_set_write_format(sub->owner, sub->owner->writeformat); Index: channels/chan_vpb.c =================================================================== --- channels/chan_vpb.c (revision 7745) +++ channels/chan_vpb.c (working copy) @@ -529,7 +529,8 @@ res = AST_BRIDGE_RETRY; break; } - ast_log(LOG_DEBUG, "%s: vpb_bridge: Empty frame read...\n",p0->dev); + if (option_debug) + ast_log(LOG_DEBUG, "%s: vpb_bridge: Empty frame read...\n",p0->dev); /* check for hangup / whentohangup */ if (ast_check_hangup(c0) || ast_check_hangup(c1)) break; @@ -541,7 +542,8 @@ ((who == c1) && (flags & AST_BRIDGE_DTMF_CHANNEL_1))))) { *fo = f; *rc = who; - ast_log(LOG_DEBUG, "%s: vpb_bridge: Got a [%s]\n",p0->dev, f ? "digit" : "hangup"); + if (option_debug) + ast_log(LOG_DEBUG, "%s: vpb_bridge: Got a [%s]\n",p0->dev, f ? "digit" : "hangup"); /* if ((c0->tech_pvt == pvt0) && (!c0->_softhangup)) { if (pr0->set_rtp_peer(c0, NULL, NULL, 0)) @@ -926,9 +928,9 @@ ast_log(LOG_WARNING, "Failed to async goto '%s' into fax of '%s'\n", p->owner->name, target_context); } else ast_log(LOG_NOTICE, "Fax detected, but no fax extension\n"); - } else + } else if (option_debug) ast_log(LOG_DEBUG, "Already in a fax extension, not redirecting\n"); - } else + } else if (option_debug) ast_log(LOG_DEBUG, "Fax already handled\n"); } @@ -1792,7 +1794,8 @@ if (option_verbose > 3) ast_verbose("%s: LOCKING count[%d] owner[%d] \n", p->dev, p->lock.__m_count,p->lock.__m_owner); */ ast_mutex_lock(&p->lock); - ast_log(LOG_DEBUG, "New owner for channel %s is %s\n", p->dev, newchan->name); + if (option_debug > 1) + ast_log(LOG_DEBUG, "New owner for channel %s is %s\n", p->dev, newchan->name); if (p->owner == oldchan) { p->owner = newchan; @@ -1945,7 +1948,8 @@ #endif if (res != VPB_OK) { - ast_log(LOG_DEBUG, "Call on %s to %s failed: %s\n", ast->name, s, vpb_strerror(res)); + if (option_debug) + ast_log(LOG_DEBUG, "Call on %s to %s failed: %s\n", ast->name, s, vpb_strerror(res)); res = -1; } else res = 0; @@ -2282,10 +2286,12 @@ } tdiff = ast_tvdiff_ms(ast_tvnow(), p->lastplay); - ast_log(LOG_DEBUG, "%s: vpb_write: time since last play(%d) \n", p->dev, tdiff); + if (option_debug > 1) + ast_log(LOG_DEBUG, "%s: vpb_write: time since last play(%d) \n", p->dev, tdiff); if (tdiff < (VPB_SAMPLES/8 - 1)){ - ast_log(LOG_DEBUG, "%s: vpb_write: Asked to play too often (%d) (%d)\n", p->dev, tdiff,frame->datalen); -// return 0; + if (option_debug > 1) + ast_log(LOG_DEBUG, "%s: vpb_write: Asked to play too often (%d) (%d)\n", p->dev, tdiff,frame->datalen); +/* return 0; */ } p->lastplay = ast_tvnow(); /* @@ -2338,7 +2344,8 @@ } else { p->chuck_count++; - ast_log(LOG_DEBUG, "%s: vpb_write: Tossed data away, tooooo much data!![%d]\n", p->dev,p->chuck_count); + if (option_debug > 1) + ast_log(LOG_DEBUG, "%s: vpb_write: Tossed data away, tooooo much data!![%d]\n", p->dev,p->chuck_count); p->play_buf_time=0; } @@ -2519,7 +2526,8 @@ if ((use_ast_dtmfdet)&&(p->vad)){ fr = ast_dsp_process(p->owner,p->vad,fr); if (fr && (fr->frametype == AST_FRAME_DTMF)) - ast_log(LOG_DEBUG, "%s: chanreads: Detected DTMF '%c'\n",p->dev, fr->subclass); + if (option_debug > 1) + ast_log(LOG_DEBUG, "%s: chanreads: Detected DTMF '%c'\n",p->dev, fr->subclass); if (fr->subclass == 'm'){ /* conf mute request */ fr->frametype = AST_FRAME_NULL; Index: channels/chan_local.c =================================================================== --- channels/chan_local.c (revision 7745) +++ channels/chan_local.c (working copy) @@ -243,7 +243,8 @@ if (!p->alreadymasqed) res = local_queue_frame(p, isoutbound, f, ast); else { - ast_log(LOG_DEBUG, "Not posting to queue since already masked on '%s'\n", ast->name); + if (option_debug) + ast_log(LOG_DEBUG, "Not posting to queue since already masked on '%s'\n", ast->name); res = 0; } ast_mutex_unlock(&p->lock); Index: manager.c =================================================================== --- manager.c (revision 7745) +++ manager.c (working copy) @@ -1250,8 +1250,10 @@ char iabuf[INET_ADDRSTRLEN]; 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"); return 0; Index: app.c =================================================================== --- app.c (revision 7745) +++ app.c (working copy) @@ -486,7 +486,8 @@ /* 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 > 1) + ast_log(LOG_DEBUG, "we'll restart the stream here at next loop\n"); pause_restart_point = 0; continue; } @@ -564,8 +565,9 @@ return -1; } - ast_log(LOG_DEBUG,"play_and_record: %s, %s, '%s'\n", playfile ? playfile : "", recordfile, fmt); - snprintf(comment,sizeof(comment),"Playing %s, Recording to: %s on %s\n", playfile ? playfile : "", recordfile, chan->name); + if (option_debug > 1) + ast_log(LOG_DEBUG, "play_and_record: %s, %s, '%s'\n", playfile ? playfile : "", recordfile, fmt); + snprintf(comment,sizeof(comment), "Playing %s, Recording to: %s on %s\n", playfile ? playfile : "", recordfile, chan->name); if (playfile) { d = ast_play_and_wait(chan, playfile); @@ -581,7 +583,8 @@ 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, "|"))) { @@ -594,9 +597,10 @@ time(&start); end=start; /* pre-initialize end to be same as start in case we never get into loop */ - for (x=0;x 2) + ast_verbose( VERBOSE_PREFIX_3 "x=%d, open writing: %s format: %s, %p\n", x, recordfile, sfmt[x], others[x]); if (!others[x]) { break; @@ -635,7 +639,8 @@ for(;;) { res = ast_waitfor(chan, 2000); if (!res) { - ast_log(LOG_DEBUG, "One waitfor failed, trying another\n"); + if (option_debug > 1) + 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) { @@ -791,7 +796,8 @@ return -1; } - ast_log(LOG_DEBUG,"play_and_prepend: %s, %s, '%s'\n", playfile ? playfile : "", recordfile, fmt); + if (option_debug > 1) + ast_log(LOG_DEBUG,"play_and_prepend: %s, %s, '%s'\n", playfile ? playfile : "", recordfile, fmt); snprintf(comment,sizeof(comment),"Playing %s, Recording to: %s on %s\n", playfile ? playfile : "", recordfile, chan->name); if (playfile || beep) { @@ -811,12 +817,13 @@ stringp=fmts; strsep(&stringp, "|"); - ast_log(LOG_DEBUG,"Recording Formats: sfmts=%s\n", fmts); + if (option_debug > 1) + ast_log(LOG_DEBUG,"Recording Formats: sfmts=%s\n", fmts); sfmt[0] = ast_strdupa(fmts); while((fmt = strsep(&stringp, "|"))) { if (fmtcnt > MAX_OTHER_FORMATS - 1) { - ast_log(LOG_WARNING, "Please increase MAX_OTHER_FORMATS in app_voicemail.c\n"); + ast_log(LOG_WARNING, "Please increase MAX_OTHER_FORMATS in app.c\n"); break; } sfmt[fmtcnt++] = ast_strdupa(fmt); @@ -824,9 +831,10 @@ time(&start); end=start; /* pre-initialize end to be same as start in case we never get into loop */ - for (x=0;x 2) + ast_verbose( VERBOSE_PREFIX_3 "x=%d, open writing: %s format: %s, %p\n", x, prependfile, sfmt[x], others[x]); if (!others[x]) { break; } @@ -855,7 +863,8 @@ 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) { @@ -1162,7 +1171,8 @@ return AST_LOCK_TIMEOUT; } else { unlink(fs); - 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; } } @@ -1408,7 +1418,8 @@ 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) @@ -1460,7 +1471,8 @@ } 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"); Index: apps/app_zapras.c =================================================================== --- apps/app_zapras.c (revision 7745) +++ apps/app_zapras.c (working copy) @@ -162,7 +162,8 @@ if (!res) { /* Check for hangup */ if (chan->_softhangup && !signalled) { - ast_log(LOG_DEBUG, "Channel '%s' hungup. Signalling RAS at %d to die...\n", chan->name, pid); + if (option_debug) + ast_log(LOG_DEBUG, "Channel '%s' hungup. Signalling RAS at %d to die...\n", chan->name, pid); kill(pid, SIGTERM); signalled=1; } Index: apps/app_festival.c =================================================================== --- apps/app_festival.c (revision 7745) +++ apps/app_festival.c (working copy) @@ -55,6 +55,7 @@ #include "asterisk/config.h" #include "asterisk/utils.h" #include "asterisk/lock.h" +#include "asterisk/options.h" #define FESTIVAL_CONFIG "festival.conf" @@ -204,7 +205,8 @@ break; } if (f->frametype == AST_FRAME_DTMF) { - ast_log(LOG_DEBUG, "User pressed a key\n"); + if (option_debug > 2) + ast_log(LOG_DEBUG, "User pressed a key\n"); if (intkeys && strchr(intkeys, f->subclass)) { res = f->subclass; ast_frfree(f); @@ -234,12 +236,14 @@ break; } if (res < needed) { /* last frame */ - ast_log(LOG_DEBUG, "Last frame\n"); + if (option_debug > 2) + ast_log(LOG_DEBUG, "Last frame\n"); res=0; break; } } else { - ast_log(LOG_DEBUG, "No more waveform\n"); + if (option_debug) + ast_log(LOG_DEBUG, "No more waveform\n"); res = 0; } } @@ -348,7 +352,8 @@ intstr = AST_DIGIT_ANY; } - ast_log(LOG_DEBUG, "Text passed to festival server : %s\n",(char *)data); + if (option_debug) + ast_log(LOG_DEBUG, "Text passed to festival server : %s\n",(char *)data); /* Connect to local festival server */ fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); @@ -403,17 +408,21 @@ if (fdesc!=-1) { writecache=1; strln=strlen((char *)data); - ast_log(LOG_DEBUG,"line length : %d\n",strln); + if (option_debug > 2) + ast_log(LOG_DEBUG,"line length : %d\n",strln); write(fdesc,&strln,sizeof(int)); write(fdesc,data,strln); seekpos=lseek(fdesc,0,SEEK_CUR); - ast_log(LOG_DEBUG,"Seek position : %d\n",seekpos); + if (option_debug > 2) + ast_log(LOG_DEBUG,"Seek position : %d\n",seekpos); } } else { read(fdesc,&strln,sizeof(int)); - ast_log(LOG_DEBUG,"Cache file exists, strln=%d, strlen=%d\n",strln,(int)strlen((char *)data)); + if (option_debug) + ast_log(LOG_DEBUG,"Cache file exists, strln=%d, strlen=%d\n",strln,(int)strlen((char *)data)); if (strlen((char *)data)==strln) { - ast_log(LOG_DEBUG,"Size OK\n"); + if (option_debug > 2) + ast_log(LOG_DEBUG,"Size OK\n"); read(fdesc,&bigstring,strln); bigstring[strln] = 0; if (strcmp(bigstring,data)==0) { @@ -430,9 +439,11 @@ if (readcache==1) { close(fd); fd=fdesc; - ast_log(LOG_DEBUG,"Reading from cache...\n"); + if (option_debug) + ast_log(LOG_DEBUG,"Reading from cache...\n"); } else { - ast_log(LOG_DEBUG,"Passing text to festival...\n"); + if (option_debug) + ast_log(LOG_DEBUG,"Passing text to festival...\n"); fs=fdopen(dup(fd),"wb"); fprintf(fs,festivalcommand,(char *)data); fflush(fs); @@ -441,7 +452,8 @@ /* Write to cache and then pass it down */ if (writecache==1) { - ast_log(LOG_DEBUG,"Writing result to cache...\n"); + if (option_debug) + ast_log(LOG_DEBUG,"Writing result to cache...\n"); while ((strln=read(fd,buffer,16384))!=0) { write(fdesc,buffer,strln); } @@ -451,7 +463,8 @@ lseek(fd,seekpos,SEEK_SET); } - ast_log(LOG_DEBUG,"Passing data to channel...\n"); + if (option_debug) + ast_log(LOG_DEBUG,"Passing data to channel...\n"); /* Read back info from server */ /* This assumes only one waveform will come back, also LP is unlikely */ @@ -473,14 +486,16 @@ } ack[3] = '\0'; if (strcmp(ack,"WV\n") == 0) { /* receive a waveform */ - ast_log(LOG_DEBUG,"Festival WV command\n"); + if (option_debug > 2) + ast_log(LOG_DEBUG,"Festival WV command\n"); waveform = socket_receive_file_to_buff(fd,&filesize); res = send_waveform_to_channel(chan,waveform,filesize, intstr); free(waveform); break; } else if (strcmp(ack,"LP\n") == 0) { /* receive an s-expr */ - ast_log(LOG_DEBUG,"Festival LP command\n"); + if (option_debug > 2) + ast_log(LOG_DEBUG,"Festival LP command\n"); waveform = socket_receive_file_to_buff(fd,&filesize); waveform[filesize]='\0'; ast_log(LOG_WARNING,"Festival returned LP : %s\n",waveform); Index: apps/app_alarmreceiver.c =================================================================== --- apps/app_alarmreceiver.c (revision 7745) +++ apps/app_alarmreceiver.c (working copy) @@ -258,14 +258,16 @@ if(option_verbose >= 4) ast_verbose(VERBOSE_PREFIX_4 "AlarmReceiver: DTMF Digit Timeout on %s\n", chan->name); - ast_log(LOG_DEBUG,"AlarmReceiver: DTMF timeout on chan %s\n",chan->name); + else if (option_debug) + ast_log(LOG_DEBUG,"AlarmReceiver: DTMF timeout on chan %s\n",chan->name); res = 1; break; } if ((r = ast_waitfor(chan, -1) < 0)) { - ast_log(LOG_DEBUG, "Waitfor returned %d\n", r); + if (option_debug) + ast_log(LOG_DEBUG, "Waitfor returned %d\n", r); continue; } @@ -357,9 +359,11 @@ res = fprintf(logfile, "[events]\n\n"); if(res < 0){ - ast_verbose(VERBOSE_PREFIX_4 "AlarmReceiver: can't write metadata\n"); + if (option_verbose > 3) + ast_verbose(VERBOSE_PREFIX_4 "AlarmReceiver: can't write metadata\n"); - ast_log(LOG_DEBUG,"AlarmReceiver: can't write metadata\n"); + if (option_debug) + ast_log(LOG_DEBUG,"AlarmReceiver: can't write metadata\n"); } else res = 0; @@ -408,8 +412,10 @@ fd = mkstemp(workstring); if(fd == -1){ - ast_verbose(VERBOSE_PREFIX_4 "AlarmReceiver: can't make temporary file\n"); - ast_log(LOG_DEBUG,"AlarmReceiver: can't make temporary file\n"); + if (option_verbose > 3) + ast_verbose(VERBOSE_PREFIX_4 "AlarmReceiver: can't make temporary file\n"); + if (option_debug) + ast_log(LOG_DEBUG,"AlarmReceiver: can't make temporary file\n"); res = -1; } @@ -530,7 +536,8 @@ if(option_verbose >= 2) ast_verbose(VERBOSE_PREFIX_2 "AlarmReceiver: Received Event %s\n", event); - ast_log(LOG_DEBUG, "AlarmReceiver: Received event: %s\n", event); + if (option_debug) + ast_log(LOG_DEBUG, "AlarmReceiver: Received event: %s\n", event); /* Calculate checksum */ @@ -560,7 +567,8 @@ database_increment("checksum-errors"); if(option_verbose >= 2){ ast_verbose(VERBOSE_PREFIX_2 "AlarmReceiver: Nonzero checksum\n"); - ast_log(LOG_DEBUG, "AlarmReceiver: Nonzero checksum\n"); + if (option_debug) + ast_log(LOG_DEBUG, "AlarmReceiver: Nonzero checksum\n"); continue; } } @@ -572,7 +580,8 @@ database_increment("format-errors"); if(option_verbose >= 2) ast_verbose(VERBOSE_PREFIX_2 "AlarmReceiver: Wrong message type\n"); - ast_log(LOG_DEBUG, "AlarmReceiver: Wrong message type\n"); + if (option_debug) + ast_log(LOG_DEBUG, "AlarmReceiver: Wrong message type\n"); continue; } } @@ -720,7 +729,8 @@ */ if((!res) && (!ast_strlen_zero(event_app)) && (event_head)){ - ast_log(LOG_DEBUG,"Alarmreceiver: executing: %s\n", event_app); + if (option_debug) + ast_log(LOG_DEBUG,"Alarmreceiver: executing: %s\n", event_app); ast_safe_system(event_app); } Index: apps/app_talkdetect.c =================================================================== --- apps/app_talkdetect.c (revision 7745) +++ apps/app_talkdetect.c (working copy) @@ -42,6 +42,7 @@ #include "asterisk/translate.h" #include "asterisk/utils.h" #include "asterisk/dsp.h" +#include "asterisk/options.h" static char *tdesc = "Playback with Talk Detection"; @@ -112,7 +113,8 @@ } } } - ast_log(LOG_DEBUG, "Preparing detect of '%s', sil=%d,min=%d,max=%d\n", + if (option_debug) + ast_log(LOG_DEBUG, "Preparing detect of '%s', sil=%d,min=%d,max=%d\n", tmp, sil, min, max); if (chan->_state != AST_STATE_UP) { /* Otherwise answer unless we're supposed to send this while on-hook */ @@ -172,7 +174,8 @@ ms = 0; if ((ms > min) && ((max < 0) || (ms < max))) { char ms_str[10]; - ast_log(LOG_DEBUG, "Found qualified token of %d ms\n", ms); + if (option_debug) + ast_log(LOG_DEBUG, "Found qualified token of %d ms\n", ms); /* Save detected talk time (in milliseconds) */ sprintf(ms_str, "%d", ms ); @@ -182,7 +185,7 @@ res = 0; ast_frfree(fr); break; - } else + } else if (option_debug) ast_log(LOG_DEBUG, "Found unqualified token of %d ms\n", ms); notsilent = 0; } @@ -190,7 +193,8 @@ if (!notsilent) { /* Heard some audio, mark the begining of the token */ start = ast_tvnow(); - ast_log(LOG_DEBUG, "Start of voice token!\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Start of voice token!\n"); notsilent = 1; } } Index: apps/app_db.c =================================================================== --- apps/app_db.c (revision 7745) +++ apps/app_db.c (working copy) @@ -86,7 +86,8 @@ family = strsep(&argv, "/"); keytree = strsep(&argv, "\0"); if (!family || !keytree) { - ast_log(LOG_DEBUG, "Ignoring; Syntax error in argument\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Ignoring; Syntax error in argument\n"); LOCAL_USER_REMOVE(u); return 0; } @@ -132,7 +133,8 @@ family = strsep(&argv, "/"); key = strsep(&argv, "\0"); if (!family || !key) { - ast_log(LOG_DEBUG, "Ignoring; Syntax error in argument\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Ignoring; Syntax error in argument\n"); LOCAL_USER_REMOVE(u); return 0; } @@ -142,7 +144,7 @@ if (option_verbose > 2) ast_verbose(VERBOSE_PREFIX_3 "DBdel: Error deleting key from database.\n"); } - } else { + } else if (option_debug) { ast_log(LOG_DEBUG, "Ignoring, no parameters\n"); } Index: apps/app_mp3.c =================================================================== --- apps/app_mp3.c (revision 7745) +++ apps/app_mp3.c (working copy) @@ -45,6 +45,7 @@ #include "asterisk/pbx.h" #include "asterisk/module.h" #include "asterisk/translate.h" +#include "asterisk/options.h" #define LOCAL_MPG_123 "/usr/local/bin/mpg123" #define MPG_123 "/usr/bin/mpg123" @@ -185,7 +186,8 @@ break; } } else { - ast_log(LOG_DEBUG, "No more mp3\n"); + if (option_debug) + ast_log(LOG_DEBUG, "No more mp3\n"); res = 0; break; } @@ -193,19 +195,22 @@ } else { ms = ast_waitfor(chan, ms); if (ms < 0) { - ast_log(LOG_DEBUG, "Hangup detected\n"); + if (option_debug > 1) + ast_log(LOG_DEBUG, "Hangup detected\n"); res = -1; break; } if (ms) { f = ast_read(chan); if (!f) { - ast_log(LOG_DEBUG, "Null frame == hangup() detected\n"); + if (option_debug > 1) + ast_log(LOG_DEBUG, "Null frame == hangup() detected\n"); res = -1; break; } if (f->frametype == AST_FRAME_DTMF) { - ast_log(LOG_DEBUG, "User pressed a key\n"); + if (option_debug > 1) + ast_log(LOG_DEBUG, "User pressed a key\n"); ast_frfree(f); res = 0; break; Index: apps/app_rpt.c =================================================================== --- apps/app_rpt.c (revision 7745) +++ apps/app_rpt.c (working copy) @@ -5729,7 +5729,8 @@ if(i != strlen(this)) continue; /* Not a node defn */ - ast_log(LOG_DEBUG,"Loading config for repeater %s\n",this); + if (option_debug) + ast_log(LOG_DEBUG,"Loading config for repeater %s\n",this); ast_mutex_init(&rpt_vars[n].lock); rpt_vars[n].tele.next = &rpt_vars[n].tele; rpt_vars[n].tele.prev = &rpt_vars[n].tele; @@ -5793,7 +5794,8 @@ n++; } nrpts = n; - ast_log(LOG_DEBUG, "Total of %d repeaters configured.\n",n); + if (option_debug) + ast_log(LOG_DEBUG, "Total of %d repeaters configured.\n",n); /* start em all */ for(i = 0; i < n; i++) { Index: apps/app_meetme.c =================================================================== --- apps/app_meetme.c (revision 7745) +++ apps/app_meetme.c (working copy) @@ -677,7 +677,8 @@ return RESULT_SUCCESS; } else return RESULT_SHOWUSAGE; - ast_log(LOG_DEBUG, "Cmdline: %s\n", cmdline); + if (option_debug) + ast_log(LOG_DEBUG, "Cmdline: %s\n", cmdline); admin_exec(NULL, cmdline); return 0; @@ -1077,7 +1078,8 @@ if (ztc.confmode) { /* Whoa, already in a conference... Retry... */ if (!retryzap) { - ast_log(LOG_DEBUG, "Zap channel is in a conference already, retrying with pseudo\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Zap channel is in a conference already, retrying with pseudo\n"); retryzap = 1; goto zapretry; } @@ -1111,7 +1113,8 @@ ast_mutex_unlock(&conf->playlock); goto outrun; } - ast_log(LOG_DEBUG, "Placed channel %s in ZAP conf %d\n", chan->name, conf->zapconf); + if (option_debug) + ast_log(LOG_DEBUG, "Placed channel %s in ZAP conf %d\n", chan->name, conf->zapconf); manager_event(EVENT_FLAG_CALL, "MeetmeJoin", "Channel: %s\r\n" @@ -1323,7 +1326,8 @@ close(fd); using_pseudo = 0; } - ast_log(LOG_DEBUG, "Ooh, something swapped out under us, starting over\n"); + if (option_debug > 1) + ast_log(LOG_DEBUG, "Ooh, something swapped out under us, starting over\n"); retryzap = strcasecmp(c->type, "Zap"); user->zapchannel = !retryzap; goto zapretry; @@ -1388,7 +1392,8 @@ tmp[0] = f->subclass; tmp[1] = '\0'; if (!ast_goto_if_exists(chan, exitcontext, tmp, 1)) { - ast_log(LOG_DEBUG, "Got DTMF %c, goto context %s\n", tmp[0], exitcontext); + if (option_debug > 1) + ast_log(LOG_DEBUG, "Got DTMF %c, goto context %s\n", tmp[0], exitcontext); ret = 0; break; } else if (option_debug > 1) @@ -1735,7 +1740,8 @@ if (!cnf) { if (dynamic) { /* No need to parse meetme.conf */ - ast_log(LOG_DEBUG, "Building dynamic conference '%s'\n", confno); + if (option_debug) + ast_log(LOG_DEBUG, "Building dynamic conference '%s'\n", confno); if (dynamic_pin) { if (dynamic_pin[0] == 'q') { /* Query the user to enter a PIN */ @@ -1780,7 +1786,7 @@ break; } } - if (!var) { + if (option_debug && !var) { ast_log(LOG_DEBUG, "%s isn't a valid conference\n", confno); } ast_config_destroy(cfg); Index: apps/app_test.c =================================================================== --- apps/app_test.c (revision 7745) +++ apps/app_test.c (working copy) @@ -117,7 +117,8 @@ ast_log(LOG_NOTICE, "No samples were received from the other side!\n"); return -1; } - ast_log(LOG_DEBUG, "%s: Noise: %d, samples: %d, avg: %d\n", who, noise, samples, noise / samples); + if (option_debug) + ast_log(LOG_DEBUG, "%s: Noise: %d, samples: %d, avg: %d\n", who, noise, samples, noise / samples); return (noise / samples); } Index: apps/app_intercom.c =================================================================== --- apps/app_intercom.c (revision 7745) +++ apps/app_intercom.c (working copy) @@ -179,7 +179,7 @@ res = write_audio(f->data, f->datalen); if (res > 0) res = 0; - } else + } else if (option_debug) ast_log(LOG_DEBUG, "Unable to handle non-signed linear frame (%d)\n", f->subclass); } } Index: apps/app_ices.c =================================================================== --- apps/app_ices.c (revision 7745) +++ apps/app_ices.c (working copy) @@ -46,6 +46,7 @@ #include "asterisk/pbx.h" #include "asterisk/module.h" #include "asterisk/translate.h" +#include "asterisk/options.h" #define ICES "/usr/bin/ices" #define LOCAL_ICES "/usr/local/bin/ices" @@ -158,13 +159,15 @@ /* Wait for audio, and stream */ ms = ast_waitfor(chan, -1); if (ms < 0) { - ast_log(LOG_DEBUG, "Hangup detected\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Hangup detected\n"); res = -1; break; } f = ast_read(chan); if (!f) { - ast_log(LOG_DEBUG, "Null frame == hangup() detected\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Null frame == hangup() detected\n"); res = -1; break; } Index: apps/app_directed_pickup.c =================================================================== --- apps/app_directed_pickup.c (revision 7745) +++ apps/app_directed_pickup.c (working copy) @@ -41,6 +41,7 @@ #include "asterisk/module.h" #include "asterisk/lock.h" #include "asterisk/app.h" +#include "asterisk/options.h" static const char *tdesc = "Directed Call Pickup Application"; static const char *app = "Pickup"; @@ -86,22 +87,25 @@ /* We have a possible channel... now we need to find it! */ target = ast_get_channel_by_name_locked(tmp); } else { - ast_log(LOG_DEBUG, "No target channel found.\n"); + if (option_debug) + ast_log(LOG_DEBUG, "No target channel found.\n"); res = -1; } ast_mutex_unlock(&origin->lock); } else { if (origin) ast_mutex_unlock(&origin->lock); - ast_log(LOG_DEBUG, "No originating channel found.\n"); + if (option_debug) + ast_log(LOG_DEBUG, "No originating channel found.\n"); } if (res) goto out; if (target && (!target->pbx) && ((target->_state == AST_STATE_RINGING) || (target->_state == AST_STATE_RING))) { - ast_log(LOG_DEBUG, "Call pickup on chan '%s' by '%s'\n", target->name, - chan->name); + if (option_debug) + ast_log(LOG_DEBUG, "Call pickup on chan '%s' by '%s'\n", target->name, + chan->name); res = ast_answer(chan); if (res) { ast_log(LOG_WARNING, "Unable to answer '%s'\n", chan->name); @@ -122,7 +126,8 @@ goto out; } } else { - ast_log(LOG_DEBUG, "No call pickup possible...\n"); + if (option_debug) + ast_log(LOG_DEBUG, "No call pickup possible...\n"); res = -1; } /* Done */ Index: apps/app_macro.c =================================================================== --- apps/app_macro.c (revision 7745) +++ apps/app_macro.c (working copy) @@ -209,7 +209,8 @@ if (((res >= '0') && (res <= '9')) || ((res >= 'A') && (res <= 'F')) || (res == '*') || (res == '#')) { /* Just return result as to the previous application as if it had been dialed */ - 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); break; } switch(res) { @@ -238,8 +239,9 @@ } /* don't stop executing extensions when we're in "h" */ if (chan->_softhangup && strcasecmp(oldexten,"h")) { - ast_log(LOG_DEBUG, "Extension %s, priority %d returned normally even though call was hung up\n", - chan->exten, chan->priority); + if (option_debug) + ast_log(LOG_DEBUG, "Extension %s, priority %d returned normally even though call was hung up\n", + chan->exten, chan->priority); goto out; } chan->priority++; Index: apps/app_voicemail.c =================================================================== --- apps/app_voicemail.c (revision 7745) +++ apps/app_voicemail.c (working copy) @@ -1660,7 +1660,8 @@ } if (!strcmp(format, "wav49")) format = "WAV"; - ast_log(LOG_DEBUG, "Attaching file '%s', format '%s', uservm is '%d', global is %d\n", attach, format, attach_user_voicemail, ast_test_flag((&globalflags), VM_ATTACH)); + if (option_debug) + ast_log(LOG_DEBUG, "Attaching file '%s', format '%s', uservm is '%d', global is %d\n", attach, format, attach_user_voicemail, ast_test_flag((&globalflags), VM_ATTACH)); /* Make a temporary file instead of piping directly to sendmail, in case the mail command hangs */ p = vm_mkftemp(tmp); @@ -1769,7 +1770,8 @@ fclose(p); snprintf(tmp2, sizeof(tmp2), "( %s < %s ; rm -f %s ) &", mailcmd, tmp, tmp); ast_safe_system(tmp2); - ast_log(LOG_DEBUG, "Sent mail to %s with command '%s'\n", vmu->email, mailcmd); + if (option_debug) + ast_log(LOG_DEBUG, "Sent mail to %s with command '%s'\n", vmu->email, mailcmd); } return 0; } @@ -1852,7 +1854,8 @@ fclose(p); snprintf(tmp2, sizeof(tmp2), "( %s < %s ; rm -f %s ) &", mailcmd, tmp, tmp); ast_safe_system(tmp2); - ast_log(LOG_DEBUG, "Sent page to %s with command '%s'\n", pager, mailcmd); + if (option_debug) + ast_log(LOG_DEBUG, "Sent page to %s with command '%s'\n", pager, mailcmd); } return 0; } @@ -2303,7 +2306,8 @@ ast_log(LOG_ERROR, "Problem in calculating number of voicemail messages available for extension %s\n", extension); } else { snprintf(arguments, sizeof(arguments), "%s %s %s %d&", externnotify, context, extension, newvoicemails); - ast_log(LOG_DEBUG, "Executing %s\n", arguments); + if (option_debug) + ast_log(LOG_DEBUG, "Executing %s\n", arguments); ast_safe_system(arguments); } } @@ -2418,12 +2422,14 @@ if (ast_streamfile(chan, prefile, chan->language) > -1) res = ast_waitstream(chan, ecodes); } else { - ast_log(LOG_DEBUG, "%s doesn't exist, doing what we can\n", prefile); + if (option_debug) + ast_log(LOG_DEBUG, "%s doesn't exist, doing what we can\n", prefile); res = invent_message(chan, vmu->context, ext, ast_test_flag(options, OPT_BUSY_GREETING), ecodes); } DISPOSE(prefile, -1); if (res < 0) { - ast_log(LOG_DEBUG, "Hang up during prefile playback\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Hang up during prefile playback\n"); free_user(vmu); pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED"); return -1; @@ -2792,7 +2798,8 @@ bytes += adsi_voice_mode(buf + bytes, 0); adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DOWNLOAD); - ast_log(LOG_DEBUG, "Done downloading scripts...\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Done downloading scripts...\n"); #ifdef DISPLAY /* Add last dot */ @@ -2800,7 +2807,8 @@ bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, " ......", ""); bytes += adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1); #endif - ast_log(LOG_DEBUG, "Restarting session...\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Restarting session...\n"); bytes = 0; /* Load the session now */ @@ -3459,7 +3467,8 @@ snprintf(todir, sizeof(todir), "%s%s/%s/INBOX", VM_SPOOL_DIR, vmtmp->context, vmtmp->mailbox); snprintf(sys, sizeof(sys), "mkdir -p %s\n", todir); snprintf(ext_context, sizeof(ext_context), "%s@%s", vmtmp->mailbox, vmtmp->context); - ast_log(LOG_DEBUG, "%s", sys); + if (option_debug) + ast_log(LOG_DEBUG, "%s", sys); ast_safe_system(sys); res = count_messages(receiver, todir); @@ -3479,11 +3488,13 @@ if (!strcasecmp(s, "wav49")) s = "WAV"; snprintf(sys, sizeof(sys), "cp %s/msg%04d.%s %s/msg%04d.%s\n", dir, curmsg, s, todir, todircount, s); - ast_log(LOG_DEBUG, "%s", sys); + if (option_debug) + ast_log(LOG_DEBUG, "%s", sys); ast_safe_system(sys); } snprintf(sys, sizeof(sys), "cp %s/msg%04d.txt %s/msg%04d.txt\n", dir, curmsg, todir, todircount); - ast_log(LOG_DEBUG, "%s", sys); + if (option_debug) + ast_log(LOG_DEBUG, "%s", sys); ast_safe_system(sys); snprintf(fn, sizeof(fn), "%s/msg%04d", todir,todircount); @@ -3651,13 +3662,15 @@ return res; /* Strip off caller ID number from name */ - ast_log(LOG_DEBUG, "VM-CID: composite caller ID received: %s, context: %s\n", cid, context); + if (option_debug) + ast_log(LOG_DEBUG, "VM-CID: composite caller ID received: %s, context: %s\n", cid, context); ast_callerid_parse(cid, &name, &callerid); if ((!ast_strlen_zero(callerid)) && strcmp(callerid, "Unknown")) { /* Check for internal contexts and only */ /* say extension when the call didn't come from an internal context in the list */ for (i = 0 ; i < MAX_NUM_CID_CONTEXTS ; i++){ - ast_log(LOG_DEBUG, "VM-CID: comparing internalcontext: %s\n", cidinternalcontexts[i]); + if (option_debug) + ast_log(LOG_DEBUG, "VM-CID: comparing internalcontext: %s\n", cidinternalcontexts[i]); if ((strcmp(cidinternalcontexts[i], context) == 0)) break; } @@ -3684,7 +3697,8 @@ } else if (!res){ - ast_log(LOG_DEBUG, "VM-CID: Numeric caller id: (%s)\n",callerid); + if (option_debug) + ast_log(LOG_DEBUG, "VM-CID: Numeric caller id: (%s)\n",callerid); /* BB: Since this is all nicely figured out, why not say "from phone number" in this case" */ if (!callback) res = wait_file2(chan, vms, "vm-from-phonenumber"); @@ -3692,7 +3706,8 @@ } } else { /* Number unknown */ - ast_log(LOG_DEBUG, "VM-CID: From an unknown number\n"); + if (option_debug) + ast_log(LOG_DEBUG, "VM-CID: From an unknown number\n"); /* Say "from an unknown caller" as one phrase - it is already recorded by "the voice" anyhow */ res = wait_file2(chan, vms, "vm-unknown-caller"); } @@ -3712,7 +3727,8 @@ durations=atoi(duration); durationm=(durations / 60); - ast_log(LOG_DEBUG, "VM-Duration: duration is: %d seconds converted to: %d minutes\n", durations, durationm); + if (option_debug) + ast_log(LOG_DEBUG, "VM-Duration: duration is: %d seconds converted to: %d minutes\n", durations, durationm); if((!res)&&(durationm>=minduration)) { res = ast_say_number(chan, durationm, AST_DIGIT_ANY, chan->language, (char *) NULL); @@ -4700,7 +4716,8 @@ vm_change_password(vmu,newpassword); else vm_change_password_shell(vmu,newpassword); - ast_log(LOG_DEBUG,"User %s set password to %s of length %d\n",vms->username,newpassword,(int)strlen(newpassword)); + if (option_debug) + ast_log(LOG_DEBUG,"User %s set password to %s of length %d\n",vms->username,newpassword,(int)strlen(newpassword)); cmd = ast_play_and_wait(chan,"vm-passchanged"); break; case '*': @@ -5896,7 +5913,8 @@ if ((notifystr = ast_variable_retrieve(cfg, "general", "externnotify"))) { ast_copy_string(externnotify, notifystr, sizeof(externnotify)); - ast_log(LOG_DEBUG, "found externnotify: %s\n", externnotify); + if (option_debug) + ast_log(LOG_DEBUG, "found externnotify: %s\n", externnotify); } else { externnotify[0] = '\0'; } @@ -5971,7 +5989,8 @@ ast_set2_flag((&globalflags), ast_true(astattach), VM_FORCEGREET); if ((s = ast_variable_retrieve(cfg, "general", "cidinternalcontexts"))){ - ast_log(LOG_DEBUG,"VM_CID Internal context string: %s\n",s); + if (option_debug) + ast_log(LOG_DEBUG,"VM_CID Internal context string: %s\n",s); stringp = ast_strdupa(s); for (x = 0 ; x < MAX_NUM_CID_CONTEXTS ; x++){ if (!ast_strlen_zero(stringp)) { @@ -5979,44 +5998,51 @@ while ((*q == ' ')||(*q == '\t')) /* Eat white space between contexts */ q++; ast_copy_string(cidinternalcontexts[x], q, sizeof(cidinternalcontexts[x])); - ast_log(LOG_DEBUG,"VM_CID Internal context %d: %s\n", x, cidinternalcontexts[x]); + if (option_debug) + ast_log(LOG_DEBUG,"VM_CID Internal context %d: %s\n", x, cidinternalcontexts[x]); } else { cidinternalcontexts[x][0] = '\0'; } } } if (!(astreview = ast_variable_retrieve(cfg, "general", "review"))){ - ast_log(LOG_DEBUG,"VM Review Option disabled globally\n"); + if (option_debug) + ast_log(LOG_DEBUG,"VM Review Option disabled globally\n"); astreview = "no"; } ast_set2_flag((&globalflags), ast_true(astreview), VM_REVIEW); if (!(astcallop = ast_variable_retrieve(cfg, "general", "operator"))){ - ast_log(LOG_DEBUG,"VM Operator break disabled globally\n"); + if (option_debug) + ast_log(LOG_DEBUG,"VM Operator break disabled globally\n"); astcallop = "no"; } ast_set2_flag((&globalflags), ast_true(astcallop), VM_OPERATOR); if (!(astsaycid = ast_variable_retrieve(cfg, "general", "saycid"))) { - ast_log(LOG_DEBUG,"VM CID Info before msg disabled globally\n"); + if (option_debug) + ast_log(LOG_DEBUG,"VM CID Info before msg disabled globally\n"); astsaycid = "no"; } ast_set2_flag((&globalflags), ast_true(astsaycid), VM_SAYCID); if (!(send_voicemail = ast_variable_retrieve(cfg,"general", "sendvoicemail"))){ - ast_log(LOG_DEBUG,"Send Voicemail msg disabled globally\n"); + if (option_debug) + ast_log(LOG_DEBUG,"Send Voicemail msg disabled globally\n"); send_voicemail = "no"; } ast_set2_flag((&globalflags), ast_true(send_voicemail), VM_SVMAIL); if (!(asthearenv = ast_variable_retrieve(cfg, "general", "envelope"))) { - ast_log(LOG_DEBUG,"ENVELOPE before msg enabled globally\n"); + if (option_debug) + ast_log(LOG_DEBUG,"ENVELOPE before msg enabled globally\n"); asthearenv = "yes"; } ast_set2_flag((&globalflags), ast_true(asthearenv), VM_ENVELOPE); if (!(astsaydurationinfo = ast_variable_retrieve(cfg, "general", "sayduration"))) { - ast_log(LOG_DEBUG,"Duration info before msg enabled globally\n"); + if (option_debug) + ast_log(LOG_DEBUG,"Duration info before msg enabled globally\n"); astsaydurationinfo = "yes"; } ast_set2_flag((&globalflags), ast_true(astsaydurationinfo), VM_SAYDURATION); @@ -6031,28 +6057,32 @@ } if (!(astskipcmd = ast_variable_retrieve(cfg, "general", "nextaftercmd"))) { - ast_log(LOG_DEBUG,"We are not going to skip to the next msg after save/delete\n"); + if (option_debug) + ast_log(LOG_DEBUG,"We are not going to skip to the next msg after save/delete\n"); astskipcmd = "no"; } ast_set2_flag((&globalflags), ast_true(astskipcmd), VM_SKIPAFTERCMD); if ((dialoutcxt = ast_variable_retrieve(cfg, "general", "dialout"))) { ast_copy_string(dialcontext, dialoutcxt, sizeof(dialcontext)); - ast_log(LOG_DEBUG, "found dialout context: %s\n", dialcontext); + if (option_debug) + ast_log(LOG_DEBUG, "found dialout context: %s\n", dialcontext); } else { dialcontext[0] = '\0'; } if ((callbackcxt = ast_variable_retrieve(cfg, "general", "callback"))) { ast_copy_string(callcontext, callbackcxt, sizeof(callcontext)); - ast_log(LOG_DEBUG, "found callback context: %s\n", callcontext); + if (option_debug) + ast_log(LOG_DEBUG, "found callback context: %s\n", callcontext); } else { callcontext[0] = '\0'; } if ((exitcxt = ast_variable_retrieve(cfg, "general", "exitcontext"))) { ast_copy_string(exitcontext, exitcxt, sizeof(exitcontext)); - ast_log(LOG_DEBUG, "found operator context: %s\n", exitcontext); + if (option_debug) + ast_log(LOG_DEBUG, "found operator context: %s\n", exitcontext); } else { exitcontext[0] = '\0'; } Index: apps/app_dial.c =================================================================== --- apps/app_dial.c (revision 7745) +++ apps/app_dial.c (working copy) @@ -629,20 +629,24 @@ } break; default: - ast_log(LOG_DEBUG, "Dunno what to do with control type %d\n", f->subclass); + if (option_debug > 2) + ast_log(LOG_DEBUG, "Dunno what to do with control type %d\n", f->subclass); } } else if (single && (f->frametype == AST_FRAME_VOICE) && !(ast_test_flag(outgoing, OPT_RINGBACK|OPT_MUSICBACK))) { if (ast_write(in, f)) - ast_log(LOG_DEBUG, "Unable to forward frame\n"); + if (option_debug > 2) + ast_log(LOG_DEBUG, "Unable to forward frame\n"); } else if (single && (f->frametype == AST_FRAME_IMAGE) && !(ast_test_flag(outgoing, OPT_RINGBACK|OPT_MUSICBACK))) { if (ast_write(in, f)) - ast_log(LOG_DEBUG, "Unable to forward image\n"); + if (option_debug > 2) + ast_log(LOG_DEBUG, "Unable to forward image\n"); } else if (single && (f->frametype == AST_FRAME_TEXT) && !(ast_test_flag(outgoing, OPT_RINGBACK|OPT_MUSICBACK))) { if (ast_write(in, f)) - ast_log(LOG_DEBUG, "Unable to text\n"); + if (option_debug > 2) + ast_log(LOG_DEBUG, "Unable to send text\n"); } else if (single && (f->frametype == AST_FRAME_HTML) && !ast_test_flag(outgoing, DIAL_NOFORWARDHTML)) ast_channel_sendhtml(in, f->subclass, f->data, f->datalen); @@ -1203,7 +1207,8 @@ number = numsubst; pbx_builtin_setvar_helper(chan, "DIALEDPEERNUMBER", number); if (!ast_strlen_zero(args.url) && ast_channel_supports_html(peer) ) { - ast_log(LOG_DEBUG, "app_dial: sendurl=%s.\n", args.url); + if (option_debug) + ast_log(LOG_DEBUG, "app_dial: sendurl=%s.\n", args.url); ast_channel_sendurl( peer, args.url ); } if (ast_test_flag(&opts, OPT_PRIVACY) || ast_test_flag(&opts, OPT_SCREENING)) { @@ -1445,7 +1450,8 @@ *ch = '|'; } res = pbx_exec(peer, app, opt_args[OPT_ARG_CALLEE_MACRO], 1); - ast_log(LOG_DEBUG, "Macro exited with status %d\n", res); + if (option_debug) + ast_log(LOG_DEBUG, "Macro exited with status %d\n", res); res = 0; } else { ast_log(LOG_ERROR, "Could not find application Macro\n"); @@ -1591,7 +1597,8 @@ } hanguptree(outgoing, NULL); pbx_builtin_setvar_helper(chan, "DIALSTATUS", status); - ast_log(LOG_DEBUG, "Exiting with DIALSTATUS=%s.\n", status); + if (option_debug) + ast_log(LOG_DEBUG, "Exiting with DIALSTATUS=%s.\n", status); if ((ast_test_flag(peerflags, OPT_GO_ON)) && (!chan->_softhangup) && (res != AST_PBX_KEEPALIVE)) res=0; Index: apps/app_nbscat.c =================================================================== --- apps/app_nbscat.c (revision 7745) +++ apps/app_nbscat.c (working copy) @@ -46,6 +46,7 @@ #include "asterisk/pbx.h" #include "asterisk/module.h" #include "asterisk/translate.h" +#include "asterisk/options.h" #define LOCAL_NBSCAT "/usr/local/bin/nbscat8k" #define NBSCAT "/usr/bin/nbscat8k" @@ -166,7 +167,8 @@ break; } } else { - ast_log(LOG_DEBUG, "No more mp3\n"); + if (option_debug) + ast_log(LOG_DEBUG, "No more audio\n"); res = 0; break; } @@ -174,19 +176,22 @@ } else { ms = ast_waitfor(chan, ms); if (ms < 0) { - ast_log(LOG_DEBUG, "Hangup detected\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Hangup detected\n"); res = -1; break; } if (ms) { f = ast_read(chan); if (!f) { - ast_log(LOG_DEBUG, "Null frame == hangup() detected\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Null frame == hangup() detected\n"); res = -1; break; } if (f->frametype == AST_FRAME_DTMF) { - ast_log(LOG_DEBUG, "User pressed a key\n"); + if (option_debug) + ast_log(LOG_DEBUG, "User pressed a key\n"); ast_frfree(f); res = 0; break; Index: apps/app_waitforsilence.c =================================================================== --- apps/app_waitforsilence.c (revision 7745) +++ apps/app_waitforsilence.c (working copy) @@ -129,12 +129,14 @@ /* Ended happily with silence */ gotsilence = 1; pbx_builtin_setvar_helper(chan, "WAITSTATUS", "SILENCE"); - ast_log(LOG_DEBUG, "WAITSTATUS was set to SILENCE\n"); + if (option_debug) + ast_log(LOG_DEBUG, "WAITSTATUS was set to SILENCE\n"); ast_frfree(f); break; } else if ( difftime(time(&now),start) >= maxsilence/1000 ) { pbx_builtin_setvar_helper(chan, "WAITSTATUS", "TIMEOUT"); - ast_log(LOG_DEBUG, "WAITSTATUS was set to TIMEOUT\n"); + if (option_debug) + ast_log(LOG_DEBUG, "WAITSTATUS was set to TIMEOUT\n"); ast_frfree(f); break; } Index: apps/app_userevent.c =================================================================== --- apps/app_userevent.c (revision 7745) +++ apps/app_userevent.c (working copy) @@ -38,6 +38,7 @@ #include "asterisk/pbx.h" #include "asterisk/module.h" #include "asterisk/manager.h" +#include "asterisk/options.h" static char *tdesc = "Custom User Event Application"; @@ -89,13 +90,15 @@ } if(eventbody) { - ast_log(LOG_DEBUG, "Sending user event: %s, %s\n", eventname, eventbody); - manager_event(EVENT_FLAG_USER, eventname, + if (option_debug) + ast_log(LOG_DEBUG, "Sending user event: %s, %s\n", eventname, eventbody); + manager_event(EVENT_FLAG_USER, eventname, "Channel: %s\r\nUniqueid: %s\r\n%s\r\n", chan->name, chan->uniqueid, eventbody); } else { - ast_log(LOG_DEBUG, "Sending user event: %s\n", eventname); - manager_event(EVENT_FLAG_USER, eventname, + if (option_debug) + ast_log(LOG_DEBUG, "Sending user event: %s\n", eventname); + manager_event(EVENT_FLAG_USER, eventname, "Channel: %s\r\nUniqueid: %s\r\n", chan->name, chan->uniqueid); } Index: apps/app_disa.c =================================================================== --- apps/app_disa.c (revision 7745) +++ apps/app_disa.c (working copy) @@ -47,6 +47,7 @@ #include "asterisk/translate.h" #include "asterisk/ulaw.h" #include "asterisk/callerid.h" +#include "asterisk/options.h" static char *tdesc = "DISA (Direct Inward System Access) Application"; @@ -156,8 +157,10 @@ return -1; } - ast_log(LOG_DEBUG, "Digittimeout: %d\n", digittimeout); - ast_log(LOG_DEBUG, "Responsetimeout: %d\n", firstdigittimeout); + if (option_debug) { + ast_log(LOG_DEBUG, "Digittimeout: %d\n", digittimeout); + ast_log(LOG_DEBUG, "Responsetimeout: %d\n", firstdigittimeout); + } tmp = ast_strdupa(data); if (!tmp) { @@ -173,7 +176,8 @@ if (ast_strlen_zero(args.mailbox)) args.mailbox = ""; - ast_log(LOG_DEBUG, "Mailbox: %s\n",args.mailbox); + if (option_debug) + ast_log(LOG_DEBUG, "Mailbox: %s\n", args.mailbox); if (chan->_state != AST_STATE_UP) { /* answer */ @@ -185,11 +189,13 @@ acctcode[0] = 0; /* can we access DISA without password? */ - ast_log(LOG_DEBUG, "Context: %s\n",args.context); + if (option_debug) + ast_log(LOG_DEBUG, "Context: %s\n",args.context); if (!strcasecmp(args.passcode, "no-password")) { k |= 1; /* We have the password */ - ast_log(LOG_DEBUG, "DISA no-password login success\n"); + if (option_debug) + ast_log(LOG_DEBUG, "DISA no-password login success\n"); } lastdigittime = ast_tvnow(); @@ -198,14 +204,15 @@ for (;;) { /* if outa time, give em reorder */ if (ast_tvdiff_ms(ast_tvnow(), lastdigittime) > - ((k&2) ? digittimeout : firstdigittimeout)) - { - ast_log(LOG_DEBUG,"DISA %s entry timeout on chan %s\n", - ((k&1) ? "extension" : "password"),chan->name); + ((k&2) ? digittimeout : firstdigittimeout)) { + if (option_debug) + ast_log(LOG_DEBUG,"DISA %s entry timeout on chan %s\n", + ((k&1) ? "extension" : "password"),chan->name); break; } if ((res = ast_waitfor(chan, -1) < 0)) { - ast_log(LOG_DEBUG, "Waitfor returned %d\n", res); + if (option_debug) + ast_log(LOG_DEBUG, "Waitfor returned %d\n", res); continue; } @@ -216,8 +223,7 @@ return -1; } if ((f->frametype == AST_FRAME_CONTROL) && - (f->subclass == AST_CONTROL_HANGUP)) - { + (f->subclass == AST_CONTROL_HANGUP)) { ast_frfree(f); LOCAL_USER_REMOVE(u); return -1; @@ -227,40 +233,32 @@ continue; } /* if not DTMF, just do it again */ - if (f->frametype != AST_FRAME_DTMF) - { + if (f->frametype != AST_FRAME_DTMF) { ast_frfree(f); continue; } j = f->subclass; /* save digit */ ast_frfree(f); - if (i == 0) - { + if (i == 0) { k|=2; /* We have the first digit */ ast_playtones_stop(chan); } lastdigittime = ast_tvnow(); /* got a DTMF tone */ - if (i < AST_MAX_EXTENSION) /* if still valid number of digits */ - { - if (!(k&1)) /* if in password state */ - { - if (j == '#') /* end of password */ - { + if (i < AST_MAX_EXTENSION) { /* if still valid number of digits */ + if (!(k&1)) { /* if in password state */ + if (j == '#') { /* end of password */ /* see if this is an integer */ - if (sscanf(args.passcode,"%d",&j) < 1) - { /* nope, it must be a filename */ + if (sscanf(args.passcode,"%d",&j) < 1) { /* nope, it must be a filename */ fp = fopen(args.passcode,"r"); - if (!fp) - { - ast_log(LOG_WARNING,"DISA password file %s not found on chan %s\n",args.passcode,chan->name); + if (!fp) { + ast_log(LOG_WARNING,"DISA password file %s not found on chan %s\n", args.passcode, chan->name); LOCAL_USER_REMOVE(u); return -1; - } + } pwline[0] = 0; - while(fgets(pwline,sizeof(pwline) - 1,fp)) - { + while(fgets(pwline,sizeof(pwline) - 1,fp)) { if (!pwline[0]) continue; if (pwline[strlen(pwline) - 1] == '\n') pwline[strlen(pwline) - 1] = 0; @@ -271,7 +269,8 @@ AST_STANDARD_APP_ARGS(args, pwline); - ast_log(LOG_DEBUG, "Mailbox: %s\n",args.mailbox); + if (option_debug) + ast_log(LOG_DEBUG, "Mailbox: %s\n", args.mailbox); /* password must be in valid format (numeric) */ if (sscanf(args.passcode,"%d",&j) < 1) continue; @@ -302,7 +301,8 @@ exten[sizeof(acctcode)] = 0; ast_copy_string(acctcode, exten, sizeof(acctcode)); exten[0] = 0; - ast_log(LOG_DEBUG,"Successful DISA log-in on chan %s\n",chan->name); + if (option_debug) + ast_log(LOG_DEBUG,"Successful DISA log-in on chan %s\n",chan->name); continue; } } Index: apps/app_zapbarge.c =================================================================== --- apps/app_zapbarge.c (revision 7745) +++ apps/app_zapbarge.c (working copy) @@ -180,7 +180,8 @@ if (ztc.confmode) { /* Whoa, already in a conference... Retry... */ if (!retryzap) { - ast_log(LOG_DEBUG, "Zap channel is in a conference already, retrying with pseudo\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Zap channel is in a conference already, retrying with pseudo\n"); retryzap = 1; goto zapretry; } @@ -196,8 +197,10 @@ close(fd); goto outrun; } - ast_log(LOG_DEBUG, "Placed channel %s in ZAP channel %d monitor\n", chan->name, confno); + if (option_debug) + ast_log(LOG_DEBUG, "Placed channel %s in ZAP channel %d monitor\n", chan->name, confno); + for(;;) { outfd = -1; ms = -1; @@ -208,7 +211,8 @@ /* Kill old pseudo */ close(fd); } - ast_log(LOG_DEBUG, "Ooh, something swapped out under us, starting over\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Ooh, something swapped out under us, starting over\n"); retryzap = 0; goto zapretry; } Index: apps/app_osplookup.c =================================================================== --- apps/app_osplookup.c (revision 7745) +++ apps/app_osplookup.c (working copy) @@ -152,7 +152,8 @@ priority_jump = 1; } - ast_log(LOG_DEBUG, "Whoo hoo, looking up OSP on '%s' via '%s'\n", args.extension, args.provider ? args.provider : ""); + if (option_debug > 1) + ast_log(LOG_DEBUG, "Whoo hoo, looking up OSP on '%s' via '%s'\n", args.extension, args.provider ? args.provider : ""); if ((res = ast_osp_lookup(chan, args.provider, args.extension, chan->cid.cid_num, &result)) > 0) { char tmp[80]; snprintf(tmp, sizeof(tmp), "%d", result.handle); @@ -168,7 +169,7 @@ if (!res) { ast_log(LOG_NOTICE, "OSP Lookup failed for '%s' (provider '%s')\n", args.extension, args.provider ? args.provider : ""); pbx_builtin_setvar_helper(chan, "OSPLOOKUPSTATUS", "FAILED"); - } else + } else if (option_debug) ast_log(LOG_DEBUG, "Got hangup on '%s' while doing OSP Lookup for '%s' (provider '%s')!\n", chan->name, args.extension, args.provider ? args.provider : "" ); } if (!res) { @@ -238,10 +239,10 @@ if (!res) { if (result.handle < 0) ast_log(LOG_NOTICE, "OSP Lookup Next failed for handle '%d'\n", result.handle); - else + else if (option_debug) ast_log(LOG_DEBUG, "No OSP handle specified\n"); pbx_builtin_setvar_helper(chan, "OSPNEXTSTATUS", "FAILED"); - } else + } else if (option_debug) ast_log(LOG_DEBUG, "Got hangup on '%s' while doing OSP Next!\n", chan->name); } if (!res) { @@ -311,10 +312,10 @@ if (!res) { if (result.handle > -1) ast_log(LOG_NOTICE, "OSP Finish failed for handle '%d'\n", result.handle); - else + else if (option_debug) ast_log(LOG_DEBUG, "No OSP handle specified\n"); pbx_builtin_setvar_helper(chan, "OSPFINISHSTATUS", "FAILED"); - } else + } else if (option_debug) ast_log(LOG_DEBUG, "Got hangup on '%s' while doing OSP Terminate!\n", chan->name); } if (!res) { Index: apps/app_zapscan.c =================================================================== --- apps/app_zapscan.c (revision 7745) +++ apps/app_zapscan.c (working copy) @@ -186,7 +186,8 @@ if (ztc.confmode) { /* Whoa, already in a conference... Retry... */ if (!retryzap) { - ast_log(LOG_DEBUG, "Zap channel is in a conference already, retrying with pseudo\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Zap channel is in a conference already, retrying with pseudo\n"); retryzap = 1; goto zapretry; } Index: apps/app_externalivr.c =================================================================== --- apps/app_externalivr.c (revision 7745) +++ apps/app_externalivr.c (working copy) @@ -49,6 +49,7 @@ #include "asterisk/module.h" #include "asterisk/linkedlists.h" #include "asterisk/app.h" +#include "asterisk/options.h" static const char *tdesc = "External IVR Interface Application"; @@ -105,7 +106,8 @@ } fprintf(handle, "%s\n", tmp); - ast_chan_log(LOG_DEBUG, chan, "sent '%s'\n", tmp); + if (option_debug) + ast_chan_log(LOG_DEBUG, chan, "sent '%s'\n", tmp); } static void *gen_alloc(struct ast_channel *chan, void *params) @@ -442,7 +444,8 @@ command = ast_strip(input); - ast_chan_log(LOG_DEBUG, chan, "got command '%s'\n", input); + if (option_debug) + ast_chan_log(LOG_DEBUG, chan, "got command '%s'\n", input); if (strlen(input) < 4) continue; Index: apps/app_record.c =================================================================== --- apps/app_record.c (revision 7745) +++ apps/app_record.c (working copy) @@ -314,7 +314,8 @@ ast_frfree(f); } if (!f) { - ast_log(LOG_DEBUG, "Got hangup\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Got hangup\n"); res = -1; } Index: apps/app_queue.c =================================================================== --- apps/app_queue.c (revision 7745) +++ apps/app_queue.c (working copy) @@ -804,7 +804,8 @@ /*! \note Hmm, can't seem to distinguish a DB failure from a not found condition... So we might delete an in-core queue in case of DB failure. */ - ast_log(LOG_DEBUG, "Queue %s not found in realtime.\n", queuename); + if (option_debug) + ast_log(LOG_DEBUG, "Queue %s not found in realtime.\n", queuename); q->dead = 1; /* Delete if unused (else will be deleted when last caller leaves). */ @@ -1308,9 +1309,11 @@ if (q->count && q->members) { for (mem = q->members; mem; mem = mem->next) { if (!strcmp(mem->interface, member->interface)) { - ast_log(LOG_DEBUG, "Found matching member %s in queue '%s'\n", mem->interface, q->name); + if (option_debug) + ast_log(LOG_DEBUG, "Found matching member %s in queue '%s'\n", mem->interface, q->name); if (q->weight > rq->weight) { - ast_log(LOG_DEBUG, "Queue '%s' (weight %d, calls %d) is preferred over '%s' (weight %d, calls %d)\n", q->name, q->weight, q->count, rq->name, rq->weight, rq->count); + if (option_debug) + ast_log(LOG_DEBUG, "Queue '%s' (weight %d, calls %d) is preferred over '%s' (weight %d, calls %d)\n", q->name, q->weight, q->count, rq->name, rq->weight, rq->count); found = 1; break; } @@ -1351,7 +1354,8 @@ return 0; } if (use_weight && compare_weight(qe->parent,tmp->member)) { - ast_log(LOG_DEBUG, "Priority queue delaying call to %s:%s\n", qe->parent->name, tmp->interface); + if (option_debug) + ast_log(LOG_DEBUG, "Priority queue delaying call to %s:%s\n", qe->parent->name, tmp->interface); if (qe->chan->cdr) ast_cdr_busy(qe->chan->cdr); tmp->stillgoing = 0; @@ -1637,7 +1641,8 @@ } if (found < 0) { if (numlines == (numbusies + numnochan)) { - ast_log(LOG_DEBUG, "Everyone is busy at this time\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Everyone is busy at this time\n"); } else { ast_log(LOG_NOTICE, "No one is answering queue '%s' (%d/%d/%d)\n", queue, numlines, numbusies, numnochan); } @@ -1783,7 +1788,8 @@ /* Ignore going off hook */ break; default: - ast_log(LOG_DEBUG, "Dunno what to do with control type %d\n", f->subclass); + if (option_debug) + ast_log(LOG_DEBUG, "Dunno what to do with control type %d\n", f->subclass); } } ast_frfree(f); @@ -2466,11 +2472,12 @@ if ((mem = interface_exists(q, interface))) { found++; if (mem->paused == paused) - ast_log(LOG_DEBUG, "%spausing already-%spaused queue member %s:%s\n", (paused ? "" : "un"), (paused ? "" : "un"), q->name, interface); + if (option_debug) + ast_log(LOG_DEBUG, "%spausing already-%spaused queue member %s:%s\n", (paused ? "" : "un"), (paused ? "" : "un"), q->name, interface); mem->paused = paused; if (queue_persistent_members) - dump_queue_members(q); + dump_queue_members(q); ast_queue_log(q->name, "NONE", interface, (paused ? "PAUSE" : "UNPAUSE"), "%s", ""); Index: dns.c =================================================================== --- dns.c (revision 7745) +++ dns.c (working copy) @@ -40,6 +40,7 @@ #include "asterisk/channel.h" #include "asterisk/dns.h" #include "asterisk/endian.h" +#include "asterisk/options.h" #define MAX_SIZE 4096 @@ -210,7 +211,8 @@ 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 Index: db.c =================================================================== --- db.c (revision 7745) +++ db.c (working copy) @@ -196,7 +196,8 @@ /* 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 ASTdb key '%s' in family '%s'\n", keys, family); } else { #if 0 printf("Got value of size %d\n", data.size); @@ -235,7 +236,7 @@ ast_mutex_unlock(&dblock); - if (res) + if (option_debug && res) ast_log(LOG_DEBUG, "Unable to find key '%s' in family '%s'\n", keys, family); return res; } Index: acl.c =================================================================== --- acl.c (revision 7745) +++ acl.c (working copy) @@ -197,10 +197,12 @@ ret = ha; } } - ast_log(LOG_DEBUG, "%s/%s appended to acl for peer\n", stuff, nm); + if (option_debug) + ast_log(LOG_DEBUG, "%s/%s appended to ACL\n", stuff, nm); return ret; } +/*! \brief Apply ACL to IP address and see if it is approved */ int ast_apply_ha(struct ast_ha *ha, struct sockaddr_in *sin) { /* Start optimistic */ @@ -208,11 +210,13 @@ while (ha) { char iabuf[INET_ADDRSTRLEN]; char iabuf2[INET_ADDRSTRLEN]; - /* DEBUG */ - ast_log(LOG_DEBUG, - "##### Testing %s with %s\n", - ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), - ast_inet_ntoa(iabuf2, sizeof(iabuf2), ha->netaddr)); + + if (option_debug) + ast_log(LOG_DEBUG, + "##### Testing %s with %s\n", + ast_inet_ntoa(iabuf, sizeof(iabuf), sin->sin_addr), + ast_inet_ntoa(iabuf2, sizeof(iabuf2), ha->netaddr)); + /* 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) Index: dsp.c =================================================================== --- dsp.c (revision 7745) +++ dsp.c (working copy) @@ -58,6 +58,7 @@ #include "asterisk/dsp.h" #include "asterisk/ulaw.h" #include "asterisk/alaw.h" +#include "asterisk/options.h" /* Number of goertzels for progress detect */ #define GSAMP_SIZE_NA 183 /* North America - 350, 440, 480, 620, 950, 1400, 1800 Hz */ @@ -1435,7 +1436,8 @@ 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)) { @@ -1618,7 +1620,8 @@ { 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 > 1) + ast_log(LOG_DEBUG, "dsp busy pattern set to %d,%d\n", tonelength, quietlength); } void ast_dsp_digitreset(struct ast_dsp *dsp) Index: say.c =================================================================== --- say.c (revision 7745) +++ say.c (working copy) @@ -508,7 +508,7 @@ num = num % 1000000; snprintf(fn, sizeof(fn), "digits/million"); } else { - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + ast_log(LOG_WARNING, "Number '%d' is too big\n", num); res = -1; } } @@ -737,7 +737,7 @@ snprintf(fn, sizeof(fn), "digits/millions"); num = num % 1000000; } else { - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + ast_log(LOG_WARNING, "Number '%d' is too big\n", num); res = -1; } } @@ -872,7 +872,7 @@ snprintf(fn, sizeof(fn), "digits/milliards"); } } else { - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + ast_log(LOG_WARNING, "Number '%d' is too big\n", num); res = -1; } if (!res) { @@ -957,7 +957,7 @@ if (num && num < 100) playa++; } else { - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + ast_log(LOG_WARNING, "Number '%d' is too big\n", num); res = -1; } @@ -1058,7 +1058,7 @@ } num = num % 1000000; } else { - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + ast_log(LOG_WARNING, "Number '%d' is too big\n", num); res = -1; } } @@ -1154,7 +1154,7 @@ snprintf(fn, sizeof(fn), "digits/million"); num = num % 1000000; } else { - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + ast_log(LOG_WARNING, "Number '%d' is too big\n", num); res = -1; } if (!res) { @@ -1300,7 +1300,7 @@ snprintf(fn, sizeof(fn), "digits/million"); num = num % 1000000; } else { - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + ast_log(LOG_WARNING, "Number '%d' is too big\n", num); res = -1; } if (!res) { @@ -1450,7 +1450,7 @@ else snprintf(fn, sizeof(fn), "digits/millions"); } else { - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + ast_log(LOG_WARNING, "Number '%d' is too big\n", num); res = -1; } } @@ -1526,7 +1526,7 @@ num = num % 1000000; snprintf(fn, sizeof(fn), "digits/million"); } else { - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + ast_log(LOG_WARNING, "Number '%d' is too big\n", num); res = -1; } } @@ -1621,7 +1621,7 @@ if (num && num < 100) playa++; } else { - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + ast_log(LOG_WARNING, "Number '%d' is too big\n", num); res = -1; } @@ -1672,7 +1672,8 @@ { 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); @@ -2080,7 +2081,7 @@ num = num % 1000000; snprintf(fn, sizeof(fn), "digits/million"); } else { - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + ast_log(LOG_WARNING, "Number '%d' is too big\n", num); res = -1; } } @@ -2145,7 +2146,7 @@ num = num % 1000000; snprintf(fn, sizeof(fn), "digits/million"); } else { - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + ast_log(LOG_WARNING, "Number '%d' is too big\n", num); res = -1; } } @@ -2254,7 +2255,7 @@ } num %= 1000000; } else { - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + ast_log(LOG_WARNING, "Number '%d' is too big\n", num); res = -1; } if (!res) { @@ -2374,7 +2375,7 @@ snprintf(fn, sizeof(fn), "digits/h-last"); num = 0; } else { - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + ast_log(LOG_WARNING, "Number '%d' is too big\n", num); res = -1; } @@ -2527,7 +2528,7 @@ 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); + ast_log(LOG_WARNING, "Number '%d' is too big\n", num); res = -1; } @@ -2690,7 +2691,7 @@ 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); + ast_log(LOG_WARNING, "Number '%d' is too big\n", num); res = -1; } @@ -2987,7 +2988,8 @@ 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 '\'': @@ -3224,7 +3226,8 @@ 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 '\'': @@ -3424,7 +3427,8 @@ 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 '\'': @@ -3649,7 +3653,8 @@ 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 '\'': @@ -3827,7 +3832,8 @@ 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 '\'': @@ -4012,7 +4018,8 @@ 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 '\'': @@ -4210,7 +4217,8 @@ 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 '\'': @@ -4438,7 +4446,8 @@ 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 '\'': @@ -4666,7 +4675,8 @@ 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 '\'': @@ -4884,7 +4894,8 @@ 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 '\'': @@ -5849,7 +5860,7 @@ num = num % 1000000; snprintf(fn, sizeof(fn), "digits/millions"); } else { - ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num); + ast_log(LOG_WARNING, "Number '%d' is too big\n", num); res = -1; } } @@ -6010,7 +6021,8 @@ 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 '\'': Index: enum.c =================================================================== --- enum.c (revision 7745) +++ enum.c (working copy) @@ -491,7 +491,8 @@ 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)); ret = 0; } @@ -600,7 +601,8 @@ 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)); ret = 0; } if (chan) Index: pbx.c =================================================================== --- pbx.c (revision 7745) +++ pbx.c (working copy) @@ -1495,7 +1495,8 @@ /* Evaluate function */ cp4 = ast_func_read(c, vars, workspace, VAR_BUF_SIZE); - 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); @@ -1562,7 +1563,8 @@ 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; } @@ -1650,7 +1652,8 @@ c->priority = priority; pbx_substitute_variables(passdata, sizeof(passdata), c, e); if (option_debug) { - ast_log(LOG_DEBUG, "Launching '%s'\n", app->name); + if (option_debug) + ast_log(LOG_DEBUG, "Launching '%s'\n", app->name); snprintf(atmp, 80, "STACK-%s-%s-%d", context, exten, priority); snprintf(atmp2, EXT_DATA_SIZE+100, "%s(\"%s\", \"%s\") %s", app->name, c->name, passdata, (newstack ? "in new stack" : "in same stack")); pbx_builtin_setvar_helper(c, atmp, atmp2); @@ -2062,8 +2065,7 @@ list = calloc(1, sizeof(struct ast_hint)); if (!list) { ast_mutex_unlock(&hintlock); - if (option_debug > 1) - ast_log(LOG_DEBUG, "HINTS: Out of memory...\n"); + ast_log(LOG_WARNING, "HINTS: Out of memory...\n"); return -1; } /* Initialize and insert new item at the top */ Index: res/res_monitor.c =================================================================== --- res/res_monitor.c (revision 7745) +++ res/res_monitor.c (working copy) @@ -47,6 +47,7 @@ #include "asterisk/app.h" #include "asterisk/utils.h" #include "asterisk/config.h" +#include "asterisk/options.h" AST_MUTEX_DEFINE_STATIC(monitorlock); @@ -199,7 +200,8 @@ /* so we know this call has been monitored in case we need to bill for it or something */ pbx_builtin_setvar_helper(chan, "__MONITORED","true"); } else { - ast_log(LOG_DEBUG,"Cannot start monitoring %s, already monitored\n", + if (option_debug) + ast_log(LOG_DEBUG,"Cannot start monitoring %s, already monitored\n", chan->name); res = -1; } @@ -279,7 +281,8 @@ snprintf(tmp2,sizeof(tmp2), "( %s& rm -f \"%s/%s-\"* ) &",tmp, dir ,name); /* remove legs when done mixing */ ast_copy_string(tmp, tmp2, sizeof(tmp)); } - ast_log(LOG_DEBUG,"monitor executing %s\n",tmp); + if (option_debug) + ast_log(LOG_DEBUG,"monitor executing %s\n",tmp); if (ast_safe_system(tmp) == -1) ast_log(LOG_WARNING, "Execute of %s failed.\n",tmp); } Index: res/res_features.c =================================================================== --- res/res_features.c (revision 7745) +++ res/res_features.c (working copy) @@ -682,7 +682,8 @@ struct ast_frame *f = NULL; struct ast_bridge_thread_obj *tobj; - ast_log(LOG_DEBUG, "Executing Attended Transfer %s, %s (sense=%d) XXX\n", chan->name, peer->name, sense); + if (option_debug) + ast_log(LOG_DEBUG, "Executing Attended Transfer %s, %s (sense=%d) XXX\n", chan->name, peer->name, sense); if (sense == FEATURE_SENSE_PEER) { transferer = peer; transferee = chan; @@ -991,7 +992,8 @@ ast_copy_flags(&features, &(config->features_caller), AST_FLAGS_ALL); else ast_copy_flags(&features, &(config->features_callee), AST_FLAGS_ALL); - ast_log(LOG_DEBUG, "Feature interpret: chan=%s, peer=%s, sense=%d, features=%d\n", chan->name, peer->name, sense, features.flags); + if (option_debug) + ast_log(LOG_DEBUG, "Feature interpret: chan=%s, peer=%s, sense=%d, features=%d\n", chan->name, peer->name, sense, features.flags); for (x=0; x < FEATURES_COUNT; x++) { if ((ast_test_flag(&features, builtin_features[x].feature_mask)) && @@ -1331,7 +1333,8 @@ activated, but that's no excuse to keep things going indefinitely! */ if (backup_config.feature_timer && ((backup_config.feature_timer -= diff) <= 0)) { - ast_log(LOG_DEBUG, "Timed out, realtime this time!\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Timed out, realtime this time!\n"); config->feature_timer = 0; who = chan; if (f) @@ -1341,7 +1344,8 @@ } else if (config->feature_timer <= 0) { /* Not *really* out of time, just out of time for digits to come in for features. */ - ast_log(LOG_DEBUG, "Timed out for feature!\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Timed out for feature!\n"); if (!ast_strlen_zero(peer_featurecode)) { ast_dtmf_stream(chan, peer, peer_featurecode, 0); memset(peer_featurecode, 0, sizeof(peer_featurecode)); @@ -1466,7 +1470,8 @@ config->firstpass = 0; } config->feature_timer = featuredigittimeout; - ast_log(LOG_DEBUG, "Set time limit to %ld\n", config->feature_timer); + if (option_debug) + ast_log(LOG_DEBUG, "Set time limit to %ld\n", config->feature_timer); } } if (f) @@ -1618,7 +1623,8 @@ /* XXX Maybe we could do something with packets, like dial "0" for operator or something XXX */ ast_frfree(f); if (pu->moh_trys < 3 && !pu->chan->generatordata) { - ast_log(LOG_DEBUG, "MOH on parked call stopped by outside source. Restarting.\n"); + if (option_debug) + ast_log(LOG_DEBUG, "MOH on parked call stopped by outside source. Restarting.\n"); ast_moh_start(pu->chan, NULL); pu->moh_trys++; } @@ -2120,7 +2126,8 @@ /* Remove the old parking extension */ if (!ast_strlen_zero(old_parking_con) && (con = ast_context_find(old_parking_con))) { ast_context_remove_extension2(con, old_parking_ext, 1, registrar); - ast_log(LOG_DEBUG, "Removed old parking extension %s@%s\n", old_parking_ext, old_parking_con); + if (option_debug) + ast_log(LOG_DEBUG, "Removed old parking extension %s@%s\n", old_parking_ext, old_parking_con); } if (!(con = ast_context_find(parking_con))) { Index: res/res_adsi.c =================================================================== --- res/res_adsi.c (revision 7745) +++ res/res_adsi.c (working copy) @@ -47,6 +47,7 @@ #include "asterisk/module.h" #include "asterisk/config.h" #include "asterisk/file.h" +#include "asterisk/options.h" #define DEFAULT_ADSI_MAX_RETRIES 3 @@ -225,7 +226,8 @@ for(;;) { if (((res = ast_waitfor(chan, waittime)) < 1)) { /* Didn't get back DTMF A in time */ - ast_log(LOG_DEBUG, "No ADSI CPE detected (%d)\n", res); + if (option_debug) + ast_log(LOG_DEBUG, "No ADSI CPE detected (%d)\n", res); if (!chan->adsicpe) chan->adsicpe = AST_ADSI_UNAVAILABLE; errno = ENOSYS; @@ -234,7 +236,8 @@ waittime = res; f = ast_read(chan); if (!f) { - ast_log(LOG_DEBUG, "Hangup in ADSI\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Hangup in ADSI\n"); return -1; } if (f->frametype == AST_FRAME_DTMF) { @@ -245,7 +248,8 @@ break; } else { if (f->subclass == 'D') { - ast_log(LOG_DEBUG, "Off-hook capable CPE only, not ADSI\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Off-hook capable CPE only, not ADSI\n"); } else ast_log(LOG_WARNING, "Unknown ADSI response '%c'\n", f->subclass); if (!chan->adsicpe) @@ -257,9 +261,11 @@ ast_frfree(f); } - ast_log(LOG_DEBUG, "ADSI Compatible CPE Detected\n"); + if (option_debug) + ast_log(LOG_DEBUG, "ADSI Compatible CPE Detected\n"); } else - ast_log(LOG_DEBUG, "Already in data mode\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Already in data mode\n"); x = 0; pos = 0; @@ -272,7 +278,8 @@ ast_log(LOG_WARNING, "Failed to generate ADSI message %d on channel %s\n", x + 1, chan->name); return -1; } - ast_log(LOG_DEBUG, "Message %d, of %d input bytes, %d output bytes\n", + if (option_debug) + ast_log(LOG_DEBUG, "Message %d, of %d input bytes, %d output bytes\n", x + 1, msglen[x], res); pos += res; x++; @@ -286,7 +293,8 @@ if (res) return -1; - ast_log(LOG_DEBUG, "Sent total spill of %d bytes\n", pos); + if (option_debug) + ast_log(LOG_DEBUG, "Sent total spill of %d bytes\n", pos); memset(ack, 0, sizeof(ack)); /* Get real result */ @@ -295,13 +303,15 @@ if (res < 0) return -1; if (ack[0] == 'D') { - ast_log(LOG_DEBUG, "Acked up to message %d\n", atoi(ack + 1)); + if (option_debug > 2) + ast_log(LOG_DEBUG, "Acked up to message %d\n", atoi(ack + 1)); start += atoi(ack + 1); if (start >= x) break; else { retries++; - ast_log(LOG_DEBUG, "Retransmitting (%d), from %d\n", retries, start + 1); + if (option_debug > 2) + ast_log(LOG_DEBUG, "Retransmitting (%d), from %d\n", retries, start + 1); } } else { retries++; @@ -332,7 +342,7 @@ return -1; if (ack[0] == 'B') return 0; - ast_log(LOG_DEBUG, "Download was denied by CPE\n"); + ast_log(LOG_ERROR, "Download was denied by CPE\n"); return -1; } @@ -367,13 +377,15 @@ for (x=0;x 2) + ast_log(LOG_DEBUG, "Switch to data is sent!\n"); waitforswitch++; newdatamode = ADSI_FLAG_DATAMODE; } if (msg[x] == ADSI_SWITCH_TO_VOICE) { - ast_log(LOG_DEBUG, "Switch to voice is sent!\n"); + if (option_debug > 2) + ast_log(LOG_DEBUG, "Switch to voice is sent!\n"); waitforswitch++; newdatamode = 0; } @@ -406,7 +418,8 @@ res = __adsi_transmit_messages(chan, msgs, msglens, msgtypes); if (dowait) { - ast_log(LOG_DEBUG, "Wait for switch is '%d'\n", waitforswitch); + if (option_debug > 2) + ast_log(LOG_DEBUG, "Wait for switch is '%d'\n", waitforswitch); while(waitforswitch-- && ((res = ast_waitfordigit(chan, 1000)) > 0)) { res = 0; ast_log(LOG_DEBUG, "Waiting for 'B'...\n"); } } @@ -989,14 +1002,17 @@ if (res < 0) return -1; if (res) { - ast_log(LOG_DEBUG, "No response from CPE about version. Assuming not there.\n"); + if (option_debug) + ast_log(LOG_DEBUG, "No response from CPE about version. Assuming not there.\n"); return 0; } if (!strcmp(resp, "B")) { - ast_log(LOG_DEBUG, "CPE has script '%s' version %d already loaded\n", app, ver); + if (option_debug) + ast_log(LOG_DEBUG, "CPE has script '%s' version %d already loaded\n", app, ver); return 1; } else if (!strcmp(resp, "A")) { - ast_log(LOG_DEBUG, "CPE hasn't script '%s' version %d already loaded\n", app, ver); + if (option_debug) + ast_log(LOG_DEBUG, "CPE hasn't script '%s' version %d already loaded\n", app, ver); } else { ast_log(LOG_WARNING, "Unexpected CPE response to script query: %s\n", resp); } Index: res/res_agi.c =================================================================== --- res/res_agi.c (revision 7745) +++ res/res_agi.c (working copy) @@ -1847,7 +1847,8 @@ /* Idle the channel until we get a command */ f = ast_read(c); if (!f) { - ast_log(LOG_DEBUG, "%s hungup\n", chan->name); + if (option_debug) + ast_log(LOG_DEBUG, "%s hungup\n", chan->name); returnstatus = -1; break; } else { Index: res/res_crypto.c =================================================================== --- res/res_crypto.c (revision 7745) +++ res/res_crypto.c (working copy) @@ -432,7 +432,8 @@ res = RSA_verify(NID_sha1, digest, sizeof(digest), (unsigned char *)dsig, 128, key->rsa); if (!res) { - ast_log(LOG_DEBUG, "Key failed verification: %s\n", key->name); + if (option_debug) + ast_log(LOG_DEBUG, "Key failed verification: %s\n", key->name); return -1; } /* Pass */ @@ -486,7 +487,8 @@ while(key) { nkey = key->next; if (key->delme) { - ast_log(LOG_DEBUG, "Deleting key %s type %d\n", key->name, key->ktype); + if (option_debug) + ast_log(LOG_DEBUG, "Deleting key %s type %d\n", key->name, key->ktype); /* Do the delete */ if (last) last->next = nkey; Index: res/res_osp.c =================================================================== --- res/res_osp.c (revision 7745) +++ res/res_osp.c (working copy) @@ -140,7 +140,8 @@ osp->retrylimit = OSP_DEFAULT_RETRY_LIMIT; osp->timeout = OSP_DEFAULT_TIMEOUT; osp->source[0] = '\0'; - ast_log(LOG_DEBUG, "Building OSP Provider '%s'\n", cat); + if (option_debug) + ast_log(LOG_DEBUG, "Building OSP Provider '%s'\n", cat); v = ast_variable_browse(cfg, cat); while(v) { if (!strcasecmp(v->name, "privatekey")) { @@ -205,7 +206,8 @@ ast_mutex_lock(&osplock); osp->dead = 0; if (osp->handle > -1) { - ast_log(LOG_DEBUG, "Deleting old handle for '%s'\n", osp->name); + if (option_debug) + ast_log(LOG_DEBUG, "Deleting old handle for '%s'\n", osp->name); OSPPProviderDelete(osp->handle, 0); } Index: res/res_musiconhold.c =================================================================== --- res/res_musiconhold.c (revision 7745) +++ res/res_musiconhold.c (working copy) @@ -523,7 +523,7 @@ kill(class->pid, SIGKILL); class->pid = 0; } - } else + } else if (option_debug) ast_log(LOG_DEBUG, "Read %d bytes of audio while expecting %d\n", res2, len); continue; } @@ -794,7 +794,8 @@ ast_mutex_lock(&moh_lock); if (get_mohbyname(moh->name)) { if (reload) { - ast_log(LOG_DEBUG, "Music on Hold class '%s' left alone from initial load.\n", moh->name); + if (option_debug) + ast_log(LOG_DEBUG, "Music on Hold class '%s' left alone from initial load.\n", moh->name); } else { ast_log(LOG_WARNING, "Music on Hold class '%s' already exists\n", moh->name); } @@ -1070,7 +1071,8 @@ while (moh) { if (moh->pid) { - ast_log(LOG_DEBUG, "killing %d!\n", moh->pid); + if (option_debug) + ast_log(LOG_DEBUG, "MOH killing pid %d!\n", moh->pid); stime = time(NULL) + 2; pid = moh->pid; moh->pid = 0; @@ -1078,7 +1080,8 @@ while ((ast_wait_for_input(moh->srcfd, 100) > 0) && (bytes = read(moh->srcfd, buff, 8192)) && time(NULL) < stime) { tbytes = tbytes + bytes; } - ast_log(LOG_DEBUG, "mpg123 pid %d and child died after %d bytes read\n", pid, tbytes); + if (option_debug) + ast_log(LOG_DEBUG, "mpg123 pid %d and child died after %d bytes read\n", pid, tbytes); close(moh->srcfd); } tmp = moh; Index: file.c =================================================================== --- file.c (revision 7745) +++ file.c (working copy) @@ -206,7 +206,8 @@ /* XXX Support other video formats XXX */ const char *type = "h263"; 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); @@ -801,7 +802,7 @@ fs = ast_openstream(chan, filename, preflang); vfs = ast_openvstream(chan, filename, preflang); - if (vfs) + if (option_debug && vfs) ast_log(LOG_DEBUG, "Ooh, found a video stream, too\n"); if (fs){ if (ast_applystream(chan, fs)) @@ -1004,9 +1005,8 @@ } else if (res > 0) { fr = ast_read(c); if (!fr) { -#if 0 - ast_log(LOG_DEBUG, "Got hung up\n"); -#endif + if (option_debug > 3) + ast_log(LOG_DEBUG, "Got hung up\n"); return -1; } @@ -1068,9 +1068,8 @@ if (res > 0) { fr = ast_read(c); if (!fr) { -#if 0 - ast_log(LOG_DEBUG, "Got hung up\n"); -#endif + if (option_debug > 3) + ast_log(LOG_DEBUG, "Got hung up\n"); return -1; } @@ -1141,9 +1140,8 @@ } else if (rchan) { fr = ast_read(c); if (!fr) { -#if 0 - ast_log(LOG_DEBUG, "Got hung up\n"); -#endif + if (option_debug > 3) + ast_log(LOG_DEBUG, "Got hung up\n"); return -1; } @@ -1205,9 +1203,8 @@ } else if (res > 0) { fr = ast_read(c); if (!fr) { -#if 0 - ast_log(LOG_DEBUG, "Got hung up\n"); -#endif + if (option_debug > 3) + ast_log(LOG_DEBUG, "Got hung up\n"); return -1; } Index: callerid.c =================================================================== --- callerid.c (revision 7745) +++ callerid.c (working copy) @@ -43,6 +43,7 @@ #include "asterisk/logger.h" #include "asterisk/fskmodem.h" #include "asterisk/utils.h" +#include "asterisk/options.h" struct callerid_state { fsk_data fskd; @@ -179,7 +180,8 @@ number[0] = 0; if (strlen(cidstring) < 2) { - ast_log(LOG_DEBUG, "No cid detected\n"); + if (option_debug) + ast_log(LOG_DEBUG, "No cid detected\n"); *flags = CID_UNKNOWN_NUMBER; return; } @@ -192,7 +194,7 @@ *flags = CID_UNKNOWN_NUMBER; else if (code == 10) *flags = CID_PRIVATE_NUMBER; - else + else if (option_debug) ast_log(LOG_DEBUG, "Unknown DTMF code %d\n", code); } else if (cidstring[0] == 'D' && cidstring[2] == '#') { /* .DK special code */ @@ -207,9 +209,8 @@ break; if (isdigit(cidstring[i])) number[i-1] = cidstring[i]; - else - ast_log(LOG_DEBUG, "Unknown CID digit '%c'\n", - cidstring[i]); + else if (option_debug) + ast_log(LOG_DEBUG, "Unknown CID digit '%c'\n", cidstring[i]); } number[i-1] = 0; } else if (isdigit(cidstring[0])) { @@ -225,8 +226,8 @@ } number[i] = 0; } else { - ast_log(LOG_DEBUG, "Unknown CID protocol, start digit '%c'\n", - cidstring[0]); + if (option_debug) + ast_log(LOG_DEBUG, "Unknown CID protocol, start digit '%c'\n", cidstring[0]); *flags = CID_UNKNOWN_NUMBER; } } Index: cdr/cdr_pgsql.c =================================================================== --- cdr/cdr_pgsql.c (revision 7745) +++ cdr/cdr_pgsql.c (working copy) @@ -118,7 +118,8 @@ return -1; } - ast_log(LOG_DEBUG,"cdr_pgsql: inserting a CDR record.\n"); + if (option_debug) + ast_log(LOG_DEBUG,"cdr_pgsql: inserting a CDR record.\n"); snprintf(sqlcmd,sizeof(sqlcmd),"INSERT INTO %s (calldate,clid,src,dst,dcontext,channel,dstchannel," "lastapp,lastdata,duration,billsec,disposition,amaflags,accountcode,uniqueid,userfield) VALUES" @@ -126,7 +127,8 @@ table,timestr,clid,cdr->src, cdr->dst, dcontext,channel, dstchannel, lastapp, lastdata, cdr->duration,cdr->billsec,ast_cdr_disp2str(cdr->disposition),cdr->amaflags, cdr->accountcode, uniqueid, userfield); - ast_log(LOG_DEBUG,"cdr_pgsql: SQL command executed: %s\n",sqlcmd); + if (option_debug > 1) + ast_log(LOG_DEBUG,"cdr_pgsql: SQL command executed: %s\n",sqlcmd); /* Test to be sure we're still connected... */ /* If we're connected, and connection is working, good. */ @@ -280,18 +282,21 @@ return -1; } - ast_log(LOG_DEBUG,"cdr_pgsql: got hostname of %s\n",pghostname); - ast_log(LOG_DEBUG,"cdr_pgsql: got port of %s\n",pgdbport); - if (pgdbsock) - ast_log(LOG_DEBUG,"cdr_pgsql: got sock file of %s\n",pgdbsock); - ast_log(LOG_DEBUG,"cdr_pgsql: got user of %s\n",pgdbuser); - ast_log(LOG_DEBUG,"cdr_pgsql: got dbname of %s\n",pgdbname); - ast_log(LOG_DEBUG,"cdr_pgsql: got password of %s\n",pgpassword); - ast_log(LOG_DEBUG,"cdr_pgsql: got sql table name of %s\n",table); + if (option_debug ) { + ast_log(LOG_DEBUG,"cdr_pgsql: got hostname of %s\n",pghostname); + ast_log(LOG_DEBUG,"cdr_pgsql: got port of %s\n",pgdbport); + if (pgdbsock) + ast_log(LOG_DEBUG,"cdr_pgsql: got sock file of %s\n",pgdbsock); + ast_log(LOG_DEBUG,"cdr_pgsql: got user of %s\n",pgdbuser); + ast_log(LOG_DEBUG,"cdr_pgsql: got dbname of %s\n",pgdbname); + ast_log(LOG_DEBUG,"cdr_pgsql: got password of %s\n",pgpassword); + ast_log(LOG_DEBUG,"cdr_pgsql: got sql table name of %s\n",table); + } conn = PQsetdbLogin(pghostname, pgdbport, NULL, NULL, pgdbname, pgdbuser, pgpassword); if (PQstatus(conn) != CONNECTION_BAD) { - ast_log(LOG_DEBUG,"Successfully connected to PostgreSQL database.\n"); + if (option_debug) + ast_log(LOG_DEBUG,"Successfully connected to PostgreSQL database.\n"); connected = 1; } else { pgerror = PQerrorMessage(conn); Index: cdr/cdr_odbc.c =================================================================== --- cdr/cdr_odbc.c (revision 7745) +++ cdr/cdr_odbc.c (working copy) @@ -305,26 +305,28 @@ tmp = ast_variable_retrieve(cfg,"global","loguniqueid"); if (tmp) { loguniqueid = ast_true(tmp); - if (loguniqueid) { + if (option_debug && loguniqueid) { ast_log(LOG_DEBUG,"cdr_odbc: Logging uniqueid\n"); } else { ast_log(LOG_DEBUG,"cdr_odbc: Not logging uniqueid\n"); } } else { - ast_log(LOG_DEBUG,"cdr_odbc: Not logging uniqueid\n"); + if (option_debug) + ast_log(LOG_DEBUG,"cdr_odbc: Not logging uniqueid\n"); loguniqueid = 0; } tmp = ast_variable_retrieve(cfg,"global","usegmtime"); if (tmp) { usegmtime = ast_true(tmp); - if (usegmtime) { + if (option_debug && usegmtime) { ast_log(LOG_DEBUG,"cdr_odbc: Logging in GMT\n"); } else { ast_log(LOG_DEBUG,"cdr_odbc: Not logging in GMT\n"); } } else { - ast_log(LOG_DEBUG,"cdr_odbc: Not logging in GMT\n"); + if (option_debug) + ast_log(LOG_DEBUG,"cdr_odbc: Not logging in GMT\n"); usegmtime = 0; } Index: formats/format_ogg_vorbis.c =================================================================== --- formats/format_ogg_vorbis.c (revision 7745) +++ formats/format_ogg_vorbis.c (working copy) @@ -214,11 +214,14 @@ ptr = tmp->vc.user_comments; while(*ptr){ - ast_log(LOG_DEBUG, "OGG/Vorbis comment: %s\n", *ptr); + if (option_debug > 1) + ast_log(LOG_DEBUG, "OGG/Vorbis comment: %s\n", *ptr); ++ptr; } - ast_log(LOG_DEBUG, "OGG/Vorbis bitstream is %d channel, %ldHz\n", tmp->vi.channels, tmp->vi.rate); - ast_log(LOG_DEBUG, "OGG/Vorbis file encoded by: %s\n", tmp->vc.vendor); + if (option_debug > 1) { + ast_log(LOG_DEBUG, "OGG/Vorbis bitstream is %d channel, %ldHz\n", tmp->vi.channels, tmp->vi.rate); + ast_log(LOG_DEBUG, "OGG/Vorbis file encoded by: %s\n", tmp->vc.vendor); + } if(tmp->vi.channels != 1) { ast_log(LOG_ERROR, "Only monophonic OGG/Vorbis files are currently supported!\n");