diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-06-14 19:39:12 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-06-14 19:39:12 +0000 |
commit | f0424318479863edeed2a6a128e6d1ac926966e3 (patch) | |
tree | 4fd144260e58c9a66d331fc81b46473723452479 /apps | |
parent | c8ca7d2f263f5161ce1b29ec2c9de835131fc950 (diff) |
Add a massive set of changes for converting to use the ast_debug() macro.
(issue #9957, patches from mvanbaak, caio1982, critch, and dimas)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@69327 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rw-r--r-- | apps/app_alarmreceiver.c | 24 | ||||
-rw-r--r-- | apps/app_amd.c | 8 | ||||
-rw-r--r-- | apps/app_channelredirect.c | 3 | ||||
-rw-r--r-- | apps/app_chanspy.c | 14 | ||||
-rw-r--r-- | apps/app_db.c | 9 | ||||
-rw-r--r-- | apps/app_dial.c | 15 | ||||
-rw-r--r-- | apps/app_directed_pickup.c | 3 | ||||
-rw-r--r-- | apps/app_disa.c | 32 | ||||
-rw-r--r-- | apps/app_festival.c | 42 | ||||
-rw-r--r-- | apps/app_followme.c | 45 | ||||
-rw-r--r-- | apps/app_ices.c | 6 | ||||
-rw-r--r-- | apps/app_macro.c | 43 | ||||
-rw-r--r-- | apps/app_meetme.c | 32 | ||||
-rw-r--r-- | apps/app_minivm.c | 171 | ||||
-rw-r--r-- | apps/app_mp3.c | 12 | ||||
-rw-r--r-- | apps/app_nbscat.c | 12 | ||||
-rw-r--r-- | apps/app_osplookup.c | 338 | ||||
-rw-r--r-- | apps/app_queue.c | 138 | ||||
-rw-r--r-- | apps/app_record.c | 3 | ||||
-rw-r--r-- | apps/app_rpt.c | 194 | ||||
-rw-r--r-- | apps/app_stack.c | 14 | ||||
-rw-r--r-- | apps/app_talkdetect.c | 13 | ||||
-rw-r--r-- | apps/app_test.c | 103 | ||||
-rw-r--r-- | apps/app_voicemail.c | 337 | ||||
-rw-r--r-- | apps/app_waitforsilence.c | 6 | ||||
-rw-r--r-- | apps/app_zapbarge.c | 9 | ||||
-rw-r--r-- | apps/app_zapras.c | 3 | ||||
-rw-r--r-- | apps/app_zapscan.c | 9 |
28 files changed, 576 insertions, 1062 deletions
diff --git a/apps/app_alarmreceiver.c b/apps/app_alarmreceiver.c index 56f604f27..f74abb8a6 100644 --- a/apps/app_alarmreceiver.c +++ b/apps/app_alarmreceiver.c @@ -251,16 +251,14 @@ static int receive_dtmf_digits(struct ast_channel *chan, char *digit_string, int if(option_verbose >= 4) ast_verbose(VERBOSE_PREFIX_4 "AlarmReceiver: DTMF Digit Timeout on %s\n", chan->name); - if (option_debug) - ast_log(LOG_DEBUG,"AlarmReceiver: DTMF timeout on chan %s\n",chan->name); + ast_debug(1,"AlarmReceiver: DTMF timeout on chan %s\n",chan->name); res = 1; break; } if ((r = ast_waitfor(chan, -1) < 0)) { - if (option_debug) - ast_log(LOG_DEBUG, "Waitfor returned %d\n", r); + ast_debug(1, "Waitfor returned %d\n", r); continue; } @@ -355,8 +353,7 @@ static int write_metadata( FILE *logfile, char *signalling_type, struct ast_chan if (option_verbose >= 3 ) ast_verbose(VERBOSE_PREFIX_4 "AlarmReceiver: can't write metadata\n"); - if (option_debug) - ast_log(LOG_DEBUG,"AlarmReceiver: can't write metadata\n"); + ast_debug(1,"AlarmReceiver: can't write metadata\n"); } else res = 0; @@ -407,8 +404,7 @@ static int log_events(struct ast_channel *chan, char *signalling_type, event_no if(fd == -1) { 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"); + ast_debug(1,"AlarmReceiver: can't make temporary file\n"); res = -1; } @@ -529,8 +525,7 @@ static int receive_ademco_contact_id( struct ast_channel *chan, void *data, int if (option_verbose >= 2) ast_verbose(VERBOSE_PREFIX_2 "AlarmReceiver: Received Event %s\n", event); - if (option_debug) - ast_log(LOG_DEBUG, "AlarmReceiver: Received event: %s\n", event); + ast_debug(1, "AlarmReceiver: Received event: %s\n", event); /* Calculate checksum */ @@ -560,8 +555,7 @@ static int receive_ademco_contact_id( struct ast_channel *chan, void *data, int database_increment("checksum-errors"); if (option_verbose >= 2) ast_verbose(VERBOSE_PREFIX_2 "AlarmReceiver: Nonzero checksum\n"); - if (option_debug) - ast_log(LOG_DEBUG, "AlarmReceiver: Nonzero checksum\n"); + ast_debug(1, "AlarmReceiver: Nonzero checksum\n"); continue; } @@ -572,8 +566,7 @@ static int receive_ademco_contact_id( struct ast_channel *chan, void *data, int database_increment("format-errors"); if(option_verbose >= 2) ast_verbose(VERBOSE_PREFIX_2 "AlarmReceiver: Wrong message type\n"); - if (option_debug) - ast_log(LOG_DEBUG, "AlarmReceiver: Wrong message type\n"); + ast_debug(1, "AlarmReceiver: Wrong message type\n"); continue; } } @@ -715,8 +708,7 @@ static int alarmreceiver_exec(struct ast_channel *chan, void *data) */ if((!res) && (!ast_strlen_zero(event_app)) && (event_head)){ - if (option_debug) - ast_log(LOG_DEBUG,"Alarmreceiver: executing: %s\n", event_app); + ast_debug(1,"Alarmreceiver: executing: %s\n", event_app); ast_safe_system(event_app); } diff --git a/apps/app_amd.c b/apps/app_amd.c index 0ab10dd9c..59bc5ab8a 100644 --- a/apps/app_amd.c +++ b/apps/app_amd.c @@ -159,8 +159,9 @@ static void isAnsweringMachine(struct ast_channel *chan, void *data) maximumNumberOfWords = atoi(args.argMaximumNumberOfWords); if (!ast_strlen_zero(args.argSilenceThreshold)) silenceThreshold = atoi(args.argSilenceThreshold); - } else if (option_debug) - ast_log(LOG_DEBUG, "AMD using the default parameters.\n"); + } else { + ast_debug(1, "AMD using the default parameters.\n"); + } /* Now we're ready to roll! */ if (option_verbose > 2) @@ -195,8 +196,7 @@ static void isAnsweringMachine(struct ast_channel *chan, void *data) if (!(f = ast_read(chan))) { if (option_verbose > 2) ast_verbose(VERBOSE_PREFIX_3 "AMD: HANGUP\n"); - if (option_debug) - ast_log(LOG_DEBUG, "Got hangup\n"); + ast_debug(1, "Got hangup\n"); strcpy(amdStatus, "HANGUP"); break; } diff --git a/apps/app_channelredirect.c b/apps/app_channelredirect.c index 075f8bb3f..bba90b939 100644 --- a/apps/app_channelredirect.c +++ b/apps/app_channelredirect.c @@ -105,8 +105,7 @@ static int asyncgoto_exec(struct ast_channel *chan, void *data) goto chanquit; } - if (option_debug > 1) - ast_log(LOG_DEBUG, "Attempting async goto (%s) to %s|%s|%d\n", args.channel, S_OR(context, chan2->context), S_OR(exten, chan2->exten), prio); + ast_debug(2, "Attempting async goto (%s) to %s|%s|%d\n", args.channel, S_OR(context, chan2->context), S_OR(exten, chan2->exten), prio); if (ast_async_goto_if_exists(chan2, S_OR(context, chan2->context), S_OR(exten, chan2->exten), prio)) ast_log(LOG_WARNING, "%s failed for %s\n", app, args.channel); diff --git a/apps/app_chanspy.c b/apps/app_chanspy.c index 81d50ef69..f30631450 100644 --- a/apps/app_chanspy.c +++ b/apps/app_chanspy.c @@ -378,12 +378,12 @@ static int channel_spy(struct ast_channel *chan, struct ast_channel *spyee, int tmp[0] = res; 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); + ast_debug(1, "Got DTMF %c, goto context %s\n", tmp[0], exitcontext); pbx_builtin_setvar_helper(chan, "SPY_CHANNEL", name); running = -2; break; - } else if (option_debug > 1) { - ast_log(LOG_DEBUG, "Exit by single digit did not work in chanspy. Extension %s does not exist in context %s\n", tmp, exitcontext); + } else { + ast_debug(2, "Exit by single digit did not work in chanspy. Extension %s does not exist in context %s\n", tmp, exitcontext); } } else if (res >= '0' && res <= '9') { inp[x++] = res; @@ -508,8 +508,8 @@ static int common_exec(struct ast_channel *chan, const struct ast_flags *flags, tmp[1] = '\0'; if (!ast_goto_if_exists(chan, exitcontext, tmp, 1)) goto exit; - else if (option_debug > 1) - ast_log(LOG_DEBUG, "Exit by single digit did not work in chanspy. Extension %s does not exist in context %s\n", tmp, exitcontext); + else + ast_debug(2, "Exit by single digit did not work in chanspy. Extension %s does not exist in context %s\n", tmp, exitcontext); } } @@ -524,8 +524,8 @@ static int common_exec(struct ast_channel *chan, const struct ast_flags *flags, tmp[1] = '\0'; if (!ast_goto_if_exists(chan, exitcontext, tmp, 1)) goto exit; - else if (option_debug > 1) - ast_log(LOG_DEBUG, "Exit by single digit did not work in chanspy. Extension %s does not exist in context %s\n", tmp, exitcontext); + else + ast_debug(2, "Exit by single digit did not work in chanspy. Extension %s does not exist in context %s\n", tmp, exitcontext); } /* reset for the next loop around, unless overridden later */ diff --git a/apps/app_db.c b/apps/app_db.c index aaadf4ebf..01e440856 100644 --- a/apps/app_db.c +++ b/apps/app_db.c @@ -78,8 +78,7 @@ static int deltree_exec(struct ast_channel *chan, void *data) family = strsep(&argv, "/"); keytree = strsep(&argv, "\0"); if (!family || !keytree) { - if (option_debug) - ast_log(LOG_DEBUG, "Ignoring; Syntax error in argument\n"); + ast_debug(1, "Ignoring; Syntax error in argument\n"); ast_module_user_remove(u); return 0; } @@ -126,8 +125,7 @@ static int del_exec(struct ast_channel *chan, void *data) family = strsep(&argv, "/"); key = strsep(&argv, "\0"); if (!family || !key) { - if (option_debug) - ast_log(LOG_DEBUG, "Ignoring; Syntax error in argument\n"); + ast_debug(1, "Ignoring; Syntax error in argument\n"); ast_module_user_remove(u); return 0; } @@ -138,8 +136,7 @@ static int del_exec(struct ast_channel *chan, void *data) ast_verbose(VERBOSE_PREFIX_3 "DBdel: Error deleting key from database.\n"); } } else { - if (option_debug) - ast_log(LOG_DEBUG, "Ignoring, no parameters\n"); + ast_debug(1, "Ignoring, no parameters\n"); } ast_module_user_remove(u); diff --git a/apps/app_dial.c b/apps/app_dial.c index 1d1a92fa1..a4cc3cb8f 100644 --- a/apps/app_dial.c +++ b/apps/app_dial.c @@ -711,8 +711,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, } break; default: - if (option_debug) - ast_log(LOG_DEBUG, "Dunno what to do with control type %d\n", f->subclass); + ast_debug(1, "Dunno what to do with control type %d\n", f->subclass); } } else if (single) { /* XXX are we sure the logic is correct ? or we should just switch on f->frametype ? */ @@ -1417,8 +1416,7 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags /* check the results of ast_call */ if (res) { /* Again, keep going even if there's an error */ - if (option_debug) - ast_log(LOG_DEBUG, "ast call on peer returned %d\n", res); + ast_debug(1, "ast call on peer returned %d\n", res); if (option_verbose > 2) ast_verbose(VERBOSE_PREFIX_3 "Couldn't call %s\n", numsubst); ast_hangup(tc); @@ -1510,8 +1508,7 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags number = numsubst; pbx_builtin_setvar_helper(chan, "DIALEDPEERNUMBER", number); if (!ast_strlen_zero(args.url) && ast_channel_supports_html(peer) ) { - if (option_debug) - ast_log(LOG_DEBUG, "app_dial: sendurl=%s.\n", args.url); + ast_debug(1, "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)) && pa.privdb_val == AST_PRIVACY_UNKNOWN) { @@ -1569,8 +1566,7 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags if (theapp && !res) { /* XXX why check res here ? */ replace_macro_delimiter(opt_args[OPT_ARG_CALLEE_MACRO]); res = pbx_exec(peer, theapp, opt_args[OPT_ARG_CALLEE_MACRO]); - if (option_debug) - ast_log(LOG_DEBUG, "Macro exited with status %d\n", res); + ast_debug(1, "Macro exited with status %d\n", res); res = 0; } else { ast_log(LOG_ERROR, "Could not find application Macro\n"); @@ -1706,8 +1702,7 @@ out: hanguptree(outgoing, NULL); pbx_builtin_setvar_helper(chan, "DIALSTATUS", pa.status); senddialendevent(chan, pa.status); - if (option_debug) - ast_log(LOG_DEBUG, "Exiting with DIALSTATUS=%s.\n", pa.status); + ast_debug(1, "Exiting with DIALSTATUS=%s.\n", pa.status); if ((ast_test_flag(peerflags, OPT_GO_ON)) && (!chan->_softhangup) && (res != AST_PBX_KEEPALIVE)) { if (calldurationlimit) diff --git a/apps/app_directed_pickup.c b/apps/app_directed_pickup.c index f377205ef..9d84f6985 100644 --- a/apps/app_directed_pickup.c +++ b/apps/app_directed_pickup.c @@ -59,8 +59,7 @@ static int pickup_do(struct ast_channel *chan, struct ast_channel *target) { int res = 0; - if (option_debug) - ast_log(LOG_DEBUG, "Call pickup on '%s' by '%s'\n", target->name, chan->name); + ast_debug(1, "Call pickup on '%s' by '%s'\n", target->name, chan->name); if ((res = ast_answer(chan))) { ast_log(LOG_WARNING, "Unable to answer '%s'\n", chan->name); diff --git a/apps/app_disa.c b/apps/app_disa.c index 8473f1c43..137fee3d0 100644 --- a/apps/app_disa.c +++ b/apps/app_disa.c @@ -164,10 +164,8 @@ static int disa_exec(struct ast_channel *chan, void *data) return -1; } - if (option_debug) { - ast_log(LOG_DEBUG, "Digittimeout: %d\n", digittimeout); - ast_log(LOG_DEBUG, "Responsetimeout: %d\n", firstdigittimeout); - } + ast_debug(1, "Digittimeout: %d\n", digittimeout); + ast_debug(1, "Responsetimeout: %d\n", firstdigittimeout); tmp = ast_strdupa(data); @@ -180,8 +178,7 @@ static int disa_exec(struct ast_channel *chan, void *data) if (!ast_strlen_zero(args.options)) ast_app_parse_options(app_opts, &flags, NULL, args.options); - if (option_debug) - ast_log(LOG_DEBUG, "Mailbox: %s\n",args.mailbox); + ast_debug(1, "Mailbox: %s\n",args.mailbox); special_noanswer = 0; if (ast_test_flag(&flags, NOANSWER_FLAG)) { @@ -196,13 +193,11 @@ static int disa_exec(struct ast_channel *chan, void *data) acctcode[0] = 0; /* can we access DISA without password? */ - if (option_debug) - ast_log(LOG_DEBUG, "Context: %s\n",args.context); + ast_debug(1, "Context: %s\n",args.context); if (!strcasecmp(args.passcode, "no-password")) { k |= 1; /* We have the password */ - if (option_debug) - ast_log(LOG_DEBUG, "DISA no-password login success\n"); + ast_debug(1, "DISA no-password login success\n"); } lastdigittime = ast_tvnow(); @@ -212,14 +207,12 @@ static int disa_exec(struct ast_channel *chan, void *data) /* if outa time, give em reorder */ if (ast_tvdiff_ms(ast_tvnow(), lastdigittime) > ((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); + ast_debug(1,"DISA %s entry timeout on chan %s\n", + ((k&1) ? "extension" : "password"),chan->name); break; } if ((res = ast_waitfor(chan, -1) < 0)) { - if (option_debug) - ast_log(LOG_DEBUG, "Waitfor returned %d\n", res); + ast_debug(1, "Waitfor returned %d\n", res); continue; } @@ -280,8 +273,7 @@ static int disa_exec(struct ast_channel *chan, void *data) AST_STANDARD_APP_ARGS(args, pwline); - if (option_debug) - ast_log(LOG_DEBUG, "Mailbox: %s\n",args.mailbox); + ast_debug(1, "Mailbox: %s\n",args.mailbox); /* password must be in valid format (numeric) */ if (sscanf(args.passcode,"%d", &j) < 1) @@ -304,8 +296,7 @@ static int disa_exec(struct ast_channel *chan, void *data) } /* password good, set to dial state */ - if (option_debug) - ast_log(LOG_DEBUG,"DISA on chan %s password is good\n",chan->name); + ast_debug(1,"DISA on chan %s password is good\n",chan->name); play_dialtone(chan, args.mailbox); k|=1; /* In number mode */ @@ -313,8 +304,7 @@ static int disa_exec(struct ast_channel *chan, void *data) exten[sizeof(acctcode)] = 0; ast_copy_string(acctcode, exten, sizeof(acctcode)); exten[0] = 0; - if (option_debug) - ast_log(LOG_DEBUG,"Successful DISA log-in on chan %s\n", chan->name); + ast_debug(1,"Successful DISA log-in on chan %s\n", chan->name); continue; } } diff --git a/apps/app_festival.c b/apps/app_festival.c index dbc9d6244..6a8a26f54 100644 --- a/apps/app_festival.c +++ b/apps/app_festival.c @@ -221,8 +221,7 @@ static int send_waveform_to_channel(struct ast_channel *chan, char *waveform, in break; } if (f->frametype == AST_FRAME_DTMF) { - if (option_debug) - ast_log(LOG_DEBUG, "User pressed a key\n"); + ast_debug(1, "User pressed a key\n"); if (intkeys && strchr(intkeys, f->subclass)) { res = f->subclass; ast_frfree(f); @@ -252,15 +251,13 @@ static int send_waveform_to_channel(struct ast_channel *chan, char *waveform, in break; } if (res < needed) { /* last frame */ - if (option_debug) - ast_log(LOG_DEBUG, "Last frame\n"); + ast_debug(1, "Last frame\n"); res=0; ast_frfree(f); break; } } else { - if (option_debug) - ast_log(LOG_DEBUG, "No more waveform\n"); + ast_debug(1, "No more waveform\n"); res = 0; } } @@ -380,8 +377,7 @@ static int festival_exec(struct ast_channel *chan, void *vdata) intstr = AST_DIGIT_ANY; } - if (option_debug) - ast_log(LOG_DEBUG, "Text passed to festival server : %s\n",(char *)data); + ast_debug(1, "Text passed to festival server : %s\n",(char *)data); /* Connect to local festival server */ fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); @@ -440,21 +436,17 @@ static int festival_exec(struct ast_channel *chan, void *vdata) if (fdesc!=-1) { writecache=1; strln=strlen((char *)data); - if (option_debug) - ast_log(LOG_DEBUG,"line length : %d\n",strln); + ast_debug(1,"line length : %d\n",strln); write(fdesc,&strln,sizeof(int)); write(fdesc,data,strln); seekpos=lseek(fdesc,0,SEEK_CUR); - if (option_debug) - ast_log(LOG_DEBUG,"Seek position : %d\n",seekpos); + ast_debug(1,"Seek position : %d\n",seekpos); } } else { read(fdesc,&strln,sizeof(int)); - if (option_debug) - ast_log(LOG_DEBUG,"Cache file exists, strln=%d, strlen=%d\n",strln,(int)strlen((char *)data)); + ast_debug(1,"Cache file exists, strln=%d, strlen=%d\n",strln,(int)strlen((char *)data)); if (strlen((char *)data)==strln) { - if (option_debug) - ast_log(LOG_DEBUG,"Size OK\n"); + ast_debug(1,"Size OK\n"); read(fdesc,&bigstring,strln); bigstring[strln] = 0; if (strcmp(bigstring,data)==0) { @@ -471,11 +463,9 @@ static int festival_exec(struct ast_channel *chan, void *vdata) if (readcache==1) { close(fd); fd=fdesc; - if (option_debug) - ast_log(LOG_DEBUG,"Reading from cache...\n"); + ast_debug(1,"Reading from cache...\n"); } else { - if (option_debug) - ast_log(LOG_DEBUG,"Passing text to festival...\n"); + ast_debug(1,"Passing text to festival...\n"); fs=fdopen(dup(fd),"wb"); fprintf(fs,festivalcommand,(char *)data); fflush(fs); @@ -484,8 +474,7 @@ static int festival_exec(struct ast_channel *chan, void *vdata) /* Write to cache and then pass it down */ if (writecache==1) { - if (option_debug) - ast_log(LOG_DEBUG,"Writing result to cache...\n"); + ast_debug(1,"Writing result to cache...\n"); while ((strln=read(fd,buffer,16384))!=0) { write(fdesc,buffer,strln); } @@ -495,8 +484,7 @@ static int festival_exec(struct ast_channel *chan, void *vdata) lseek(fd,seekpos,SEEK_SET); } - if (option_debug) - ast_log(LOG_DEBUG,"Passing data to channel...\n"); + ast_debug(1,"Passing data to channel...\n"); /* Read back info from server */ /* This assumes only one waveform will come back, also LP is unlikely */ @@ -521,16 +509,14 @@ static int festival_exec(struct ast_channel *chan, void *vdata) } ack[3] = '\0'; if (strcmp(ack,"WV\n") == 0) { /* receive a waveform */ - if (option_debug) - ast_log(LOG_DEBUG,"Festival WV command\n"); + ast_debug(1,"Festival WV command\n"); waveform = socket_receive_file_to_buff(fd,&filesize); res = send_waveform_to_channel(chan,waveform,filesize, intstr); ast_free(waveform); break; } else if (strcmp(ack,"LP\n") == 0) { /* receive an s-expr */ - if (option_debug) - ast_log(LOG_DEBUG,"Festival LP command\n"); + ast_debug(1,"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); diff --git a/apps/app_followme.c b/apps/app_followme.c index 37c81d136..3e9c90aa4 100644 --- a/apps/app_followme.c +++ b/apps/app_followme.c @@ -269,8 +269,7 @@ static struct number *create_followme_number(char *number, int timeout, int numo *tmp = '\0'; ast_copy_string(cur->number, number, sizeof(cur->number)); cur->order = numorder; - if (option_debug) - ast_log(LOG_DEBUG, "Created a number, %s, order of , %d, with a timeout of %ld.\n", cur->number, cur->order, cur->timeout); + ast_debug(1, "Created a number, %s, order of , %d, with a timeout of %ld.\n", cur->number, cur->order, cur->timeout); return cur; } @@ -356,8 +355,7 @@ static int reload_followme(void) if (!strcasecmp(f->name, cat)) break; } - if (option_debug) - ast_log(LOG_DEBUG, "New profile %s.\n", cat); + ast_debug(1, "New profile %s.\n", cat); if (!f) { /* Make one then */ f = alloc_profile(cat); @@ -406,8 +404,7 @@ static int reload_followme(void) AST_LIST_INSERT_TAIL(&f->numbers, cur, entry); } else { profile_set_param(f, var->name, var->value, var->lineno, 1); - if (option_debug > 1) - ast_log(LOG_DEBUG, "Logging parameter %s with value %s from lineno %d\n", var->name, var->value, var->lineno); + ast_debug(2, "Logging parameter %s with value %s from lineno %d\n", var->name, var->value, var->lineno); } var = var->next; } /* End while(var) loop */ @@ -688,8 +685,7 @@ static struct ast_channel *wait_for_winner(struct findme_user_listptr *findme_us ast_verbose( VERBOSE_PREFIX_3 "%s stopped sounds\n", winner->name); break; default: - if (option_debug) - ast_log(LOG_DEBUG, "Dunno what to do with control type %d\n", f->subclass); + ast_debug(1, "Dunno what to do with control type %d\n", f->subclass); break; } } @@ -697,24 +693,19 @@ static struct ast_channel *wait_for_winner(struct findme_user_listptr *findme_us if (winner->stream) ast_stopstream(winner); tmpuser->digts = 0; - if (option_debug) - ast_log(LOG_DEBUG, "DTMF received: %c\n",(char) f->subclass); + ast_debug(1, "DTMF received: %c\n",(char) f->subclass); tmpuser->yn[tmpuser->ynidx] = (char) f->subclass; tmpuser->ynidx++; - if (option_debug) - ast_log(LOG_DEBUG, "DTMF string: %s\n", tmpuser->yn); + ast_debug(1, "DTMF string: %s\n", tmpuser->yn); if (tmpuser->ynidx >= ynlongest) { - if (option_debug) - ast_log(LOG_DEBUG, "reached longest possible match - doing evals\n"); + ast_debug(1, "reached longest possible match - doing evals\n"); if (!strcmp(tmpuser->yn, tpargs->takecall)) { - if (option_debug) - ast_log(LOG_DEBUG, "Match to take the call!\n"); + ast_debug(1, "Match to take the call!\n"); ast_frfree(f); return tmpuser->ochan; } if (!strcmp(tmpuser->yn, tpargs->nextindp)) { - if (option_debug) - ast_log(LOG_DEBUG, "Next in dial plan step requested.\n"); + ast_debug(1, "Next in dial plan step requested.\n"); *status = 1; ast_frfree(f); return NULL; @@ -726,8 +717,7 @@ static struct ast_channel *wait_for_winner(struct findme_user_listptr *findme_us ast_frfree(f); } else { if (winner) { - if (option_debug) - ast_log(LOG_DEBUG, "we didn't get a frame. hanging up. dg is %d\n",dg); + ast_debug(1, "we didn't get a frame. hanging up. dg is %d\n",dg); if (!dg) { clear_calling_tree(findme_user_list); return NULL; @@ -735,8 +725,7 @@ static struct ast_channel *wait_for_winner(struct findme_user_listptr *findme_us tmpuser->state = -1; ast_hangup(winner); livechannels--; - if (option_debug) - ast_log(LOG_DEBUG, "live channels left %d\n", livechannels); + ast_debug(1, "live channels left %d\n", livechannels); if (!livechannels) { if (option_verbose > 2) ast_verbose(VERBOSE_PREFIX_3 "no live channels left. exiting.\n"); @@ -747,8 +736,7 @@ static struct ast_channel *wait_for_winner(struct findme_user_listptr *findme_us } } else - if (option_debug) - ast_log(LOG_DEBUG, "timed out waiting for action\n"); + ast_debug(1, "timed out waiting for action\n"); } } else { @@ -793,13 +781,11 @@ static void findmeexec(struct fm_args *tpargs) while (nm) { - if (option_debug > 1) - ast_log(LOG_DEBUG, "Number %s timeout %ld\n", nm->number,nm->timeout); + ast_debug(2, "Number %s timeout %ld\n", nm->number,nm->timeout); time(&start_time); number = ast_strdupa(nm->number); - if (option_debug > 2) - ast_log(LOG_DEBUG, "examining %s\n", number); + ast_debug(3, "examining %s\n", number); do { rest = strchr(number, '&'); if (rest) { @@ -948,8 +934,7 @@ static int app_exec(struct ast_channel *chan, void *data) } AST_LIST_UNLOCK(&followmes); - if (option_debug) - ast_log(LOG_DEBUG, "New profile %s.\n", args.followmeid); + ast_debug(1, "New profile %s.\n", args.followmeid); if (!f) { ast_log(LOG_WARNING, "Profile requested, %s, not found in the configuration.\n", args.followmeid); res = 0; diff --git a/apps/app_ices.c b/apps/app_ices.c index 5829231b4..c4bee4c5f 100644 --- a/apps/app_ices.c +++ b/apps/app_ices.c @@ -170,15 +170,13 @@ static int ices_exec(struct ast_channel *chan, void *data) /* Wait for audio, and stream */ ms = ast_waitfor(chan, -1); if (ms < 0) { - if (option_debug) - ast_log(LOG_DEBUG, "Hangup detected\n"); + ast_debug(1, "Hangup detected\n"); res = -1; break; } f = ast_read(chan); if (!f) { - if (option_debug) - ast_log(LOG_DEBUG, "Null frame == hangup() detected\n"); + ast_debug(1, "Null frame == hangup() detected\n"); res = -1; break; } diff --git a/apps/app_macro.c b/apps/app_macro.c index 21f65f1ab..53a012cdb 100644 --- a/apps/app_macro.c +++ b/apps/app_macro.c @@ -220,8 +220,7 @@ static int _macro_exec(struct ast_channel *chan, void *data, int exclusive) /* If we are to run the macro exclusively, take the mutex */ if (exclusive) { - if (option_debug) - ast_log(LOG_DEBUG, "Locking macrolock for '%s'\n", fullmacro); + ast_debug(1, "Locking macrolock for '%s'\n", fullmacro); ast_autoservice_start(chan); if (ast_context_lockmacro(fullmacro)) { ast_log(LOG_WARNING, "Failed to lock macro '%s' as in-use\n", fullmacro); @@ -313,8 +312,7 @@ static int _macro_exec(struct ast_channel *chan, void *data, int exclusive) 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 */ - if (option_debug) - ast_log(LOG_DEBUG, "Oooh, got something to jump out with ('%c')!\n", res); + ast_debug(1, "Oooh, got something to jump out with ('%c')!\n", res); break; } switch(res) { @@ -322,27 +320,25 @@ static int _macro_exec(struct ast_channel *chan, void *data, int exclusive) res = 0; goto out; case AST_PBX_KEEPALIVE: - if (option_debug) - ast_log(LOG_DEBUG, "Spawn extension (%s,%s,%d) exited KEEPALIVE in macro %s on '%s'\n", chan->context, chan->exten, chan->priority, macro, chan->name); - else if (option_verbose > 1) + ast_debug(2, "Spawn extension (%s,%s,%d) exited KEEPALIVE in macro %s on '%s'\n", chan->context, chan->exten, chan->priority, macro, chan->name); + if (option_verbose > 1) ast_verbose( VERBOSE_PREFIX_2 "Spawn extension (%s, %s, %d) exited KEEPALIVE in macro '%s' on '%s'\n", chan->context, chan->exten, chan->priority, macro, chan->name); goto out; break; default: - if (option_debug) - ast_log(LOG_DEBUG, "Spawn extension (%s,%s,%d) exited non-zero on '%s' in macro '%s'\n", chan->context, chan->exten, chan->priority, chan->name, macro); - else if (option_verbose > 1) + ast_debug(2, "Spawn extension (%s,%s,%d) exited non-zero on '%s' in macro '%s'\n", chan->context, chan->exten, chan->priority, chan->name, macro); + if (option_verbose > 1) ast_verbose( VERBOSE_PREFIX_2 "Spawn extension (%s, %s, %d) exited non-zero on '%s' in macro '%s'\n", chan->context, chan->exten, chan->priority, chan->name, macro); dead = 1; goto out; } } - ast_log(LOG_DEBUG, "Executed application: %s\n", runningapp); + ast_debug(1, "Executed application: %s\n", runningapp); if (!strcasecmp(runningapp, "GOSUB")) { gosub_level++; - ast_log(LOG_DEBUG, "Incrementing gosub_level\n"); + ast_debug(1, "Incrementing gosub_level\n"); } else if (!strcasecmp(runningapp, "GOSUBIF")) { char tmp2[1024] = "", *cond, *app, *app2 = tmp2; pbx_substitute_variables_helper(chan, runningdata, tmp2, sizeof(tmp2) - 1); @@ -351,20 +347,20 @@ static int _macro_exec(struct ast_channel *chan, void *data, int exclusive) if (pbx_checkcondition(cond)) { if (!ast_strlen_zero(app)) { gosub_level++; - ast_log(LOG_DEBUG, "Incrementing gosub_level\n"); + ast_debug(1, "Incrementing gosub_level\n"); } } else { if (!ast_strlen_zero(app2)) { gosub_level++; - ast_log(LOG_DEBUG, "Incrementing gosub_level\n"); + ast_debug(1, "Incrementing gosub_level\n"); } } } else if (!strcasecmp(runningapp, "RETURN")) { gosub_level--; - ast_log(LOG_DEBUG, "Decrementing gosub_level\n"); + ast_debug(1, "Decrementing gosub_level\n"); } else if (!strcasecmp(runningapp, "STACKPOP")) { gosub_level--; - ast_log(LOG_DEBUG, "Decrementing gosub_level\n"); + ast_debug(1, "Decrementing gosub_level\n"); } else if (!strncasecmp(runningapp, "EXEC", 4)) { /* Must evaluate args to find actual app */ char tmp2[1024] = "", *tmp3 = NULL; @@ -379,17 +375,17 @@ static int _macro_exec(struct ast_channel *chan, void *data, int exclusive) tmp3 = tmp2; if (tmp3) - ast_log(LOG_DEBUG, "Last app: %s\n", tmp3); + ast_debug(1, "Last app: %s\n", tmp3); if (tmp3 && !strncasecmp(tmp3, "GOSUB", 5)) { gosub_level++; - ast_log(LOG_DEBUG, "Incrementing gosub_level\n"); + ast_debug(1, "Incrementing gosub_level\n"); } else if (tmp3 && !strncasecmp(tmp3, "RETURN", 6)) { gosub_level--; - ast_log(LOG_DEBUG, "Decrementing gosub_level\n"); + ast_debug(1, "Decrementing gosub_level\n"); } else if (tmp3 && !strncasecmp(tmp3, "STACKPOP", 8)) { gosub_level--; - ast_log(LOG_DEBUG, "Decrementing gosub_level\n"); + ast_debug(1, "Decrementing gosub_level\n"); } } @@ -401,9 +397,7 @@ static int _macro_exec(struct ast_channel *chan, void *data, int exclusive) /* don't stop executing extensions when we're in "h" */ if (chan->_softhangup && !inhangup) { - if (option_debug) - ast_log(LOG_DEBUG, "Extension %s, macroexten %s, priority %d returned normally even though call was hung up\n", - chan->exten, chan->macroexten, chan->priority); + ast_debug(1, "Extension %s, macroexten %s, priority %d returned normally even though call was hung up\n", chan->exten, chan->macroexten, chan->priority); goto out; } chan->priority++; @@ -474,8 +468,7 @@ static int _macro_exec(struct ast_channel *chan, void *data, int exclusive) /* Unlock the macro */ if (exclusive) { - if (option_debug) - ast_log(LOG_DEBUG, "Unlocking macrolock for '%s'\n", fullmacro); + ast_debug(1, "Unlocking macrolock for '%s'\n", fullmacro); if (ast_context_unlockmacro(fullmacro)) { ast_log(LOG_ERROR, "Failed to unlock macro '%s' - that isn't good\n", fullmacro); res = 0; diff --git a/apps/app_meetme.c b/apps/app_meetme.c index 934a8d4e1..d651db45e 100644 --- a/apps/app_meetme.c +++ b/apps/app_meetme.c @@ -948,8 +948,7 @@ static int meetme_cmd(int fd, int argc, char **argv) } else return RESULT_SHOWUSAGE; - if (option_debug) - ast_log(LOG_DEBUG, "Cmdline: %s\n", cmdline); + ast_debug(1, "Cmdline: %s\n", cmdline); admin_exec(NULL, cmdline); @@ -1325,7 +1324,7 @@ static void sla_queue_event_conf(enum sla_event_type type, struct ast_channel *c AST_RWLIST_UNLOCK(&sla_stations); if (!trunk_ref) { - ast_log(LOG_DEBUG, "Trunk not found for event!\n"); + ast_debug(1, "Trunk not found for event!\n"); return; } @@ -1616,8 +1615,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c if (ztc.confmode) { /* Whoa, already in a conference... Retry... */ if (!retryzap) { - if (option_debug) - ast_log(LOG_DEBUG, "Zap channel is in a conference already, retrying with pseudo\n"); + ast_debug(1, "Zap channel is in a conference already, retrying with pseudo\n"); retryzap = 1; goto zapretry; } @@ -1651,8 +1649,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c ast_mutex_unlock(&conf->playlock); goto outrun; } - if (option_debug) - ast_log(LOG_DEBUG, "Placed channel %s in ZAP conf %d\n", chan->name, conf->zapconf); + ast_debug(1, "Placed channel %s in ZAP conf %d\n", chan->name, conf->zapconf); if (!sent_event) { manager_event(EVENT_FLAG_CALL, "MeetmeJoin", @@ -1891,8 +1888,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c close(fd); using_pseudo = 0; } - if (option_debug) - ast_log(LOG_DEBUG, "Ooh, something swapped out under us, starting over\n"); + ast_debug(1, "Ooh, something swapped out under us, starting over\n"); retryzap = strcasecmp(c->tech->type, "Zap"); user->zapchannel = !retryzap; goto zapretry; @@ -1959,13 +1955,13 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c tmp[0] = f->subclass; tmp[1] = '\0'; if (!ast_goto_if_exists(chan, exitcontext, tmp, 1)) { - if (option_debug) - ast_log(LOG_DEBUG, "Got DTMF %c, goto context %s\n", tmp[0], exitcontext); + ast_debug(1, "Got DTMF %c, goto context %s\n", tmp[0], exitcontext); ret = 0; ast_frfree(f); break; - } else if (option_debug > 1) - ast_log(LOG_DEBUG, "Exit by single digit did not work in meetme. Extension %s does not exist in context %s\n", tmp, exitcontext); + } else { + ast_debug(2, "Exit by single digit did not work in meetme. Extension %s does not exist in context %s\n", tmp, exitcontext); + } } else if ((f->frametype == AST_FRAME_DTMF) && (f->subclass == '#') && (confflags & CONFFLAG_POUNDEXIT)) { ret = 0; ast_frfree(f); @@ -2372,8 +2368,7 @@ static struct ast_conference *find_conf(struct ast_channel *chan, char *confno, if (!cnf) { if (dynamic) { /* No need to parse meetme.conf */ - if (option_debug) - ast_log(LOG_DEBUG, "Building dynamic conference '%s'\n", confno); + ast_debug(1, "Building dynamic conference '%s'\n", confno); if (dynamic_pin) { if (dynamic_pin[0] == 'q') { /* Query the user to enter a PIN */ @@ -2409,7 +2404,7 @@ static struct ast_conference *find_conf(struct ast_channel *chan, char *confno, } } if (!var) { - ast_log(LOG_DEBUG, "%s isn't a valid conference\n", confno); + ast_debug(1, "%s isn't a valid conference\n", confno); } ast_config_destroy(cfg); } @@ -3484,8 +3479,7 @@ static void sla_handle_dial_state_event(void) ringing_trunk = sla_choose_ringing_trunk(ringing_station->station, &s_trunk_ref, 1); ast_mutex_unlock(&sla.lock); if (!ringing_trunk) { - ast_log(LOG_DEBUG, "Found no ringing trunk for station '%s' to answer!\n", - ringing_station->station->name); + ast_debug(1, "Found no ringing trunk for station '%s' to answer!\n", ringing_station->station->name); break; } /* Track the channel that answered this trunk */ @@ -4260,7 +4254,7 @@ static int sla_station_exec(struct ast_channel *chan, void *data) ast_cond_destroy(&cond); ast_autoservice_stop(chan); if (!trunk_ref->trunk->chan) { - ast_log(LOG_DEBUG, "Trunk didn't get created. chan: %lx\n", (long) trunk_ref->trunk->chan); + ast_debug(1, "Trunk didn't get created. chan: %lx\n", (long) trunk_ref->trunk->chan); pbx_builtin_setvar_helper(chan, "SLASTATION_STATUS", "CONGESTION"); sla_change_trunk_state(trunk_ref->trunk, SLA_TRUNK_STATE_IDLE, ALL_TRUNK_REFS, NULL); trunk_ref->chan = NULL; diff --git a/apps/app_minivm.c b/apps/app_minivm.c index 919337c62..6479f7c70 100644 --- a/apps/app_minivm.c +++ b/apps/app_minivm.c @@ -506,8 +506,7 @@ static int message_template_build(const char *name, struct ast_variable *var) } while (var) { - if (option_debug > 2) - ast_log(LOG_DEBUG, "-_-_- Configuring template option %s = \"%s\" for template %s\n", var->name, var->value, name); + ast_debug(3, "-_-_- Configuring template option %s = \"%s\" for template %s\n", var->name, var->value, name); if (!strcasecmp(var->name, "fromaddress")) { ast_copy_string(template->fromaddress, var->value, sizeof(template->fromaddress)); } else if (!strcasecmp(var->name, "fromemail")) { @@ -823,8 +822,7 @@ static struct minivm_account *find_account(const char *domain, const char *usern ast_log(LOG_NOTICE, "No username or domain? \n"); return NULL; } - if (option_debug > 2) - ast_log(LOG_DEBUG, "-_-_-_- Looking for voicemail user %s in domain %s\n", username, domain); + ast_debug(3, "-_-_-_- Looking for voicemail user %s in domain %s\n", username, domain); AST_LIST_LOCK(&minivm_accounts); AST_LIST_TRAVERSE(&minivm_accounts, cur, list) { @@ -835,8 +833,7 @@ static struct minivm_account *find_account(const char *domain, const char *usern AST_LIST_UNLOCK(&minivm_accounts); if (cur) { - if (option_debug > 2) - ast_log(LOG_DEBUG, "-_-_- Found account for %s@%s\n", username, domain); + ast_debug(3, "-_-_- Found account for %s@%s\n", username, domain); vmu = cur; } else @@ -849,8 +846,7 @@ static struct minivm_account *find_account(const char *domain, const char *usern if (vmu) { ast_copy_string(vmu->username, username, sizeof(vmu->username)); ast_copy_string(vmu->domain, domain, sizeof(vmu->domain)); - if (option_debug) - ast_log(LOG_DEBUG, "--- Created temporary account\n"); + ast_debug(1, "--- Created temporary account\n"); } } @@ -926,8 +922,7 @@ static int sendmail(struct minivm_template *template, struct minivm_account *vmu return -1; } - if (option_debug > 2) - ast_log(LOG_DEBUG, "-_-_- Sending mail to %s@%s - Using template %s\n", vmu->username, vmu->domain, template->name); + ast_debug(3, "-_-_- Sending mail to %s@%s - Using template %s\n", vmu->username, vmu->domain, template->name); if (!strcmp(format, "wav49")) format = "WAV"; @@ -940,8 +935,7 @@ static int sendmail(struct minivm_template *template, struct minivm_account *vmu int tmpfd; snprintf(newtmp, sizeof(newtmp), "/tmp/XXXXXX"); - if (option_debug > 2) - ast_log(LOG_DEBUG, "newtmp: %s\n", newtmp); + ast_debug(3, "newtmp: %s\n", newtmp); tmpfd = mkstemp(newtmp); snprintf(tmpcmd, sizeof(tmpcmd), "sox -v %.4f %s.%s %s.%s", vmu->volgain, filename, format, newtmp, format); ast_safe_system(tmpcmd); @@ -955,8 +949,8 @@ static int sendmail(struct minivm_template *template, struct minivm_account *vmu /* Create file name */ snprintf(fname, sizeof(fname), "%s.%s", finalfilename, format); - if (option_debug && template->attachment) - ast_log(LOG_DEBUG, "-- Attaching file '%s', format '%s', uservm is '%d'\n", finalfilename, format, attach_user_voicemail); + if (template->attachment) + ast_debug(1, "-- Attaching file '%s', format '%s', uservm is '%d'\n", finalfilename, format, attach_user_voicemail); /* Make a temporary file instead of piping directly to sendmail, in case the mail command hangs */ @@ -967,8 +961,7 @@ static int sendmail(struct minivm_template *template, struct minivm_account *vmu close(pfd); pfd = -1; } - if (option_debug) - ast_log(LOG_DEBUG, "-_-_- Opening temp file for e-mail: %s\n", tmp); + ast_debug(1, "-_-_- Opening temp file for e-mail: %s\n", tmp); } if (!p) { ast_log(LOG_WARNING, "Unable to open temporary file '%s'\n", tmp); @@ -1029,8 +1022,7 @@ static int sendmail(struct minivm_template *template, struct minivm_account *vmu if (ast_strlen_zero(fromaddress)) { fprintf(p, "From: Asterisk PBX <%s>\n", who); } else { - if (option_debug > 3) - ast_log(LOG_DEBUG, "-_-_- Fromaddress template: %s\n", fromaddress); + ast_debug(4, "-_-_- Fromaddress template: %s\n", fromaddress); /* Allocate a buffer big enough for variable substitution */ int vmlen = strlen(fromaddress) * 3 + 200; @@ -1046,8 +1038,7 @@ static int sendmail(struct minivm_template *template, struct minivm_account *vmu return -1; } } - if (option_debug > 3) - ast_log(LOG_DEBUG, "-_-_- Fromstring now: %s\n", ast_strlen_zero(passdata) ? "-default-" : passdata); + ast_debug(4, "-_-_- Fromstring now: %s\n", ast_strlen_zero(passdata) ? "-default-" : passdata); fprintf(p, "Message-ID: <Asterisk-%d-%s-%d-%s>\n", (unsigned int)rand(), vmu->username, getpid(), who); len_passdata = strlen(vmu->fullname) * 2 + 3; @@ -1069,11 +1060,12 @@ static int sendmail(struct minivm_template *template, struct minivm_account *vmu fclose(p); return -1; } - if (option_debug > 3) - ast_log(LOG_DEBUG, "-_-_- Subject now: %s\n", passdata); + + ast_debug(4, "-_-_- Subject now: %s\n", passdata); + } else { fprintf(p, "Subject: New message in mailbox %s@%s\n", vmu->username, vmu->domain); - ast_log(LOG_DEBUG, "-_-_- Using default subject for this email \n"); + ast_debug(1, "-_-_- Using default subject for this email \n"); } @@ -1094,8 +1086,7 @@ static int sendmail(struct minivm_template *template, struct minivm_account *vmu if ((passdata = alloca(vmlen))) { memset(passdata, 0, vmlen); pbx_substitute_variables_helper(ast, template->body, passdata, vmlen); - if (option_debug > 2) - ast_log(LOG_DEBUG, "Message now: %s\n-----\n", passdata); + ast_debug(3, "Message now: %s\n-----\n", passdata); fprintf(p, "%s\n", passdata); } else ast_log(LOG_WARNING, "Cannot allocate workspace for variable substitution\n"); @@ -1105,13 +1096,11 @@ static int sendmail(struct minivm_template *template, struct minivm_account *vmu "in mailbox %s from %s, on %s so you might\n" "want to check it when you get a chance. Thanks!\n\n\t\t\t\t--Asterisk\n\n", vmu->fullname, dur, vmu->username, (cidname ? cidname : (cidnum ? cidnum : "an unknown caller")), date); - if (option_debug > 2) - ast_log(LOG_DEBUG, "Using default message body (no template)\n-----\n"); + ast_debug(3, "Using default message body (no template)\n-----\n"); } /* Eww. We want formats to tell us their own MIME type */ if (template->attachment) { - if (option_debug > 2) - ast_log(LOG_DEBUG, "-_-_- Attaching file to message: %s\n", fname); + ast_debug(3, "-_-_- Attaching file to message: %s\n", fname); char *ctype = "audio/x-"; if (!strcasecmp(format, "ogg")) ctype = "application/"; @@ -1128,11 +1117,8 @@ static int sendmail(struct minivm_template *template, struct minivm_account *vmu fclose(p); snprintf(tmp2, sizeof(tmp2), "( %s < %s ; rm -f %s ) &", global_mailcmd, tmp, tmp); ast_safe_system(tmp2); - if (option_debug) { - ast_log(LOG_DEBUG, "Sent message to %s with command '%s' - %s\n", vmu->email, global_mailcmd, template->attachment ? "(media attachment)" : ""); - if (option_debug > 2) - ast_log(LOG_DEBUG, "-_-_- Actual command used: %s\n", tmp2); - } + ast_debug(1, "Sent message to %s with command '%s' - %s\n", vmu->email, global_mailcmd, template->attachment ? "(media attachment)" : ""); + ast_debug(3, "-_-_- Actual command used: %s\n", tmp2); if (ast) ast_channel_free(ast); return 0; @@ -1195,8 +1181,7 @@ static int create_dirpath(char *dest, int len, char *domain, char *username, cha return -1; } } - if (option_debug > 1) - ast_log(LOG_DEBUG, "Creating directory for %s@%s folder %s : %s\n", username, domain, folder, dest); + ast_debug(2, "Creating directory for %s@%s folder %s : %s\n", username, domain, folder, dest); return 0; } @@ -1208,8 +1193,7 @@ static int invent_message(struct ast_channel *chan, char *domain, char *username int res; char fn[PATH_MAX]; - if (option_debug > 1) - ast_log(LOG_DEBUG, "-_-_- Still preparing to play message ...\n"); + ast_debug(2, "-_-_- Still preparing to play message ...\n"); snprintf(fn, sizeof(fn), "%s%s/%s/greet", MVM_SPOOL_DIR, domain, username); @@ -1224,12 +1208,10 @@ static int invent_message(struct ast_channel *chan, char *domain, char *username int numericusername = 1; char *i = username; - if (option_debug > 1) - ast_log(LOG_DEBUG, "-_-_- No personal prompts. Using default prompt set for language\n"); + ast_debug(2, "-_-_- No personal prompts. Using default prompt set for language\n"); while (*i) { - if (option_debug > 1) - ast_log(LOG_DEBUG, "-_-_- Numeric? Checking %c\n", *i); + ast_debug(2, "-_-_- Numeric? Checking %c\n", *i); if (!isdigit(*i)) { numericusername = FALSE; break; @@ -1266,8 +1248,7 @@ static int vm_delete(char *file) { int res; - if (option_debug) - ast_log(LOG_DEBUG, "-_-_- Deleting voicemail file %s\n", file); + ast_debug(1, "-_-_- Deleting voicemail file %s\n", file); res = unlink(file); /* Remove the meta data file */ res |= ast_filedelete(file, NULL); /* remove the media file */ @@ -1418,9 +1399,7 @@ static void run_externnotify(struct ast_channel *chan, struct minivm_account *vm vmu->username, vmu->domain, chan->cid.cid_name, chan->cid.cid_num); - if (option_debug) - ast_log(LOG_DEBUG, "Executing: %s\n", arguments); - + ast_debug(1, "Executing: %s\n", arguments); ast_safe_system(arguments); } @@ -1454,8 +1433,7 @@ static int notify_new_message(struct ast_channel *chan, const char *templatename if (!ast_strlen_zero(etemplate->locale)) { char *newlocale; ast_copy_string(oldlocale, setlocale(LC_TIME, NULL), sizeof(oldlocale)); - if (option_debug > 1) - ast_log(LOG_DEBUG, "-_-_- Changing locale from %s to %s\n", oldlocale, etemplate->locale); + ast_debug(2, "-_-_- Changing locale from %s to %s\n", oldlocale, etemplate->locale); newlocale = setlocale(LC_TIME, etemplate->locale); if (newlocale == NULL) { ast_log(LOG_WARNING, "-_-_- Changing to new locale did not work. Locale: %s\n", etemplate->locale); @@ -1466,11 +1444,10 @@ static int notify_new_message(struct ast_channel *chan, const char *templatename /* Read counter if available */ counter = pbx_builtin_getvar_helper(chan, "MVM_COUNTER"); - if (option_debug > 1) { - if (ast_strlen_zero(counter)) - ast_log(LOG_DEBUG, "-_-_- MVM_COUNTER not found\n"); - else - ast_log(LOG_DEBUG, "-_-_- MVM_COUNTER found - will use it with value %s\n", counter); + if (ast_strlen_zero(counter)) { + ast_debug(2, "-_-_- MVM_COUNTER not found\n"); + } else { + ast_debug(2, "-_-_- MVM_COUNTER found - will use it with value %s\n", counter); } res = sendmail(etemplate, vmu, cidnum, cidname, filename, messageformat, duration, etemplate->attachment, MVM_MESSAGE_EMAIL, counter); @@ -1555,8 +1532,7 @@ static int leave_voicemail(struct ast_channel *chan, char *username, struct leav /* If we have no user directory, use generic temporary directory */ if (!userdir) { create_dirpath(tmpdir, sizeof(tmpdir), "0000_minivm_temp", "mediafiles", ""); - if (option_debug > 2) - ast_log(LOG_DEBUG, "Creating temporary directory %s\n", tmpdir); + ast_debug(3, "Creating temporary directory %s\n", tmpdir); } @@ -1583,8 +1559,7 @@ static int leave_voicemail(struct ast_channel *chan, char *username, struct leav /* OEJ XXX Maybe this can be turned into a log file? Hmm. */ /* Store information */ - if (option_debug > 1) - ast_log(LOG_DEBUG, "Open file for metadata: %s\n", tmptxtfile); + ast_debug(2, "Open file for metadata: %s\n", tmptxtfile); res = play_record_review(chan, NULL, tmptxtfile, global_vmmaxmessage, fmt, 1, vmu, &duration, NULL, options->record_gain); @@ -1635,8 +1610,7 @@ static int leave_voicemail(struct ast_channel *chan, char *username, struct leav } fclose(txt); /* Close log file */ if (ast_fileexists(tmptxtfile, NULL, NULL) <= 0) { - if (option_debug) - ast_log(LOG_DEBUG, "The recorded media file is gone, so we should remove the .txt file too!\n"); + ast_debug(1, "The recorded media file is gone, so we should remove the .txt file too!\n"); unlink(tmptxtfile); pbx_builtin_setvar_helper(chan, "MINIVM_RECORD_STATUS", "FAILED"); if(ast_test_flag(vmu, MVM_ALLOCED)) @@ -1656,8 +1630,8 @@ static int leave_voicemail(struct ast_channel *chan, char *username, struct leav // /* Go ahead and delete audio files from system, they're not needed any more */ // if (ast_fileexists(tmptxtfile, NULL, NULL) <= 0) { // ast_filedelete(tmptxtfile, NULL); -// if (option_debug > 1) -// ast_log(LOG_DEBUG, "-_-_- Deleted audio file after notification :: %s \n", tmptxtfile); +// /* Even not being used at the moment, it's better to convert ast_log to ast_debug anyway */ +// ast_debug(2, "-_-_- Deleted audio file after notification :: %s \n", tmptxtfile); // } if (res > 0) @@ -1873,8 +1847,7 @@ static int minivm_greet_exec(struct ast_channel *chan, void *data) ast_module_user_remove(u); return -1; } - if (option_debug) - ast_log(LOG_DEBUG, "-_-_- Trying to find configuration for user %s in domain %s\n", username, domain); + ast_debug(1, "-_-_- Trying to find configuration for user %s in domain %s\n", username, domain); if (!(vmu = find_account(domain, username, TRUE))) { ast_log(LOG_ERROR, "Could not allocate memory. \n"); @@ -1904,12 +1877,10 @@ static int minivm_greet_exec(struct ast_channel *chan, void *data) /* Check for temporary greeting - it overrides busy and unavail */ snprintf(tempfile, sizeof(tempfile), "%s%s/%s/temp", MVM_SPOOL_DIR, vmu->domain, username); if (!(res = check_dirpath(dest, sizeof(dest), vmu->domain, username, "temp"))) { - if (option_debug > 1) - ast_log(LOG_DEBUG, "Temporary message directory does not exist, using default (%s)\n", tempfile); + ast_debug(2, "Temporary message directory does not exist, using default (%s)\n", tempfile); ast_copy_string(prefile, tempfile, sizeof(prefile)); } - if (option_debug > 1) - ast_log(LOG_DEBUG, "-_-_- Preparing to play message ...\n"); + ast_debug(2, "-_-_- Preparing to play message ...\n"); /* Check current or macro-calling context for special extensions */ if (ast_test_flag(vmu, MVM_OPERATOR)) { @@ -1944,13 +1915,11 @@ static int minivm_greet_exec(struct ast_channel *chan, void *data) if (ast_streamfile(chan, prefile, chan->language) > -1) res = ast_waitstream(chan, ecodes); } else { - if (option_debug > 1) - ast_log(LOG_DEBUG, "%s doesn't exist, doing what we can\n", prefile); + ast_debug(2, "%s doesn't exist, doing what we can\n", prefile); res = invent_message(chan, vmu->domain, username, ast_test_flag(&leave_options, OPT_BUSY_GREETING), ecodes); } if (res < 0) { - if (option_debug > 1) - ast_log(LOG_DEBUG, "Hang up during prefile playback\n"); + ast_debug(2, "Hang up during prefile playback\n"); pbx_builtin_setvar_helper(chan, "MINIVM_GREET_STATUS", "FAILED"); if(ast_test_flag(vmu, MVM_ALLOCED)) free_user(vmu); @@ -2042,17 +2011,14 @@ static int minivm_delete_exec(struct ast_channel *chan, void *data) if (ast_fileexists(filename, NULL, NULL) > 0) { res = vm_delete(filename); if (res) { - if (option_debug > 1) - ast_log(LOG_DEBUG, "-_-_- Can't delete file: %s\n", filename); + ast_debug(2, "-_-_- Can't delete file: %s\n", filename); pbx_builtin_setvar_helper(chan, "MINIVM_DELETE_STATUS", "FAILED"); } else { - if (option_debug > 1) - ast_log(LOG_DEBUG, "-_-_- Deleted voicemail file :: %s \n", filename); + ast_debug(2, "-_-_- Deleted voicemail file :: %s \n", filename); pbx_builtin_setvar_helper(chan, "MINIVM_DELETE_STATUS", "SUCCESS"); } } else { - if (option_debug > 1) - ast_log(LOG_DEBUG, "-_-_- Filename does not exist: %s\n", filename); + ast_debug(2, "-_-_- Filename does not exist: %s\n", filename); pbx_builtin_setvar_helper(chan, "MINIVM_DELETE_STATUS", "FAILED"); } @@ -2159,8 +2125,7 @@ static int minivm_accmess_exec(struct ast_channel *chan, void *data) /* Maybe we should check the result of play_record_review ? */ cmd = play_record_review(chan, prompt, filename, global_maxgreet, default_vmformat, 0, vmu, &duration, NULL, FALSE); - if (option_debug) - ast_log(LOG_DEBUG, "Recorded new %s message in %s (duration %d)\n", message, filename, duration); + ast_debug(1, "Recorded new %s message in %s (duration %d)\n", message, filename, duration); if(ast_test_flag(vmu, MVM_ALLOCED)) free_user(vmu); @@ -2181,8 +2146,7 @@ static int create_vmaccount(char *name, struct ast_variable *var, int realtime) char *username; char accbuf[BUFSIZ]; - if (option_debug > 2) - ast_log(LOG_DEBUG, "Creating %s account for [%s]\n", realtime ? "realtime" : "static", name); + ast_debug(3, "Creating %s account for [%s]\n", realtime ? "realtime" : "static", name); ast_copy_string(accbuf, name, sizeof(accbuf)); username = accbuf; @@ -2196,8 +2160,7 @@ static int create_vmaccount(char *name, struct ast_variable *var, int realtime) return 0; } - if (option_debug > 2) - ast_log(LOG_DEBUG, "Creating static account for user %s domain %s\n", username, domain); + ast_debug(3, "Creating static account for user %s domain %s\n", username, domain); /* Allocate user account */ vmu = ast_calloc(1, sizeof(*vmu)); @@ -2209,12 +2172,10 @@ static int create_vmaccount(char *name, struct ast_variable *var, int realtime) populate_defaults(vmu); - if (option_debug > 2) - ast_log(LOG_DEBUG, "...Configuring account %s\n", name); + ast_debug(3, "...Configuring account %s\n", name); while (var) { - if (option_debug > 2) - ast_log(LOG_DEBUG, "---- Configuring %s = \"%s\" for account %s\n", var->name, var->value, name); + ast_debug(3, "---- Configuring %s = \"%s\" for account %s\n", var->name, var->value, name); if (!strcasecmp(var->name, "serveremail")) { ast_copy_string(vmu->serveremail, var->value, sizeof(vmu->serveremail)); } else if (!strcasecmp(var->name, "email")) { @@ -2259,8 +2220,7 @@ static int create_vmaccount(char *name, struct ast_variable *var, int realtime) } var = var->next; } - if (option_debug > 2) - ast_log(LOG_DEBUG, "...Linking account %s\n", name); + ast_debug(3, "...Linking account %s\n", name); AST_LIST_LOCK(&minivm_accounts); AST_LIST_INSERT_TAIL(&minivm_accounts, vmu, list); @@ -2268,8 +2228,7 @@ static int create_vmaccount(char *name, struct ast_variable *var, int realtime) global_stats.voicemailaccounts++; - if (option_debug > 1) - ast_log(LOG_DEBUG, "MINIVM :: Created account %s@%s - tz %s etemplate %s %s\n", username, domain, ast_strlen_zero(vmu->zonetag) ? "" : vmu->zonetag, ast_strlen_zero(vmu->etemplate) ? "" : vmu->etemplate, realtime ? "(realtime)" : ""); + ast_debug(2, "MINIVM :: Created account %s@%s - tz %s etemplate %s %s\n", username, domain, ast_strlen_zero(vmu->zonetag) ? "" : vmu->zonetag, ast_strlen_zero(vmu->etemplate) ? "" : vmu->etemplate, realtime ? "(realtime)" : ""); return 0; } @@ -2363,10 +2322,8 @@ static char *message_template_parse_filebody(char *filename) { fclose(fi); messagebody = ast_calloc(1, strlen(buf + 1)); ast_copy_string(messagebody, buf, strlen(buf) + 1); - if (option_debug > 3) { - ast_log(LOG_DEBUG, "---> Size of allocation %d\n", (int) strlen(buf + 1) ); - ast_log(LOG_DEBUG, "---> Done reading message template : \n%s\n---- END message template--- \n", messagebody); - } + ast_debug(4, "---> Size of allocation %d\n", (int) strlen(buf + 1) ); + ast_debug(4, "---> Done reading message template : \n%s\n---- END message template--- \n", messagebody); return messagebody; } @@ -2472,8 +2429,7 @@ static int load_config(void) message_destroy_list(); /* Destroy list of voicemail message templates */ timezone_destroy_list(); /* Destroy list of timezones */ vmaccounts_destroy_list(); /* Destroy list of voicemail accounts */ - if (option_debug > 1) - ast_log(LOG_DEBUG, "Destroyed memory objects...\n"); + ast_debug(2, "Destroyed memory objects...\n"); /* First, set some default settings */ global_externnotify[0] = '\0'; @@ -2501,15 +2457,13 @@ static int load_config(void) return 0; } - if (option_debug > 1) - ast_log(LOG_DEBUG, "-_-_- Loaded configuration file, now parsing\n"); + ast_debug(2, "-_-_- Loaded configuration file, now parsing\n"); /* General settings */ cat = ast_category_browse(cfg, NULL); while (cat) { - if (option_debug > 2) - ast_log(LOG_DEBUG, "-_-_- Found configuration section [%s]\n", cat); + ast_debug(3, "-_-_- Found configuration section [%s]\n", cat); if (!strcasecmp(cat, "general")) { /* Nothing right now */ error += apply_general_options(ast_variable_browse(cfg, cat)); @@ -2584,8 +2538,8 @@ static int load_config(void) minivmlogfile = fopen(global_logfile, "a"); if(!minivmlogfile) ast_log(LOG_ERROR, "Failed to open minivm log file %s : %s\n", global_logfile, strerror(errno)); - if (option_debug > 2 && minivmlogfile) - ast_log(LOG_DEBUG, "-_-_- Opened log file %s \n", global_logfile); + if (minivmlogfile) + ast_debug(3, "-_-_- Opened log file %s \n", global_logfile); } return 0; @@ -2901,8 +2855,7 @@ static int access_counter_file(char *directory, char *countername, int value, in counterfile = fopen(filename, "r"); if (counterfile) { if(fgets(readbuf, sizeof(readbuf), counterfile)) { - if (option_debug > 2) - ast_log(LOG_DEBUG, "Read this string from counter file: %s\n", readbuf); + ast_debug(3, "Read this string from counter file: %s\n", readbuf); old = counter = atoi(readbuf); } fclose(counterfile); @@ -2911,8 +2864,7 @@ static int access_counter_file(char *directory, char *countername, int value, in switch (operand) { case 0: /* Read only */ ast_unlock_path(directory); - if (option_debug > 1) - ast_log(LOG_DEBUG, "MINIVM Counter %s/%s: Value %d\n", directory, countername, counter); + ast_debug(2, "MINIVM Counter %s/%s: Value %d\n", directory, countername, counter); return counter; break; case 1: /* Set new value */ @@ -2935,8 +2887,7 @@ static int access_counter_file(char *directory, char *countername, int value, in fprintf(counterfile, "%d\n\n", counter); fclose(counterfile); ast_unlock_path(directory); - if (option_debug > 1) - ast_log(LOG_DEBUG, "MINIVM Counter %s/%s: Old value %d New value %d\n", directory, countername, old, counter); + ast_debug(2, "MINIVM Counter %s/%s: Old value %d New value %d\n", directory, countername, old, counter); return counter; } diff --git a/apps/app_mp3.c b/apps/app_mp3.c index e0df37d61..b0539e17b 100644 --- a/apps/app_mp3.c +++ b/apps/app_mp3.c @@ -193,8 +193,7 @@ static int mp3_exec(struct ast_channel *chan, void *data) break; } } else { - if (option_debug) - ast_log(LOG_DEBUG, "No more mp3\n"); + ast_debug(1, "No more mp3\n"); res = 0; break; } @@ -202,22 +201,19 @@ static int mp3_exec(struct ast_channel *chan, void *data) } else { ms = ast_waitfor(chan, ms); if (ms < 0) { - if (option_debug) - ast_log(LOG_DEBUG, "Hangup detected\n"); + ast_debug(1, "Hangup detected\n"); res = -1; break; } if (ms) { f = ast_read(chan); if (!f) { - if (option_debug) - ast_log(LOG_DEBUG, "Null frame == hangup() detected\n"); + ast_debug(1, "Null frame == hangup() detected\n"); res = -1; break; } if (f->frametype == AST_FRAME_DTMF) { - if (option_debug) - ast_log(LOG_DEBUG, "User pressed a key\n"); + ast_debug(1, "User pressed a key\n"); ast_frfree(f); res = 0; break; diff --git a/apps/app_nbscat.c b/apps/app_nbscat.c index 1fb51e688..6a922ecd2 100644 --- a/apps/app_nbscat.c +++ b/apps/app_nbscat.c @@ -175,8 +175,7 @@ static int NBScat_exec(struct ast_channel *chan, void *data) break; } } else { - if (option_debug) - ast_log(LOG_DEBUG, "No more mp3\n"); + ast_debug(1, "No more mp3\n"); res = 0; break; } @@ -184,22 +183,19 @@ static int NBScat_exec(struct ast_channel *chan, void *data) } else { ms = ast_waitfor(chan, ms); if (ms < 0) { - if (option_debug) - ast_log(LOG_DEBUG, "Hangup detected\n"); + ast_debug(1, "Hangup detected\n"); res = -1; break; } if (ms) { f = ast_read(chan); if (!f) { - if (option_debug) - ast_log(LOG_DEBUG, "Null frame == hangup() detected\n"); + ast_debug(1, "Null frame == hangup() detected\n"); res = -1; break; } if (f->frametype == AST_FRAME_DTMF) { - if (option_debug) - ast_log(LOG_DEBUG, "User pressed a key\n"); + ast_debug(1, "User pressed a key\n"); ast_frfree(f); res = 0; break; diff --git a/apps/app_osplookup.c b/apps/app_osplookup.c index 0e62e7819..dd5116fd5 100644 --- a/apps/app_osplookup.c +++ b/apps/app_osplookup.c @@ -223,16 +223,14 @@ static int osp_create_provider( } else { snprintf(p->privatekey, sizeof(p->privatekey), "%s/%s", ast_config_AST_KEY_DIR, v->value); } - if (option_debug) - ast_log(LOG_DEBUG, "OSP: privatekey '%s'\n", p->privatekey); + ast_debug(1, "OSP: privatekey '%s'\n", p->privatekey); } else if (!strcasecmp(v->name, "localcert")) { if (v->value[0] == '/') { ast_copy_string(p->localcert, v->value, sizeof(p->localcert)); } else { snprintf(p->localcert, sizeof(p->localcert), "%s/%s", ast_config_AST_KEY_DIR, v->value); } - if (option_debug) - ast_log(LOG_DEBUG, "OSP: localcert '%s'\n", p->localcert); + ast_debug(1, "OSP: localcert '%s'\n", p->localcert); } else if (!strcasecmp(v->name, "cacert")) { if (p->cacount < OSP_MAX_CERTS) { if (v->value[0] == '/') { @@ -240,8 +238,7 @@ static int osp_create_provider( } else { snprintf(p->cacerts[p->cacount], sizeof(p->cacerts[0]), "%s/%s", ast_config_AST_KEY_DIR, v->value); } - if (option_debug) - ast_log(LOG_DEBUG, "OSP: cacert[%d]: '%s'\n", p->cacount, p->cacerts[p->cacount]); + ast_debug(1, "OSP: cacert[%d]: '%s'\n", p->cacount, p->cacerts[p->cacount]); p->cacount++; } else { ast_log(LOG_WARNING, "OSP: Too many CA Certificates at line %d\n", v->lineno); @@ -249,8 +246,7 @@ static int osp_create_provider( } else if (!strcasecmp(v->name, "servicepoint")) { if (p->spcount < OSP_MAX_SRVS) { ast_copy_string(p->srvpoints[p->spcount], v->value, sizeof(p->srvpoints[0])); - if (option_debug) - ast_log(LOG_DEBUG, "OSP: servicepoint[%d]: '%s'\n", p->spcount, p->srvpoints[p->spcount]); + ast_debug(1, "OSP: servicepoint[%d]: '%s'\n", p->spcount, p->srvpoints[p->spcount]); p->spcount++; } else { ast_log(LOG_WARNING, "OSP: Too many Service Points at line %d\n", v->lineno); @@ -258,8 +254,7 @@ static int osp_create_provider( } else if (!strcasecmp(v->name, "maxconnections")) { if ((sscanf(v->value, "%d", &t) == 1) && (t >= OSP_MIN_MAXCONNECTIONS) && (t <= OSP_MAX_MAXCONNECTIONS)) { p->maxconnections = t; - if (option_debug) - ast_log(LOG_DEBUG, "OSP: maxconnections '%d'\n", t); + ast_debug(1, "OSP: maxconnections '%d'\n", t); } else { ast_log(LOG_WARNING, "OSP: maxconnections should be an integer from %d to %d, not '%s' at line %d\n", OSP_MIN_MAXCONNECTIONS, OSP_MAX_MAXCONNECTIONS, v->value, v->lineno); @@ -267,8 +262,7 @@ static int osp_create_provider( } else if (!strcasecmp(v->name, "retrydelay")) { if ((sscanf(v->value, "%d", &t) == 1) && (t >= OSP_MIN_RETRYDELAY) && (t <= OSP_MAX_RETRYDELAY)) { p->retrydelay = t; - if (option_debug) - ast_log(LOG_DEBUG, "OSP: retrydelay '%d'\n", t); + ast_debug(1, "OSP: retrydelay '%d'\n", t); } else { ast_log(LOG_WARNING, "OSP: retrydelay should be an integer from %d to %d, not '%s' at line %d\n", OSP_MIN_RETRYDELAY, OSP_MAX_RETRYDELAY, v->value, v->lineno); @@ -276,8 +270,7 @@ static int osp_create_provider( } else if (!strcasecmp(v->name, "retrylimit")) { if ((sscanf(v->value, "%d", &t) == 1) && (t >= OSP_MIN_RETRYLIMIT) && (t <= OSP_MAX_RETRYLIMIT)) { p->retrylimit = t; - if (option_debug) - ast_log(LOG_DEBUG, "OSP: retrylimit '%d'\n", t); + ast_debug(1, "OSP: retrylimit '%d'\n", t); } else { ast_log(LOG_WARNING, "OSP: retrylimit should be an integer from %d to %d, not '%s' at line %d\n", OSP_MIN_RETRYLIMIT, OSP_MAX_RETRYLIMIT, v->value, v->lineno); @@ -285,21 +278,18 @@ static int osp_create_provider( } else if (!strcasecmp(v->name, "timeout")) { if ((sscanf(v->value, "%d", &t) == 1) && (t >= OSP_MIN_TIMEOUT) && (t <= OSP_MAX_TIMEOUT)) { p->timeout = t; - if (option_debug) - ast_log(LOG_DEBUG, "OSP: timeout '%d'\n", t); + ast_debug(1, "OSP: timeout '%d'\n", t); } else { ast_log(LOG_WARNING, "OSP: timeout should be an integer from %d to %d, not '%s' at line %d\n", OSP_MIN_TIMEOUT, OSP_MAX_TIMEOUT, v->value, v->lineno); } } else if (!strcasecmp(v->name, "source")) { ast_copy_string(p->source, v->value, sizeof(p->source)); - if (option_debug) - ast_log(LOG_DEBUG, "OSP: source '%s'\n", p->source); + ast_debug(1, "OSP: source '%s'\n", p->source); } else if (!strcasecmp(v->name, "authpolicy")) { if ((sscanf(v->value, "%d", &t) == 1) && ((t == OSP_AUTH_NO) || (t == OSP_AUTH_YES) || (t == OSP_AUTH_EXCLUSIVE))) { p->authpolicy = t; - if (option_debug) - ast_log(LOG_DEBUG, "OSP: authpolicy '%d'\n", t); + ast_debug(1, "OSP: authpolicy '%d'\n", t); } else { ast_log(LOG_WARNING, "OSP: authpolicy should be %d, %d or %d, not '%s' at line %d\n", OSP_AUTH_NO, OSP_AUTH_YES, OSP_AUTH_EXCLUSIVE, v->value, v->lineno); @@ -307,16 +297,13 @@ static int osp_create_provider( } else if (!strcasecmp(v->name, "defaultprotocol")) { if (!strcasecmp(v->value, OSP_PROT_SIP)) { p->defaultprotocol = OSP_PROT_SIP; - if (option_debug) - ast_log(LOG_DEBUG, "OSP: default protocol '%s'\n", p->defaultprotocol); + ast_debug(1, "OSP: default protocol '%s'\n", p->defaultprotocol); } else if (!strcasecmp(v->value, OSP_PROT_H323)) { p->defaultprotocol = OSP_PROT_H323; - if (option_debug) - ast_log(LOG_DEBUG, "OSP: default protocol '%s'\n", p->defaultprotocol); + ast_debug(1, "OSP: default protocol '%s'\n", p->defaultprotocol); } else if (!strcasecmp(v->value, OSP_PROT_IAX)) { p->defaultprotocol = OSP_PROT_IAX; - if (option_debug) - ast_log(LOG_DEBUG, "OSP: default protocol '%s'\n", p->defaultprotocol); + ast_debug(1, "OSP: default protocol '%s'\n", p->defaultprotocol); } else { ast_log(LOG_WARNING, "OSP: default protocol should be %s, %s, %s, or %s not '%s' at line %d\n", OSP_PROT_SIP, OSP_PROT_H323, OSP_PROT_IAX, OSP_PROT_OTHER, v->value, v->lineno); @@ -344,8 +331,7 @@ static int osp_create_provider( if (p->cacount < 1) { snprintf(p->cacerts[p->cacount], sizeof(p->cacerts[0]), "%s/%s-cacert.pem", ast_config_AST_KEY_DIR, provider); - if (option_debug) - ast_log(LOG_DEBUG, "OSP: cacert[%d]: '%s'\n", p->cacount, p->cacerts[p->cacount]); + ast_debug(1, "OSP: cacert[%d]: '%s'\n", p->cacount, p->cacerts[p->cacount]); p->cacount++; } for (i = 0; i < p->cacount; i++) { @@ -397,8 +383,7 @@ static int osp_create_provider( ast_free(p); res = -1; } else { - if (option_debug) - ast_log(LOG_DEBUG, "OSP: provider '%s'\n", provider); + ast_debug(1, "OSP: provider '%s'\n", provider); ast_mutex_lock(&osplock); p->next = ospproviders; ospproviders = p; @@ -439,8 +424,7 @@ static int osp_get_provider( while(p) { if (!strcasecmp(p->name, name)) { *provider = p; - if (option_debug) - ast_log(LOG_DEBUG, "OSP: find provider '%s'\n", name); + ast_debug(1, "OSP: find provider '%s'\n", name); res = 1; break; } @@ -475,16 +459,13 @@ static int osp_create_transaction( if (!strcasecmp(p->name, provider)) { error = OSPPTransactionNew(p->handle, transaction); if (error == OSPC_ERR_NO_ERROR) { - if (option_debug) - ast_log(LOG_DEBUG, "OSP: transaction '%d'\n", *transaction); + ast_debug(1, "OSP: transaction '%d'\n", *transaction); ast_copy_string(source, p->source, sourcesize); - if (option_debug) - ast_log(LOG_DEBUG, "OSP: source '%s'\n", source); + ast_debug(1, "OSP: source '%s'\n", source); res = 1; } else { *transaction = OSP_INVALID_HANDLE; - if (option_debug) - ast_log(LOG_DEBUG, "OSP: Unable to create transaction handle, error '%d'\n", error); + ast_debug(1, "OSP: Unable to create transaction handle, error '%d'\n", error); res = -1; } break; @@ -568,16 +549,13 @@ static int osp_validate_token( NULL, osp_tokenformat); if (error != OSPC_ERR_NO_ERROR) { - if (option_debug) - ast_log(LOG_DEBUG, "OSP: Unable to validate inbound token\n"); + ast_debug(1, "OSP: Unable to validate inbound token\n"); res = -1; } else if (authorised) { - if (option_debug) - ast_log(LOG_DEBUG, "OSP: Authorised\n"); + ast_debug(1, "OSP: Authorised\n"); res = 1; } else { - if (option_debug) - ast_log(LOG_DEBUG, "OSP: Unauthorised\n"); + ast_debug(1, "OSP: Unauthorised\n"); res = 0; } @@ -631,15 +609,13 @@ static int osp_check_destination( int error; if (strlen(destination) <= 2) { - if (option_debug) - ast_log(LOG_DEBUG, "OSP: Wrong destination format '%s'\n", destination); + ast_debug(1, "OSP: Wrong destination format '%s'\n", destination); *reason = OSPC_FAIL_NORMAL_UNSPECIFIED; return -1; } if ((error = OSPPTransactionIsDestOSPEnabled(result->outhandle, &enabled)) != OSPC_ERR_NO_ERROR) { - if (option_debug) - ast_log(LOG_DEBUG, "OSP: Unable to get destination OSP version, error '%d'\n", error); + ast_debug(1, "OSP: Unable to get destination OSP version, error '%d'\n", error); *reason = OSPC_FAIL_NORMAL_UNSPECIFIED; return -1; } @@ -651,14 +627,12 @@ static int osp_check_destination( } if ((error = OSPPTransactionGetDestNetworkId(result->outhandle, result->networkid)) != OSPC_ERR_NO_ERROR) { - if (option_debug) - ast_log(LOG_DEBUG, "OSP: Unable to get destination network ID, error '%d'\n", error); + ast_debug(1, "OSP: Unable to get destination network ID, error '%d'\n", error); result->networkid[0] = '\0'; } if ((error = OSPPTransactionGetDestProtocol(result->outhandle, &protocol)) != OSPC_ERR_NO_ERROR) { - if (option_debug) - ast_log(LOG_DEBUG, "OSP: Unable to get destination protocol, error '%d'\n", error); + ast_debug(1, "OSP: Unable to get destination protocol, error '%d'\n", error); *reason = OSPC_FAIL_NORMAL_UNSPECIFIED; result->token[0] = '\0'; result->networkid[0] = '\0'; @@ -670,24 +644,21 @@ static int osp_check_destination( destination[strlen(destination) - 1] = '\0'; switch(protocol) { case OSPE_DEST_PROT_H323_SETUP: - if (option_debug) - ast_log(LOG_DEBUG, "OSP: protocol '%s'\n", OSP_PROT_H323); + ast_debug(1, "OSP: protocol '%s'\n", OSP_PROT_H323); ast_copy_string(result->tech, OSP_TECH_H323, sizeof(result->tech)); ast_copy_string(result->dest, destination + 1, sizeof(result->dest)); ast_copy_string(result->called, called, sizeof(result->called)); ast_copy_string(result->calling, calling, sizeof(result->calling)); break; case OSPE_DEST_PROT_SIP: - if (option_debug) - ast_log(LOG_DEBUG, "OSP: protocol '%s'\n", OSP_PROT_SIP); + ast_debug(1, "OSP: protocol '%s'\n", OSP_PROT_SIP); ast_copy_string(result->tech, OSP_TECH_SIP, sizeof(result->tech)); ast_copy_string(result->dest, destination + 1, sizeof(result->dest)); ast_copy_string(result->called, called, sizeof(result->called)); ast_copy_string(result->calling, calling, sizeof(result->calling)); break; case OSPE_DEST_PROT_IAX: - if (option_debug) - ast_log(LOG_DEBUG, "OSP: protocol '%s'\n", OSP_PROT_IAX); + ast_debug(1, "OSP: protocol '%s'\n", OSP_PROT_IAX); ast_copy_string(result->tech, OSP_TECH_IAX, sizeof(result->tech)); ast_copy_string(result->dest, destination + 1, sizeof(result->dest)); ast_copy_string(result->called, called, sizeof(result->called)); @@ -695,10 +666,9 @@ static int osp_check_destination( break; case OSPE_DEST_PROT_UNDEFINED: case OSPE_DEST_PROT_UNKNOWN: - if (option_debug) { - ast_log(LOG_DEBUG, "OSP: unknown/undefined protocol '%d'\n", protocol); - ast_log(LOG_DEBUG, "OSP: use default protocol '%s'\n", provider->defaultprotocol); - } + ast_debug(1, "OSP: unknown/undefined protocol '%d'\n", protocol); + ast_debug(1, "OSP: use default protocol '%s'\n", provider->defaultprotocol); + ast_copy_string(result->tech, provider->defaultprotocol, sizeof(result->tech)); ast_copy_string(result->dest, destination + 1, sizeof(result->dest)); ast_copy_string(result->called, called, sizeof(result->called)); @@ -756,8 +726,7 @@ static int osp_auth( *timelimit = OSP_DEF_TIMELIMIT; if ((res = osp_get_provider(provider, &p)) <= 0) { - if (option_debug) - ast_log(LOG_DEBUG, "OSP: Unabe to find OSP provider '%s'\n", provider); + ast_debug(1, "OSP: Unabe to find OSP provider '%s'\n", provider); return res; } @@ -769,8 +738,7 @@ static int osp_auth( if (ast_strlen_zero(token)) { res = 0; } else if ((res = osp_create_transaction(provider, transaction, sizeof(dest), dest)) <= 0) { - if (option_debug) - ast_log(LOG_DEBUG, "OSP: Unable to generate transaction handle\n"); + ast_debug(1, "OSP: Unable to generate transaction handle\n"); *transaction = OSP_INVALID_HANDLE; res = 0; } else if((res = osp_validate_token(*transaction, source, dest, calling, called, token, timelimit)) <= 0) { @@ -782,8 +750,7 @@ static int osp_auth( if (ast_strlen_zero(token)) { res = 1; } else if ((res = osp_create_transaction(provider, transaction, sizeof(dest), dest)) <= 0) { - if (option_debug) - ast_log(LOG_DEBUG, "OSP: Unable to generate transaction handle\n"); + ast_debug(1, "OSP: Unable to generate transaction handle\n"); *transaction = OSP_INVALID_HANDLE; res = 0; } else if((res = osp_validate_token(*transaction, source, dest, calling, called, token, timelimit)) <= 0) { @@ -928,14 +895,12 @@ static int osp_lookup( result->outtimelimit = OSP_DEF_TIMELIMIT; if ((res = osp_get_provider(provider, &p)) <= 0) { - if (option_debug) - ast_log(LOG_DEBUG, "OSP: Unabe to find OSP provider '%s'\n", provider); + ast_debug(1, "OSP: Unabe to find OSP provider '%s'\n", provider); return res; } if ((res = osp_create_transaction(provider, &result->outhandle, sizeof(source), source)) <= 0) { - if (option_debug) - ast_log(LOG_DEBUG, "OSP: Unable to generate transaction handle\n"); + ast_debug(1, "OSP: Unable to generate transaction handle\n"); result->outhandle = OSP_INVALID_HANDLE; if (result->inhandle != OSP_INVALID_HANDLE) { OSPPTransactionRecordFailure(result->inhandle, OSPC_FAIL_NORMAL_UNSPECIFIED); @@ -980,8 +945,7 @@ static int osp_lookup( } if (error != OSPC_ERR_NO_ERROR) { - if (option_debug) - ast_log(LOG_DEBUG, "OSP: Unable to request authorization\n"); + ast_debug(1, "OSP: Unable to request authorization\n"); result->numresults = 0; if (result->inhandle != OSP_INVALID_HANDLE) { OSPPTransactionRecordFailure(result->inhandle, OSPC_FAIL_NORMAL_UNSPECIFIED); @@ -990,8 +954,7 @@ static int osp_lookup( } if (!result->numresults) { - if (option_debug) - ast_log(LOG_DEBUG, "OSP: No more destination\n"); + ast_debug(1, "OSP: No more destination\n"); if (result->inhandle != OSP_INVALID_HANDLE) { OSPPTransactionRecordFailure(result->inhandle, OSPC_FAIL_NO_ROUTE_TO_DEST); } @@ -1019,8 +982,7 @@ static int osp_lookup( &tokenlen, token); if (error != OSPC_ERR_NO_ERROR) { - if (option_debug) - ast_log(LOG_DEBUG, "OSP: Unable to get first route\n"); + ast_debug(1, "OSP: Unable to get first route\n"); result->numresults = 0; result->outtimelimit = OSP_DEF_TIMELIMIT; if (result->inhandle != OSP_INVALID_HANDLE) { @@ -1031,21 +993,18 @@ static int osp_lookup( result->numresults--; result->outtimelimit = osp_choose_timelimit(result->intimelimit, result->outtimelimit); - if (option_debug) { - ast_log(LOG_DEBUG, "OSP: outtimelimit '%d'\n", result->outtimelimit); - ast_log(LOG_DEBUG, "OSP: called '%s'\n", callednum); - ast_log(LOG_DEBUG, "OSP: calling '%s'\n", callingnum); - ast_log(LOG_DEBUG, "OSP: destination '%s'\n", destination); - ast_log(LOG_DEBUG, "OSP: token size '%d'\n", tokenlen); - } + ast_debug(1, "OSP: outtimelimit '%d'\n", result->outtimelimit); + ast_debug(1, "OSP: called '%s'\n", callednum); + ast_debug(1, "OSP: calling '%s'\n", callingnum); + ast_debug(1, "OSP: destination '%s'\n", destination); + ast_debug(1, "OSP: token size '%d'\n", tokenlen); if ((res = osp_check_destination(p, callednum, callingnum, destination, tokenlen, token, &reason, result)) > 0) { return 1; } if (!result->numresults) { - if (option_debug) - ast_log(LOG_DEBUG, "OSP: No more destination\n"); + ast_debug(1, "OSP: No more destination\n"); result->outtimelimit = OSP_DEF_TIMELIMIT; OSPPTransactionRecordFailure(result->outhandle, reason); if (result->inhandle != OSP_INVALID_HANDLE) { @@ -1079,18 +1038,16 @@ static int osp_lookup( if (error == OSPC_ERR_NO_ERROR) { result->numresults--; result->outtimelimit = osp_choose_timelimit(result->intimelimit, result->outtimelimit); - if (option_debug) { - ast_log(LOG_DEBUG, "OSP: outtimelimit '%d'\n", result->outtimelimit); - ast_log(LOG_DEBUG, "OSP: called '%s'\n", callednum); - ast_log(LOG_DEBUG, "OSP: calling '%s'\n", callingnum); - ast_log(LOG_DEBUG, "OSP: destination '%s'\n", destination); - ast_log(LOG_DEBUG, "OSP: token size '%d'\n", tokenlen); - } + ast_debug(1, "OSP: outtimelimit '%d'\n", result->outtimelimit); + ast_debug(1, "OSP: called '%s'\n", callednum); + ast_debug(1, "OSP: calling '%s'\n", callingnum); + ast_debug(1, "OSP: destination '%s'\n", destination); + ast_debug(1, "OSP: token size '%d'\n", tokenlen); + if ((res = osp_check_destination(p, callednum, callingnum, destination, tokenlen, token, &reason, result)) > 0) { break; } else if (!result->numresults) { - if (option_debug) - ast_log(LOG_DEBUG, "OSP: No more destination\n"); + ast_debug(1, "OSP: No more destination\n"); OSPPTransactionRecordFailure(result->outhandle, reason); if (result->inhandle != OSP_INVALID_HANDLE) { OSPPTransactionRecordFailure(result->inhandle, OSPC_FAIL_NO_ROUTE_TO_DEST); @@ -1099,8 +1056,7 @@ static int osp_lookup( break; } } else { - if (option_debug) - ast_log(LOG_DEBUG, "OSP: Unable to get route, error '%d'\n", error); + ast_debug(1, "OSP: Unable to get route, error '%d'\n", error); result->numresults = 0; result->outtimelimit = OSP_DEF_TIMELIMIT; if (result->inhandle != OSP_INVALID_HANDLE) { @@ -1144,14 +1100,12 @@ static int osp_next( result->outtimelimit = OSP_DEF_TIMELIMIT; if ((res = osp_get_provider(provider, &p)) <= 0) { - if (option_debug) - ast_log(LOG_DEBUG, "OSP: Unabe to find OSP provider '%s'\n", provider); + ast_debug(1, "OSP: Unabe to find OSP provider '%s'\n", provider); return res; } if (result->outhandle == OSP_INVALID_HANDLE) { - if (option_debug) - ast_log(LOG_DEBUG, "OSP: Transaction handle undefined\n"); + ast_debug(1, "OSP: Transaction handle undefined\n"); result->numresults = 0; if (result->inhandle != OSP_INVALID_HANDLE) { OSPPTransactionRecordFailure(result->inhandle, OSPC_FAIL_NORMAL_UNSPECIFIED); @@ -1162,8 +1116,7 @@ static int osp_next( reason = asterisk2osp(cause); if (!result->numresults) { - if (option_debug) - ast_log(LOG_DEBUG, "OSP: No more destination\n"); + ast_debug(1, "OSP: No more destination\n"); OSPPTransactionRecordFailure(result->outhandle, reason); if (result->inhandle != OSP_INVALID_HANDLE) { OSPPTransactionRecordFailure(result->inhandle, OSPC_FAIL_NO_ROUTE_TO_DEST); @@ -1196,19 +1149,17 @@ static int osp_next( if (error == OSPC_ERR_NO_ERROR) { result->numresults--; result->outtimelimit = osp_choose_timelimit(result->intimelimit, result->outtimelimit); - if (option_debug) { - ast_log(LOG_DEBUG, "OSP: outtimelimit '%d'\n", result->outtimelimit); - ast_log(LOG_DEBUG, "OSP: called '%s'\n", callednum); - ast_log(LOG_DEBUG, "OSP: calling '%s'\n", callingnum); - ast_log(LOG_DEBUG, "OSP: destination '%s'\n", destination); - ast_log(LOG_DEBUG, "OSP: token size '%d'\n", tokenlen); - } + ast_debug(1, "OSP: outtimelimit '%d'\n", result->outtimelimit); + ast_debug(1, "OSP: called '%s'\n", callednum); + ast_debug(1, "OSP: calling '%s'\n", callingnum); + ast_debug(1, "OSP: destination '%s'\n", destination); + ast_debug(1, "OSP: token size '%d'\n", tokenlen); + if ((res = osp_check_destination(p, callednum, callingnum, destination, tokenlen, token, &reason, result)) > 0) { res = 1; break; } else if (!result->numresults) { - if (option_debug) - ast_log(LOG_DEBUG, "OSP: No more destination\n"); + ast_debug(1, "OSP: No more destination\n"); OSPPTransactionRecordFailure(result->outhandle, reason); if (result->inhandle != OSP_INVALID_HANDLE) { OSPPTransactionRecordFailure(result->inhandle, OSPC_FAIL_NO_ROUTE_TO_DEST); @@ -1217,8 +1168,7 @@ static int osp_next( break; } } else { - if (option_debug) - ast_log(LOG_DEBUG, "OSP: Unable to get route, error '%d'\n", error); + ast_debug(1, "OSP: Unable to get route, error '%d'\n", error); result->token[0] = '\0'; result->numresults = 0; result->outtimelimit = OSP_DEF_TIMELIMIT; @@ -1288,12 +1238,10 @@ static int osp_finish( &dummy, NULL); if (error == OSPC_ERR_NO_ERROR) { - if (option_debug) - ast_log(LOG_DEBUG, "OSP: Usage reported\n"); + ast_debug(1, "OSP: Usage reported\n"); res = 1; } else { - if (option_debug) - ast_log(LOG_DEBUG, "OSP: Unable to report usage, error '%d'\n", error); + ast_debug(1, "OSP: Unable to report usage, error '%d'\n", error); res = -1; } OSPPTransactionDelete(handle); @@ -1344,10 +1292,7 @@ static int ospauth_exec( if (!ast_strlen_zero(args.provider)) { provider = args.provider; } - if (option_debug) - ast_log(LOG_DEBUG, "OSPAuth: provider '%s'\n", provider); - - } + ast_debug(1, "OSPAuth: provider '%s'\n", provider); headp = &chan->varshead; AST_LIST_TRAVERSE(headp, current, entries) { @@ -1358,10 +1303,8 @@ static int ospauth_exec( } } - if (option_debug) { - ast_log(LOG_DEBUG, "OSPAuth: source '%s'\n", source); - ast_log(LOG_DEBUG, "OSPAuth: token size '%zd'\n", strlen(token)); - } + ast_debug(1, "OSPAuth: source '%s'\n", source); + ast_debug(1, "OSPAuth: token size '%zd'\n", strlen(token)); if ((res = osp_auth(provider, &handle, source, chan->cid.cid_num, chan->exten, token, &timelimit)) > 0) { status = AST_OSP_SUCCESS; @@ -1376,15 +1319,12 @@ static int ospauth_exec( snprintf(buffer, sizeof(buffer), "%d", handle); pbx_builtin_setvar_helper(chan, "OSPINHANDLE", buffer); - if (option_debug) - ast_log(LOG_DEBUG, "OSPAuth: OSPINHANDLE '%s'\n", buffer); + ast_debug(1, "OSPAuth: OSPINHANDLE '%s'\n", buffer); snprintf(buffer, sizeof(buffer), "%d", timelimit); pbx_builtin_setvar_helper(chan, "OSPINTIMELIMIT", buffer); - if (option_debug) - ast_log(LOG_DEBUG, "OSPAuth: OSPINTIMELIMIT '%s'\n", buffer); + ast_debug(1, "OSPAuth: OSPINTIMELIMIT '%s'\n", buffer); pbx_builtin_setvar_helper(chan, "OSPAUTHSTATUS", status); - if (option_debug) - ast_log(LOG_DEBUG, "OSPAuth: %s\n", status); + ast_debug(1, "OSPAuth: %s\n", status); if(res <= 0) { res = -1; @@ -1441,14 +1381,12 @@ static int osplookup_exec( AST_STANDARD_APP_ARGS(args, tmp); - if (option_debug) - ast_log(LOG_DEBUG, "OSPLookup: exten '%s'\n", args.exten); + ast_debug(1, "OSPLookup: exten '%s'\n", args.exten); if (!ast_strlen_zero(args.provider)) { provider = args.provider; } - if (option_debug) - ast_log(LOG_DEBUG, "OSPlookup: provider '%s'\n", provider); + ast_debug(1, "OSPlookup: provider '%s'\n", provider); if (args.options) { if (strchr(args.options, 'h')) { @@ -1461,9 +1399,7 @@ static int osplookup_exec( callidtypes |= OSP_CALLID_IAX; } } - if (option_debug) { - ast_log(LOG_DEBUG, "OSPLookup: call id types '%d'\n", callidtypes); - } + ast_debug(1, "OSPLookup: call id types '%d'\n", callidtypes); result.inhandle = OSP_INVALID_HANDLE; result.intimelimit = OSP_DEF_TIMELIMIT; @@ -1484,12 +1420,10 @@ static int osplookup_exec( srcdev = ast_var_value(current); } } - if (option_debug) { - ast_log(LOG_DEBUG, "OSPLookup: OSPINHANDLE '%d'\n", result.inhandle); - ast_log(LOG_DEBUG, "OSPLookup: OSPINTIMELIMIT '%d'\n", result.intimelimit); - ast_log(LOG_DEBUG, "OSPLookup: OSPINNETWORKID '%s'\n", netid); - ast_log(LOG_DEBUG, "OSPLookup: source device '%s'\n", srcdev); - } + ast_debug(1, "OSPLookup: OSPINHANDLE '%d'\n", result.inhandle); + ast_debug(1, "OSPLookup: OSPINTIMELIMIT '%d'\n", result.intimelimit); + ast_debug(1, "OSPLookup: OSPINNETWORKID '%s'\n", netid); + ast_debug(1, "OSPLookup: source device '%s'\n", srcdev); if ((cres = ast_autoservice_start(chan)) < 0) { ast_module_user_remove(u); @@ -1518,38 +1452,28 @@ static int osplookup_exec( snprintf(buffer, sizeof(buffer), "%d", result.outhandle); pbx_builtin_setvar_helper(chan, "OSPOUTHANDLE", buffer); - if (option_debug) - ast_log(LOG_DEBUG, "OSPLookup: OSPOUTHANDLE '%s'\n", buffer); + ast_debug(1, "OSPLookup: OSPOUTHANDLE '%s'\n", buffer); pbx_builtin_setvar_helper(chan, "OSPTECH", result.tech); - if (option_debug) - ast_log(LOG_DEBUG, "OSPLookup: OSPTECH '%s'\n", result.tech); + ast_debug(1, "OSPLookup: OSPTECH '%s'\n", result.tech); pbx_builtin_setvar_helper(chan, "OSPDEST", result.dest); - if (option_debug) - ast_log(LOG_DEBUG, "OSPLookup: OSPDEST '%s'\n", result.dest); + ast_debug(1, "OSPLookup: OSPDEST '%s'\n", result.dest); pbx_builtin_setvar_helper(chan, "OSPCALLED", result.called); - if (option_debug) - ast_log(LOG_DEBUG, "OSPLookup: OSPCALLED '%s'\n", result.called); + ast_debug(1, "OSPLookup: OSPCALLED '%s'\n", result.called); pbx_builtin_setvar_helper(chan, "OSPCALLING", result.calling); - if (option_debug) - ast_log(LOG_DEBUG, "OSPLookup: OSPCALLING '%s'\n", result.calling); + ast_debug(1, "OSPLookup: OSPCALLING '%s'\n", result.calling); pbx_builtin_setvar_helper(chan, "OSPOUTTOKEN", result.token); - if (option_debug) - ast_log(LOG_DEBUG, "OSPLookup: OSPOUTTOKEN size '%zd'\n", strlen(result.token)); + ast_debug(1, "OSPLookup: OSPOUTTOKEN size '%zd'\n", strlen(result.token)); snprintf(buffer, sizeof(buffer), "%d", result.numresults); pbx_builtin_setvar_helper(chan, "OSPRESULTS", buffer); - if (option_debug) - ast_log(LOG_DEBUG, "OSPLookup: OSPRESULTS '%s'\n", buffer); + ast_debug(1, "OSPLookup: OSPRESULTS '%s'\n", buffer); snprintf(buffer, sizeof(buffer), "%d", result.outtimelimit); pbx_builtin_setvar_helper(chan, "OSPOUTTIMELIMIT", buffer); - if (option_debug) - ast_log(LOG_DEBUG, "OSPLookup: OSPOUTTIMELIMIT '%s'\n", buffer); + ast_debug(1, "OSPLookup: OSPOUTTIMELIMIT '%s'\n", buffer); snprintf(buffer, sizeof(buffer), "%d", callidtypes); pbx_builtin_setvar_helper(chan, "OSPOUTCALLIDTYPES", buffer); - if (option_debug) - ast_log(LOG_DEBUG, "OSPLookup: OSPOUTCALLIDTYPES '%s'\n", buffer); + ast_debug(1, "OSPLookup: OSPOUTCALLIDTYPES '%s'\n", buffer); pbx_builtin_setvar_helper(chan, "OSPLOOKUPSTATUS", status); - if (option_debug) - ast_log(LOG_DEBUG, "OSPLookup: %s\n", status); + ast_debug(1, "OSPLookup: %s\n", status); if (!strcasecmp(result.tech, OSP_TECH_H323)) { if ((callidtypes & OSP_CALLID_H323) && (result.outcallid.len != 0)) { @@ -1566,8 +1490,7 @@ static int osplookup_exec( if (!ast_strlen_zero(result.token)) { snprintf(buffer, sizeof(buffer), "%s%s", OSP_SIP_HEADER, result.token); pbx_builtin_setvar_helper(chan, "_SIPADDHEADER", buffer); - if (option_debug) - ast_log(LOG_DEBUG, "OSPLookup: SIPADDHEADER size '%zd'\n", strlen(buffer)); + ast_debug(1, "OSPLookup: SIPADDHEADER size '%zd'\n", strlen(buffer)); } } else if (!strcasecmp(result.tech, OSP_TECH_IAX)) { snprintf(buffer, sizeof(buffer), "%s/%s/%s", result.tech, result.dest, result.called); @@ -1636,14 +1559,12 @@ static int ospnext_exec( if (!ast_strlen_zero(args.cause) && sscanf(args.cause, "%d", &cause) != 1) { cause = 0; } - if (option_debug) - ast_log(LOG_DEBUG, "OSPNext: cause '%d'\n", cause); + ast_debug(1, "OSPNext: cause '%d'\n", cause); if (!ast_strlen_zero(args.provider)) { provider = args.provider; } - if (option_debug) - ast_log(LOG_DEBUG, "OSPlookup: provider '%s'\n", provider); + ast_debug(1, "OSPlookup: provider '%s'\n", provider); result.inhandle = OSP_INVALID_HANDLE; result.outhandle = OSP_INVALID_HANDLE; @@ -1674,13 +1595,11 @@ static int ospnext_exec( } } } - if (option_debug) { - ast_log(LOG_DEBUG, "OSPNext: OSPINHANDLE '%d'\n", result.inhandle); - ast_log(LOG_DEBUG, "OSPNext: OSPOUTHANDLE '%d'\n", result.outhandle); - ast_log(LOG_DEBUG, "OSPNext: OSPINTIMELIMIT '%d'\n", result.intimelimit); - ast_log(LOG_DEBUG, "OSPNext: OSPOUTCALLIDTYPES '%d'\n", callidtypes); - ast_log(LOG_DEBUG, "OSPNext: OSPRESULTS '%d'\n", result.numresults); - } + ast_debug(1, "OSPNext: OSPINHANDLE '%d'\n", result.inhandle); + ast_debug(1, "OSPNext: OSPOUTHANDLE '%d'\n", result.outhandle); + ast_debug(1, "OSPNext: OSPINTIMELIMIT '%d'\n", result.intimelimit); + ast_debug(1, "OSPNext: OSPOUTCALLIDTYPES '%d'\n", callidtypes); + ast_debug(1, "OSPNext: OSPRESULTS '%d'\n", result.numresults); if ((res = osp_next(provider, cause, &result)) > 0) { status = AST_OSP_SUCCESS; @@ -1703,31 +1622,23 @@ static int ospnext_exec( } pbx_builtin_setvar_helper(chan, "OSPTECH", result.tech); - if (option_debug) - ast_log(LOG_DEBUG, "OSPNext: OSPTECH '%s'\n", result.tech); + ast_debug(1, "OSPNext: OSPTECH '%s'\n", result.tech); pbx_builtin_setvar_helper(chan, "OSPDEST", result.dest); - if (option_debug) - ast_log(LOG_DEBUG, "OSPNext: OSPDEST '%s'\n", result.dest); + ast_debug(1, "OSPNext: OSPDEST '%s'\n", result.dest); pbx_builtin_setvar_helper(chan, "OSPCALLED", result.called); - if (option_debug) - ast_log(LOG_DEBUG, "OSPNext: OSPCALLED'%s'\n", result.called); + ast_debug(1, "OSPNext: OSPCALLED'%s'\n", result.called); pbx_builtin_setvar_helper(chan, "OSPCALLING", result.calling); - if (option_debug) - ast_log(LOG_DEBUG, "OSPNext: OSPCALLING '%s'\n", result.calling); + ast_debug(1, "OSPNext: OSPCALLING '%s'\n", result.calling); pbx_builtin_setvar_helper(chan, "OSPOUTTOKEN", result.token); - if (option_debug) - ast_log(LOG_DEBUG, "OSPNext: OSPOUTTOKEN size '%zd'\n", strlen(result.token)); + ast_debug(1, "OSPNext: OSPOUTTOKEN size '%zd'\n", strlen(result.token)); snprintf(buffer, sizeof(buffer), "%d", result.numresults); pbx_builtin_setvar_helper(chan, "OSPRESULTS", buffer); - if (option_debug) - ast_log(LOG_DEBUG, "OSPNext: OSPRESULTS '%s'\n", buffer); + ast_debug(1, "OSPNext: OSPRESULTS '%s'\n", buffer); snprintf(buffer, sizeof(buffer), "%d", result.outtimelimit); pbx_builtin_setvar_helper(chan, "OSPOUTTIMELIMIT", buffer); - if (option_debug) - ast_log(LOG_DEBUG, "OSPNext: OSPOUTTIMELIMIT '%s'\n", buffer); + ast_debug(1, "OSPNext: OSPOUTTIMELIMIT '%s'\n", buffer); pbx_builtin_setvar_helper(chan, "OSPNEXTSTATUS", status); - if (option_debug) - ast_log(LOG_DEBUG, "OSPNext: %s\n", status); + ast_debug(1, "OSPNext: %s\n", status); if (!strcasecmp(result.tech, OSP_TECH_H323)) { if ((callidtypes & OSP_CALLID_H323) && (result.outcallid.len != 0)) { @@ -1744,8 +1655,7 @@ static int ospnext_exec( if (!ast_strlen_zero(result.token)) { snprintf(buffer, sizeof(buffer), "%s%s", OSP_SIP_HEADER, result.token); pbx_builtin_setvar_helper(chan, "_SIPADDHEADER", buffer); - if (option_debug) - ast_log(LOG_DEBUG, "OSPLookup: SIPADDHEADER size '%zd'\n", strlen(buffer)); + ast_debug(1, "OSPLookup: SIPADDHEADER size '%zd'\n", strlen(buffer)); } } else if (!strcasecmp(result.tech, OSP_TECH_IAX)) { snprintf(buffer, sizeof(buffer), "%s/%s/%s", result.tech, result.dest, result.called); @@ -1822,17 +1732,14 @@ static int ospfinished_exec( } } } - if (option_debug) { - ast_log(LOG_DEBUG, "OSPFinish: OSPINHANDLE '%d'\n", inhandle); - ast_log(LOG_DEBUG, "OSPFinish: OSPOUTHANDLE '%d'\n", outhandle); - ast_log(LOG_DEBUG, "OSPFinish: recorded '%d'\n", recorded); - } + ast_debug(1, "OSPFinish: OSPINHANDLE '%d'\n", inhandle); + ast_debug(1, "OSPFinish: OSPOUTHANDLE '%d'\n", outhandle); + ast_debug(1, "OSPFinish: recorded '%d'\n", recorded); if (!ast_strlen_zero(args.cause) && sscanf(args.cause, "%d", &cause) != 1) { cause = 0; } - if (option_debug) - ast_log(LOG_DEBUG, "OSPFinish: cause '%d'\n", cause); + ast_debug(1, "OSPFinish: cause '%d'\n", cause); if (chan->cdr) { start = chan->cdr->start.tv_sec; @@ -1847,17 +1754,14 @@ static int ospfinished_exec( connect = 0; end = 0; } - if (option_debug) { - ast_log(LOG_DEBUG, "OSPFinish: start '%ld'\n", start); - ast_log(LOG_DEBUG, "OSPFinish: connect '%ld'\n", connect); - ast_log(LOG_DEBUG, "OSPFinish: end '%ld'\n", end); - } + ast_debug(1, "OSPFinish: start '%ld'\n", start); + ast_debug(1, "OSPFinish: connect '%ld'\n", connect); + ast_debug(1, "OSPFinish: end '%ld'\n", end); release = chan->_softhangup ? 0 : 1; if (osp_finish(outhandle, recorded, cause, start, connect, end, release) <= 0) { - if (option_debug) - ast_log(LOG_DEBUG, "OSPFinish: Unable to report usage for outbound call\n"); + ast_debug(1, "OSPFinish: Unable to report usage for outbound call\n"); } switch (cause) { case AST_CAUSE_NORMAL_CLEARING: @@ -1867,8 +1771,7 @@ static int ospfinished_exec( break; } if (osp_finish(inhandle, recorded, cause, start, connect, end, release) <= 0) { - if (option_debug) - ast_log(LOG_DEBUG, "OSPFinish: Unable to report usage for inbound call\n"); + ast_debug(1, "OSPFinish: Unable to report usage for inbound call\n"); } snprintf(buffer, sizeof(buffer), "%d", OSP_INVALID_HANDLE); pbx_builtin_setvar_helper(chan, "OSPOUTHANDLE", buffer); @@ -1916,8 +1819,7 @@ static int osp_load(void) } else { OSPPInit(0); } - if (option_debug) - ast_log(LOG_DEBUG, "OSP: osp_hardware '%d'\n", osp_hardware); + ast_debug(1, "OSP: osp_hardware '%d'\n", osp_hardware); t = ast_variable_retrieve(cfg, OSP_GENERAL_CAT, "tokenformat"); if (t) { @@ -1930,8 +1832,7 @@ static int osp_load(void) TOKEN_ALGO_SIGNED, TOKEN_ALGO_UNSIGNED, TOKEN_ALGO_BOTH, t); } } - if (option_debug) - ast_log(LOG_DEBUG, "OSP: osp_tokenformat '%d'\n", osp_tokenformat); + ast_debug(1, "OSP: osp_tokenformat '%d'\n", osp_tokenformat); t = ast_category_browse(cfg, NULL); while(t) { @@ -1948,8 +1849,7 @@ static int osp_load(void) ast_log(LOG_WARNING, "OSP: Unable to find configuration. OSP support disabled\n"); return 0; } - if (option_debug) - ast_log(LOG_DEBUG, "OSP: osp_initialized '%d'\n", osp_initialized); + ast_debug(1, "OSP: osp_initialized '%d'\n", osp_initialized); return 1; } diff --git a/apps/app_queue.c b/apps/app_queue.c index f7c14dec6..fb919f107 100644 --- a/apps/app_queue.c +++ b/apps/app_queue.c @@ -559,13 +559,11 @@ static void *handle_statechange(struct statechange *sc) AST_LIST_UNLOCK(&interfaces); if (!curint) { - if (option_debug > 2) - ast_log(LOG_DEBUG, "Device '%s/%s' changed to state '%d' (%s) but we don't care because they're not a member of any queue.\n", technology, loc, sc->state, devstate2str(sc->state)); + ast_debug(3, "Device '%s/%s' changed to state '%d' (%s) but we don't care because they're not a member of any queue.\n", technology, loc, sc->state, devstate2str(sc->state)); return NULL; } - if (option_debug) - ast_log(LOG_DEBUG, "Device '%s/%s' changed to state '%d' (%s)\n", technology, loc, sc->state, devstate2str(sc->state)); + ast_debug(1, "Device '%s/%s' changed to state '%d' (%s)\n", technology, loc, sc->state, devstate2str(sc->state)); AST_LIST_LOCK(&queues); AST_LIST_TRAVERSE(&queues, q, list) { ast_mutex_lock(&q->lock); @@ -772,8 +770,7 @@ static int add_to_interfaces(const char *interface) return 0; } - if (option_debug) - ast_log(LOG_DEBUG, "Adding %s to the list of interfaces that make up all of our queue members.\n", interface); + ast_debug(1, "Adding %s to the list of interfaces that make up all of our queue members.\n", interface); if ((curint = ast_calloc(1, sizeof(*curint)))) { ast_copy_string(curint->interface, interface, sizeof(curint->interface)); @@ -814,8 +811,7 @@ static int remove_from_interfaces(const char *interface) AST_LIST_TRAVERSE_SAFE_BEGIN(&interfaces, curint, list) { if (!strcasecmp(curint->interface, interface)) { if (!interface_exists_global(interface)) { - if (option_debug) - ast_log(LOG_DEBUG, "Removing %s from the list of interfaces that make up all of our queue members.\n", interface); + ast_debug(1, "Removing %s from the list of interfaces that make up all of our queue members.\n", interface); AST_LIST_REMOVE_CURRENT(&interfaces, list); ast_free(curint); } @@ -894,7 +890,7 @@ static void queue_set_param(struct call_queue *q, const char *param, const char q->announcefrequency = atoi(val); } else if (!strcasecmp(param, "min-announce-frequency")) { q->minannouncefrequency = atoi(val); - ast_log(LOG_DEBUG, "%s=%s for queue '%s'\n", param, val, q->name); + ast_debug(1, "%s=%s for queue '%s'\n", param, val, q->name); } else if (!strcasecmp(param, "announce-round-seconds")) { q->roundingseconds = atoi(val); /* Rounding to any other values just doesn't make sense... */ @@ -1116,8 +1112,7 @@ static struct call_queue *find_queue_by_name_rt(const char *queuename, struct as /*! \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. */ - if (option_debug) - ast_log(LOG_DEBUG, "Queue %s not found in realtime.\n", queuename); + ast_debug(1, "Queue %s not found in realtime.\n", queuename); q->dead = 1; /* Delete if unused (else will be deleted when last caller leaves). */ @@ -1299,8 +1294,7 @@ static int join_queue(char *queuename, struct queue_ent *qe, enum queue_result * S_OR(qe->chan->cid.cid_num, "unknown"), /* XXX somewhere else it is <unknown> */ S_OR(qe->chan->cid.cid_name, "unknown"), q->name, qe->pos, q->count, qe->chan->uniqueid ); - if (option_debug) - ast_log(LOG_DEBUG, "Queue '%s' Join, Channel '%s', Position '%d'\n", q->name, qe->chan->name, qe->pos ); + ast_debug(1, "Queue '%s' Join, Channel '%s', Position '%d'\n", q->name, qe->chan->name, qe->pos ); } ast_mutex_unlock(&q->lock); AST_LIST_UNLOCK(&queues); @@ -1497,8 +1491,7 @@ static void leave_queue(struct queue_ent *qe) manager_event(EVENT_FLAG_CALL, "Leave", "Channel: %s\r\nQueue: %s\r\nCount: %d\r\nUniqueid: %s\r\n", qe->chan->name, q->name, q->count, qe->chan->uniqueid); - if (option_debug) - ast_log(LOG_DEBUG, "Queue '%s' Leave, Channel '%s'\n", q->name, qe->chan->name ); + ast_debug(1, "Queue '%s' Leave, Channel '%s'\n", q->name, qe->chan->name ); /* Take us out of the queue */ if (prev) prev->next = cur->next; @@ -1599,11 +1592,9 @@ static int compare_weight(struct call_queue *rq, struct member *member) if (strcmp(mem->interface, member->interface)) continue; - if (option_debug) - ast_log(LOG_DEBUG, "Found matching member %s in queue '%s'\n", mem->interface, q->name); + ast_debug(1, "Found matching member %s in queue '%s'\n", mem->interface, q->name); if (q->weight > rq->weight) { - 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); + ast_debug(1, "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; } @@ -1670,8 +1661,7 @@ static int ring_entry(struct queue_ent *qe, struct callattempt *tmp, int *busies /* on entry here, we know that tmp->chan == NULL */ if (qe->parent->wrapuptime && (time(NULL) - tmp->lastcall < qe->parent->wrapuptime)) { - if (option_debug) - ast_log(LOG_DEBUG, "Wrapuptime not yet expired for %s\n", tmp->interface); + ast_debug(1, "Wrapuptime not yet expired for %s\n", tmp->interface); if (qe->chan->cdr) ast_cdr_busy(qe->chan->cdr); tmp->stillgoing = 0; @@ -1680,8 +1670,7 @@ static int ring_entry(struct queue_ent *qe, struct callattempt *tmp, int *busies } if (!qe->parent->ringinuse && (tmp->member->status != AST_DEVICE_NOT_INUSE) && (tmp->member->status != AST_DEVICE_UNKNOWN)) { - if (option_debug) - ast_log(LOG_DEBUG, "%s in use, can't receive call\n", tmp->interface); + ast_debug(1, "%s in use, can't receive call\n", tmp->interface); if (qe->chan->cdr) ast_cdr_busy(qe->chan->cdr); tmp->stillgoing = 0; @@ -1689,16 +1678,14 @@ static int ring_entry(struct queue_ent *qe, struct callattempt *tmp, int *busies } if (tmp->member->paused) { - if (option_debug) - ast_log(LOG_DEBUG, "%s paused, can't receive call\n", tmp->interface); + ast_debug(1, "%s paused, can't receive call\n", tmp->interface); if (qe->chan->cdr) ast_cdr_busy(qe->chan->cdr); tmp->stillgoing = 0; return 0; } if (use_weight && compare_weight(qe->parent,tmp->member)) { - if (option_debug) - ast_log(LOG_DEBUG, "Priority queue delaying call to %s:%s\n", qe->parent->name, tmp->interface); + ast_debug(1, "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; @@ -1751,8 +1738,7 @@ static int ring_entry(struct queue_ent *qe, struct callattempt *tmp, int *busies /* Place the call, but don't wait on the answer */ if ((res = ast_call(tmp->chan, location, 0))) { /* Again, keep going even if there's an error */ - if (option_debug) - ast_log(LOG_DEBUG, "ast call on peer returned %d\n", res); + ast_debug(1, "ast call on peer returned %d\n", res); if (option_verbose > 2) ast_verbose(VERBOSE_PREFIX_3 "Couldn't call %s\n", tmp->interface); do_hang(tmp); @@ -1805,8 +1791,7 @@ static int ring_one(struct queue_ent *qe, struct callattempt *outgoing, int *bus while (ret == 0) { struct callattempt *best = find_best(outgoing); if (!best) { - if (option_debug) - ast_log(LOG_DEBUG, "Nobody left to try ringing in queue\n"); + ast_debug(1, "Nobody left to try ringing in queue\n"); break; } if (qe->parent->strategy == QUEUE_STRATEGY_RINGALL) { @@ -1814,15 +1799,13 @@ static int ring_one(struct queue_ent *qe, struct callattempt *outgoing, int *bus /* Ring everyone who shares this best metric (for ringall) */ for (cur = outgoing; cur; cur = cur->q_next) { if (cur->stillgoing && !cur->chan && cur->metric <= best->metric) { - if (option_debug) - ast_log(LOG_DEBUG, "(Parallel) Trying '%s' with metric %d\n", cur->interface, cur->metric); + ast_debug(1, "(Parallel) Trying '%s' with metric %d\n", cur->interface, cur->metric); ring_entry(qe, cur, busies); } } } else { /* Ring just the best channel */ - if (option_debug) - ast_log(LOG_DEBUG, "Trying '%s' with metric %d\n", best->interface, best->metric); + ast_debug(1, "Trying '%s' with metric %d\n", best->interface, best->metric); ring_entry(qe, best, busies); } if (best->chan) /* break out with result = 1 */ @@ -1838,8 +1821,7 @@ static int store_next(struct queue_ent *qe, struct callattempt *outgoing) if (best) { /* Ring just the best channel */ - if (option_debug) - ast_log(LOG_DEBUG, "Next is '%s' with metric %d\n", best->interface, best->metric); + ast_debug(1, "Next is '%s' with metric %d\n", best->interface, best->metric); qe->parent->rrpos = best->metric % 1000; } else { /* Just increment rrpos */ @@ -1997,8 +1979,7 @@ static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callatte } if (pos == 1 /* not found */) { if (numlines == (numbusies + numnochan)) { - if (option_debug) - ast_log(LOG_DEBUG, "Everyone is busy at this time\n"); + ast_debug(1, "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); } @@ -2139,8 +2120,7 @@ static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callatte /* Ignore going off hook */ break; default: - if (option_debug) - ast_log(LOG_DEBUG, "Dunno what to do with control type %d\n", f->subclass); + ast_debug(1, "Dunno what to do with control type %d\n", f->subclass); } } ast_frfree(f); @@ -2202,12 +2182,10 @@ static int is_our_turn(struct queue_ent *qe) ch = qe->parent->head; /* If we are now at the top of the head, break out */ if (ch == qe) { - if (option_debug) - ast_log(LOG_DEBUG, "It's our turn (%s).\n", qe->chan->name); + ast_debug(1, "It's our turn (%s).\n", qe->chan->name); res = 1; } else { - if (option_debug) - ast_log(LOG_DEBUG, "It's not our turn (%s).\n", qe->chan->name); + ast_debug(1, "It's not our turn (%s).\n", qe->chan->name); res = 0; } @@ -2218,8 +2196,7 @@ static int is_our_turn(struct queue_ent *qe) ch = qe->parent->head; if (qe->parent->strategy == QUEUE_STRATEGY_RINGALL) { - if (option_debug) - ast_log(LOG_DEBUG, "Even though there are %d available members, the strategy is ringall so only the head call is allowed in\n", avl); + ast_debug(1, "Even though there are %d available members, the strategy is ringall so only the head call is allowed in\n", avl); avl = 1; } else { for (cur = qe->parent->members; cur; cur = cur->next) { @@ -2232,8 +2209,7 @@ static int is_our_turn(struct queue_ent *qe) } } - if (option_debug) - ast_log(LOG_DEBUG, "There are %d available members.\n", avl); + ast_debug(1, "There are %d available members.\n", avl); while ((idx < avl) && (ch) && (ch != qe)) { idx++; @@ -2242,12 +2218,10 @@ static int is_our_turn(struct queue_ent *qe) /* If the queue entry is within avl [the number of available members] calls from the top ... */ if (ch && idx < avl) { - if (option_debug) - ast_log(LOG_DEBUG, "It's our turn (%s).\n", qe->chan->name); + ast_debug(1, "It's our turn (%s).\n", qe->chan->name); res = 1; } else { - if (option_debug) - ast_log(LOG_DEBUG, "It's not our turn (%s).\n", qe->chan->name); + ast_debug(1, "It's not our turn (%s).\n", qe->chan->name); res = 0; } @@ -2497,8 +2471,7 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce if (use_weight) AST_LIST_LOCK(&queues); ast_mutex_lock(&qe->parent->lock); - if (option_debug) - ast_log(LOG_DEBUG, "%s is trying to call a queue member.\n", + ast_debug(1, "%s is trying to call a queue member.\n", qe->chan->name); ast_copy_string(queuename, qe->parent->name, sizeof(queuename)); cur = qe->parent->members; @@ -2558,8 +2531,7 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce } else { res = digit; } - if (option_debug) - ast_log(LOG_DEBUG, "%s: Nobody answered.\n", qe->chan->name); + ast_debug(1, "%s: Nobody answered.\n", qe->chan->name); } else { /* peer is valid */ /* Ah ha! Someone answered within the desired timeframe. Of course after this we will always return with -1 so that it is hung up properly after the @@ -2646,8 +2618,7 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce /* Begin Monitoring */ if (qe->parent->monfmt && *qe->parent->monfmt) { if (!qe->parent->montype) { - if (option_debug) - ast_log(LOG_DEBUG, "Starting Monitor as requested.\n"); + ast_debug(1, "Starting Monitor as requested.\n"); monitorfilename = pbx_builtin_getvar_helper(qe->chan, "MONITOR_FILENAME"); if (pbx_builtin_getvar_helper(qe->chan, "MONITOR_EXEC") || pbx_builtin_getvar_helper(qe->chan, "MONITOR_EXEC_ARGS")) which = qe->chan; @@ -2665,8 +2636,7 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce if (qe->parent->monjoin) ast_monitor_setjoinfiles(which, 1); } else { - if (option_debug) - ast_log(LOG_DEBUG, "Starting MixMonitor as requested.\n"); + ast_debug(1, "Starting MixMonitor as requested.\n"); monitorfilename = pbx_builtin_getvar_helper(qe->chan, "MONITOR_FILENAME"); if (!monitorfilename) { if (qe->chan->cdr) @@ -2723,8 +2693,7 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce else snprintf(mixmonargs, sizeof(mixmonargs)-1, "%s|b%s", tmpid2, monitor_options); - if (option_debug) - ast_log(LOG_DEBUG, "Arguments being passed to MixMonitor: %s\n", mixmonargs); + ast_debug(1, "Arguments being passed to MixMonitor: %s\n", mixmonargs); ret = pbx_exec(qe->chan, mixmonapp, mixmonargs); @@ -2736,8 +2705,7 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce /* Drop out of the queue at this point, to prepare for next caller */ leave_queue(qe); if (!ast_strlen_zero(url) && ast_channel_supports_html(peer)) { - if (option_debug) - ast_log(LOG_DEBUG, "app_queue: sendurl=%s.\n", url); + ast_debug(1, "app_queue: sendurl=%s.\n", url); ast_channel_sendurl(peer, url); } @@ -2772,8 +2740,7 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce } if (!ast_strlen_zero(macroexec)) { - if (option_debug) - ast_log(LOG_DEBUG, "app_queue: macro=%s.\n", macroexec); + ast_debug(1, "app_queue: macro=%s.\n", macroexec); res = ast_autoservice_start(qe->chan); if (res) { @@ -2785,8 +2752,7 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce if (app) { res = pbx_exec(qe->chan, app, macroexec); - if (option_debug) - ast_log(LOG_DEBUG, "Macro exited with status %d\n", res); + ast_debug(1, "Macro exited with status %d\n", res); res = 0; } else { ast_log(LOG_ERROR, "Could not find application Macro\n"); @@ -2800,8 +2766,7 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce } if (!ast_strlen_zero(agi)) { - if (option_debug) - ast_log(LOG_DEBUG, "app_queue: agi=%s.\n", agi); + ast_debug(1, "app_queue: agi=%s.\n", agi); app = pbx_findapp("agi"); if (app) { agiexec = ast_strdupa(agi); @@ -3041,8 +3006,7 @@ static int set_member_paused(const char *queuename, const char *interface, int p if ((mem = interface_exists(q, interface))) { found++; if (mem->paused == paused) { - if (option_debug) - ast_log(LOG_DEBUG, "%spausing already-%spaused queue member %s:%s\n", (paused ? "" : "un"), (paused ? "" : "un"), q->name, interface); + ast_debug(1, "%spausing already-%spaused queue member %s:%s\n", (paused ? "" : "un"), (paused ? "" : "un"), q->name, interface); } mem->paused = paused; @@ -3145,8 +3109,7 @@ static void reload_queue_members(void) if (ast_strlen_zero(membername)) membername = interface; - if (option_debug) - ast_log(LOG_DEBUG, "Reload Members: Queue: %s Member: %s Name: %s Penalty: %d Paused: %d\n", queue_name, interface, membername, penalty, paused); + ast_debug(1, "Reload Members: Queue: %s Member: %s Name: %s Penalty: %d Paused: %d\n", queue_name, interface, membername, penalty, paused); if (add_to_queue(queue_name, interface, membername, penalty, paused, 0) == RES_OUTOFMEMORY) { ast_log(LOG_ERROR, "Out of Memory when reloading persistent queue member\n"); @@ -3289,8 +3252,7 @@ static int rqm_exec(struct ast_channel *chan, void *data) res = 0; break; case RES_EXISTS: - if (option_debug) - ast_log(LOG_DEBUG, "Unable to remove interface '%s' from queue '%s': Not there\n", args.interface, args.queuename); + ast_debug(1, "Unable to remove interface '%s' from queue '%s': Not there\n", args.interface, args.queuename); pbx_builtin_setvar_helper(chan, "RQMSTATUS", "NOTINQUEUE"); res = 0; break; @@ -3468,26 +3430,21 @@ static int queue_exec(struct ast_channel *chan, void *data) user_priority = pbx_builtin_getvar_helper(chan, "QUEUE_PRIO"); if (user_priority) { if (sscanf(user_priority, "%d", &prio) == 1) { - if (option_debug) - ast_log(LOG_DEBUG, "%s: Got priority %d from ${QUEUE_PRIO}.\n", - chan->name, prio); + ast_debug(1, "%s: Got priority %d from ${QUEUE_PRIO}.\n", chan->name, prio); } else { ast_log(LOG_WARNING, "${QUEUE_PRIO}: Invalid value (%s), channel %s.\n", user_priority, chan->name); prio = 0; } } else { - if (option_debug > 2) - ast_log(LOG_DEBUG, "NO QUEUE_PRIO variable found. Using default.\n"); + ast_debug(3, "NO QUEUE_PRIO variable found. Using default.\n"); prio = 0; } /* Get the maximum penalty from the variable ${QUEUE_MAX_PENALTY} */ if ((max_penalty_str = pbx_builtin_getvar_helper(chan, "QUEUE_MAX_PENALTY"))) { if (sscanf(max_penalty_str, "%d", &max_penalty) == 1) { - if (option_debug) - ast_log(LOG_DEBUG, "%s: Got max penalty %d from ${QUEUE_MAX_PENALTY}.\n", - chan->name, max_penalty); + ast_debug(1, "%s: Got max penalty %d from ${QUEUE_MAX_PENALTY}.\n", chan->name, max_penalty); } else { ast_log(LOG_WARNING, "${QUEUE_MAX_PENALTY}: Invalid value (%s), channel %s.\n", max_penalty_str, chan->name); @@ -3503,9 +3460,8 @@ static int queue_exec(struct ast_channel *chan, void *data) if (args.options && (strchr(args.options, 'c'))) qcontinue = 1; - if (option_debug) - ast_log(LOG_DEBUG, "queue: %s, options: %s, url: %s, announce: %s, expires: %ld, priority: %d\n", - args.queuename, args.options, args.url, args.announceoverride, (long)qe.expire, prio); + ast_debug(1, "queue: %s, options: %s, url: %s, announce: %s, expires: %ld, priority: %d\n", + args.queuename, args.options, args.url, args.announceoverride, (long)qe.expire, prio); qe.chan = chan; qe.prio = prio; @@ -3673,9 +3629,7 @@ check_turns: * of the queue, go and check for our turn again. */ if (!is_our_turn(&qe)) { - if (option_debug) - ast_log(LOG_DEBUG, "Darn priorities, going back in queue (%s)!\n", - qe.chan->name); + ast_debug(1, "Darn priorities, going back in queue (%s)!\n", qe.chan->name); goto check_turns; } } @@ -4093,7 +4047,7 @@ static int reload_queues(void) if (!q->count) destroy_queue(q); else - ast_log(LOG_DEBUG, "XXX Leaking a little memory :( XXX\n"); + ast_debug(1, "XXX Leaking a little memory :( XXX\n"); } else { ast_mutex_lock(&q->lock); for (cur = q->members; cur; cur = cur->next) diff --git a/apps/app_record.c b/apps/app_record.c index 863ba70e3..fc4bbcd83 100644 --- a/apps/app_record.c +++ b/apps/app_record.c @@ -336,8 +336,7 @@ static int record_exec(struct ast_channel *chan, void *data) ast_frfree(f); } if (!f) { - if (option_debug) - ast_log(LOG_DEBUG, "Got hangup\n"); + ast_debug(1, "Got hangup\n"); res = -1; } diff --git a/apps/app_rpt.c b/apps/app_rpt.c index cfded49c9..490ac2197 100644 --- a/apps/app_rpt.c +++ b/apps/app_rpt.c @@ -2775,9 +2775,7 @@ static int function_ilink(struct rpt *myrpt, char *param, char *digits, int comm return DC_ERROR; ast_copy_string(digitbuf, digits, sizeof(digitbuf)); - - if (debug) - ast_log(LOG_DEBUG, "@@@@ ilink param = %s, digitbuf = %s\n", S_OR(param, "(null)"), digitbuf); + ast_debug(1, "@@@@ ilink param = %s, digitbuf = %s\n", S_OR(param, "(null)"), digitbuf); switch (myatoi(param)) { case 1: /* Link off */ @@ -3122,8 +3120,7 @@ static int function_autopatchup(struct rpt *myrpt, char *param, char *digitbuf, if (!myrpt->enable) return DC_ERROR; - if (debug) - ast_log(LOG_DEBUG, "@@@@ Autopatch up\n"); + ast_debug(1, "@@@@ Autopatch up\n"); if (!myrpt->callmode) { /* Set defaults */ @@ -3192,8 +3189,7 @@ static int function_autopatchdn(struct rpt *myrpt, char *param, char *digitbuf, if (!myrpt->enable) return DC_ERROR; - if (debug) - ast_log(LOG_DEBUG, "@@@@ Autopatch down\n"); + ast_debug(1, "@@@@ Autopatch down\n"); rpt_mutex_lock(&myrpt->lock); @@ -3221,8 +3217,7 @@ static int function_status(struct rpt *myrpt, char *param, char *digitbuf, int c if (!myrpt->enable) return DC_ERROR; - if (debug) - ast_log(LOG_DEBUG, "@@@@ status param = %s, digitbuf = %s\n", (param)? param : "(null)", digitbuf); + ast_debug(1, "@@@@ status param = %s, digitbuf = %s\n", (param)? param : "(null)", digitbuf); switch (myatoi(param)) { case 1: /* System ID */ @@ -3255,8 +3250,7 @@ static int function_macro(struct rpt *myrpt, char *param, char *digitbuf, int co if ((!myrpt->remote) && (!myrpt->enable)) return DC_ERROR; - if (debug) - ast_log(LOG_DEBUG, "@@@@ macro-oni param = %s, digitbuf = %s\n", (param)? param : "(null)", digitbuf); + ast_debug(1, "@@@@ macro-oni param = %s, digitbuf = %s\n", (param)? param : "(null)", digitbuf); mychannel = myrpt->remchannel; @@ -3338,8 +3332,7 @@ static int collect_function_digits(struct rpt *myrpt, char *digits, int command_ AST_APP_ARG(param); ); - if (debug) - ast_log(LOG_DEBUG, "@@@@ Digits collected: %s, source: %d\n", digits, command_source); + ast_debug(1, "@@@@ Digits collected: %s, source: %d\n", digits, command_source); if (command_source == SOURCE_DPHONE) { if (!myrpt->p.dphone_functions) @@ -3379,23 +3372,20 @@ static int collect_function_digits(struct rpt *myrpt, char *digits, int command_ stringp = ast_strdupa(vp->value); AST_NONSTANDARD_APP_ARGS(args, stringp, ','); - if (debug) - ast_log(LOG_DEBUG, "@@@@ action: %s, param = %s\n", args.action, S_OR(args.param, "(null)")); + ast_debug(1, "@@@@ action: %s, param = %s\n", args.action, S_OR(args.param, "(null)")); /* Look up the action */ for (i = 0; i < (sizeof(function_table) / sizeof(struct function_table_tag)); i++) { if (!strncasecmp(args.action, function_table[i].action, strlen(args.action))) break; } - if (debug) - ast_log(LOG_DEBUG, "@@@@ table index i = %d\n", i); + ast_debug(1, "@@@@ table index i = %d\n", i); if (i == (sizeof(function_table) / sizeof(struct function_table_tag))) { /* Error, action not in table */ return DC_ERROR; } if (function_table[i].function == NULL) { /* Error, function undefined */ - if (debug) - ast_log(LOG_DEBUG, "@@@@ NULL for action: %s\n", args.action); + ast_debug(1, "@@@@ NULL for action: %s\n", args.action); return DC_ERROR; } functiondigits = digits + strlen(vp->name); @@ -3872,16 +3862,14 @@ static int serial_remote_io(struct rpt *myrpt, unsigned char *txbuf, int txbytes int i; struct zt_radio_param prm; - if (debug) { - char *buf = alloca(30 + txbytes * 3); - int len; - ast_copy_string(buf, "String output was: ", 30 + txbytes * 3); - len = strlen(buf); - for (i = 0; i < txbytes; i++) - len += snprintf(buf + len, 30 + txbytes * 3 - len, "%02X ", (unsigned char) txbuf[i]); - strcat(buf + len, "\n"); - ast_log(LOG_DEBUG, "%s", buf); - } + char *buf = alloca(30 + txbytes * 3); + int len; + ast_copy_string(buf, "String output was: ", 30 + txbytes * 3); + len = strlen(buf); + for (i = 0; i < txbytes; i++) + len += snprintf(buf + len, 30 + txbytes * 3 - len, "%02X ", (unsigned char) txbuf[i]); + strcat(buf + len, "\n"); + ast_debug(1, "%s", buf); prm.radpar = ZT_RADPAR_REMMODE; if (asciiflag) @@ -3920,42 +3908,36 @@ static int setrbi(struct rpt *myrpt) /* if no decimal, is invalid */ if (s == NULL) { - if (debug) - ast_log(LOG_DEBUG, "@@@@ Frequency needs a decimal\n"); + ast_debug(1, "@@@@ Frequency needs a decimal\n"); return -1; } *s++ = 0; if (strlen(tmp) < 2) { - if (debug) - ast_log(LOG_DEBUG, "@@@@ Bad MHz digits: %s\n", tmp); + ast_debug(1, "@@@@ Bad MHz digits: %s\n", tmp); return -1; } if (strlen(s) < 3) { - if (debug) - ast_log(LOG_DEBUG, "@@@@ Bad KHz digits: %s\n", s); + ast_debug(1, "@@@@ Bad KHz digits: %s\n", s); return -1; } if ((s[2] != '0') && (s[2] != '5')) { - if (debug) - ast_log(LOG_DEBUG, "@@@@ KHz must end in 0 or 5: %c\n", s[2]); + ast_debug(1, "@@@@ KHz must end in 0 or 5: %c\n", s[2]); return -1; } band = rbi_mhztoband(tmp); if (band == -1) { - if (debug) - ast_log(LOG_DEBUG, "@@@@ Bad Band: %s\n", tmp); + ast_debug(1, "@@@@ Bad Band: %s\n", tmp); return -1; } txpl = rbi_pltocode(myrpt->txpl); if (txpl == -1) { - if (debug) - ast_log(LOG_DEBUG, "@@@@ Bad TX PL: %s\n", myrpt->txpl); + ast_debug(1, "@@@@ Bad TX PL: %s\n", myrpt->txpl); return -1; } @@ -4148,8 +4130,7 @@ static int set_freq_ft897(struct rpt *myrpt, char *newfreq) int fd, m, d; fd = 0; - if (debug) - ast_log(LOG_DEBUG, "New frequency: %s\n", newfreq); + ast_debug(1, "New frequency: %s\n", newfreq); if (split_freq(&m, &d, newfreq)) return -1; @@ -4274,53 +4255,44 @@ static int set_ft897(struct rpt *myrpt) { int res; - if (debug) - ast_log(LOG_DEBUG, "@@@@ lock on\n"); + ast_debug(1, "@@@@ lock on\n"); res = simple_command_ft897(myrpt, 0x00); /* LOCK on */ - if (debug) - ast_log(LOG_DEBUG, "@@@@ ptt off\n"); + ast_debug(1, "@@@@ ptt off\n"); if (!res) res = simple_command_ft897(myrpt, 0x88); /* PTT off */ - if (debug) - ast_log(LOG_DEBUG, "Modulation mode\n"); + ast_debug(1, "Modulation mode\n"); if (!res) res = set_mode_ft897(myrpt, myrpt->remmode); /* Modulation mode */ - if (debug) - ast_log(LOG_DEBUG, "Split off\n"); + ast_debug(1, "Split off\n"); if (!res) simple_command_ft897(myrpt, 0x82); /* Split off */ - if (debug) - ast_log(LOG_DEBUG, "Frequency\n"); + ast_debug(1, "Frequency\n"); if (!res) res = set_freq_ft897(myrpt, myrpt->freq); /* Frequency */ if ((myrpt->remmode == REM_MODE_FM)) { - if (debug) - ast_log(LOG_DEBUG, "Offset\n"); + ast_debug(1, "Offset\n"); if (!res) res = set_offset_ft897(myrpt, myrpt->offset); /* Offset if FM */ if ((!res)&&(myrpt->rxplon || myrpt->txplon)) { - if (debug) - ast_log(LOG_DEBUG, "CTCSS tone freqs.\n"); + ast_debug(1, "CTCSS tone freqs.\n"); res = set_ctcss_freq_ft897(myrpt, myrpt->txpl, myrpt->rxpl); /* CTCSS freqs if CTCSS is enabled */ } if (!res) { - if (debug) - ast_log(LOG_DEBUG, "CTCSS mode\n"); + ast_debug(1, "CTCSS mode\n"); res = set_ctcss_mode_ft897(myrpt, myrpt->txplon, myrpt->rxplon); /* CTCSS mode */ } } if ((myrpt->remmode == REM_MODE_USB)||(myrpt->remmode == REM_MODE_LSB)) { - if (debug) - ast_log(LOG_DEBUG, "Clarifier off\n"); + ast_debug(1, "Clarifier off\n"); simple_command_ft897(myrpt, 0x85); /* Clarifier off if LSB or USB */ } return res; @@ -4342,8 +4314,7 @@ static int multimode_bump_freq_ft897(struct rpt *myrpt, int interval) { int m, d; - if (debug) - ast_log(LOG_DEBUG, "Before bump: %s\n", myrpt->freq); + ast_debug(1, "Before bump: %s\n", myrpt->freq); if (split_freq(&m, &d, myrpt->freq)) return -1; @@ -4358,15 +4329,12 @@ static int multimode_bump_freq_ft897(struct rpt *myrpt, int interval) } if (check_freq_ft897(m, d, NULL)) { - if (debug) - ast_log(LOG_DEBUG, "Bump freq invalid\n"); + ast_debug(1, "Bump freq invalid\n"); return -1; } snprintf(myrpt->freq, MAXREMSTR, "%d.%05d", m, d); - - if (debug) - ast_log(LOG_DEBUG, "After bump: %s\n", myrpt->freq); + ast_debug(1, "After bump: %s\n", myrpt->freq); return set_freq_ft897(myrpt, myrpt->freq); } @@ -4768,9 +4736,7 @@ static int function_remote(struct rpt *myrpt, char *param, char *digitbuf, int c /* Check frequency for validity and establish a default mode */ snprintf(freq, sizeof(freq), "%s.%03d%02d", args.s1, k, ht); - - if (debug) - ast_log(LOG_DEBUG, "New frequency: %s\n", freq); + ast_debug(1, "New frequency: %s\n", freq); split_freq(&mhz, &decimals, freq); @@ -4842,8 +4808,7 @@ invalid_freq: i = strlen(digitbuf) - 1; if ((j != 1) || (k < 2)|| (l != 1)) break; /* Not yet */ - if (debug) - ast_log(LOG_DEBUG, "PL digits entered %s\n", digitbuf); + ast_debug(1, "PL digits entered %s\n", digitbuf); ast_copy_string(tmp, digitbuf, sizeof(tmp)); /* see if we have at least 1 */ @@ -4879,8 +4844,7 @@ invalid_freq: i = strlen(digitbuf) - 1; if ((j != 1) || (k < 2)|| (l != 1)) break; /* Not yet */ - if (debug) - ast_log(LOG_DEBUG, "PL digits entered %s\n", digitbuf); + ast_debug(1, "PL digits entered %s\n", digitbuf); ast_copy_string(tmp, digitbuf, sizeof(tmp)); /* see if we have at least 1 */ @@ -6287,8 +6251,7 @@ static void *rpt(void *this) if (who == myrpt->rxchannel) { /* if it was a read from rx */ f = ast_read(myrpt->rxchannel); if (!f) { - if (debug) - ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n"); + ast_debug(1, "@@@@ rpt:Hung Up\n"); break; } if (f->frametype == AST_FRAME_VOICE) { @@ -6347,24 +6310,21 @@ static void *rpt(void *this) continue; } else if (f->frametype == AST_FRAME_CONTROL) { if (f->subclass == AST_CONTROL_HANGUP) { - if (debug) - ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n"); + ast_debug(1, "@@@@ rpt:Hung Up\n"); ast_frfree(f); break; } /* if RX key */ if (f->subclass == AST_CONTROL_RADIO_KEY) { if ((!lasttx) || (myrpt->p.duplex > 1)) { - if (debug == 7) - ast_log(LOG_DEBUG, "@@@@ rx key\n"); + ast_debug(8, "@@@@ rx key\n"); myrpt->keyed = 1; } } /* if RX un-key */ if (f->subclass == AST_CONTROL_RADIO_UNKEY) { if ((!lasttx) || (myrpt->p.duplex > 1)) { - if (debug == 7) - ast_log(LOG_DEBUG, "@@@@ rx un-key\n"); + ast_debug(8, "@@@@ rx un-key\n"); if (myrpt->keyed) { rpt_telemetry(myrpt, UNKEY, NULL); } @@ -6378,8 +6338,7 @@ static void *rpt(void *this) if (who == myrpt->pchannel) { /* if it was a read from pseudo */ f = ast_read(myrpt->pchannel); if (!f) { - if (debug) - ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n"); + ast_debug(1, "@@@@ rpt:Hung Up\n"); break; } if (f->frametype == AST_FRAME_VOICE) { @@ -6387,8 +6346,7 @@ static void *rpt(void *this) } if (f->frametype == AST_FRAME_CONTROL) { if (f->subclass == AST_CONTROL_HANGUP) { - if (debug) - ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n"); + ast_debug(1, "@@@@ rpt:Hung Up\n"); ast_frfree(f); break; } @@ -6399,14 +6357,12 @@ static void *rpt(void *this) if (who == myrpt->txchannel) { /* if it was a read from tx */ f = ast_read(myrpt->txchannel); if (!f) { - if (debug) - ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n"); + ast_debug(1, "@@@@ rpt:Hung Up\n"); break; } if (f->frametype == AST_FRAME_CONTROL) { if (f->subclass == AST_CONTROL_HANGUP) { - if (debug) - ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n"); + ast_debug(1, "@@@@ rpt:Hung Up\n"); ast_frfree(f); break; } @@ -6514,14 +6470,12 @@ static void *rpt(void *this) } /* if RX key */ if (f->subclass == AST_CONTROL_RADIO_KEY) { - if (debug == 7 ) - ast_log(LOG_DEBUG, "@@@@ rx key\n"); + ast_debug(8, "@@@@ rx key\n"); l->lastrx = 1; } /* if RX un-key */ if (f->subclass == AST_CONTROL_RADIO_UNKEY) { - if (debug == 7) - ast_log(LOG_DEBUG, "@@@@ rx un-key\n"); + ast_debug(8, "@@@@ rx un-key\n"); l->lastrx = 0; } if (f->subclass == AST_CONTROL_HANGUP) { @@ -6577,8 +6531,7 @@ static void *rpt(void *this) rpt_mutex_unlock(&myrpt->lock); f = ast_read(l->pchan); if (!f) { - if (debug) - ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n"); + ast_debug(1, "@@@@ rpt:Hung Up\n"); toexit = 1; rpt_mutex_lock(&myrpt->lock); break; @@ -6589,8 +6542,7 @@ static void *rpt(void *this) } if (f->frametype == AST_FRAME_CONTROL) { if (f->subclass == AST_CONTROL_HANGUP) { - if (debug) - ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n"); + ast_debug(1, "@@@@ rpt:Hung Up\n"); ast_frfree(f); toexit = 1; rpt_mutex_lock(&myrpt->lock); @@ -6609,14 +6561,12 @@ static void *rpt(void *this) if (who == myrpt->txpchannel) { /* if it was a read from remote tx */ f = ast_read(myrpt->txpchannel); if (!f) { - if (debug) - ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n"); + ast_debug(1, "@@@@ rpt:Hung Up\n"); break; } if (f->frametype == AST_FRAME_CONTROL) { if (f->subclass == AST_CONTROL_HANGUP) { - if (debug) - ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n"); + ast_debug(1, "@@@@ rpt:Hung Up\n"); ast_frfree(f); break; } @@ -6645,8 +6595,7 @@ static void *rpt(void *this) ast_free(ll); } rpt_mutex_unlock(&myrpt->lock); - if (debug) - ast_log(LOG_DEBUG, "@@@@ rpt:Hung up channel\n"); + ast_debug(1, "@@@@ rpt:Hung up channel\n"); myrpt->rpt_thread = AST_PTHREADT_STOP; pthread_exit(NULL); return NULL; @@ -7222,8 +7171,7 @@ static int rpt_exec(struct ast_channel *chan, void *data) if (who == chan) { /* if it was a read from incoming */ f = ast_read(chan); if (!f) { - if (debug) - ast_log(LOG_DEBUG, "@@@@ link:Hung Up\n"); + ast_debug(1, "@@@@ link:Hung Up\n"); break; } if (f->frametype == AST_FRAME_VOICE) { @@ -7235,8 +7183,7 @@ static int rpt_exec(struct ast_channel *chan, void *data) if (f->frametype == AST_FRAME_DTMF) { myrpt->remchannel = chan; /* Save copy of channel */ if (handle_remote_phone_dtmf(myrpt, f->subclass, &keyed, phone_mode) == -1) { - if (debug) - ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n"); + ast_debug(1, "@@@@ rpt:Hung Up\n"); ast_frfree(f); break; } @@ -7244,29 +7191,25 @@ static int rpt_exec(struct ast_channel *chan, void *data) if (f->frametype == AST_FRAME_TEXT) { myrpt->remchannel = chan; /* Save copy of channel */ if (handle_remote_data(myrpt, f->data) == -1) { - if (debug) - ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n"); + ast_debug(1, "@@@@ rpt:Hung Up\n"); ast_frfree(f); break; } } if (f->frametype == AST_FRAME_CONTROL) { if (f->subclass == AST_CONTROL_HANGUP) { - if (debug) - ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n"); + ast_debug(1, "@@@@ rpt:Hung Up\n"); ast_frfree(f); break; } /* if RX key */ if (f->subclass == AST_CONTROL_RADIO_KEY) { - if (debug == 7) - ast_log(LOG_DEBUG, "@@@@ rx key\n"); + ast_debug(8, "@@@@ rx key\n"); keyed = 1; } /* if RX un-key */ if (f->subclass == AST_CONTROL_RADIO_UNKEY) { - if (debug == 7) - ast_log(LOG_DEBUG, "@@@@ rx un-key\n"); + ast_debug(8, "@@@@ rx un-key\n"); keyed = 0; } } @@ -7308,7 +7251,7 @@ static int rpt_exec(struct ast_channel *chan, void *data) if (who == myrpt->rxchannel) { /* if it was a read from radio */ f = ast_read(myrpt->rxchannel); if (!f) { - if (debug) ast_log(LOG_DEBUG, "@@@@ link:Hung Up\n"); + ast_debug(1, "@@@@ link:Hung Up\n"); break; } if (f->frametype == AST_FRAME_VOICE) { @@ -7317,15 +7260,13 @@ static int rpt_exec(struct ast_channel *chan, void *data) ast_write(chan, f); } else if (f->frametype == AST_FRAME_CONTROL) { if (f->subclass == AST_CONTROL_HANGUP) { - if (debug) - ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n"); + ast_debug(1, "@@@@ rpt:Hung Up\n"); ast_frfree(f); break; } /* if RX key */ if (f->subclass == AST_CONTROL_RADIO_KEY) { - if (debug == 7) - ast_log(LOG_DEBUG, "@@@@ remote rx key\n"); + ast_debug(8, "@@@@ remote rx key\n"); if (!myrpt->remotetx) { ast_indicate(chan, AST_CONTROL_RADIO_KEY); myrpt->remoterx = 1; @@ -7333,8 +7274,7 @@ static int rpt_exec(struct ast_channel *chan, void *data) } /* if RX un-key */ if (f->subclass == AST_CONTROL_RADIO_UNKEY) { - if (debug == 7) - ast_log(LOG_DEBUG, "@@@@ remote rx un-key\n"); + ast_debug(8, "@@@@ remote rx un-key\n"); if (!myrpt->remotetx) { ast_indicate(chan, AST_CONTROL_RADIO_UNKEY); myrpt->remoterx = 0; @@ -7348,14 +7288,12 @@ static int rpt_exec(struct ast_channel *chan, void *data) /* do this cuz you have to */ f = ast_read(myrpt->txchannel); if (!f) { - if (debug) - ast_log(LOG_DEBUG, "@@@@ link:Hung Up\n"); + ast_debug(1, "@@@@ link:Hung Up\n"); break; } if (f->frametype == AST_FRAME_CONTROL) { if (f->subclass == AST_CONTROL_HANGUP) { - if (debug) - ast_log(LOG_DEBUG, "@@@@ rpt:Hung Up\n"); + ast_debug(1, "@@@@ rpt:Hung Up\n"); ast_frfree(f); break; } diff --git a/apps/app_stack.c b/apps/app_stack.c index 014d2d9ba..bc903cf75 100644 --- a/apps/app_stack.c +++ b/apps/app_stack.c @@ -152,11 +152,11 @@ static int pop_exec(struct ast_channel *chan, void *data) oldframe = AST_LIST_REMOVE_HEAD(oldlist, entries); AST_LIST_UNLOCK(oldlist); - if (oldframe) + if (oldframe) { gosub_release_frame(chan, oldframe); - else if (option_debug) - ast_log(LOG_DEBUG, "%s called with an empty gosub stack\n", app_pop); - + } else { + ast_debug(1, "%s called with an empty gosub stack\n", app_pop); + } return 0; } @@ -210,8 +210,7 @@ static int gosub_exec(struct ast_channel *chan, void *data) u = ast_module_user_add(chan); if (!stack_store) { - if (option_debug) - ast_log(LOG_DEBUG, "Channel %s has no datastore, so we're allocating one.\n", chan->name); + ast_debug(1, "Channel %s has no datastore, so we're allocating one.\n", chan->name); stack_store = ast_channel_datastore_alloc(&stack_info, NULL); if (!stack_store) { ast_log(LOG_ERROR, "Unable to allocate new datastore. Gosub will fail.\n"); @@ -259,8 +258,7 @@ static int gosub_exec(struct ast_channel *chan, void *data) for (i = 0; i < args2.argc; i++) { snprintf(argname, sizeof(argname), "ARG%d", i + 1); pbx_builtin_pushvar_helper(chan, argname, args2.argval[i]); - if (option_debug) - ast_log(LOG_DEBUG, "Setting '%s' to '%s'\n", argname, args2.argval[i]); + ast_debug(1, "Setting '%s' to '%s'\n", argname, args2.argval[i]); } /* And finally, save our return address */ diff --git a/apps/app_talkdetect.c b/apps/app_talkdetect.c index 7d9376a13..b261d402f 100644 --- a/apps/app_talkdetect.c +++ b/apps/app_talkdetect.c @@ -103,9 +103,7 @@ static int background_detect_exec(struct ast_channel *chan, void *data) } } } - if (option_debug) - ast_log(LOG_DEBUG, "Preparing detect of '%s', sil=%d,min=%d,max=%d\n", - tmp, sil, min, max); + ast_debug(1, "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 */ res = ast_answer(chan); @@ -164,8 +162,7 @@ static int background_detect_exec(struct ast_channel *chan, void *data) ms = 0; if ((ms > min) && ((max < 0) || (ms < max))) { char ms_str[10]; - if (option_debug) - ast_log(LOG_DEBUG, "Found qualified token of %d ms\n", ms); + ast_debug(1, "Found qualified token of %d ms\n", ms); /* Save detected talk time (in milliseconds) */ sprintf(ms_str, "%d", ms ); @@ -176,8 +173,7 @@ static int background_detect_exec(struct ast_channel *chan, void *data) ast_frfree(fr); break; } else { - if (option_debug) - ast_log(LOG_DEBUG, "Found unqualified token of %d ms\n", ms); + ast_debug(1, "Found unqualified token of %d ms\n", ms); } notsilent = 0; } @@ -185,8 +181,7 @@ static int background_detect_exec(struct ast_channel *chan, void *data) if (!notsilent) { /* Heard some audio, mark the begining of the token */ start = ast_tvnow(); - if (option_debug) - ast_log(LOG_DEBUG, "Start of voice token!\n"); + ast_debug(1, "Start of voice token!\n"); notsilent = 1; } } diff --git a/apps/app_test.c b/apps/app_test.c index 02c354f98..a41403a18 100644 --- a/apps/app_test.c +++ b/apps/app_test.c @@ -112,8 +112,7 @@ static int measurenoise(struct ast_channel *chan, int ms, char *who) ast_log(LOG_NOTICE, "No samples were received from the other side!\n"); return -1; } - if (option_debug) - ast_log(LOG_DEBUG, "%s: Noise: %d, samples: %d, avg: %d\n", who, noise, samples, noise / samples); + ast_debug(1, "%s: Noise: %d, samples: %d, avg: %d\n", who, noise, samples, noise / samples); return (noise / samples); } @@ -153,18 +152,15 @@ static int testclient_exec(struct ast_channel *chan, void *data) /* Transmit client version */ if (!res) res = ast_dtmf_stream(chan, NULL, "8378*1#", 0); - if (option_debug) - ast_log(LOG_DEBUG, "Transmit client version\n"); + ast_debug(1, "Transmit client version\n"); /* Read server version */ - if (option_debug) - ast_log(LOG_DEBUG, "Read server version\n"); + ast_debug(1, "Read server version\n"); if (!res) res = ast_app_getdata(chan, NULL, serverver, sizeof(serverver) - 1, 0); if (res > 0) res = 0; - if (option_debug) - ast_log(LOG_DEBUG, "server version: %s\n", serverver); + ast_debug(1, "server version: %s\n", serverver); if (res > 0) res = 0; @@ -176,8 +172,7 @@ static int testclient_exec(struct ast_channel *chan, void *data) res = ast_dtmf_stream(chan, NULL, testid, 0); if (!res) res = ast_dtmf_stream(chan, NULL, "#", 0); - if (option_debug) - ast_log(LOG_DEBUG, "send test identifier: %s\n", testid); + ast_debug(1, "send test identifier: %s\n", testid); if ((res >=0) && (!ast_strlen_zero(testid))) { /* Make the directory to hold the test results in case it's not there */ @@ -193,8 +188,7 @@ static int testclient_exec(struct ast_channel *chan, void *data) if (!res) { /* Step 1: Wait for "1" */ - if (option_debug) - ast_log(LOG_DEBUG, "TestClient: 2. Wait DTMF 1\n"); + ast_debug(1, "TestClient: 2. Wait DTMF 1\n"); res = ast_waitfordigit(chan, 3000); fprintf(f, "WAIT DTMF 1: %s\n", (res != '1') ? "FAIL" : "PASS"); if (res == '1') @@ -206,8 +200,7 @@ static int testclient_exec(struct ast_channel *chan, void *data) res = ast_safe_sleep(chan, 1000); if (!res) { /* Step 2: Send "2" */ - if (option_debug) - ast_log(LOG_DEBUG, "TestClient: 2. Send DTMF 2\n"); + ast_debug(1, "TestClient: 2. Send DTMF 2\n"); res = ast_dtmf_stream(chan, NULL, "2", 0); fprintf(f, "SEND DTMF 2: %s\n", (res < 0) ? "FAIL" : "PASS"); if (res > 0) @@ -215,8 +208,7 @@ static int testclient_exec(struct ast_channel *chan, void *data) } if (!res) { /* Step 3: Wait one second */ - if (option_debug) - ast_log(LOG_DEBUG, "TestClient: 3. Wait one second\n"); + ast_debug(1, "TestClient: 3. Wait one second\n"); res = ast_safe_sleep(chan, 1000); fprintf(f, "WAIT 1 SEC: %s\n", (res < 0) ? "FAIL" : "PASS"); if (res > 0) @@ -224,8 +216,7 @@ static int testclient_exec(struct ast_channel *chan, void *data) } if (!res) { /* Step 4: Measure noise */ - if (option_debug) - ast_log(LOG_DEBUG, "TestClient: 4. Measure noise\n"); + ast_debug(1, "TestClient: 4. Measure noise\n"); res = measurenoise(chan, 5000, "TestClient"); fprintf(f, "MEASURENOISE: %s (%d)\n", (res < 0) ? "FAIL" : "PASS", res); if (res > 0) @@ -233,8 +224,7 @@ static int testclient_exec(struct ast_channel *chan, void *data) } if (!res) { /* Step 5: Wait for "4" */ - if (option_debug) - ast_log(LOG_DEBUG, "TestClient: 5. Wait DTMF 4\n"); + ast_debug(1, "TestClient: 5. Wait DTMF 4\n"); res = ast_waitfordigit(chan, 3000); fprintf(f, "WAIT DTMF 4: %s\n", (res != '4') ? "FAIL" : "PASS"); if (res == '4') @@ -244,15 +234,13 @@ static int testclient_exec(struct ast_channel *chan, void *data) } if (!res) { /* Step 6: Transmit tone noise */ - if (option_debug) - ast_log(LOG_DEBUG, "TestClient: 6. Transmit tone\n"); + ast_debug(1, "TestClient: 6. Transmit tone\n"); res = sendnoise(chan, 6000); fprintf(f, "SENDTONE: %s\n", (res < 0) ? "FAIL" : "PASS"); } if (!res || (res == '5')) { /* Step 7: Wait for "5" */ - if (option_debug) - ast_log(LOG_DEBUG, "TestClient: 7. Wait DTMF 5\n"); + ast_debug(1, "TestClient: 7. Wait DTMF 5\n"); if (!res) res = ast_waitfordigit(chan, 3000); fprintf(f, "WAIT DTMF 5: %s\n", (res != '5') ? "FAIL" : "PASS"); @@ -263,8 +251,7 @@ static int testclient_exec(struct ast_channel *chan, void *data) } if (!res) { /* Step 8: Wait one second */ - if (option_debug) - ast_log(LOG_DEBUG, "TestClient: 8. Wait one second\n"); + ast_debug(1, "TestClient: 8. Wait one second\n"); res = ast_safe_sleep(chan, 1000); fprintf(f, "WAIT 1 SEC: %s\n", (res < 0) ? "FAIL" : "PASS"); if (res > 0) @@ -272,8 +259,7 @@ static int testclient_exec(struct ast_channel *chan, void *data) } if (!res) { /* Step 9: Measure noise */ - if (option_debug) - ast_log(LOG_DEBUG, "TestClient: 6. Measure tone\n"); + ast_debug(1, "TestClient: 6. Measure tone\n"); res = measurenoise(chan, 4000, "TestClient"); fprintf(f, "MEASURETONE: %s (%d)\n", (res < 0) ? "FAIL" : "PASS", res); if (res > 0) @@ -281,8 +267,7 @@ static int testclient_exec(struct ast_channel *chan, void *data) } if (!res) { /* Step 10: Send "7" */ - if (option_debug) - ast_log(LOG_DEBUG, "TestClient: 7. Send DTMF 7\n"); + ast_debug(1, "TestClient: 7. Send DTMF 7\n"); res = ast_dtmf_stream(chan, NULL, "7", 0); fprintf(f, "SEND DTMF 7: %s\n", (res < 0) ? "FAIL" : "PASS"); if (res > 0) @@ -290,8 +275,7 @@ static int testclient_exec(struct ast_channel *chan, void *data) } if (!res) { /* Step 11: Wait for "8" */ - if (option_debug) - ast_log(LOG_DEBUG, "TestClient: 11. Wait DTMF 8\n"); + ast_debug(1, "TestClient: 11. Wait DTMF 8\n"); res = ast_waitfordigit(chan, 3000); fprintf(f, "WAIT DTMF 8: %s\n", (res != '8') ? "FAIL" : "PASS"); if (res == '8') @@ -301,11 +285,10 @@ static int testclient_exec(struct ast_channel *chan, void *data) } if (option_debug && !res ) { /* Step 12: Hangup! */ - ast_log(LOG_DEBUG, "TestClient: 12. Hangup\n"); + ast_debug(1, "TestClient: 12. Hangup\n"); } - if (option_debug) - ast_log(LOG_DEBUG, "-- TEST COMPLETE--\n"); + ast_debug(1, "-- TEST COMPLETE--\n"); fprintf(f, "-- END TEST--\n"); fclose(f); res = -1; @@ -330,16 +313,15 @@ static int testserver_exec(struct ast_channel *chan, void *data) if (chan->_state != AST_STATE_UP) res = ast_answer(chan); /* Read version */ - if (option_debug) - ast_log(LOG_DEBUG, "Read client version\n"); + ast_debug(1, "Read client version\n"); if (!res) res = ast_app_getdata(chan, NULL, testid, sizeof(testid) - 1, 0); if (res > 0) res = 0; - if (option_debug) { - ast_log(LOG_DEBUG, "client version: %s\n", testid); - ast_log(LOG_DEBUG, "Transmit server version\n"); - } + + ast_debug(1, "client version: %s\n", testid); + ast_debug(1, "Transmit server version\n"); + res = ast_safe_sleep(chan, 1000); if (!res) res = ast_dtmf_stream(chan, NULL, "8378*1#", 0); @@ -348,8 +330,7 @@ static int testserver_exec(struct ast_channel *chan, void *data) if (!res) res = ast_app_getdata(chan, NULL, testid, sizeof(testid) - 1, 0); - if (option_debug) - ast_log(LOG_DEBUG, "read test identifier: %s\n", testid); + ast_debug(1, "read test identifier: %s\n", testid); /* Check for sneakyness */ if (strchr(testid, '/')) res = -1; @@ -364,13 +345,11 @@ static int testserver_exec(struct ast_channel *chan, void *data) fprintf(f, "SERVERCHAN: %s\n", chan->name); fprintf(f, "SERVERTEST ID: %s\n", testid); fprintf(f, "ANSWER: PASS\n"); - if (option_debug) - ast_log(LOG_DEBUG, "Processing Test ID '%s'\n", testid); + ast_debug(1, "Processing Test ID '%s'\n", testid); res = ast_safe_sleep(chan, 1000); if (!res) { /* Step 1: Send "1" */ - if (option_debug) - ast_log(LOG_DEBUG, "TestServer: 1. Send DTMF 1\n"); + ast_debug(1, "TestServer: 1. Send DTMF 1\n"); res = ast_dtmf_stream(chan, NULL, "1", 0); fprintf(f, "SEND DTMF 1: %s\n", (res < 0) ? "FAIL" : "PASS"); if (res > 0) @@ -378,8 +357,7 @@ static int testserver_exec(struct ast_channel *chan, void *data) } if (!res) { /* Step 2: Wait for "2" */ - if (option_debug) - ast_log(LOG_DEBUG, "TestServer: 2. Wait DTMF 2\n"); + ast_debug(1, "TestServer: 2. Wait DTMF 2\n"); res = ast_waitfordigit(chan, 3000); fprintf(f, "WAIT DTMF 2: %s\n", (res != '2') ? "FAIL" : "PASS"); if (res == '2') @@ -389,8 +367,7 @@ static int testserver_exec(struct ast_channel *chan, void *data) } if (!res) { /* Step 3: Measure noise */ - if (option_debug) - ast_log(LOG_DEBUG, "TestServer: 3. Measure noise\n"); + ast_debug(1, "TestServer: 3. Measure noise\n"); res = measurenoise(chan, 6000, "TestServer"); fprintf(f, "MEASURENOISE: %s (%d)\n", (res < 0) ? "FAIL" : "PASS", res); if (res > 0) @@ -398,8 +375,7 @@ static int testserver_exec(struct ast_channel *chan, void *data) } if (!res) { /* Step 4: Send "4" */ - if (option_debug) - ast_log(LOG_DEBUG, "TestServer: 4. Send DTMF 4\n"); + ast_debug(1, "TestServer: 4. Send DTMF 4\n"); res = ast_dtmf_stream(chan, NULL, "4", 0); fprintf(f, "SEND DTMF 4: %s\n", (res < 0) ? "FAIL" : "PASS"); if (res > 0) @@ -408,8 +384,7 @@ static int testserver_exec(struct ast_channel *chan, void *data) if (!res) { /* Step 5: Wait one second */ - if (option_debug) - ast_log(LOG_DEBUG, "TestServer: 5. Wait one second\n"); + ast_debug(1, "TestServer: 5. Wait one second\n"); res = ast_safe_sleep(chan, 1000); fprintf(f, "WAIT 1 SEC: %s\n", (res < 0) ? "FAIL" : "PASS"); if (res > 0) @@ -418,8 +393,7 @@ static int testserver_exec(struct ast_channel *chan, void *data) if (!res) { /* Step 6: Measure noise */ - if (option_debug) - ast_log(LOG_DEBUG, "TestServer: 6. Measure tone\n"); + ast_debug(1, "TestServer: 6. Measure tone\n"); res = measurenoise(chan, 4000, "TestServer"); fprintf(f, "MEASURETONE: %s (%d)\n", (res < 0) ? "FAIL" : "PASS", res); if (res > 0) @@ -428,8 +402,7 @@ static int testserver_exec(struct ast_channel *chan, void *data) if (!res) { /* Step 7: Send "5" */ - if (option_debug) - ast_log(LOG_DEBUG, "TestServer: 7. Send DTMF 5\n"); + ast_debug(1, "TestServer: 7. Send DTMF 5\n"); res = ast_dtmf_stream(chan, NULL, "5", 0); fprintf(f, "SEND DTMF 5: %s\n", (res < 0) ? "FAIL" : "PASS"); if (res > 0) @@ -438,16 +411,14 @@ static int testserver_exec(struct ast_channel *chan, void *data) if (!res) { /* Step 8: Transmit tone noise */ - if (option_debug) - ast_log(LOG_DEBUG, "TestServer: 8. Transmit tone\n"); + ast_debug(1, "TestServer: 8. Transmit tone\n"); res = sendnoise(chan, 6000); fprintf(f, "SENDTONE: %s\n", (res < 0) ? "FAIL" : "PASS"); } if (!res || (res == '7')) { /* Step 9: Wait for "7" */ - if (option_debug) - ast_log(LOG_DEBUG, "TestServer: 9. Wait DTMF 7\n"); + ast_debug(1, "TestServer: 9. Wait DTMF 7\n"); if (!res) res = ast_waitfordigit(chan, 3000); fprintf(f, "WAIT DTMF 7: %s\n", (res != '7') ? "FAIL" : "PASS"); @@ -460,8 +431,7 @@ static int testserver_exec(struct ast_channel *chan, void *data) res = ast_safe_sleep(chan, 1000); if (!res) { /* Step 10: Send "8" */ - if (option_debug) - ast_log(LOG_DEBUG, "TestServer: 10. Send DTMF 8\n"); + ast_debug(1, "TestServer: 10. Send DTMF 8\n"); res = ast_dtmf_stream(chan, NULL, "8", 0); fprintf(f, "SEND DTMF 8: %s\n", (res < 0) ? "FAIL" : "PASS"); if (res > 0) @@ -469,8 +439,7 @@ static int testserver_exec(struct ast_channel *chan, void *data) } if (!res) { /* Step 11: Wait for hangup to arrive! */ - if (option_debug) - ast_log(LOG_DEBUG, "TestServer: 11. Waiting for hangup\n"); + ast_debug(1, "TestServer: 11. Waiting for hangup\n"); res = ast_safe_sleep(chan, 10000); fprintf(f, "WAIT HANGUP: %s\n", (res < 0) ? "PASS" : "FAIL"); } diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 801a8702d..675d96670 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -885,22 +885,18 @@ static void vm_change_password(struct ast_vm_user *vmu, const char *newpassword) /* check users.conf and update the password stored for the mailbox*/ /* if no vmsecret entry exists create one. */ if ((cfg = ast_config_load_with_comments("users.conf"))) { - if (option_debug > 3) - ast_log(LOG_DEBUG, "we are looking for %s\n", vmu->mailbox); + ast_debug(4, "we are looking for %s\n", vmu->mailbox); while ((category = ast_category_browse(cfg, category))) { - if (option_debug > 3) - ast_log(LOG_DEBUG, "users.conf: %s\n", category); + ast_debug(4, "users.conf: %s\n", category); if (!strcasecmp(category, vmu->mailbox)) { if (!(tmp = ast_variable_retrieve(cfg, category, "vmsecret"))) { - if (option_debug > 3) - ast_log(LOG_DEBUG, "looks like we need to make vmsecret!\n"); + ast_debug(3, "looks like we need to make vmsecret!\n"); var = ast_variable_new("vmsecret", newpassword); } new = alloca(strlen(newpassword)+1); sprintf(new, "%s", newpassword); if (!(cat = ast_category_get(cfg, category))) { - if (option_debug > 3) - ast_log(LOG_DEBUG, "failed to get category!\n"); + ast_debug(4, "failed to get category!\n"); break; } if (!var) @@ -953,8 +949,7 @@ static void vm_imap_delete(int msgnum, struct vm_state *vms) ast_log(LOG_WARNING, "msgnum %d, mailbox message %lu is zero.\n",msgnum,messageNum); return; } - if(option_debug > 2) - ast_log(LOG_DEBUG, "deleting msgnum %d, which is mailbox message %lu\n",msgnum,messageNum); + ast_debug(3, "deleting msgnum %d, which is mailbox message %lu\n",msgnum,messageNum); /* delete message */ sprintf (arg,"%lu",messageNum); mail_setflag (vms->mailstream,arg,"\\DELETED"); @@ -2094,14 +2089,12 @@ 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); + ast_debug(3, "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); + ast_debug(3, "VOLGAIN: Stored at: %s.%s - Level: %.4f - Mailbox: %s\n", attach, format, vmu->volgain, mailbox); } fprintf(p, "--%s" ENDL, bound); fprintf(p, "Content-Type: %s%s; name=\"msg%04d.%s\"" ENDL, ctype, format, msgnum + 1, format); @@ -2130,8 +2123,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)); + ast_debug(3, "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) { @@ -2142,8 +2134,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) - ast_log(LOG_DEBUG, "Sent mail to %s with command '%s'\n", vmu->email, mailcmd); + ast_debug(1, "Sent mail to %s with command '%s'\n", vmu->email, mailcmd); } return 0; } @@ -2229,8 +2220,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) - ast_log(LOG_DEBUG, "Sent page to %s with command '%s'\n", pager, mailcmd); + ast_debug(1, "Sent page to %s with command '%s'\n", pager, mailcmd); return 0; } @@ -2524,8 +2514,7 @@ static int imap_store_file(char *dir, char *mailboxuser, char *mailboxcontext, i if (!strcmp(fmt, "wav49")) fmt = "WAV"; - if(option_debug > 2) - ast_log(LOG_DEBUG, "Storing file '%s', format '%s'\n", fn, fmt); + ast_debug(3, "Storing file '%s', format '%s'\n", fn, fmt); /* Make a temporary file instead of piping directly to sendmail, in case the mail command hangs */ @@ -2552,8 +2541,7 @@ static int imap_store_file(char *dir, char *mailboxuser, char *mailboxcontext, i fclose(p); unlink(tmp); ast_free(buf); - if(option_debug > 2) - ast_log(LOG_DEBUG, "%s stored\n", fn); + ast_debug(3, "%s stored\n", fn); return 0; } @@ -2577,8 +2565,7 @@ static int inboxcount(const char *mailbox, int *newmsgs, int *oldmsgs) if (oldmsgs) *oldmsgs = 0; - if(option_debug > 2) - ast_log (LOG_DEBUG,"Mailbox is set to %s\n",mailbox); + ast_debug(3,"Mailbox is set to %s\n",mailbox); /* If no mailbox, return immediately */ if (ast_strlen_zero(mailbox)) @@ -2616,7 +2603,7 @@ static int inboxcount(const char *mailbox, int *newmsgs, int *oldmsgs) } /* We have to get the user before we can open the stream! */ - /*ast_log (LOG_DEBUG,"Before find_user, context is %s and mailbox is %s\n",context,mailbox); */ + /*ast_debug(1,"Before find_user, context is %s and mailbox is %s\n",context,mailbox); */ if (!(vmu = find_user(NULL, context, mailboxnc))) { ast_log(LOG_ERROR, "Couldn't find mailbox %s in context %s\n", mailboxnc, context); return -1; @@ -2631,8 +2618,7 @@ static int inboxcount(const char *mailbox, int *newmsgs, int *oldmsgs) /* check if someone is accessing this box right now... */ if ((vms_p = get_vm_state_by_imapuser(vmu->imapuser, 1)) || (vms_p = get_vm_state_by_mailbox(mailboxnc, 1))) { - if(option_debug > 2) - ast_log (LOG_DEBUG,"Returning before search - user is logged in\n"); + ast_debug(3,"Returning before search - user is logged in\n"); *newmsgs = vms_p->newmessages; *oldmsgs = vms_p->oldmessages; free_user(vmu); @@ -2641,8 +2627,7 @@ static int inboxcount(const char *mailbox, int *newmsgs, int *oldmsgs) /* add one if not there... */ if (!(vms_p = get_vm_state_by_imapuser(vmu->imapuser, 0)) && !(vms_p = get_vm_state_by_mailbox(mailboxnc, 0))) { - if(option_debug > 2) - ast_log (LOG_DEBUG,"Adding new vmstate for %s\n",vmu->imapuser); + ast_debug(3,"Adding new vmstate for %s\n",vmu->imapuser); if (!(vms_p = ast_calloc(1, sizeof(*vms_p)))) { free_user(vmu); return -1; @@ -2650,8 +2635,7 @@ static int inboxcount(const char *mailbox, int *newmsgs, int *oldmsgs) ast_copy_string(vms_p->imapuser,vmu->imapuser, sizeof(vms_p->imapuser)); ast_copy_string(vms_p->username, mailboxnc, sizeof(vms_p->username)); /* save for access from interactive entry point */ vms_p->mailstream = NIL; /* save for access from interactive entry point */ - if(option_debug > 2) - ast_log (LOG_DEBUG,"Copied %s to %s\n",vmu->imapuser,vms_p->imapuser); + ast_debug(3,"Copied %s to %s\n",vmu->imapuser,vms_p->imapuser); vms_p->updated = 1; /* set mailbox to INBOX! */ ast_copy_string(vms_p->curbox, mbox(0), sizeof(vms_p->curbox)); @@ -2914,8 +2898,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); + ast_debug(1, "Successfully executed SMDI MWI change for %s on %s\n", extension, smdi_iface->name); } } @@ -2924,8 +2907,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_debug(1, "Executing %s\n", arguments); ast_safe_system(arguments); } } @@ -2986,8 +2968,7 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_ category = pbx_builtin_getvar_helper(chan, "VM_CATEGORY"); - if (option_debug > 2) - ast_log(LOG_DEBUG, "Before find_user\n"); + ast_debug(3, "Before find_user\n"); if (!(vmu = find_user(&svm, context, ext))) { ast_log(LOG_WARNING, "No entry in voicemail config file for '%s'\n", ext); pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED"); @@ -3052,14 +3033,12 @@ 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); + ast_debug(1, "%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"); + ast_debug(1, "Hang up during prefile playback\n"); free_user(vmu); pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED"); return -1; @@ -3128,8 +3107,7 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_ /* must open stream for this user to get info! */ vms = get_vm_state_by_mailbox(ext,0); if (vms) { - if(option_debug > 2) - ast_log(LOG_DEBUG, "Using vm_state, interactive set to %d.\n",vms->interactive); + ast_debug(3, "Using vm_state, interactive set to %d.\n",vms->interactive); newmsgs = vms->newmessages++; oldmsgs = vms->oldmessages; } else { @@ -3142,23 +3120,20 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_ } /* here is a big difference! We add one to it later */ msgnum = newmsgs + oldmsgs; - if(option_debug > 2) - ast_log(LOG_DEBUG, "Messagecount set to %d\n",msgnum); + ast_debug(3, "Messagecount set to %d\n",msgnum); snprintf(fn, sizeof(fn), "%s/imap/msg%s%04d", VM_SPOOL_DIR, vmu->mailbox, msgnum); /* set variable for compatibility */ pbx_builtin_setvar_helper(chan, "VM_MESSAGEFILE", "IMAP_STORAGE"); /* Check if mailbox is full */ if (vms->quota_limit && vms->quota_usage >= vms->quota_limit) { - if (option_debug) - ast_log(LOG_DEBUG, "*** QUOTA EXCEEDED!! %u >= %u\n", vms->quota_usage, vms->quota_limit); + ast_debug(1, "*** QUOTA EXCEEDED!! %u >= %u\n", vms->quota_usage, vms->quota_limit); ast_play_and_wait(chan, "vm-mailboxfull"); return -1; } /* here is a big difference! We add one to it later */ msgnum = newmsgs + oldmsgs; - if(option_debug > 2) - ast_log(LOG_DEBUG, "Messagecount set to %d\n",msgnum); + ast_debug(3, "Messagecount set to %d\n",msgnum); #else if (count_messages(vmu, dir) >= vmu->maxmsg) { @@ -3251,8 +3226,7 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_ ast_filedelete(tmptxtfile, NULL); unlink(tmptxtfile); } else if (ast_fileexists(tmptxtfile, NULL, NULL) <= 0) { - if (option_debug) - ast_log(LOG_DEBUG, "The recorded media file is gone, so we should remove the .txt file too!\n"); + ast_debug(1, "The recorded media file is gone, so we should remove the .txt file too!\n"); unlink(tmptxtfile); ast_unlock_path(dir); if (ast_check_realtime("voicemail_data")) { @@ -3375,8 +3349,7 @@ static int save_to_folder(struct ast_vm_user *vmu, struct vm_state *vms, int msg /* get the real IMAP message number for this message */ sprintf(sequence,"%ld",vms->msgArray[msg]); imap_mailbox_name(dbox, vms, box, 1); - if (option_debug > 2) - ast_log(LOG_DEBUG, "Copying sequence %s to mailbox %s\n",sequence,dbox); + ast_debug(3, "Copying sequence %s to mailbox %s\n",sequence,dbox); res = mail_copy(vms->mailstream, sequence, dbox); if (res == 1) return 0; return 1; @@ -3525,8 +3498,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"); + ast_debug(1, "Done downloading scripts...\n"); #ifdef DISPLAY /* Add last dot */ @@ -3534,8 +3506,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"); + ast_debug(1, "Restarting session...\n"); bytes = 0; /* Load the session now */ @@ -4264,8 +4235,7 @@ static int forward_message(struct ast_channel *chan, char *context, struct vm_st AST_LIST_TRAVERSE_SAFE_BEGIN(&extensions, vmtmp, list) { #ifdef IMAP_STORAGE /* Need to get message content */ - if(option_debug > 2) - ast_log (LOG_DEBUG,"Before mail_fetchheaders, curmsg is: %d, imap messages is %lu\n",vms->curmsg, vms->msgArray[vms->curmsg]); + ast_debug(3,"Before mail_fetchheaders, curmsg is: %d, imap messages is %lu\n",vms->curmsg, vms->msgArray[vms->curmsg]); if (!vms->msgArray[vms->curmsg]) { ast_log (LOG_WARNING,"Trying to access unknown message\n"); return -1; @@ -4294,14 +4264,12 @@ static int forward_message(struct ast_channel *chan, char *context, struct vm_st } if (!strcasecmp(fmt, "wav49")) fmt = "WAV"; - if (option_debug > 2) - ast_log (LOG_DEBUG,"**** format set to %s, vmfmts set to %s\n",fmt,vmfmts); + ast_debug(3,"**** format set to %s, vmfmts set to %s\n",fmt,vmfmts); /* ast_copy_string(fmt, vmfmts, sizeof(fmt));*/ /* if (!ast_strlen_zero(fmt)) { */ snprintf(todir, sizeof(todir), "%s%s/%s/tmp", VM_SPOOL_DIR, vmtmp->context, vmtmp->mailbox); make_gsm_file(vms->fn, vms->imapuser, todir, vms->curmsg); - if (option_debug > 2) - ast_log (LOG_DEBUG,"Before mail_fetchstructure, message number is %ld, filename is:%s\n",vms->msgArray[vms->curmsg], vms->fn); + ast_debug(3,"Before mail_fetchstructure, message number is %ld, filename is:%s\n",vms->msgArray[vms->curmsg], vms->fn); /*mail_fetchstructure (mailstream, vmArray[0], &body); */ mail_fetchstructure (vms->mailstream, vms->msgArray[vms->curmsg], &body); save_body(body,vms,"3","gsm"); @@ -4458,15 +4426,13 @@ 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) - ast_log(LOG_DEBUG, "VM-CID: composite caller ID received: %s, context: %s\n", cid, context); + ast_debug(1, "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) - ast_log(LOG_DEBUG, "VM-CID: comparing internalcontext: %s\n", cidinternalcontexts[i]); + ast_debug(1, "VM-CID: comparing internalcontext: %s\n", cidinternalcontexts[i]); if ((strcmp(cidinternalcontexts[i], context) == 0)) break; } @@ -4494,8 +4460,7 @@ static int play_message_callerid(struct ast_channel *chan, struct vm_state *vms, } else if (!res) { - if (option_debug) - ast_log(LOG_DEBUG, "VM-CID: Numeric caller id: (%s)\n", callerid); + ast_debug(1, "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"); @@ -4503,8 +4468,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"); + ast_debug(1, "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"); } @@ -4524,8 +4488,7 @@ static int play_message_duration(struct ast_channel *chan, struct vm_state *vms, durations=atoi(duration); durationm=(durations / 60); - if (option_debug) - ast_log(LOG_DEBUG, "VM-Duration: duration is: %d seconds converted to: %d minutes\n", durations, durationm); + ast_debug(1, "VM-Duration: duration is: %d seconds converted to: %d minutes\n", durations, durationm); if ((!res) && (durationm >= minduration)) { res = wait_file2(chan, vms, "vm-duration"); @@ -4579,8 +4542,7 @@ static int play_message(struct ast_channel *chan, struct ast_vm_user *vmu, struc char buf[1024]; vms->starting = 0; - if(option_debug > 2) - ast_log (LOG_DEBUG,"Before mail_fetchheaders, curmsg is: %d, imap messages is %lu\n",vms->curmsg, vms->msgArray[vms->curmsg]); + ast_debug(3,"Before mail_fetchheaders, curmsg is: %d, imap messages is %lu\n",vms->curmsg, vms->msgArray[vms->curmsg]); if (!vms->msgArray[vms->curmsg]) { ast_log (LOG_WARNING,"Trying to access unknown message\n"); @@ -4831,11 +4793,9 @@ static int init_mailstream(struct vm_state *vms, int box) ast_log (LOG_ERROR,"vm_state is NULL!\n"); return -1; } - if(option_debug > 2) - ast_log (LOG_DEBUG,"vm_state user is:%s\n",vms->imapuser); + ast_debug(3,"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"); + ast_debug(1,"mailstream not set.\n"); } else { stream = vms->mailstream; } @@ -4861,8 +4821,7 @@ static int init_mailstream(struct vm_state *vms, int box) } /* Now connect to the target folder */ imap_mailbox_name(tmp, vms, box, 1); - if(option_debug > 2) - ast_log (LOG_DEBUG,"Before mail_open, server: %s, box:%d\n", tmp, box); + ast_debug(3,"Before mail_open, server: %s, box:%d\n", tmp, box); vms->mailstream = mail_open(stream, tmp, debug ? OP_DEBUG : NIL); if (vms->mailstream == NIL) { return -1; @@ -4879,9 +4838,7 @@ static int open_mailbox(struct vm_state *vms, struct ast_vm_user *vmu, int box) char dbox[256]; ast_copy_string(vms->imapuser,vmu->imapuser, sizeof(vms->imapuser)); - - if(option_debug > 2) - ast_log(LOG_DEBUG,"Before init_mailstream, user is %s\n",vmu->imapuser); + ast_debug(3,"Before init_mailstream, user is %s\n",vmu->imapuser); if ((ret = init_mailstream(vms, box)) || !vms->mailstream) { ast_log (LOG_ERROR,"Could not initialize mailstream\n"); @@ -4910,8 +4867,7 @@ static int open_mailbox(struct vm_state *vms, struct ast_vm_user *vmu, int box) pgm->unseen = 0; } - if(option_debug > 2) - ast_log(LOG_DEBUG,"Before mail_search_full, user is %s\n",vmu->imapuser); + ast_debug(3,"Before mail_search_full, user is %s\n",vmu->imapuser); vms->vmArrayIndex = 0; mail_search_full (vms->mailstream, NULL, pgm, NIL); @@ -5028,8 +4984,7 @@ static int close_mailbox(struct vm_state *vms, struct ast_vm_user *vmu) if (vms->deleted) { for (x=0;x < vmu->maxmsg;x++) { if (vms->deleted[x]) { - if(option_debug > 2) - ast_log(LOG_DEBUG,"IMAP delete of %d\n",x); + ast_debug(3,"IMAP delete of %d\n",x); IMAP_DELETE(vms->curdir, x, vms->fn, vms); } } @@ -5973,8 +5928,7 @@ static int vm_newuser(struct ast_channel *chan, struct ast_vm_user *vmu, struct if ((pwdchange & PWDCHANGE_EXTERNAL) && !ast_strlen_zero(ext_pass_cmd)) vm_change_password_shell(vmu, newpassword); - if (option_debug) - ast_log(LOG_DEBUG,"User %s set password to %s of length %d\n",vms->username,newpassword,(int)strlen(newpassword)); + ast_debug(1,"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 */ @@ -6108,8 +6062,7 @@ static int vm_options(struct ast_channel *chan, struct ast_vm_user *vmu, struct if ((pwdchange & PWDCHANGE_EXTERNAL) && !ast_strlen_zero(ext_pass_cmd)) vm_change_password_shell(vmu, newpassword); - if (option_debug) - ast_log(LOG_DEBUG,"User %s set password to %s of length %d\n",vms->username,newpassword,(int)strlen(newpassword)); + ast_debug(1,"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 '*': @@ -6368,8 +6321,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); + ast_debug(1, "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 */ @@ -6461,8 +6413,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_debug(1, "Before ast_answer\n"); ast_answer(chan); } @@ -6544,8 +6495,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"); + ast_debug(1, "After vm_authenticate\n"); if (!res) { valid = 1; if (!skipuser) @@ -6580,21 +6530,18 @@ 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"); + ast_debug(1, "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) - ast_log(LOG_DEBUG, "Number of old messages: %d\n",vms.oldmessages); + ast_debug(1, "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) - ast_log(LOG_DEBUG, "Number of new messages: %d\n",vms.newmessages); + ast_debug(1, "Number of new messages: %d\n",vms.newmessages); /* Select proper mailbox FIRST!! */ if (play_auto) { @@ -6638,11 +6585,9 @@ static int vm_execmain(struct ast_channel *chan, void *data) } } #ifdef IMAP_STORAGE - if(option_debug > 2) - ast_log(LOG_DEBUG, "Checking quotas: comparing %u to %u\n",vms.quota_usage,vms.quota_limit); + ast_debug(3, "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"); + ast_debug(1, "*** QUOTA EXCEEDED!!\n"); cmd = ast_play_and_wait(chan, "vm-mailboxfull"); } #endif @@ -6948,8 +6893,7 @@ out: } #ifdef IMAP_STORAGE /* expunge message - use UID Expunge if supported on IMAP server*/ - if(option_debug > 2) - ast_log(LOG_DEBUG, "*** Checking if we can expunge, deleted set to %d, expungeonhangup set to %d\n",deleted,expungeonhangup); + ast_debug(3, "*** Checking if we can expunge, deleted set to %d, expungeonhangup set to %d\n",deleted,expungeonhangup); if (vmu && deleted == 1 && expungeonhangup == 1) { #ifdef HAVE_IMAP_TK2006 if (LEVELUIDPLUS (vms.mailstream)) { @@ -7734,28 +7678,24 @@ static int load_config(void) /* External voicemail notify application */ if ((val = ast_variable_retrieve(cfg, "general", "externnotify"))) { ast_copy_string(externnotify, val, sizeof(externnotify)); - if (option_debug) - ast_log(LOG_DEBUG, "found externnotify: %s\n", externnotify); + ast_debug(1, "found externnotify: %s\n", externnotify); } else { externnotify[0] = '\0'; } /* SMDI voicemail notification */ if ((s = ast_variable_retrieve(cfg, "general", "smdienable")) && ast_true(s)) { - if (option_debug) - ast_log(LOG_DEBUG, "Enabled SMDI voicemail notification\n"); + ast_debug(1, "Enabled SMDI voicemail notification\n"); if ((val = ast_variable_retrieve(cfg, "general", "smdiport"))) { smdi_iface = ast_smdi_interface_find(val); } else { - if (option_debug) - ast_log(LOG_DEBUG, "No SMDI interface set, trying default (/dev/ttyS0)\n"); + ast_debug(1, "No SMDI interface set, trying default (/dev/ttyS0)\n"); smdi_iface = ast_smdi_interface_find("/dev/ttyS0"); } if (!smdi_iface) { ast_log(LOG_ERROR, "No valid SMDI interface specfied, disabling SMDI voicemail notification\n"); } else { - if (option_debug) - ast_log(LOG_DEBUG, "Using SMDI port %s\n", smdi_iface->name); + ast_debug(1, "Using SMDI port %s\n", smdi_iface->name); } } @@ -7854,8 +7794,7 @@ static int load_config(void) ast_set2_flag((&globalflags), ast_true(val), VM_FORCEGREET); if ((s = ast_variable_retrieve(cfg, "general", "cidinternalcontexts"))){ - if (option_debug) - ast_log(LOG_DEBUG,"VM_CID Internal context string: %s\n",s); + ast_debug(1,"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)) { @@ -7863,62 +7802,53 @@ 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) - ast_log(LOG_DEBUG,"VM_CID Internal context %d: %s\n", x, cidinternalcontexts[x]); + ast_debug(1,"VM_CID Internal context %d: %s\n", x, cidinternalcontexts[x]); } else { cidinternalcontexts[x][0] = '\0'; } } } if (!(val = ast_variable_retrieve(cfg, "general", "review"))){ - if (option_debug) - ast_log(LOG_DEBUG,"VM Review Option disabled globally\n"); + ast_debug(1,"VM Review Option disabled globally\n"); val = "no"; } ast_set2_flag((&globalflags), ast_true(val), VM_REVIEW); /*Temporary greeting reminder */ if (!(val = ast_variable_retrieve(cfg, "general", "tempgreetwarn"))) { - if (option_debug) - ast_log(LOG_DEBUG, "VM Temporary Greeting Reminder Option disabled globally\n"); + ast_debug(1, "VM Temporary Greeting Reminder Option disabled globally\n"); val = "no"; } else { - if (option_debug) - ast_log(LOG_DEBUG, "VM Temporary Greeting Reminder Option enabled globally\n"); + ast_debug(1, "VM Temporary Greeting Reminder Option enabled globally\n"); } ast_set2_flag((&globalflags), ast_true(val), VM_TEMPGREETWARN); if (!(val = ast_variable_retrieve(cfg, "general", "operator"))){ - if (option_debug) - ast_log(LOG_DEBUG,"VM Operator break disabled globally\n"); + ast_debug(1,"VM Operator break disabled globally\n"); val = "no"; } ast_set2_flag((&globalflags), ast_true(val), VM_OPERATOR); if (!(val = ast_variable_retrieve(cfg, "general", "saycid"))) { - if (option_debug) - ast_log(LOG_DEBUG,"VM CID Info before msg disabled globally\n"); + ast_debug(1,"VM CID Info before msg disabled globally\n"); val = "no"; } ast_set2_flag((&globalflags), ast_true(val), VM_SAYCID); if (!(val = ast_variable_retrieve(cfg,"general", "sendvoicemail"))){ - if (option_debug) - ast_log(LOG_DEBUG,"Send Voicemail msg disabled globally\n"); + ast_debug(1,"Send Voicemail msg disabled globally\n"); val = "no"; } ast_set2_flag((&globalflags), ast_true(val), VM_SVMAIL); if (!(val = ast_variable_retrieve(cfg, "general", "envelope"))) { - if (option_debug) - ast_log(LOG_DEBUG,"ENVELOPE before msg enabled globally\n"); + ast_debug(1,"ENVELOPE before msg enabled globally\n"); val = "yes"; } ast_set2_flag((&globalflags), ast_true(val), VM_ENVELOPE); if (!(val = ast_variable_retrieve(cfg, "general", "sayduration"))) { - if (option_debug) - ast_log(LOG_DEBUG,"Duration info before msg enabled globally\n"); + ast_debug(1,"Duration info before msg enabled globally\n"); val = "yes"; } ast_set2_flag((&globalflags), ast_true(val), VM_SAYDURATION); @@ -7933,32 +7863,28 @@ static int load_config(void) } if (!(val = 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"); + ast_debug(1,"We are not going to skip to the next msg after save/delete\n"); val = "no"; } ast_set2_flag((&globalflags), ast_true(val), VM_SKIPAFTERCMD); if ((val = ast_variable_retrieve(cfg, "general", "dialout"))) { ast_copy_string(dialcontext, val, sizeof(dialcontext)); - if (option_debug) - ast_log(LOG_DEBUG, "found dialout context: %s\n", dialcontext); + ast_debug(1, "found dialout context: %s\n", dialcontext); } else { dialcontext[0] = '\0'; } if ((val = ast_variable_retrieve(cfg, "general", "callback"))) { ast_copy_string(callcontext, val, sizeof(callcontext)); - if (option_debug) - ast_log(LOG_DEBUG, "found callback context: %s\n", callcontext); + ast_debug(1, "found callback context: %s\n", callcontext); } else { callcontext[0] = '\0'; } if ((val = ast_variable_retrieve(cfg, "general", "exitcontext"))) { ast_copy_string(exitcontext, val, sizeof(exitcontext)); - if (option_debug) - ast_log(LOG_DEBUG, "found operator context: %s\n", exitcontext); + ast_debug(1, "found operator context: %s\n", exitcontext); } else { exitcontext[0] = '\0'; } @@ -8295,8 +8221,7 @@ static int advanced_options(struct ast_channel *chan, struct ast_vm_user *vmu, s /* START HERE */ /* get the message info!! */ - if(option_debug > 2) - ast_log(LOG_DEBUG, "Before mail_fetchheaders, curmsg is: %d, imap messages is %lu\n", vms->curmsg, vms->msgArray[vms->curmsg]); + ast_debug(3, "Before mail_fetchheaders, curmsg is: %d, imap messages is %lu\n", vms->curmsg, vms->msgArray[vms->curmsg]); if (!vms->msgArray[vms->curmsg]) { ast_log(LOG_WARNING, "Trying to access unknown message\n"); @@ -8744,8 +8669,7 @@ void mm_searched(MAILSTREAM *stream, unsigned long number) return; } - if(option_debug > 2) - ast_log(LOG_DEBUG, "saving mailbox message number %lu as message %d. Interactive set to %d\n", number, vms->vmArrayIndex, vms->interactive); + ast_debug(3, "saving mailbox message number %lu as message %d. Interactive set to %d\n", number, vms->vmArrayIndex, vms->interactive); vms->msgArray[vms->vmArrayIndex++] = number; } @@ -8944,8 +8868,7 @@ static struct ast_vm_user *find_user_realtime_imapuser(const char *imapuser) void mm_exists(MAILSTREAM * stream, unsigned long number) { /* mail_ping will callback here if new mail! */ - if(option_debug > 3) - ast_log (LOG_DEBUG, "Entering EXISTS callback for message %ld\n", number); + ast_debug(4, "Entering EXISTS callback for message %ld\n", number); if (number == 0) return; set_update(stream); } @@ -8954,8 +8877,7 @@ void mm_exists(MAILSTREAM * stream, unsigned long number) void mm_expunged(MAILSTREAM * stream, unsigned long number) { /* mail_ping will callback here if expunged mail! */ - if(option_debug > 3) - ast_log (LOG_DEBUG, "Entering EXPUNGE callback for message %ld\n", number); + ast_debug(4, "Entering EXPUNGE callback for message %ld\n", number); if (number == 0) return; set_update(stream); } @@ -8964,8 +8886,7 @@ void mm_expunged(MAILSTREAM * stream, unsigned long number) void mm_flags(MAILSTREAM * stream, unsigned long number) { /* mail_ping will callback here if read mail! */ - if(option_debug > 3) - ast_log (LOG_DEBUG, "Entering FLAGS callback for message %ld\n", number); + ast_debug(4, "Entering FLAGS callback for message %ld\n", number); if (number == 0) return; set_update(stream); } @@ -8984,33 +8905,30 @@ void mm_list(MAILSTREAM * stream, int delim, char *mailbox, long attributes) delimiter = delim; ast_mutex_unlock(&delimiter_lock); } - if (option_debug > 4) { - ast_log(LOG_DEBUG, "Delimiter set to %c and mailbox %s\n",delim, mailbox); - if (attributes & LATT_NOINFERIORS) - ast_log(LOG_DEBUG, "no inferiors\n"); - if (attributes & LATT_NOSELECT) - ast_log(LOG_DEBUG, "no select\n"); - if (attributes & LATT_MARKED) - ast_log(LOG_DEBUG, "marked\n"); - if (attributes & LATT_UNMARKED) - ast_log(LOG_DEBUG, "unmarked\n"); - } + + ast_debug(5, "Delimiter set to %c and mailbox %s\n",delim, mailbox); + if (attributes & LATT_NOINFERIORS) + ast_debug(5, "no inferiors\n"); + if (attributes & LATT_NOSELECT) + ast_debug(5, "no select\n"); + if (attributes & LATT_MARKED) + ast_debug(5, "marked\n"); + if (attributes & LATT_UNMARKED) + ast_debug(5, "unmarked\n"); } void mm_lsub(MAILSTREAM * stream, int delimiter, char *mailbox, long attributes) { - if (option_debug > 4) { - ast_log(LOG_DEBUG, "Delimiter set to %c and mailbox %s\n",delimiter, mailbox); - if (attributes & LATT_NOINFERIORS) - ast_log(LOG_DEBUG, "no inferiors\n"); - if (attributes & LATT_NOSELECT) - ast_log(LOG_DEBUG, "no select\n"); - if (attributes & LATT_MARKED) - ast_log(LOG_DEBUG, "marked\n"); - if (attributes & LATT_UNMARKED) - ast_log(LOG_DEBUG, "unmarked\n"); - } + ast_debug(5, "Delimiter set to %c and mailbox %s\n",delimiter, mailbox); + if (attributes & LATT_NOINFERIORS) + ast_debug(5, "no inferiors\n"); + if (attributes & LATT_NOSELECT) + ast_debug(5, "no select\n"); + if (attributes & LATT_MARKED) + ast_debug(5, "marked\n"); + if (attributes & LATT_UNMARKED) + ast_debug(5, "unmarked\n"); } @@ -9035,8 +8953,7 @@ void mm_log(char *string, long errflg) { switch ((short) errflg) { case NIL: - if(option_debug) - ast_log(LOG_DEBUG,"IMAP Info: %s\n", string); + ast_debug(1,"IMAP Info: %s\n", string); break; case PARSE: case WARN: @@ -9059,8 +8976,7 @@ void mm_login(NETMBX * mb, char *user, char *pwd, long trial) { struct ast_vm_user *vmu; - if(option_debug > 3) - ast_log(LOG_DEBUG, "Entering callback mm_login\n"); + ast_debug(4, "Entering callback mm_login\n"); ast_copy_string(user, mb->user, MAILTMPLEN); @@ -9125,8 +9041,7 @@ static void mm_parsequota(MAILSTREAM *stream, unsigned char *msg, QUOTALIST *pqu return; } - if (option_debug > 2) - ast_log(LOG_DEBUG, "User %s usage is %lu, limit is %lu\n", user, usage, limit); + ast_debug(3, "User %s usage is %lu, limit is %lu\n", user, usage, limit); vms->quota_usage = usage; vms->quota_limit = limit; @@ -9186,13 +9101,11 @@ static struct vm_state *get_vm_state_by_imapuser(char *user, int interactive) AST_LIST_TRAVERSE(&vmstates, vlist, list) { if (!vlist->vms) { - if (option_debug > 2) - ast_log(LOG_DEBUG, "error: vms is NULL for %s\n", user); + ast_debug(3, "error: vms is NULL for %s\n", user); continue; } if (!vlist->vms->imapuser) { - if (option_debug > 2) - ast_log(LOG_DEBUG, "error: imapuser is NULL for %s\n", user); + ast_debug(3, "error: imapuser is NULL for %s\n", user); continue; } @@ -9202,8 +9115,7 @@ static struct vm_state *get_vm_state_by_imapuser(char *user, int interactive) return vlist->vms; } - if(option_debug > 2) - ast_log(LOG_DEBUG, "%s not found in vmstates\n", user); + ast_debug(3, "%s not found in vmstates\n", user); return NULL; } @@ -9214,28 +9126,23 @@ static struct vm_state *get_vm_state_by_mailbox(const char *mailbox, int interac AST_LIST_TRAVERSE(&vmstates, vlist, list) { if (!vlist->vms) { - if (option_debug > 2) - ast_log(LOG_DEBUG, "error: vms is NULL for %s\n", mailbox); + ast_debug(3, "error: vms is NULL for %s\n", mailbox); continue; } if (!vlist->vms->username) { - if (option_debug > 2) - ast_log(LOG_DEBUG, "error: username is NULL for %s\n", mailbox); + ast_debug(3, "error: username is NULL for %s\n", mailbox); continue; } - if (option_debug > 2) - ast_log(LOG_DEBUG, "comparing mailbox %s (i=%d) to vmstate mailbox %s (i=%d)\n", mailbox, interactive, vlist->vms->username, vlist->vms->interactive); + ast_debug(3, "comparing mailbox %s (i=%d) to vmstate mailbox %s (i=%d)\n", mailbox, interactive, vlist->vms->username, vlist->vms->interactive); if (!strcmp(vlist->vms->username,mailbox) && vlist->vms->interactive == interactive) { - if(option_debug > 2) - ast_log(LOG_DEBUG, "Found it!\n"); + ast_debug(3, "Found it!\n"); return vlist->vms; } } - if (option_debug > 2) - ast_log(LOG_DEBUG, "%s not found in vmstates\n", mailbox); + ast_debug(3, "%s not found in vmstates\n", mailbox); return NULL; } @@ -9251,17 +9158,14 @@ static void vmstate_insert(struct vm_state *vms) if (vms->interactive == 1) { altvms = get_vm_state_by_mailbox(vms->username,0); if (altvms) { - if(option_debug > 2) - ast_log(LOG_DEBUG, "Duplicate mailbox %s, copying message info...\n",vms->username); + ast_debug(3, "Duplicate mailbox %s, copying message info...\n",vms->username); vms->newmessages = altvms->newmessages; vms->oldmessages = altvms->oldmessages; - if(option_debug > 2) - ast_log(LOG_DEBUG, "check_msgArray before memcpy\n"); + ast_debug(3, "check_msgArray before memcpy\n"); check_msgArray(vms); /* memcpy(vms->msgArray, altvms->msgArray, sizeof(long)*256); */ copy_msgArray(vms, altvms); - if(option_debug > 2) - ast_log(LOG_DEBUG, "check_msgArray after memcpy\n"); + ast_debug(3, "check_msgArray after memcpy\n"); check_msgArray(vms); vms->vmArrayIndex = altvms->vmArrayIndex; vms->lastmsg = altvms->lastmsg; @@ -9279,8 +9183,7 @@ static void vmstate_insert(struct vm_state *vms) v->vms = vms; - if(option_debug > 2) - ast_log(LOG_DEBUG, "Inserting vm_state for user:%s, mailbox %s\n",vms->imapuser,vms->username); + ast_debug(3, "Inserting vm_state for user:%s, mailbox %s\n",vms->imapuser,vms->username); AST_LIST_LOCK(&vmstates); AST_LIST_INSERT_TAIL(&vmstates, v, list); @@ -9295,15 +9198,13 @@ static void vmstate_delete(struct vm_state *vms) /* If interactive, we should copy pertinent info back to the persistent state (to make update immediate) */ if (vms->interactive == 1 && (altvms = vms->persist_vms)) { - if(option_debug > 2) - ast_log(LOG_DEBUG, "Duplicate mailbox %s, copying message info...\n", vms->username); + ast_debug(3, "Duplicate mailbox %s, copying message info...\n", vms->username); altvms->newmessages = vms->newmessages; altvms->oldmessages = vms->oldmessages; altvms->updated = 2; } - if (option_debug > 2) - ast_log(LOG_DEBUG, "Removing vm_state for user:%s, mailbox %s\n", vms->imapuser, vms->username); + ast_debug(3, "Removing vm_state for user:%s, mailbox %s\n", vms->imapuser, vms->username); AST_LIST_LOCK(&vmstates); AST_LIST_TRAVERSE_SAFE_BEGIN(&vmstates, vc, list) { @@ -9333,8 +9234,7 @@ static void set_update(MAILSTREAM * stream) return; } - if (option_debug > 2) - ast_log(LOG_DEBUG, "User %s mailbox set for update.\n", user); + ast_debug(3, "User %s mailbox set for update.\n", user); vms->updated = 2; /* Set updated flag since mailbox changed */ } @@ -9353,8 +9253,7 @@ static void check_msgArray(struct vm_state *vms) int x; for (x = 0; x<256; x++) { if (vms->msgArray[x]!=0) { - if(option_debug) - ast_log (LOG_DEBUG, "Item %d set to %ld\n",x,vms->msgArray[x]); + ast_debug(1, "Item %d set to %ld\n",x,vms->msgArray[x]); } } } @@ -9381,7 +9280,7 @@ static int save_body(BODY *body, struct vm_state *vms, char *section, char *form body_content = mail_fetchbody (vms->mailstream, vms->msgArray[vms->curmsg], section, &len); if (body_content != NIL) { sprintf(filename,"%s.%s", vms->fn, format); - /* ast_log (LOG_DEBUG,body_content); */ + /* ast_debug(1,body_content); */ body_decoded = rfc822_base64 ((unsigned char *)body_content, len, &newlen); write_file (filename, (char *) body_decoded, newlen); } diff --git a/apps/app_waitforsilence.c b/apps/app_waitforsilence.c index 55fc714f9..c74bfd960 100644 --- a/apps/app_waitforsilence.c +++ b/apps/app_waitforsilence.c @@ -135,15 +135,13 @@ static int do_waiting(struct ast_channel *chan, int silencereqd, time_t waitstar /* Ended happily with silence */ res = 1; pbx_builtin_setvar_helper(chan, "WAITSTATUS", "SILENCE"); - if (option_debug) - ast_log(LOG_DEBUG, "WAITSTATUS was set to SILENCE\n"); + ast_debug(1, "WAITSTATUS was set to SILENCE\n"); break; } if ( timeout && (difftime(time(&now),waitstart) >= timeout) ) { pbx_builtin_setvar_helper(chan, "WAITSTATUS", "TIMEOUT"); - if (option_debug) - ast_log(LOG_DEBUG, "WAITSTATUS was set to TIMEOUT\n"); + ast_debug(1, "WAITSTATUS was set to TIMEOUT\n"); res = 0; break; } diff --git a/apps/app_zapbarge.c b/apps/app_zapbarge.c index 5b1f176bc..201ae78de 100644 --- a/apps/app_zapbarge.c +++ b/apps/app_zapbarge.c @@ -171,8 +171,7 @@ zapretry: if (ztc.confmode) { /* Whoa, already in a conference... Retry... */ if (!retryzap) { - if (option_debug) - ast_log(LOG_DEBUG, "Zap channel is in a conference already, retrying with pseudo\n"); + ast_debug(1, "Zap channel is in a conference already, retrying with pseudo\n"); retryzap = 1; goto zapretry; } @@ -188,8 +187,7 @@ zapretry: close(fd); goto outrun; } - if (option_debug) - ast_log(LOG_DEBUG, "Placed channel %s in ZAP channel %d monitor\n", chan->name, confno); + ast_debug(1, "Placed channel %s in ZAP channel %d monitor\n", chan->name, confno); for(;;) { outfd = -1; @@ -201,8 +199,7 @@ zapretry: /* Kill old pseudo */ close(fd); } - if (option_debug) - ast_log(LOG_DEBUG, "Ooh, something swapped out under us, starting over\n"); + ast_debug(1, "Ooh, something swapped out under us, starting over\n"); retryzap = 0; goto zapretry; } diff --git a/apps/app_zapras.c b/apps/app_zapras.c index 6057c8603..6191327b2 100644 --- a/apps/app_zapras.c +++ b/apps/app_zapras.c @@ -162,8 +162,7 @@ static void run_ras(struct ast_channel *chan, char *args) if (!res) { /* Check for hangup */ if (chan->_softhangup && !signalled) { - if (option_debug) - ast_log(LOG_DEBUG, "Channel '%s' hungup. Signalling RAS at %d to die...\n", chan->name, pid); + ast_debug(1, "Channel '%s' hungup. Signalling RAS at %d to die...\n", chan->name, pid); kill(pid, SIGTERM); signalled=1; } diff --git a/apps/app_zapscan.c b/apps/app_zapscan.c index 54dbdd265..17d84a6a0 100644 --- a/apps/app_zapscan.c +++ b/apps/app_zapscan.c @@ -179,8 +179,7 @@ static int conf_run(struct ast_channel *chan, int confno, int confflags) if (ztc.confmode) { /* Whoa, already in a conference... Retry... */ if (!retryzap) { - if (option_debug) - ast_log(LOG_DEBUG, "Zap channel is in a conference already, retrying with pseudo\n"); + ast_debug(1, "Zap channel is in a conference already, retrying with pseudo\n"); retryzap = 1; goto zapretry; } @@ -196,8 +195,7 @@ static int conf_run(struct ast_channel *chan, int confno, int confflags) close(fd); goto outrun; } - if (option_debug) - ast_log(LOG_DEBUG, "Placed channel %s in ZAP channel %d monitor\n", chan->name, confno); + ast_debug(1, "Placed channel %s in ZAP channel %d monitor\n", chan->name, confno); for(;;) { outfd = -1; @@ -209,8 +207,7 @@ static int conf_run(struct ast_channel *chan, int confno, int confflags) /* Kill old pseudo */ close(fd); } - if (option_debug) - ast_log(LOG_DEBUG, "Ooh, something swapped out under us, starting over\n"); + ast_debug(1, "Ooh, something swapped out under us, starting over\n"); retryzap = 0; goto zapretry; } |