Index: main/pbx.c =================================================================== --- main/pbx.c (revision 51180) +++ main/pbx.c (working copy) @@ -1619,7 +1619,8 @@ /* Evaluate function */ cp4 = ast_func_read(c, vars, workspace, VAR_BUF_SIZE) ? NULL : workspace; - ast_log(LOG_DEBUG, "Function result is '%s'\n", cp4 ? cp4 : "(null)"); + if (option_debug) + ast_log(LOG_DEBUG, "Function result is '%s'\n", cp4 ? cp4 : "(null)"); } else { /* Retrieve variable value */ pbx_retrieve_variable(c, vars, &cp4, workspace, VAR_BUF_SIZE, headp); @@ -1686,7 +1687,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; } @@ -1822,7 +1824,8 @@ ast_log(LOG_NOTICE, "No such label '%s' in extension '%s' in context '%s'\n", label, exten, context); break; default: - ast_log(LOG_DEBUG, "Shouldn't happen!\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Shouldn't happen!\n"); } return (matching_action) ? 0 : -1; @@ -2346,7 +2349,8 @@ if ((res = ast_spawn_extension(c, c->context, c->exten, c->priority, c->cid.cid_num))) { /* Something bad happened, or a hangup has been requested. */ if (strchr("0123456789ABCDEF*#", res)) { - ast_log(LOG_DEBUG, "Oooh, got something to jump out with ('%c')!\n", res); + if (option_debug) + ast_log(LOG_DEBUG, "Oooh, got something to jump out with ('%c')!\n", res); pos = 0; dst_exten[pos++] = digit = res; dst_exten[pos] = '\0'; @@ -2381,8 +2385,9 @@ c->whentohangup = 0; c->_softhangup &= ~AST_SOFTHANGUP_TIMEOUT; } else if (c->_softhangup) { - ast_log(LOG_DEBUG, "Extension %s, priority %d returned normally even though call was hung up\n", - c->exten, c->priority); + if (option_debug) + ast_log(LOG_DEBUG, "Extension %s, priority %d returned normally even though call was hung up\n", + c->exten, c->priority); error = 1; break; } @@ -3896,7 +3901,8 @@ tmp = *extcontexts; if (registrar) { /* XXX remove previous contexts from same registrar */ - ast_log(LOG_DEBUG, "must remove any reg %s\n", registrar); + if (option_debug) + ast_log(LOG_DEBUG, "must remove any reg %s\n", registrar); __ast_context_destroy(NULL,registrar); while (tmp) { lasttmp = tmp; @@ -4785,11 +4791,13 @@ } if (option_debug) { if (tmp->matchcid) { - ast_log(LOG_DEBUG, "Added extension '%s' priority %d (CID match '%s') to %s\n", - tmp->exten, tmp->priority, tmp->cidmatch, con->name); + if (option_debug) + ast_log(LOG_DEBUG, "Added extension '%s' priority %d (CID match '%s') to %s\n", + tmp->exten, tmp->priority, tmp->cidmatch, con->name); } else { - ast_log(LOG_DEBUG, "Added extension '%s' priority %d to %s\n", - tmp->exten, tmp->priority, con->name); + if (option_debug) + ast_log(LOG_DEBUG, "Added extension '%s' priority %d to %s\n", + tmp->exten, tmp->priority, con->name); } } if (option_verbose > 2) { @@ -5225,7 +5233,8 @@ for (tmp = contexts; tmp; ) { struct ast_context *next; /* next starting point */ for (; tmp; tmpl = tmp, tmp = tmp->next) { - ast_log(LOG_DEBUG, "check ctx %s %s\n", tmp->name, tmp->registrar); + if (option_debug) + ast_log(LOG_DEBUG, "check ctx %s %s\n", tmp->name, tmp->registrar); if ( (!registrar || !strcasecmp(registrar, tmp->registrar)) && (!con || !strcasecmp(tmp->name, con->name)) ) break; /* found it */ @@ -5233,7 +5242,8 @@ if (!tmp) /* not found, we are done */ break; ast_mutex_lock(&tmp->lock); - ast_log(LOG_DEBUG, "delete ctx %s %s\n", tmp->name, tmp->registrar); + if (option_debug) + ast_log(LOG_DEBUG, "delete ctx %s %s\n", tmp->name, tmp->registrar); next = tmp->next; if (tmpl) tmpl->next = next; @@ -5927,7 +5937,8 @@ branch = pbx_checkcondition(condition) ? branch1 : branch2; if (ast_strlen_zero(branch)) { - ast_log(LOG_DEBUG, "Not taking any branch\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Not taking any branch\n"); return 0; }