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