Add some more checks for option_debug before ast_log(LOG_DEBUG, ...) calls.

Issue 8832, patch(es) by tgrman


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@51265 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Jason Parker
2007-01-18 22:50:23 +00:00
parent eedd121fbc
commit 76eb4e76dc
5 changed files with 212 additions and 113 deletions

View File

@@ -1956,11 +1956,13 @@ static void make_email_file(FILE *p, char *srcemail, struct ast_vm_user *vmu, in
create_dirpath(tmpdir, sizeof(tmpdir), vmu->context, vmu->mailbox, "tmp");
snprintf(newtmp, sizeof(newtmp), "%s/XXXXXX", tmpdir);
tmpfd = mkstemp(newtmp);
if (option_debug > 2)
ast_log(LOG_DEBUG, "newtmp: %s\n", newtmp);
if (vmu->volgain < -.001 || vmu->volgain > .001) {
snprintf(tmpcmd, sizeof(tmpcmd), "sox -v %.4f %s.%s %s.%s", vmu->volgain, attach, format, newtmp, format);
ast_safe_system(tmpcmd);
attach = newtmp;
if (option_debug > 2)
ast_log(LOG_DEBUG, "VOLGAIN: Stored at: %s.%s - Level: %.4f - Mailbox: %s\n", attach, format, vmu->volgain, mailbox);
}
fprintf(p, "--%s\r\n", bound);
@@ -1998,6 +2000,7 @@ static int sendmail(char *srcemail, struct ast_vm_user *vmu, int msgnum, char *c
}
if (!strcmp(format, "wav49"))
format = "WAV";
if (option_debug > 2)
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 */
@@ -2009,6 +2012,7 @@ static int sendmail(char *srcemail, struct ast_vm_user *vmu, int msgnum, char *c
fclose(p);
snprintf(tmp2, sizeof(tmp2), "( %s < %s ; rm -f %s ) &", mailcmd, tmp, tmp);
ast_safe_system(tmp2);
if (option_debug > 2)
ast_log(LOG_DEBUG, "Sent mail to %s with command '%s'\n", vmu->email, mailcmd);
}
return 0;
@@ -2092,6 +2096,7 @@ static int sendpage(char *srcemail, char *pager, int msgnum, char *context, char
fclose(p);
snprintf(tmp2, sizeof(tmp2), "( %s < %s ; rm -f %s ) &", mailcmd, tmp, tmp);
ast_safe_system(tmp2);
if (option_debug > 2)
ast_log(LOG_DEBUG, "Sent page to %s with command '%s'\n", pager, mailcmd);
}
return 0;
@@ -2764,6 +2769,7 @@ static void run_externnotify(char *context, char *extension)
ast_log(LOG_WARNING, "The switch reported '%s'\n", mwi_msg->cause);
ASTOBJ_UNREF(mwi_msg, ast_smdi_mwi_message_destroy);
} else {
if (option_debug)
ast_log(LOG_DEBUG, "Successfully executed SMDI MWI change for %s on %s\n", extension, smdi_iface->name);
}
} else if (!ast_strlen_zero(externnotify)) {
@@ -2771,6 +2777,7 @@ static void run_externnotify(char *context, char *extension)
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);
if (option_debug)
ast_log(LOG_DEBUG, "Executing %s\n", arguments);
ast_safe_system(arguments);
}
@@ -2896,11 +2903,13 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_
if (ast_streamfile(chan, prefile, chan->language) > -1)
res = ast_waitstream(chan, ecodes);
} else {
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) {
if (option_debug)
ast_log(LOG_DEBUG, "Hang up during prefile playback\n");
free_user(vmu);
pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED");
@@ -3351,6 +3360,7 @@ static int adsi_load_vmail(struct ast_channel *chan, int *useadsi)
bytes += ast_adsi_voice_mode(buf + bytes, 0);
ast_adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DOWNLOAD);
if (option_debug)
ast_log(LOG_DEBUG, "Done downloading scripts...\n");
#ifdef DISPLAY
@@ -3359,6 +3369,7 @@ static int adsi_load_vmail(struct ast_channel *chan, int *useadsi)
bytes += ast_adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, " ......", "");
bytes += ast_adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
#endif
if (option_debug)
ast_log(LOG_DEBUG, "Restarting session...\n");
bytes = 0;
@@ -4252,12 +4263,14 @@ static int play_message_callerid(struct ast_channel *chan, struct vm_state *vms,
return res;
/* Strip off caller ID number from name */
if (option_debug > 2)
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++){
if (option_debug > 2)
ast_log(LOG_DEBUG, "VM-CID: comparing internalcontext: %s\n", cidinternalcontexts[i]);
if ((strcmp(cidinternalcontexts[i], context) == 0))
break;
@@ -4286,6 +4299,7 @@ static int play_message_callerid(struct ast_channel *chan, struct vm_state *vms,
}
else if (!res){
if (option_debug > 2)
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)
@@ -4294,6 +4308,7 @@ static int play_message_callerid(struct ast_channel *chan, struct vm_state *vms,
}
} else {
/* Number unknown */
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");
@@ -4314,6 +4329,7 @@ static int play_message_duration(struct ast_channel *chan, struct vm_state *vms,
durations=atoi(duration);
durationm=(durations / 60);
if (option_debug > 2)
ast_log(LOG_DEBUG, "VM-Duration: duration is: %d seconds converted to: %d minutes\n", durations, durationm);
if ((!res) && (durationm >= minduration)) {
@@ -4613,6 +4629,7 @@ static int init_mailstream(struct vm_state *vms, int box)
if(option_debug > 2)
ast_log (LOG_DEBUG,"vm_state user is:%s\n",vms->imapuser);
if (vms->mailstream == NIL || !vms->mailstream) {
if (option_debug)
ast_log (LOG_DEBUG,"mailstream not set.\n");
} else {
stream = vms->mailstream;
@@ -5684,6 +5701,7 @@ static int vm_newuser(struct ast_channel *chan, struct ast_vm_user *vmu, struct
vm_change_password(vmu,newpassword);
else
vm_change_password_shell(vmu,newpassword);
if (option_debug > 2)
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");
@@ -5786,6 +5804,7 @@ static int vm_options(struct ast_channel *chan, struct ast_vm_user *vmu, struct
vm_change_password(vmu,newpassword);
else
vm_change_password_shell(vmu,newpassword);
if (option_debug > 2)
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;
@@ -6037,6 +6056,7 @@ static int vm_authenticate(struct ast_channel *chan, char *mailbox, int mailbox_
ast_copy_string(mailbox, fullusername, mailbox_size);
}
if (option_debug)
ast_log(LOG_DEBUG, "Before find user for mailbox %s\n",mailbox);
vmu = find_user(&vmus, context, mailbox);
if (vmu && (vmu->password[0] == '\0' || (vmu->password[0] == '-' && vmu->password[1] == '\0'))) {
@@ -6129,6 +6149,7 @@ static int vm_execmain(struct ast_channel *chan, void *data)
memset(&vmus, 0, sizeof(vmus));
if (chan->_state != AST_STATE_UP) {
if (option_debug)
ast_log(LOG_DEBUG, "Before ast_answer\n");
ast_answer(chan);
}
@@ -6211,6 +6232,7 @@ static int vm_execmain(struct ast_channel *chan, void *data)
if (!valid)
res = vm_authenticate(chan, vms.username, sizeof(vms.username), &vmus, context, prefixstr, skipuser, maxlogins, 0);
if (option_debug)
ast_log(LOG_DEBUG, "After vm_authenticate\n");
if (!res) {
valid = 1;
@@ -6246,17 +6268,20 @@ static int vm_execmain(struct ast_channel *chan, void *data)
create_dirpath(vms.curdir, sizeof(vms.curdir), vmu->context, vms.username, "");
#endif
/* Retrieve old and new message counts */
if (option_debug)
ast_log(LOG_DEBUG, "Before open_mailbox\n");
res = open_mailbox(&vms, vmu, 1);
if (res == ERROR_LOCK_PATH)
goto out;
vms.oldmessages = vms.lastmsg + 1;
if (option_debug > 2)
ast_log(LOG_DEBUG, "Number of old messages: %d\n",vms.oldmessages);
/* Start in INBOX */
res = open_mailbox(&vms, vmu, 0);
if (res == ERROR_LOCK_PATH)
goto out;
vms.newmessages = vms.lastmsg + 1;
if (option_debug > 2)
ast_log(LOG_DEBUG, "Number of new messages: %d\n",vms.newmessages);
/* Select proper mailbox FIRST!! */
@@ -6304,6 +6329,7 @@ static int vm_execmain(struct ast_channel *chan, void *data)
if(option_debug > 2)
ast_log(LOG_DEBUG, "Checking quotas: comparing %u to %u\n",vms.quota_usage,vms.quota_limit);
if (vms.quota_limit && vms.quota_usage >= vms.quota_limit) {
if (option_debug)
ast_log(LOG_DEBUG, "*** QUOTA EXCEEDED!!\n");
cmd = ast_play_and_wait(chan, "vm-mailboxfull");
}
@@ -7154,12 +7180,15 @@ static int load_config(void)
if ((notifystr = ast_variable_retrieve(cfg, "general", "externnotify"))) {
ast_copy_string(externnotify, notifystr, sizeof(externnotify));
if (option_debug > 2)
ast_log(LOG_DEBUG, "found externnotify: %s\n", externnotify);
if (!strcasecmp(externnotify, "smdi")) {
if (option_debug)
ast_log(LOG_DEBUG, "Using SMDI for external voicemail notification\n");
if ((smdistr = ast_variable_retrieve(cfg, "general", "smdiport"))) {
smdi_iface = ast_smdi_interface_find(smdistr);
} else {
if (option_debug)
ast_log(LOG_DEBUG, "No SMDI interface set, trying default (/dev/ttyS0)\n");
smdi_iface = ast_smdi_interface_find("/dev/ttyS0");
}
@@ -7168,6 +7197,7 @@ static int load_config(void)
ast_log(LOG_ERROR, "No valid SMDI interface specfied, disabling external voicemail notification\n");
externnotify[0] = '\0';
} else {
if (option_debug > 2)
ast_log(LOG_DEBUG, "Using SMDI port %s\n", smdi_iface->name);
}
}
@@ -7245,6 +7275,7 @@ static int load_config(void)
ast_set2_flag((&globalflags), ast_true(astforcegreet), VM_FORCEGREET);
if ((s = ast_variable_retrieve(cfg, "general", "cidinternalcontexts"))){
if (option_debug > 2)
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++){
@@ -7253,6 +7284,7 @@ static int load_config(void)
while ((*q == ' ')||(*q == '\t')) /* Eat white space between contexts */
q++;
ast_copy_string(cidinternalcontexts[x], q, sizeof(cidinternalcontexts[x]));
if (option_debug > 2)
ast_log(LOG_DEBUG,"VM_CID Internal context %d: %s\n", x, cidinternalcontexts[x]);
} else {
cidinternalcontexts[x][0] = '\0';
@@ -7260,6 +7292,7 @@ static int load_config(void)
}
}
if (!(astreview = ast_variable_retrieve(cfg, "general", "review"))){
if (option_debug)
ast_log(LOG_DEBUG,"VM Review Option disabled globally\n");
astreview = "no";
}
@@ -7267,38 +7300,45 @@ static int load_config(void)
/*Temperary greeting reminder */
if (!(asttempgreetwarn = ast_variable_retrieve(cfg, "general", "tempgreetwarn"))) {
if (option_debug)
ast_log(LOG_DEBUG, "VM Temperary Greeting Reminder Option disabled globally\n");
asttempgreetwarn = "no";
} else {
if (option_debug)
ast_log(LOG_DEBUG, "VM Temperary Greeting Reminder Option enabled globally\n");
}
ast_set2_flag((&globalflags), ast_true(asttempgreetwarn), VM_TEMPGREETWARN);
if (!(astcallop = ast_variable_retrieve(cfg, "general", "operator"))){
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"))) {
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"))){
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"))) {
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"))) {
if (option_debug)
ast_log(LOG_DEBUG,"Duration info before msg enabled globally\n");
astsaydurationinfo = "yes";
}
@@ -7314,6 +7354,7 @@ static int load_config(void)
}
if (!(astskipcmd = ast_variable_retrieve(cfg, "general", "nextaftercmd"))) {
if (option_debug)
ast_log(LOG_DEBUG,"We are not going to skip to the next msg after save/delete\n");
astskipcmd = "no";
}
@@ -7321,6 +7362,7 @@ static int load_config(void)
if ((dialoutcxt = ast_variable_retrieve(cfg, "general", "dialout"))) {
ast_copy_string(dialcontext, dialoutcxt, sizeof(dialcontext));
if (option_debug)
ast_log(LOG_DEBUG, "found dialout context: %s\n", dialcontext);
} else {
dialcontext[0] = '\0';
@@ -7328,6 +7370,7 @@ static int load_config(void)
if ((callbackcxt = ast_variable_retrieve(cfg, "general", "callback"))) {
ast_copy_string(callcontext, callbackcxt, sizeof(callcontext));
if (option_debug)
ast_log(LOG_DEBUG, "found callback context: %s\n", callcontext);
} else {
callcontext[0] = '\0';
@@ -7335,6 +7378,7 @@ static int load_config(void)
if ((exitcxt = ast_variable_retrieve(cfg, "general", "exitcontext"))) {
ast_copy_string(exitcontext, exitcxt, sizeof(exitcontext));
if (option_debug)
ast_log(LOG_DEBUG, "found operator context: %s\n", exitcontext);
} else {
exitcontext[0] = '\0';

View File

@@ -35,6 +35,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include <regex.h>
#include "asterisk/module.h"
#include "asterisk/options.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/logger.h"
@@ -126,6 +127,7 @@ static int regex(struct ast_channel *chan, char *cmd, char *parse, char *buf,
if ((*args.str == ' ') || (*args.str == '\t'))
args.str++;
if (option_debug)
ast_log(LOG_DEBUG, "FUNCTION REGEX (%s)(%s)\n", args.reg, args.str);
if ((errcode = regcomp(&regexbuf, args.reg, REG_EXTENDED | REG_NOSUB))) {
@@ -175,6 +177,7 @@ static int array(struct ast_channel *chan, char *cmd, char *var,
* want them to be surprised by the result. Hence, we prefer commas as the
* delimiter, but we'll fall back to vertical bars if commas aren't found.
*/
if (option_debug)
ast_log(LOG_DEBUG, "array (%s=%s)\n", var, value2);
if (strchr(var, ','))
AST_NONSTANDARD_APP_ARGS(arg1, var, ',');
@@ -187,6 +190,7 @@ static int array(struct ast_channel *chan, char *cmd, char *var,
AST_STANDARD_APP_ARGS(arg2, value2);
for (i = 0; i < arg1.argc; i++) {
if (option_debug)
ast_log(LOG_DEBUG, "array set value (%s=%s)\n", arg1.var[i],
arg2.val[i]);
if (i < arg2.argc) {

View File

@@ -420,6 +420,7 @@ int ast_control_streamfile(struct ast_channel *chan, const char *file,
/* We go at next loop if we got the restart char */
if (restart && strchr(restart, res)) {
if (option_debug)
ast_log(LOG_DEBUG, "we'll restart the stream here at next loop\n");
pause_restart_point = 0;
continue;
@@ -512,6 +513,7 @@ static int __ast_play_and_record(struct ast_channel *chan, const char *playfile,
return -1;
}
if (option_debug)
ast_log(LOG_DEBUG,"play_and_record: %s, %s, '%s'\n", playfile ? playfile : "<None>", recordfile, fmt);
snprintf(comment, sizeof(comment), "Playing %s, Recording to: %s on %s\n", playfile ? playfile : "<None>", recordfile, chan->name);
@@ -533,6 +535,7 @@ static int __ast_play_and_record(struct ast_channel *chan, const char *playfile,
stringp = fmts;
strsep(&stringp, "|");
if (option_debug)
ast_log(LOG_DEBUG, "Recording Formats: sfmts=%s\n", fmts);
sfmt[0] = ast_strdupa(fmts);
@@ -588,6 +591,7 @@ static int __ast_play_and_record(struct ast_channel *chan, const char *playfile,
for (;;) {
res = ast_waitfor(chan, 2000);
if (!res) {
if (option_debug)
ast_log(LOG_DEBUG, "One waitfor failed, trying another\n");
/* Try one more time in case of masq */
res = ast_waitfor(chan, 2000);
@@ -935,6 +939,7 @@ enum AST_LOCK_RESULT ast_lock_path(const char *path)
ast_log(LOG_WARNING, "Failed to lock path '%s': %s\n", path, strerror(errno));
return AST_LOCK_TIMEOUT;
} else {
if (option_debug)
ast_log(LOG_DEBUG, "Locked path '%s'\n", path);
return AST_LOCK_SUCCESS;
}
@@ -954,8 +959,10 @@ int ast_unlock_path(const char *path)
if ((res = unlink(s)))
ast_log(LOG_ERROR, "Could not unlock path '%s': %s\n", path, strerror(errno));
else
else {
if (option_debug)
ast_log(LOG_DEBUG, "Unlocked path '%s'\n", path);
}
return res;
}
@@ -1185,6 +1192,7 @@ static int ast_ivr_menu_run_internal(struct ast_channel *chan, struct ast_ivr_me
while(menu->options[pos].option) {
if (!strcasecmp(menu->options[pos].option, exten)) {
res = ivr_dispatch(chan, menu->options + pos, exten, cbdata);
if (option_debug)
ast_log(LOG_DEBUG, "IVR Dispatch of '%s' (pos %d) yields %d\n", exten, pos, res);
if (res < 0)
break;
@@ -1201,6 +1209,7 @@ static int ast_ivr_menu_run_internal(struct ast_channel *chan, struct ast_ivr_me
if (!maxretries)
maxretries = 3;
if ((maxretries > 0) && (retries >= maxretries)) {
if (option_debug)
ast_log(LOG_DEBUG, "Max retries %d exceeded\n", maxretries);
return -2;
} else {
@@ -1212,6 +1221,7 @@ static int ast_ivr_menu_run_internal(struct ast_channel *chan, struct ast_ivr_me
pos = 0;
continue;
} else if (res && strchr(AST_DIGIT_ANY, res)) {
if (option_debug)
ast_log(LOG_DEBUG, "Got start of extension, %c\n", res);
exten[1] = '\0';
exten[0] = res;
@@ -1219,16 +1229,19 @@ static int ast_ivr_menu_run_internal(struct ast_channel *chan, struct ast_ivr_me
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");
strcpy(exten, "i");
pos = 0;
continue;
} else {
if (option_debug)
ast_log(LOG_DEBUG, "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);
pos = 0;
continue;
@@ -1237,6 +1250,7 @@ static int ast_ivr_menu_run_internal(struct ast_channel *chan, struct ast_ivr_me
}
pos++;
}
if (option_debug)
ast_log(LOG_DEBUG, "Stopping option '%s', res is %d\n", exten, res);
pos = 0;
if (!strcasecmp(exten, "s"))

View File

@@ -878,6 +878,7 @@ int ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin)
ast_log(LOG_WARNING, "Exceptionally long queue length queuing to %s\n", chan->name);
CRASH;
} else {
if (option_debug)
ast_log(LOG_DEBUG, "Dropping voice to exceptionally long queue on %s\n", chan->name);
ast_frfree(f);
ast_channel_unlock(chan);
@@ -1015,6 +1016,7 @@ static struct ast_channel *channel_find_locked(const struct ast_channel *prev,
/* this is slightly unsafe, as we _should_ hold the lock to access c->name */
done = c == NULL || ast_channel_trylock(c) == 0;
if (!done)
if (option_debug)
ast_log(LOG_DEBUG, "Avoiding %s for channel '%p'\n", msg, c);
AST_LIST_UNLOCK(&channels);
if (done)
@@ -1025,6 +1027,7 @@ static struct ast_channel *channel_find_locked(const struct ast_channel *prev,
* c is surely not null, but we don't have the lock so cannot
* access c->name
*/
if (option_debug)
ast_log(LOG_DEBUG, "Failure, could not lock '%p' after %d retries!\n",
c, retries);
@@ -1335,6 +1338,7 @@ int ast_channel_spy_add(struct ast_channel *chan, struct ast_channel_spy *spy)
ast_clear_flag(spy, CHANSPY_TRIGGER_WRITE);
}
if (option_debug)
ast_log(LOG_DEBUG, "Spy %s added to channel %s\n",
spy->type, chan->name);
@@ -1371,6 +1375,7 @@ static void spy_detach(struct ast_channel_spy *spy, struct ast_channel *chan)
}
/* Print it out while we still have a lock so the structure can't go away (if signalled above) */
if (option_debug)
ast_log(LOG_DEBUG, "Spy %s removed from channel %s\n", spy->type, chan->name);
ast_mutex_unlock(&spy->lock);
@@ -1516,6 +1521,7 @@ static void queue_frame_to_spies(struct ast_channel *chan, struct ast_frame *f,
trans->path = NULL;
}
if (!trans->path) {
if (option_debug)
ast_log(LOG_DEBUG, "Building translator from %s to SLINEAR for spies on channel %s\n",
ast_getformatname(f->subclass), chan->name);
if ((trans->path = ast_translator_build_path(AST_FORMAT_SLINEAR, f->subclass)) == NULL) {
@@ -1761,6 +1767,7 @@ static int generator_force(void *data)
res = generate(chan, tmp, 0, 160);
chan->generatordata = tmp;
if (res) {
if (option_debug)
ast_log(LOG_DEBUG, "Auto-deactivating generator\n");
ast_deactivate_generator(chan);
}
@@ -1980,6 +1987,7 @@ int ast_settimeout(struct ast_channel *c, int samples, int (*func)(void *data),
samples = 0;
data = 0;
}
if (option_debug)
ast_log(LOG_DEBUG, "Scheduling timer at %d sample intervals\n", samples);
res = ioctl(c->timingfd, ZT_TIMERCONFIG, &samples);
c->timingfunc = func;
@@ -2185,10 +2193,12 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
case AST_FRAME_CONTROL:
if (f->subclass == AST_CONTROL_ANSWER) {
if (!ast_test_flag(chan, AST_FLAG_OUTGOING)) {
if (option_debug)
ast_log(LOG_DEBUG, "Ignoring answer on an inbound call!\n");
ast_frfree(f);
f = &ast_null_frame;
} else if (prestate == AST_STATE_UP) {
if (option_debug)
ast_log(LOG_DEBUG, "Dropping duplicate answer!\n");
ast_frfree(f);
f = &ast_null_frame;
@@ -2399,6 +2409,7 @@ int ast_indicate_data(struct ast_channel *chan, int condition, const void *data,
break;
}
if (ts && ts->data[0]) {
if (option_debug)
ast_log(LOG_DEBUG, "Driver for channel '%s' does not support indication %d, emulating it\n", chan->name, condition);
ast_playtones_start(chan,0,ts->data, 1);
res = 0;
@@ -2512,6 +2523,7 @@ int ast_senddigit_begin(struct ast_channel *chan, char digit)
ast_playtones_start(chan, 0, dtmf_tones[15], 0);
else {
/* not handled */
if (option_debug)
ast_log(LOG_DEBUG, "Unable to generate DTMF tone '%c' for '%s'\n", digit, chan->name);
}
}
@@ -2548,6 +2560,7 @@ int ast_prod(struct ast_channel *chan)
/* Send an empty audio frame to get things moving */
if (chan->_state != AST_STATE_UP) {
if (option_debug)
ast_log(LOG_DEBUG, "Prodding channel '%s'\n", chan->name);
a.subclass = chan->rawwriteformat;
a.data = nothing + AST_FRIENDLY_OFFSET;
@@ -3193,6 +3206,7 @@ int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clo
return -1;
}
if (option_debug)
ast_log(LOG_DEBUG, "Planning to masquerade channel %s into the structure of %s\n",
clone->name, original->name);
if (original->masq) {
@@ -3206,6 +3220,7 @@ int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clo
clone->masqr = original;
ast_queue_frame(original, &ast_null_frame);
ast_queue_frame(clone, &ast_null_frame);
if (option_debug)
ast_log(LOG_DEBUG, "Done planning to masquerade channel %s into the structure of %s\n", clone->name, original->name);
res = 0;
}
@@ -3565,6 +3580,7 @@ int ast_do_masquerade(struct ast_channel *original)
);
ast_channel_free(clone);
} else {
if (option_debug)
ast_log(LOG_DEBUG, "Released clone lock on '%s'\n", clone->name);
ast_set_flag(clone, AST_FLAG_ZOMBIE);
ast_queue_frame(clone, &ast_null_frame);
@@ -3756,6 +3772,7 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct
if (!f) {
*fo = NULL;
*rc = who;
if (option_debug)
ast_log(LOG_DEBUG, "Didn't get a frame from channel: %s\n",who->name);
break;
}
@@ -3778,6 +3795,7 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct
*fo = f;
*rc = who;
bridge_exit = 1;
if (option_debug)
ast_log(LOG_DEBUG, "Got a FRAME_CONTROL (%d) frame on channel %s\n", f->subclass, who->name);
break;
}
@@ -3800,6 +3818,7 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct
f->frametype == AST_FRAME_DTMF_BEGIN)) {
*fo = f;
*rc = who;
if (option_debug)
ast_log(LOG_DEBUG, "Got DTMF %s on channel (%s)\n",
f->frametype == AST_FRAME_DTMF_END ? "end" : "begin",
who->name);
@@ -3955,6 +3974,7 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
c1->_softhangup = 0;
c0->_bridge = c1;
c1->_bridge = c0;
if (option_debug)
ast_log(LOG_DEBUG, "Unbridge signal received. Ending native bridge.\n");
continue;
}
@@ -3966,6 +3986,7 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
if (who)
*rc = who;
res = 0;
if (option_debug)
ast_log(LOG_DEBUG, "Bridge stops because we're zombie or need a soft hangup: c0=%s, c1=%s, flags: %s,%s,%s,%s\n",
c0->name, c1->name,
ast_test_flag(c0, AST_FLAG_ZOMBIE) ? "Yes" : "No",
@@ -3994,6 +4015,7 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
"CallerID1: %s\r\n"
"CallerID2: %s\r\n",
c0->name, c1->name, c0->uniqueid, c1->uniqueid, c0->cid.cid_num, c1->cid.cid_num);
if (option_debug)
ast_log(LOG_DEBUG, "Returning from native bridge, channels: %s, %s\n", c0->name, c1->name);
ast_clear_flag(c0, AST_FLAG_NBRIDGE);
@@ -4060,6 +4082,7 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
"CallerID1: %s\r\n"
"CallerID2: %s\r\n",
c0->name, c1->name, c0->uniqueid, c1->uniqueid, c0->cid.cid_num, c1->cid.cid_num);
if (option_debug)
ast_log(LOG_DEBUG, "Bridge stops bridging channels %s and %s\n", c0->name, c1->name);
return res;
@@ -4585,6 +4608,7 @@ int ast_channel_unlock(struct ast_channel *chan)
ast_log(LOG_DEBUG, "::::==== Unlocking AST channel %s\n", chan->name);
if (!chan) {
if (option_debug)
ast_log(LOG_DEBUG, "::::==== Unlocking non-existing channel \n");
return 0;
}
@@ -4598,8 +4622,10 @@ int ast_channel_unlock(struct ast_channel *chan)
ast_log(LOG_DEBUG, ":::=== Still have %d locks (recursive)\n", count);
#endif
if (!res)
if (option_debug)
ast_log(LOG_DEBUG, "::::==== 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);
}
}

View File

@@ -1619,6 +1619,7 @@ static void pbx_substitute_variables_helper_full(struct ast_channel *c, struct v
/* Evaluate function */
cp4 = ast_func_read(c, vars, workspace, VAR_BUF_SIZE) ? NULL : workspace;
if (option_debug)
ast_log(LOG_DEBUG, "Function result is '%s'\n", cp4 ? cp4 : "(null)");
} else {
/* Retrieve variable value */
@@ -1686,6 +1687,7 @@ static void pbx_substitute_variables_helper_full(struct ast_channel *c, struct v
length = ast_expr(vars, cp2, count);
if (length) {
if (option_debug)
ast_log(LOG_DEBUG, "Expression result is '%s'\n", cp2);
count -= length;
cp2 += length;
@@ -1822,6 +1824,7 @@ static int pbx_extension_helper(struct ast_channel *c, struct ast_context *con,
ast_log(LOG_NOTICE, "No such label '%s' in extension '%s' in context '%s'\n", label, exten, context);
break;
default:
if (option_debug)
ast_log(LOG_DEBUG, "Shouldn't happen!\n");
}
@@ -2346,6 +2349,7 @@ static int __ast_pbx_run(struct ast_channel *c)
if ((res = ast_spawn_extension(c, c->context, c->exten, c->priority, c->cid.cid_num))) {
/* Something bad happened, or a hangup has been requested. */
if (strchr("0123456789ABCDEF*#", res)) {
if (option_debug)
ast_log(LOG_DEBUG, "Oooh, got something to jump out with ('%c')!\n", res);
pos = 0;
dst_exten[pos++] = digit = res;
@@ -2381,6 +2385,7 @@ static int __ast_pbx_run(struct ast_channel *c)
c->whentohangup = 0;
c->_softhangup &= ~AST_SOFTHANGUP_TIMEOUT;
} else if (c->_softhangup) {
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;
@@ -3896,6 +3901,7 @@ void ast_merge_contexts_and_delete(struct ast_context **extcontexts, const char
tmp = *extcontexts;
if (registrar) {
/* XXX remove previous contexts from same registrar */
if (option_debug)
ast_log(LOG_DEBUG, "must remove any reg %s\n", registrar);
__ast_context_destroy(NULL,registrar);
while (tmp) {
@@ -4785,9 +4791,11 @@ int ast_add_extension2(struct ast_context *con,
}
if (option_debug) {
if (tmp->matchcid) {
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 {
if (option_debug)
ast_log(LOG_DEBUG, "Added extension '%s' priority %d to %s\n",
tmp->exten, tmp->priority, con->name);
}
@@ -5225,6 +5233,7 @@ void __ast_context_destroy(struct ast_context *con, const char *registrar)
for (tmp = contexts; tmp; ) {
struct ast_context *next; /* next starting point */
for (; tmp; tmpl = tmp, tmp = tmp->next) {
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)) )
@@ -5233,6 +5242,7 @@ void __ast_context_destroy(struct ast_context *con, const char *registrar)
if (!tmp) /* not found, we are done */
break;
ast_mutex_lock(&tmp->lock);
if (option_debug)
ast_log(LOG_DEBUG, "delete ctx %s %s\n", tmp->name, tmp->registrar);
next = tmp->next;
if (tmpl)
@@ -5927,6 +5937,7 @@ static int pbx_builtin_gotoif(struct ast_channel *chan, void *data)
branch = pbx_checkcondition(condition) ? branch1 : branch2;
if (ast_strlen_zero(branch)) {
if (option_debug)
ast_log(LOG_DEBUG, "Not taking any branch\n");
return 0;
}