Index: apps/app_voicemail.c =================================================================== --- apps/app_voicemail.c (revision 51180) +++ apps/app_voicemail.c (working copy) @@ -1956,12 +1956,14 @@ create_dirpath(tmpdir, sizeof(tmpdir), vmu->context, vmu->mailbox, "tmp"); snprintf(newtmp, sizeof(newtmp), "%s/XXXXXX", tmpdir); tmpfd = mkstemp(newtmp); - ast_log(LOG_DEBUG, "newtmp: %s\n", 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; - ast_log(LOG_DEBUG, "VOLGAIN: Stored at: %s.%s - Level: %.4f - Mailbox: %s\n", attach, format, vmu->volgain, mailbox); + 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); fprintf(p, "Content-Type: %s%s; name=\"msg%04d.%s\"\r\n", ctype, format, msgnum, format); @@ -1998,7 +2000,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 > 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 */ if ((p = vm_mkftemp(tmp)) == NULL) { @@ -2009,7 +2012,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 > 2) + ast_log(LOG_DEBUG, "Sent mail to %s with command '%s'\n", vmu->email, mailcmd); } return 0; } @@ -2092,7 +2096,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 > 2) + ast_log(LOG_DEBUG, "Sent page to %s with command '%s'\n", pager, mailcmd); } return 0; } @@ -2764,14 +2769,16 @@ ast_log(LOG_WARNING, "The switch reported '%s'\n", mwi_msg->cause); ASTOBJ_UNREF(mwi_msg, ast_smdi_mwi_message_destroy); } else { - ast_log(LOG_DEBUG, "Successfully executed SMDI MWI change for %s on %s\n", extension, smdi_iface->name); + 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)) { if (inboxcount(ext_context, &newvoicemails, &oldvoicemails)) { 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); } } @@ -2896,12 +2903,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; @@ -3351,7 +3360,8 @@ bytes += ast_adsi_voice_mode(buf + bytes, 0); ast_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 */ @@ -3359,7 +3369,8 @@ 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 - ast_log(LOG_DEBUG, "Restarting session...\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Restarting session...\n"); bytes = 0; /* Load the session now */ @@ -4252,13 +4263,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 > 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++){ - ast_log(LOG_DEBUG, "VM-CID: comparing internalcontext: %s\n", cidinternalcontexts[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,7 +4299,8 @@ } else if (!res){ - ast_log(LOG_DEBUG, "VM-CID: Numeric caller id: (%s)\n",callerid); + 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) res = wait_file2(chan, vms, "vm-from-phonenumber"); @@ -4294,7 +4308,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"); } @@ -4314,7 +4329,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 > 2) + ast_log(LOG_DEBUG, "VM-Duration: duration is: %d seconds converted to: %d minutes\n", durations, durationm); if ((!res) && (durationm >= minduration)) { res = wait_file2(chan, vms, "vm-duration"); @@ -4603,7 +4619,8 @@ if(option_debug > 2) ast_log (LOG_DEBUG,"vm_state user is:%s\n",vms->imapuser); if (vms->mailstream == NIL || !vms->mailstream) { - ast_log (LOG_DEBUG,"mailstream not set.\n"); + if (option_debug) + ast_log (LOG_DEBUG,"mailstream not set.\n"); } else { stream = vms->mailstream; } @@ -5674,7 +5691,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 > 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"); /* If forcename is set, have the user record their name */ @@ -5776,7 +5794,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 > 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; case '*': @@ -6027,7 +6046,8 @@ ast_copy_string(mailbox, fullusername, mailbox_size); } - ast_log(LOG_DEBUG, "Before find user for mailbox %s\n",mailbox); + 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'))) { /* saved password is blank, so don't bother asking */ @@ -6119,7 +6139,8 @@ memset(&vmus, 0, sizeof(vmus)); if (chan->_state != AST_STATE_UP) { - ast_log(LOG_DEBUG, "Before ast_answer\n"); + if (option_debug) + ast_log(LOG_DEBUG, "Before ast_answer\n"); ast_answer(chan); } @@ -6201,7 +6222,8 @@ if (!valid) res = vm_authenticate(chan, vms.username, sizeof(vms.username), &vmus, context, prefixstr, skipuser, maxlogins, 0); - ast_log(LOG_DEBUG, "After vm_authenticate\n"); + if (option_debug) + ast_log(LOG_DEBUG, "After vm_authenticate\n"); if (!res) { valid = 1; if (!skipuser) @@ -6236,18 +6258,21 @@ create_dirpath(vms.curdir, sizeof(vms.curdir), vmu->context, vms.username, ""); #endif /* Retrieve old and new message counts */ - ast_log(LOG_DEBUG, "Before open_mailbox\n"); + 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; - ast_log(LOG_DEBUG, "Number of old messages: %d\n",vms.oldmessages); + 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; - ast_log(LOG_DEBUG, "Number of new messages: %d\n",vms.newmessages); + if (option_debug > 2) + ast_log(LOG_DEBUG, "Number of new messages: %d\n",vms.newmessages); /* Select proper mailbox FIRST!! */ if (play_auto) { @@ -6294,7 +6319,8 @@ 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) { - ast_log(LOG_DEBUG, "*** QUOTA EXCEEDED!!\n"); + if (option_debug) + ast_log(LOG_DEBUG, "*** QUOTA EXCEEDED!!\n"); cmd = ast_play_and_wait(chan, "vm-mailboxfull"); } #endif @@ -7144,13 +7170,16 @@ 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 > 2) + ast_log(LOG_DEBUG, "found externnotify: %s\n", externnotify); if (!strcasecmp(externnotify, "smdi")) { - ast_log(LOG_DEBUG, "Using SMDI for external voicemail notification\n"); + 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 { - ast_log(LOG_DEBUG, "No SMDI interface set, trying default (/dev/ttyS0)\n"); + if (option_debug) + ast_log(LOG_DEBUG, "No SMDI interface set, trying default (/dev/ttyS0)\n"); smdi_iface = ast_smdi_interface_find("/dev/ttyS0"); } @@ -7158,7 +7187,8 @@ ast_log(LOG_ERROR, "No valid SMDI interface specfied, disabling external voicemail notification\n"); externnotify[0] = '\0'; } else { - ast_log(LOG_DEBUG, "Using SMDI port %s\n", smdi_iface->name); + if (option_debug > 2) + ast_log(LOG_DEBUG, "Using SMDI port %s\n", smdi_iface->name); } } } else { @@ -7235,7 +7265,8 @@ ast_set2_flag((&globalflags), ast_true(astforcegreet), 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 > 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++){ if (!ast_strlen_zero(stringp)) { @@ -7243,53 +7274,62 @@ 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 > 2) + 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); /*Temperary greeting reminder */ if (!(asttempgreetwarn = ast_variable_retrieve(cfg, "general", "tempgreetwarn"))) { - ast_log(LOG_DEBUG, "VM Temperary Greeting Reminder Option disabled globally\n"); + if (option_debug) + ast_log(LOG_DEBUG, "VM Temperary Greeting Reminder Option disabled globally\n"); asttempgreetwarn = "no"; } else { - ast_log(LOG_DEBUG, "VM Temperary Greeting Reminder Option enabled globally\n"); + 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"))){ - 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); @@ -7304,28 +7344,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'; }