aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/app_alarmreceiver.c24
-rw-r--r--apps/app_amd.c8
-rw-r--r--apps/app_channelredirect.c3
-rw-r--r--apps/app_chanspy.c14
-rw-r--r--apps/app_db.c9
-rw-r--r--apps/app_dial.c15
-rw-r--r--apps/app_directed_pickup.c3
-rw-r--r--apps/app_disa.c32
-rw-r--r--apps/app_festival.c42
-rw-r--r--apps/app_followme.c45
-rw-r--r--apps/app_ices.c6
-rw-r--r--apps/app_macro.c43
-rw-r--r--apps/app_meetme.c32
-rw-r--r--apps/app_minivm.c171
-rw-r--r--apps/app_mp3.c12
-rw-r--r--apps/app_nbscat.c12
-rw-r--r--apps/app_osplookup.c338
-rw-r--r--apps/app_queue.c138
-rw-r--r--apps/app_record.c3
-rw-r--r--apps/app_rpt.c194
-rw-r--r--apps/app_stack.c14
-rw-r--r--apps/app_talkdetect.c13
-rw-r--r--apps/app_test.c103
-rw-r--r--apps/app_voicemail.c337
-rw-r--r--apps/app_waitforsilence.c6
-rw-r--r--apps/app_zapbarge.c9
-rw-r--r--apps/app_zapras.c3
-rw-r--r--apps/app_zapscan.c9
-rw-r--r--cdr/cdr_csv.c9
-rw-r--r--cdr/cdr_odbc.c18
-rw-r--r--cdr/cdr_pgsql.c23
-rw-r--r--cdr/cdr_radius.c3
-rw-r--r--cdr/cdr_tds.c3
-rw-r--r--channels/chan_agent.c104
-rw-r--r--channels/chan_alsa.c18
-rw-r--r--channels/chan_features.c3
-rw-r--r--channels/chan_gtalk.c30
-rw-r--r--channels/chan_h323.c98
-rw-r--r--channels/chan_iax2.c266
-rw-r--r--channels/chan_jingle.c25
-rw-r--r--channels/chan_local.c6
-rw-r--r--channels/chan_mgcp.c71
-rw-r--r--channels/chan_misdn.c22
-rw-r--r--channels/chan_nbs.c9
-rw-r--r--channels/chan_phone.c66
-rw-r--r--channels/chan_sip.c1055
-rw-r--r--channels/chan_skinny.c15
-rw-r--r--channels/chan_vpb.cc34
-rw-r--r--channels/chan_zap.c611
-rw-r--r--channels/iax2-provision.c8
-rw-r--r--codecs/codec_zap.c2
-rw-r--r--formats/format_g726.c4
-rw-r--r--formats/format_ogg_vorbis.c6
-rw-r--r--formats/format_wav.c2
-rw-r--r--funcs/func_db.c11
-rw-r--r--funcs/func_iconv.c3
-rw-r--r--funcs/func_rand.c7
-rw-r--r--funcs/func_strings.c9
-rw-r--r--funcs/func_version.c4
-rw-r--r--main/acl.c6
-rw-r--r--main/adsistub.c3
-rw-r--r--main/app.c39
-rw-r--r--main/asterisk.c3
-rw-r--r--main/callerid.c21
-rw-r--r--main/cdr.c15
-rw-r--r--main/channel.c223
-rw-r--r--main/config.c9
-rw-r--r--main/db.c6
-rw-r--r--main/devicestate.c15
-rw-r--r--main/dial.c4
-rw-r--r--main/dns.c3
-rw-r--r--main/dsp.c9
-rw-r--r--main/enum.c17
-rw-r--r--main/file.c6
-rw-r--r--main/frame.c6
-rw-r--r--res/res_adsi.c53
-rw-r--r--res/res_agi.c12
-rw-r--r--res/res_config_pgsql.c116
-rw-r--r--res/res_config_sqlite.c6
-rw-r--r--res/res_crypto.c9
-rw-r--r--res/res_features.c50
-rw-r--r--res/res_jabber.c27
-rw-r--r--res/res_monitor.c7
-rw-r--r--res/res_musiconhold.c18
-rw-r--r--res/res_smdi.c12
85 files changed, 1810 insertions, 3068 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;
}
diff --git a/cdr/cdr_csv.c b/cdr/cdr_csv.c
index ffbfee27b..cbfe80fd0 100644
--- a/cdr/cdr_csv.c
+++ b/cdr/cdr_csv.c
@@ -122,8 +122,7 @@ static int load_config(void)
if (tmp) {
usegmtime = ast_true(tmp);
if (usegmtime) {
- if (option_debug)
- ast_log(LOG_DEBUG, "logging time in GMT\n");
+ ast_debug(1, "logging time in GMT\n");
}
}
@@ -131,8 +130,7 @@ static int load_config(void)
if (tmp) {
loguniqueid = ast_true(tmp);
if (loguniqueid) {
- if (option_debug)
- ast_log(LOG_DEBUG, "logging CDR field UNIQUEID\n");
+ ast_debug(1, "logging CDR field UNIQUEID\n");
}
}
@@ -140,8 +138,7 @@ static int load_config(void)
if (tmp) {
loguserfield = ast_true(tmp);
if (loguserfield) {
- if (option_debug)
- ast_log(LOG_DEBUG, "logging CDR user-defined field\n");
+ ast_debug(1, "logging CDR user-defined field\n");
}
}
diff --git a/cdr/cdr_odbc.c b/cdr/cdr_odbc.c
index 1a8b52143..56f0cda35 100644
--- a/cdr/cdr_odbc.c
+++ b/cdr/cdr_odbc.c
@@ -306,15 +306,12 @@ static int odbc_load_module(void)
if (tmp) {
loguniqueid = ast_true(tmp);
if (loguniqueid) {
- if (option_debug)
- ast_log(LOG_DEBUG,"cdr_odbc: Logging uniqueid\n");
+ ast_debug(1,"cdr_odbc: Logging uniqueid\n");
} else {
- if (option_debug)
- ast_log(LOG_DEBUG,"cdr_odbc: Not logging uniqueid\n");
+ ast_debug(1,"cdr_odbc: Not logging uniqueid\n");
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG,"cdr_odbc: Not logging uniqueid\n");
+ ast_debug(1,"cdr_odbc: Not logging uniqueid\n");
loguniqueid = 0;
}
@@ -322,15 +319,12 @@ static int odbc_load_module(void)
if (tmp) {
usegmtime = ast_true(tmp);
if (usegmtime) {
- if (option_debug)
- ast_log(LOG_DEBUG,"cdr_odbc: Logging in GMT\n");
+ ast_debug(1,"cdr_odbc: Logging in GMT\n");
} else {
- if (option_debug)
- ast_log(LOG_DEBUG,"cdr_odbc: Not logging in GMT\n");
+ ast_debug(1,"cdr_odbc: Not logging in GMT\n");
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG,"cdr_odbc: Not logging in GMT\n");
+ ast_debug(1,"cdr_odbc: Not logging in GMT\n");
usegmtime = 0;
}
diff --git a/cdr/cdr_pgsql.c b/cdr/cdr_pgsql.c
index d5ec87884..0b62440a8 100644
--- a/cdr/cdr_pgsql.c
+++ b/cdr/cdr_pgsql.c
@@ -121,8 +121,7 @@ static int pgsql_log(struct ast_cdr *cdr)
return -1;
}
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "cdr_pgsql: inserting a CDR record.\n");
+ ast_debug(2, "cdr_pgsql: inserting a CDR record.\n");
snprintf(sqlcmd,sizeof(sqlcmd),"INSERT INTO %s (calldate,clid,src,dst,dcontext,channel,dstchannel,"
"lastapp,lastdata,duration,billsec,disposition,amaflags,accountcode,uniqueid,userfield) VALUES"
@@ -130,8 +129,7 @@ static int pgsql_log(struct ast_cdr *cdr)
table,timestr,clid,cdr->src, cdr->dst, dcontext,channel, dstchannel, lastapp, lastdata,
cdr->duration,cdr->billsec,ast_cdr_disp2str(cdr->disposition),cdr->amaflags, cdr->accountcode, uniqueid, userfield);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "cdr_pgsql: SQL command executed: %s\n",sqlcmd);
+ ast_debug(3, "cdr_pgsql: SQL command executed: %s\n",sqlcmd);
/* Test to be sure we're still connected... */
/* If we're connected, and connection is working, good. */
@@ -259,20 +257,19 @@ static int process_my_load_module(struct ast_config *cfg)
if (option_debug) {
if (ast_strlen_zero(pghostname))
- ast_log(LOG_DEBUG, "cdr_pgsql: using default unix socket\n");
+ ast_debug(1, "cdr_pgsql: using default unix socket\n");
else
- ast_log(LOG_DEBUG, "cdr_pgsql: got hostname of %s\n", pghostname);
- ast_log(LOG_DEBUG, "cdr_pgsql: got port of %s\n", pgdbport);
- ast_log(LOG_DEBUG, "cdr_pgsql: got user of %s\n", pgdbuser);
- ast_log(LOG_DEBUG, "cdr_pgsql: got dbname of %s\n", pgdbname);
- ast_log(LOG_DEBUG, "cdr_pgsql: got password of %s\n", pgpassword);
- ast_log(LOG_DEBUG, "cdr_pgsql: got sql table name of %s\n", table);
+ ast_debug(1, "cdr_pgsql: got hostname of %s\n", pghostname);
+ ast_debug(1, "cdr_pgsql: got port of %s\n", pgdbport);
+ ast_debug(1, "cdr_pgsql: got user of %s\n", pgdbuser);
+ ast_debug(1, "cdr_pgsql: got dbname of %s\n", pgdbname);
+ ast_debug(1, "cdr_pgsql: got password of %s\n", pgpassword);
+ ast_debug(1, "cdr_pgsql: got sql table name of %s\n", table);
}
conn = PQsetdbLogin(pghostname, pgdbport, NULL, NULL, pgdbname, pgdbuser, pgpassword);
if (PQstatus(conn) != CONNECTION_BAD) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Successfully connected to PostgreSQL database.\n");
+ ast_debug(1, "Successfully connected to PostgreSQL database.\n");
connected = 1;
} else {
pgerror = PQerrorMessage(conn);
diff --git a/cdr/cdr_radius.c b/cdr/cdr_radius.c
index 99968ed31..ff380a13a 100644
--- a/cdr/cdr_radius.c
+++ b/cdr/cdr_radius.c
@@ -218,8 +218,7 @@ static int radius_log(struct ast_cdr *cdr)
VALUE_PAIR *send = NULL;
if (build_radius_record(&send, cdr)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Unable to create RADIUS record. CDR not recorded!\n");
+ ast_debug(1, "Unable to create RADIUS record. CDR not recorded!\n");
return result;
}
diff --git a/cdr/cdr_tds.c b/cdr/cdr_tds.c
index 736199a4a..3f79fc637 100644
--- a/cdr/cdr_tds.c
+++ b/cdr/cdr_tds.c
@@ -482,8 +482,7 @@ static int tds_load_module(void)
ptr = ast_variable_retrieve(cfg,"global","table");
if (ptr == NULL) {
- if (option_debug)
- ast_log(LOG_DEBUG,"cdr_tds: table not specified. Assuming cdr\n");
+ ast_debug(1,"cdr_tds: table not specified. Assuming cdr\n");
ptr = "cdr";
}
table = strdup(ptr);
diff --git a/channels/chan_agent.c b/channels/chan_agent.c
index b7a29b40c..14572bb93 100644
--- a/channels/chan_agent.c
+++ b/channels/chan_agent.c
@@ -184,12 +184,10 @@ static AST_LIST_HEAD_STATIC(agents, agent_pvt); /*!< Holds the list of agents (l
#define CHECK_FORMATS(ast, p) do { \
if (p->chan) {\
if (ast->nativeformats != p->chan->nativeformats) { \
- if (option_debug) \
- ast_log(LOG_DEBUG, "Native formats changing from %d to %d\n", ast->nativeformats, p->chan->nativeformats); \
+ ast_debug(1, "Native formats changing from %d to %d\n", ast->nativeformats, p->chan->nativeformats); \
/* Native formats changed, reset things */ \
ast->nativeformats = p->chan->nativeformats; \
- if (option_debug) \
- ast_log(LOG_DEBUG, "Resetting read to %d and write to %d\n", ast->readformat, ast->writeformat);\
+ ast_debug(1, "Resetting read to %d and write to %d\n", ast->readformat, ast->writeformat);\
ast_set_read_format(ast, ast->readformat); \
ast_set_write_format(ast, ast->writeformat); \
} \
@@ -434,8 +432,8 @@ static struct ast_frame *agent_read(struct ast_channel *ast)
/* Note that we don't hangup if it's not a callback because Asterisk will do it
for us when the PBX instance that called login finishes */
if (!ast_strlen_zero(p->loginchan)) {
- if (p->chan && option_debug)
- ast_log(LOG_DEBUG, "Bridge on '%s' being cleared (2)\n", p->chan->name);
+ if (p->chan)
+ ast_debug(1, "Bridge on '%s' being cleared (2)\n", p->chan->name);
status = pbx_builtin_getvar_helper(p->chan, "CHANLOCALSTATUS");
if (autologoffunavail && status && !strcasecmp(status, "CHANUNAVAIL")) {
@@ -505,8 +503,8 @@ static struct ast_frame *agent_read(struct ast_channel *ast)
if (p->chan && !p->chan->_bridge) {
if (strcasecmp(p->chan->tech->type, "Local")) {
p->chan->_bridge = ast;
- if (p->chan && option_debug)
- ast_log(LOG_DEBUG, "Bridge on '%s' being set to '%s' (3)\n", p->chan->name, p->chan->_bridge->name);
+ if (p->chan)
+ ast_debug(1, "Bridge on '%s' being set to '%s' (3)\n", p->chan->name, p->chan->_bridge->name);
}
}
ast_mutex_unlock(&p->lock);
@@ -551,10 +549,9 @@ static int agent_write(struct ast_channel *ast, struct ast_frame *f)
(f->subclass == p->chan->writeformat)) {
res = ast_write(p->chan, f);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Dropping one incompatible %s frame on '%s' to '%s'\n",
- f->frametype == AST_FRAME_VOICE ? "audio" : "video",
- ast->name, p->chan->name);
+ ast_debug(1, "Dropping one incompatible %s frame on '%s' to '%s'\n",
+ f->frametype == AST_FRAME_VOICE ? "audio" : "video",
+ ast->name, p->chan->name);
res = 0;
}
}
@@ -617,8 +614,7 @@ static int agent_call(struct ast_channel *ast, char *dest, int timeout)
p->acknowledged = 0;
if (!p->chan) {
if (p->pending) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Pretending to dial on pending agent\n");
+ ast_debug(1, "Pretending to dial on pending agent\n");
newstate = AST_STATE_DIALING;
res = 0;
} else {
@@ -643,20 +639,16 @@ static int agent_call(struct ast_channel *ast, char *dest, int timeout)
return res;
}
ast_verbose( VERBOSE_PREFIX_3 "agent_call, call to agent '%s' call on '%s'\n", p->agent, p->chan->name);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Playing beep, lang '%s'\n", p->chan->language);
+ ast_debug(3, "Playing beep, lang '%s'\n", p->chan->language);
res = ast_streamfile(p->chan, beep, p->chan->language);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Played beep, result '%d'\n", res);
+ ast_debug(3, "Played beep, result '%d'\n", res);
if (!res) {
res = ast_waitstream(p->chan, "");
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Waited for stream, result '%d'\n", res);
+ ast_debug(3, "Waited for stream, result '%d'\n", res);
}
if (!res) {
res = ast_set_read_format(p->chan, ast_best_codec(p->chan->nativeformats));
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Set read format, result '%d'\n", res);
+ ast_debug(3, "Set read format, result '%d'\n", res);
if (res)
ast_log(LOG_WARNING, "Unable to set read format to %s\n", ast_getformatname(ast_best_codec(p->chan->nativeformats)));
} else {
@@ -666,8 +658,7 @@ static int agent_call(struct ast_channel *ast, char *dest, int timeout)
if (!res) {
res = ast_set_write_format(p->chan, ast_best_codec(p->chan->nativeformats));
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Set write format, result '%d'\n", res);
+ ast_debug(3, "Set write format, result '%d'\n", res);
if (res)
ast_log(LOG_WARNING, "Unable to set write format to %s\n", ast_getformatname(ast_best_codec(p->chan->nativeformats)));
}
@@ -721,8 +712,7 @@ static int agent_hangup(struct ast_channel *ast)
* as in apps/app_chanisavail.c:chanavail_exec()
*/
- if (option_debug)
- ast_log(LOG_DEBUG, "Hangup called for state %s\n", ast_state2str(ast->_state));
+ ast_debug(1, "Hangup called for state %s\n", ast_state2str(ast->_state));
if (p->start && (ast->_state != AST_STATE_UP)) {
howlong = time(NULL) - p->start;
p->start = 0;
@@ -751,8 +741,7 @@ static int agent_hangup(struct ast_channel *ast)
ast_hangup(p->chan);
p->chan = NULL;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Hungup, howlong is %d, autologoff is %d\n", howlong, p->autologoff);
+ ast_debug(1, "Hungup, howlong is %d, autologoff is %d\n", howlong, p->autologoff);
if ((p->deferlogoff) || (howlong && p->autologoff && (howlong > p->autologoff))) {
long logintime = time(NULL) - p->loginstart;
p->loginstart = 0;
@@ -830,8 +819,8 @@ static int agent_cont_sleep( void *data )
}
ast_mutex_unlock(&p->lock);
- if (option_debug > 4 && !res)
- ast_log(LOG_DEBUG, "agent_cont_sleep() returning %d\n", res );
+ if (!res)
+ ast_debug(5, "agent_cont_sleep() returning %d\n", res );
return res;
}
@@ -889,8 +878,7 @@ static struct ast_channel *agent_bridgedchannel(struct ast_channel *chan, struct
ret = p->chan;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Asked for bridged channel on '%s'/'%s', returning '%s'\n", chan->name, bridge->name, ret ? ret->name : "<none>");
+ ast_debug(1, "Asked for bridged channel on '%s'/'%s', returning '%s'\n", chan->name, bridge->name, ret ? ret->name : "<none>");
return ret;
}
@@ -1145,8 +1133,7 @@ static int check_availability(struct agent_pvt *newlyavailable, int needlock)
struct agent_pvt *p;
int res;
- if (option_debug)
- ast_log(LOG_DEBUG, "Checking availability of '%s'\n", newlyavailable->agent);
+ ast_debug(1, "Checking availability of '%s'\n", newlyavailable->agent);
if (needlock)
AST_LIST_LOCK(&agents);
AST_LIST_TRAVERSE(&agents, p, list) {
@@ -1155,8 +1142,7 @@ static int check_availability(struct agent_pvt *newlyavailable, int needlock)
}
ast_mutex_lock(&p->lock);
if (!p->abouttograb && p->pending && ((p->group && (newlyavailable->group & p->group)) || !strcmp(p->agent, newlyavailable->agent))) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Call '%s' looks like a winner for agent '%s'\n", p->owner->name, newlyavailable->agent);
+ ast_debug(1, "Call '%s' looks like a winner for agent '%s'\n", p->owner->name, newlyavailable->agent);
/* We found a pending call, time to merge */
chan = agent_new(newlyavailable, AST_STATE_DOWN);
parent = p->owner;
@@ -1173,15 +1159,12 @@ static int check_availability(struct agent_pvt *newlyavailable, int needlock)
/* Don't do beep here */
res = 0;
} else {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Playing beep, lang '%s'\n", newlyavailable->chan->language);
+ ast_debug(3, "Playing beep, lang '%s'\n", newlyavailable->chan->language);
res = ast_streamfile(newlyavailable->chan, beep, newlyavailable->chan->language);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Played beep, result '%d'\n", res);
+ ast_debug(3, "Played beep, result '%d'\n", res);
if (!res) {
res = ast_waitstream(newlyavailable->chan, "");
- if (option_debug)
- ast_log(LOG_DEBUG, "Waited for stream, result '%d'\n", res);
+ ast_debug(1, "Waited for stream, result '%d'\n", res);
}
}
if (!res) {
@@ -1200,13 +1183,11 @@ static int check_availability(struct agent_pvt *newlyavailable, int needlock)
ast_mutex_unlock(&parent->lock);
p->abouttograb = 0;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Sneaky, parent disappeared in the mean time...\n");
+ ast_debug(1, "Sneaky, parent disappeared in the mean time...\n");
agent_cleanup(newlyavailable);
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Ugh... Agent hung up at exactly the wrong time\n");
+ ast_debug(1, "Ugh... Agent hung up at exactly the wrong time\n");
agent_cleanup(newlyavailable);
}
}
@@ -1218,8 +1199,7 @@ static int check_beep(struct agent_pvt *newlyavailable, int needlock)
struct agent_pvt *p;
int res=0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Checking beep availability of '%s'\n", newlyavailable->agent);
+ ast_debug(1, "Checking beep availability of '%s'\n", newlyavailable->agent);
if (needlock)
AST_LIST_LOCK(&agents);
AST_LIST_TRAVERSE(&agents, p, list) {
@@ -1228,8 +1208,7 @@ static int check_beep(struct agent_pvt *newlyavailable, int needlock)
}
ast_mutex_lock(&p->lock);
if (!p->abouttograb && p->pending && ((p->group && (newlyavailable->group & p->group)) || !strcmp(p->agent, newlyavailable->agent))) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Call '%s' looks like a would-be winner for agent '%s'\n", p->owner->name, newlyavailable->agent);
+ ast_debug(1, "Call '%s' looks like a would-be winner for agent '%s'\n", p->owner->name, newlyavailable->agent);
ast_mutex_unlock(&p->lock);
break;
}
@@ -1239,15 +1218,12 @@ static int check_beep(struct agent_pvt *newlyavailable, int needlock)
AST_LIST_UNLOCK(&agents);
if (p) {
ast_mutex_unlock(&newlyavailable->lock);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Playing beep, lang '%s'\n", newlyavailable->chan->language);
+ ast_debug(3, "Playing beep, lang '%s'\n", newlyavailable->chan->language);
res = ast_streamfile(newlyavailable->chan, beep, newlyavailable->chan->language);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Played beep, result '%d'\n", res);
+ ast_debug(1, "Played beep, result '%d'\n", res);
if (!res) {
res = ast_waitstream(newlyavailable->chan, "");
- if (option_debug)
- ast_log(LOG_DEBUG, "Waited for stream, result '%d'\n", res);
+ ast_debug(1, "Waited for stream, result '%d'\n", res);
}
ast_mutex_lock(&newlyavailable->lock);
}
@@ -1333,16 +1309,14 @@ static struct ast_channel *agent_request(const char *type, int format, void *dat
/* No agent available -- but we're requesting to wait for one.
Allocate a place holder */
if (hasagent) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Creating place holder for '%s'\n", s);
+ ast_debug(1, "Creating place holder for '%s'\n", s);
p = add_agent(data, 1);
p->group = groupmatch;
chan = agent_new(p, AST_STATE_DOWN);
if (!chan)
ast_log(LOG_WARNING, "Weird... Fix this to drop the unused pending agent\n");
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Not creating place holder for '%s' since nobody logged in\n", s);
+ ast_debug(1, "Not creating place holder for '%s' since nobody logged in\n", s);
}
}
*cause = hasagent ? AST_CAUSE_BUSY : AST_CAUSE_UNREGISTERED;
@@ -1936,8 +1910,7 @@ static int login_exec(struct ast_channel *chan, void *data)
ast_mutex_lock(&p->lock);
if (p->lastdisc.tv_sec) {
if (ast_tvdiff_ms(ast_tvnow(), p->lastdisc) > p->wrapuptime) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Wrapup time for %s expired!\n", p->agent);
+ ast_debug(1, "Wrapup time for %s expired!\n", p->agent);
p->lastdisc = ast_tv(0, 0);
if (p->ackcall > 1)
check_beep(p, 0);
@@ -2096,8 +2069,8 @@ static void dump_agents(void)
snprintf(buf, sizeof(buf), "%s;%s", cur_agent->loginchan, cur_agent->logincallerid);
if (ast_db_put(pa_family, cur_agent->agent, buf))
ast_log(LOG_WARNING, "failed to create persistent entry in ASTdb for %s!\n", buf);
- else if (option_debug)
- ast_log(LOG_DEBUG, "Saved Agent: %s on %s\n", cur_agent->agent, cur_agent->loginchan);
+ else
+ ast_debug(1, "Saved Agent: %s on %s\n", cur_agent->agent, cur_agent->loginchan);
} else {
/* Delete - no agent or there is an error */
ast_db_del(pa_family, cur_agent->agent);
@@ -2136,8 +2109,7 @@ static void reload_agents(void)
} else
ast_mutex_unlock(&cur_agent->lock);
if (!ast_db_get(pa_family, agent_num, agent_data, sizeof(agent_data)-1)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Reload Agent from AstDB: %s on %s\n", cur_agent->agent, agent_data);
+ ast_debug(1, "Reload Agent from AstDB: %s on %s\n", cur_agent->agent, agent_data);
parse = agent_data;
agent_chan = strsep(&parse, ";");
agent_callerid = strsep(&parse, ";");
diff --git a/channels/chan_alsa.c b/channels/chan_alsa.c
index feed79e04..de8f3ffef 100644
--- a/channels/chan_alsa.c
+++ b/channels/chan_alsa.c
@@ -365,8 +365,7 @@ static snd_pcm_t *alsa_card_init(char *dev, snd_pcm_stream_t stream)
ast_log(LOG_ERROR, "snd_pcm_open failed: %s\n", snd_strerror(err));
return NULL;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Opening device %s in %s mode\n", dev, (stream == SND_PCM_STREAM_CAPTURE) ? "read" : "write");
+ ast_debug(1, "Opening device %s in %s mode\n", dev, (stream == SND_PCM_STREAM_CAPTURE) ? "read" : "write");
}
snd_pcm_hw_params_alloca(&hwparams);
@@ -394,8 +393,7 @@ static snd_pcm_t *alsa_card_init(char *dev, snd_pcm_stream_t stream)
if (err < 0)
ast_log(LOG_ERROR, "period_size(%ld frames) is bad: %s\n", period_size, snd_strerror(err));
else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Period size is %d\n", err);
+ ast_debug(1, "Period size is %d\n", err);
}
buffer_size = 4096 * 2; /* period_size * 16; */
@@ -403,8 +401,7 @@ static snd_pcm_t *alsa_card_init(char *dev, snd_pcm_stream_t stream)
if (err < 0)
ast_log(LOG_WARNING, "Problem setting buffer size of %ld: %s\n", buffer_size, snd_strerror(err));
else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Buffer size is set to %d frames\n", err);
+ ast_debug(1, "Buffer size is set to %d frames\n", err);
}
#if 0
@@ -465,13 +462,11 @@ static snd_pcm_t *alsa_card_init(char *dev, snd_pcm_stream_t stream)
if (err <= 0)
ast_log(LOG_ERROR, "Unable to get a poll descriptors count, error is %s\n", snd_strerror(err));
if (err != 1) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Can't handle more than one device\n");
+ ast_debug(1, "Can't handle more than one device\n");
}
snd_pcm_poll_descriptors(handle, &pfd, err);
- if (option_debug)
- ast_log(LOG_DEBUG, "Acquired fd %d from the poll descriptor\n", pfd.fd);
+ ast_debug(1, "Acquired fd %d from the poll descriptor\n", pfd.fd);
if (stream == SND_PCM_STREAM_CAPTURE)
readdev = pfd.fd;
@@ -634,8 +629,7 @@ static int alsa_write(struct ast_channel *chan, struct ast_frame *f)
res = snd_pcm_writei(alsa.ocard, sizbuf, len / 2);
if (res == -EPIPE) {
#if DEBUG
- if (option_debug)
- ast_log(LOG_DEBUG, "XRUN write\n");
+ ast_debug(1, "XRUN write\n");
#endif
snd_pcm_prepare(alsa.ocard);
res = snd_pcm_writei(alsa.ocard, sizbuf, len / 2);
diff --git a/channels/chan_features.c b/channels/chan_features.c
index 4b65180a8..3d199c36f 100644
--- a/channels/chan_features.c
+++ b/channels/chan_features.c
@@ -209,8 +209,7 @@ static void swap_subs(struct feature_pvt *p, int a, int b)
int tinthreeway;
struct ast_channel *towner;
- if (option_debug)
- ast_log(LOG_DEBUG, "Swapping %d and %d\n", a, b);
+ ast_debug(1, "Swapping %d and %d\n", a, b);
towner = p->subs[a].owner;
tinthreeway = p->subs[a].inthreeway;
diff --git a/channels/chan_gtalk.c b/channels/chan_gtalk.c
index 1402a5a25..537bc00a0 100644
--- a/channels/chan_gtalk.c
+++ b/channels/chan_gtalk.c
@@ -515,8 +515,7 @@ static int gtalk_answer(struct ast_channel *ast)
struct gtalk_pvt *p = ast->tech_pvt;
int res = 0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Answer!\n");
+ ast_debug(1, "Answer!\n");
ast_mutex_lock(&p->lock);
gtalk_invite(p, p->them, p->us,p->sid, 0);
ast_mutex_unlock(&p->lock);
@@ -603,8 +602,7 @@ static int gtalk_is_answered(struct gtalk *client, ikspak *pak)
{
struct gtalk_pvt *tmp;
char *from;
- if (option_debug)
- ast_log(LOG_DEBUG, "The client is %s\n", client->name);
+ ast_debug(1, "The client is %s\n", client->name);
/* Make sure our new call doesn't exist yet */
for (tmp = client->p; tmp; tmp = tmp->next) {
if (iks_find_with_attrib(pak->x, "session", "id", tmp->sid))
@@ -682,8 +680,7 @@ static int gtalk_hangup_farend(struct gtalk *client, ikspak *pak)
struct gtalk_pvt *tmp;
char *from;
- if (option_debug)
- ast_log(LOG_DEBUG, "The client is %s\n", client->name);
+ ast_debug(1, "The client is %s\n", client->name);
/* Make sure our new call doesn't exist yet */
for (tmp = client->p; tmp; tmp = tmp->next) {
if (iks_find_with_attrib(pak->x, "session", "id", tmp->sid))
@@ -839,8 +836,7 @@ static struct gtalk_pvt *gtalk_alloc(struct gtalk *client, const char *us, const
char idroster[200];
char *data, *exten = NULL;
- if (option_debug)
- ast_log(LOG_DEBUG, "The client is %s for alloc\n", client->name);
+ ast_debug(1, "The client is %s for alloc\n", client->name);
if (!sid && !strchr(them, '/')) { /* I started call! */
if (!strcasecmp(client->name, "guest")) {
buddy = ASTOBJ_CONTAINER_FIND(&client->connection->buddies, them);
@@ -1173,9 +1169,9 @@ static int gtalk_update_stun(struct gtalk *client, struct gtalk_pvt *p)
else
ast_rtp_stun_request(p->rtp, &sin, username);
- if (aux.sin_addr.s_addr && option_debug > 3) {
- ast_log(LOG_DEBUG, "Receiving RTP traffic from IP %s, matches with remote candidate's IP %s\n", ast_inet_ntoa(aux.sin_addr), tmp->ip);
- ast_log(LOG_DEBUG, "Sending STUN request to %s\n", tmp->ip);
+ if (aux.sin_addr.s_addr) {
+ ast_debug(4, "Receiving RTP traffic from IP %s, matches with remote candidate's IP %s\n", ast_inet_ntoa(aux.sin_addr), tmp->ip);
+ ast_debug(4, "Sending STUN request to %s\n", tmp->ip);
}
tmp = tmp->next;
@@ -1280,8 +1276,7 @@ static struct ast_frame *gtalk_rtp_read(struct ast_channel *ast, struct gtalk_pv
/* We already hold the channel lock */
if (f->frametype == AST_FRAME_VOICE) {
if (f->subclass != (p->owner->nativeformats & AST_FORMAT_AUDIO_MASK)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
+ ast_debug(1, "Oooh, format changed to %d\n", f->subclass);
p->owner->nativeformats =
(p->owner->nativeformats & AST_FORMAT_VIDEO_MASK) | f->subclass;
ast_set_read_format(p->owner, p->owner->readformat);
@@ -1290,8 +1285,7 @@ static struct ast_frame *gtalk_rtp_read(struct ast_channel *ast, struct gtalk_pv
/* if ((ast_test_flag(p, SIP_DTMF) == SIP_DTMF_INBAND) && p->vad) {
f = ast_dsp_process(p->owner, p->vad, f);
if (option_debug && f && (f->frametype == AST_FRAME_DTMF))
- if (option_debug)
- ast_log(LOG_DEBUG, "* Detected inband DTMF '%c'\n", f->subclass);
+ ast_debug(1, "* Detected inband DTMF '%c'\n", f->subclass);
} */
}
}
@@ -1577,11 +1571,9 @@ static int gtalk_parser(void *data, ikspak *pak)
/* New call */
gtalk_newcall(client, pak);
} else if (iks_find_with_attrib(pak->x, "session", "type", "candidates") || iks_find_with_attrib(pak->x, "session", "type", "transport-info")) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "About to add candidate!\n");
+ ast_debug(3, "About to add candidate!\n");
gtalk_add_candidate(client, pak);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Candidate Added!\n");
+ ast_debug(3, "Candidate Added!\n");
} else if (iks_find_with_attrib(pak->x, "session", "type", "accept") || iks_find_with_attrib(pak->x, "session", "type", "transport-accept")) {
gtalk_is_answered(client, pak);
} else if (iks_find_with_attrib(pak->x, "session", "type", "content-info")) {
diff --git a/channels/chan_h323.c b/channels/chan_h323.c
index 0c0d937cb..85c912b32 100644
--- a/channels/chan_h323.c
+++ b/channels/chan_h323.c
@@ -287,14 +287,14 @@ static const char* redirectingreason2str(int redirectingreason)
static void oh323_destroy_alias(struct oh323_alias *alias)
{
if (h323debug)
- ast_log(LOG_DEBUG, "Destroying alias '%s'\n", alias->name);
+ ast_debug(1, "Destroying alias '%s'\n", alias->name);
ast_free(alias);
}
static void oh323_destroy_user(struct oh323_user *user)
{
if (h323debug)
- ast_log(LOG_DEBUG, "Destroying user '%s'\n", user->name);
+ ast_debug(1, "Destroying user '%s'\n", user->name);
ast_free_ha(user->ha);
ast_free(user);
}
@@ -302,7 +302,7 @@ static void oh323_destroy_user(struct oh323_user *user)
static void oh323_destroy_peer(struct oh323_peer *peer)
{
if (h323debug)
- ast_log(LOG_DEBUG, "Destroying peer '%s'\n", peer->name);
+ ast_debug(1, "Destroying peer '%s'\n", peer->name);
ast_free_ha(peer->ha);
ast_free(peer);
}
@@ -343,14 +343,14 @@ static void __oh323_update_info(struct ast_channel *c, struct oh323_pvt *pvt)
{
if (c->nativeformats != pvt->nativeformats) {
if (h323debug)
- ast_log(LOG_DEBUG, "Preparing %s for new native format\n", c->name);
+ ast_debug(1, "Preparing %s for new native format\n", c->name);
c->nativeformats = pvt->nativeformats;
ast_set_read_format(c, c->readformat);
ast_set_write_format(c, c->writeformat);
}
if (pvt->needhangup) {
if (h323debug)
- ast_log(LOG_DEBUG, "Process pending hangup for %s\n", c->name);
+ ast_debug(1, "Process pending hangup for %s\n", c->name);
c->_softhangup |= AST_SOFTHANGUP_DEV;
c->hangupcause = pvt->hangupcause;
ast_queue_hangup(c);
@@ -475,7 +475,7 @@ static void __oh323_destroy(struct oh323_pvt *pvt)
if (pvt->owner) {
ast_channel_lock(pvt->owner);
if (h323debug)
- ast_log(LOG_DEBUG, "Detaching from %s\n", pvt->owner->name);
+ ast_debug(1, "Detaching from %s\n", pvt->owner->name);
pvt->owner->tech_pvt = NULL;
ast_channel_unlock(pvt->owner);
}
@@ -503,7 +503,7 @@ static void __oh323_destroy(struct oh323_pvt *pvt)
static void oh323_destroy(struct oh323_pvt *pvt)
{
if (h323debug) {
- ast_log(LOG_DEBUG, "Destroying channel %s\n", (pvt->owner ? pvt->owner->name : "<unknown>"));
+ ast_debug(1, "Destroying channel %s\n", (pvt->owner ? pvt->owner->name : "<unknown>"));
}
ast_mutex_lock(&iflock);
ast_mutex_lock(&pvt->lock);
@@ -599,7 +599,7 @@ static int oh323_call(struct ast_channel *c, char *dest, int timeout)
char called_addr[1024];
if (h323debug) {
- ast_log(LOG_DEBUG, "Calling to %s on %s\n", dest, c->name);
+ ast_debug(1, "Calling to %s on %s\n", dest, c->name);
}
if ((c->_state != AST_STATE_DOWN) && (c->_state != AST_STATE_RESERVED)) {
ast_log(LOG_WARNING, "Line is already in use (%s)\n", c->name);
@@ -659,7 +659,7 @@ static int oh323_call(struct ast_channel *c, char *dest, int timeout)
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Requested transfer capability: 0x%.2x - %s\n", c->transfercapability, ast_transfercapability2str(c->transfercapability));
if (h323debug)
- ast_log(LOG_DEBUG, "Placing outgoing call to %s, %d/%d\n", called_addr, pvt->options.dtmfcodec[0], pvt->options.dtmfcodec[1]);
+ ast_debug(1, "Placing outgoing call to %s, %d/%d\n", called_addr, pvt->options.dtmfcodec[0], pvt->options.dtmfcodec[1]);
ast_mutex_unlock(&pvt->lock);
res = h323_make_call(called_addr, &(pvt->cd), &pvt->options);
if (res) {
@@ -677,7 +677,7 @@ static int oh323_answer(struct ast_channel *c)
char *token;
if (h323debug)
- ast_log(LOG_DEBUG, "Answering on %s\n", c->name);
+ ast_debug(1, "Answering on %s\n", c->name);
ast_mutex_lock(&pvt->lock);
token = pvt->cd.call_token ? strdup(pvt->cd.call_token) : NULL;
@@ -701,7 +701,7 @@ static int oh323_hangup(struct ast_channel *c)
if (h323debug)
- ast_log(LOG_DEBUG, "Hanging up and scheduling destroy of call %s\n", c->name);
+ ast_debug(1, "Hanging up and scheduling destroy of call %s\n", c->name);
if (!c->tech_pvt) {
ast_log(LOG_WARNING, "Asked to hangup channel not connected\n");
@@ -785,7 +785,7 @@ static struct ast_frame *oh323_rtp_read(struct oh323_pvt *pvt)
return &ast_null_frame;
}
if (h323debug)
- ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
+ ast_debug(1, "Oooh, format changed to %d\n", f->subclass);
pvt->owner->nativeformats = f->subclass;
pvt->nativeformats = f->subclass;
ast_set_read_format(pvt->owner, pvt->owner->readformat);
@@ -886,7 +886,7 @@ static int oh323_indicate(struct ast_channel *c, int condition, const void *data
ast_mutex_unlock(&pvt->lock);
if (h323debug)
- ast_log(LOG_DEBUG, "OH323: Indicating %d on %s (%s)\n", condition, token, c->name);
+ ast_debug(1, "OH323: Indicating %d on %s (%s)\n", condition, token, c->name);
switch(condition) {
case AST_CONTROL_RINGING:
@@ -937,7 +937,7 @@ static int oh323_indicate(struct ast_channel *c, int condition, const void *data
}
if (h323debug)
- ast_log(LOG_DEBUG, "OH323: Indicated %d on %s, res=%d\n", condition, token, res);
+ ast_debug(1, "OH323: Indicated %d on %s, res=%d\n", condition, token, res);
if (token)
ast_free(token);
oh323_update_info(c);
@@ -978,12 +978,12 @@ static int __oh323_rtp_create(struct oh323_pvt *pvt)
return -1;
}
if (h323debug)
- ast_log(LOG_DEBUG, "Created RTP channel\n");
+ ast_debug(1, "Created RTP channel\n");
ast_rtp_setqos(pvt->rtp, tos, cos);
if (h323debug)
- ast_log(LOG_DEBUG, "Setting NAT on RTP to %d\n", pvt->options.nat);
+ ast_debug(1, "Setting NAT on RTP to %d\n", pvt->options.nat);
ast_rtp_setnat(pvt->rtp, pvt->options.nat);
if (pvt->dtmf_pt[0] > 0)
@@ -1617,7 +1617,7 @@ static struct oh323_user *find_user(const call_details_t *cd, int realtime)
u = realtime_user(cd);
if (!u && h323debug)
- ast_log(LOG_DEBUG, "Could not find user by name %s or address %s\n", cd->call_source_aliases, cd->sourceIp);
+ ast_debug(1, "Could not find user by name %s or address %s\n", cd->call_source_aliases, cd->sourceIp);
return u;
}
@@ -1647,7 +1647,7 @@ static struct oh323_peer *find_peer(const char *peer, struct sockaddr_in *sin, i
p = realtime_peer(peer, sin);
if (!p && h323debug)
- ast_log(LOG_DEBUG, "Could not find peer by name %s or address %s\n", (peer ? peer : "<NONE>"), (sin ? ast_inet_ntoa(sin->sin_addr) : "<NONE>"));
+ ast_debug(1, "Could not find peer by name %s or address %s\n", (peer ? peer : "<NONE>"), (sin ? ast_inet_ntoa(sin->sin_addr) : "<NONE>"));
return p;
}
@@ -1735,7 +1735,7 @@ static struct ast_channel *oh323_request(const char *type, int format, void *dat
char tmp[256], tmp1[256];
if (h323debug)
- ast_log(LOG_DEBUG, "type=%s, format=%d, data=%s.\n", type, format, (char *)data);
+ ast_debug(1, "type=%s, format=%d, data=%s.\n", type, format, (char *)data);
pvt = oh323_alloc(0);
if (!pvt) {
@@ -1771,7 +1771,7 @@ static struct ast_channel *oh323_request(const char *type, int format, void *dat
ast_copy_string(pvt->exten, ext, sizeof(pvt->exten));
}
if (h323debug)
- ast_log(LOG_DEBUG, "Extension: %s Host: %s\n", pvt->exten, host);
+ ast_debug(1, "Extension: %s Host: %s\n", pvt->exten, host);
if (gatekeeper_disable) {
if (create_addr(pvt, host)) {
@@ -1933,7 +1933,7 @@ static struct rtp_info *external_rtp_create(unsigned call_reference, const char
ast_copy_string(info->addr, ast_inet_ntoa(us.sin_addr), sizeof(info->addr));
info->port = ntohs(us.sin_port);
if (h323debug)
- ast_log(LOG_DEBUG, "Sending RTP 'US' %s:%d\n", info->addr, info->port);
+ ast_debug(1, "Sending RTP 'US' %s:%d\n", info->addr, info->port);
return info;
}
@@ -1960,7 +1960,7 @@ static void setup_rtp_connection(unsigned call_reference, const char *remoteIp,
enum { NEED_NONE, NEED_HOLD, NEED_UNHOLD } rtp_change = NEED_NONE;
if (h323debug)
- ast_log(LOG_DEBUG, "Setting up RTP connection for %s\n", token);
+ ast_debug(1, "Setting up RTP connection for %s\n", token);
/* Find the call or allocate a private structure if call not found */
pvt = find_call_locked(call_reference, token);
@@ -2004,7 +2004,7 @@ static void setup_rtp_connection(unsigned call_reference, const char *remoteIp,
if (pt != 128 && pvt->rtp) { /* Payload type is invalid, so try to use previously decided */
rtptype = ast_rtp_lookup_pt(pvt->rtp, pt);
if (h323debug)
- ast_log(LOG_DEBUG, "Native format is set to %d from %d by RTP payload type %d\n", rtptype.code, pvt->nativeformats, pt);
+ ast_debug(1, "Native format is set to %d from %d by RTP payload type %d\n", rtptype.code, pvt->nativeformats, pt);
if (pvt->nativeformats != rtptype.code) {
pvt->nativeformats = rtptype.code;
nativeformats_changed = 1;
@@ -2018,7 +2018,7 @@ static void setup_rtp_connection(unsigned call_reference, const char *remoteIp,
/* Re-build translation path only if native format(s) has been changed */
if (pvt->owner->nativeformats != pvt->nativeformats) {
if (h323debug)
- ast_log(LOG_DEBUG, "Native format changed to %d from %d, read format is %d, write format is %d\n", pvt->nativeformats, pvt->owner->nativeformats, pvt->owner->readformat, pvt->owner->writeformat);
+ ast_debug(1, "Native format changed to %d from %d, read format is %d, write format is %d\n", pvt->nativeformats, pvt->owner->nativeformats, pvt->owner->readformat, pvt->owner->writeformat);
pvt->owner->nativeformats = pvt->nativeformats;
ast_set_read_format(pvt->owner, pvt->owner->readformat);
ast_set_write_format(pvt->owner, pvt->owner->writeformat);
@@ -2045,13 +2045,13 @@ static void setup_rtp_connection(unsigned call_reference, const char *remoteIp,
else if (rtp_change == NEED_UNHOLD)
pvt->newcontrol = AST_CONTROL_UNHOLD;
if (h323debug)
- ast_log(LOG_DEBUG, "RTP connection preparation for %s is pending...\n", token);
+ ast_debug(1, "RTP connection preparation for %s is pending...\n", token);
}
}
ast_mutex_unlock(&pvt->lock);
if (h323debug)
- ast_log(LOG_DEBUG, "RTP connection prepared for %s\n", token);
+ ast_debug(1, "RTP connection prepared for %s\n", token);
return;
}
@@ -2065,7 +2065,7 @@ static void connection_made(unsigned call_reference, const char *token)
struct oh323_pvt *pvt;
if (h323debug)
- ast_log(LOG_DEBUG, "Call %s answered\n", token);
+ ast_debug(1, "Call %s answered\n", token);
pvt = find_call_locked(call_reference, token);
if (!pvt) {
@@ -2092,7 +2092,7 @@ static int progress(unsigned call_reference, const char *token, int inband)
struct oh323_pvt *pvt;
if (h323debug)
- ast_log(LOG_DEBUG, "Received ALERT/PROGRESS message for %s tones\n", (inband ? "inband" : "self-generated"));
+ ast_debug(1, "Received ALERT/PROGRESS message for %s tones\n", (inband ? "inband" : "self-generated"));
pvt = find_call_locked(call_reference, token);
if (!pvt) {
@@ -2122,7 +2122,7 @@ static call_options_t *setup_incoming_call(call_details_t *cd)
struct oh323_alias *alias = NULL;
if (h323debug)
- ast_log(LOG_DEBUG, "Setting up incoming call for %s\n", cd->call_token);
+ ast_debug(1, "Setting up incoming call for %s\n", cd->call_token);
/* allocate the call*/
pvt = oh323_alloc(cd->call_reference);
@@ -2187,7 +2187,7 @@ static call_options_t *setup_incoming_call(call_details_t *cd)
ast_copy_string(pvt->exten, cd->call_dest_alias, sizeof(pvt->exten));
}
if (h323debug)
- ast_log(LOG_DEBUG, "Sending %s@%s to context [%s] extension %s\n", cd->call_source_aliases, cd->sourceIp, pvt->context, pvt->exten);
+ ast_debug(1, "Sending %s@%s to context [%s] extension %s\n", cd->call_source_aliases, cd->sourceIp, pvt->context, pvt->exten);
} else {
if (user->host) {
if (strcasecmp(cd->sourceIp, ast_inet_ntoa(user->addr.sin_addr))) {
@@ -2243,7 +2243,7 @@ static int answer_call(unsigned call_reference, const char *token)
char tmp_exten[sizeof(pvt->exten)];
if (h323debug)
- ast_log(LOG_DEBUG, "Preparing Asterisk to answer for %s\n", token);
+ ast_debug(1, "Preparing Asterisk to answer for %s\n", token);
/* Find the call or allocate a private structure if call not found */
pvt = find_call_locked(call_reference, token);
@@ -2293,7 +2293,7 @@ static int answer_call(unsigned call_reference, const char *token)
return 0;
} else if ((try_exten != ext_original) && (strcmp(pvt->exten, tmp_exten) != 0)) {
if (h323debug)
- ast_log(LOG_DEBUG, "Going to extension %s@%s because %s@%s isn't exists\n", tmp_exten, pvt->context, pvt->exten, pvt->context);
+ ast_debug(1, "Going to extension %s@%s because %s@%s isn't exists\n", tmp_exten, pvt->context, pvt->exten, pvt->context);
ast_copy_string(pvt->exten, tmp_exten, sizeof(pvt->exten));
}
@@ -2331,7 +2331,7 @@ static void chan_ringing(unsigned call_reference, const char *token)
struct oh323_pvt *pvt;
if (h323debug)
- ast_log(LOG_DEBUG, "Ringing on %s\n", token);
+ ast_debug(1, "Ringing on %s\n", token);
pvt = find_call_locked(call_reference, token);
if (!pvt) {
@@ -2357,13 +2357,13 @@ static void cleanup_connection(unsigned call_reference, const char *call_token)
struct oh323_pvt *pvt;
if (h323debug)
- ast_log(LOG_DEBUG, "Cleaning connection to %s\n", call_token);
+ ast_debug(1, "Cleaning connection to %s\n", call_token);
while (1) {
pvt = find_call_locked(call_reference, call_token);
if (!pvt) {
if (h323debug)
- ast_log(LOG_DEBUG, "No connection for %s\n", call_token);
+ ast_debug(1, "No connection for %s\n", call_token);
return;
}
if (!pvt->owner || !ast_channel_trylock(pvt->owner))
@@ -2398,7 +2398,7 @@ static void cleanup_connection(unsigned call_reference, const char *call_token)
}
ast_mutex_unlock(&pvt->lock);
if (h323debug)
- ast_log(LOG_DEBUG, "Connection to %s cleaned\n", call_token);
+ ast_debug(1, "Connection to %s cleaned\n", call_token);
return;
}
@@ -2406,15 +2406,13 @@ static void hangup_connection(unsigned int call_reference, const char *token, in
{
struct oh323_pvt *pvt;
- if (h323debug) {
- ast_log(LOG_DEBUG, "Hanging up connection to %s with cause %d\n", token, cause);
- }
+ if (h323debug)
+ ast_debug(1, "Hanging up connection to %s with cause %d\n", token, cause);
pvt = find_call_locked(call_reference, token);
if (!pvt) {
- if (h323debug) {
- ast_log(LOG_DEBUG, "Connection to %s already cleared\n", token);
- }
+ if (h323debug)
+ ast_debug(1, "Connection to %s already cleared\n", token);
return;
}
if (pvt->owner && !ast_channel_trylock(pvt->owner)) {
@@ -2427,7 +2425,7 @@ static void hangup_connection(unsigned int call_reference, const char *token, in
pvt->needhangup = 1;
pvt->hangupcause = cause;
if (h323debug)
- ast_log(LOG_DEBUG, "Hangup for %s is pending\n", token);
+ ast_debug(1, "Hangup for %s is pending\n", token);
}
ast_mutex_unlock(&pvt->lock);
}
@@ -2437,7 +2435,7 @@ static void set_dtmf_payload(unsigned call_reference, const char *token, int pay
struct oh323_pvt *pvt;
if (h323debug)
- ast_log(LOG_DEBUG, "Setting %s DTMF payload to %d on %s\n", (is_cisco ? "Cisco" : "RFC2833"), payload, token);
+ ast_debug(1, "Setting %s DTMF payload to %d on %s\n", (is_cisco ? "Cisco" : "RFC2833"), payload, token);
pvt = find_call_locked(call_reference, token);
if (!pvt) {
@@ -2449,7 +2447,7 @@ static void set_dtmf_payload(unsigned call_reference, const char *token, int pay
pvt->dtmf_pt[is_cisco ? 1 : 0] = payload;
ast_mutex_unlock(&pvt->lock);
if (h323debug)
- ast_log(LOG_DEBUG, "DTMF payload on %s set to %d\n", token, payload);
+ ast_debug(1, "DTMF payload on %s set to %d\n", token, payload);
}
static void set_peer_capabilities(unsigned call_reference, const char *token, int capabilities, struct ast_codec_pref *prefs)
@@ -2457,7 +2455,7 @@ static void set_peer_capabilities(unsigned call_reference, const char *token, in
struct oh323_pvt *pvt;
if (h323debug)
- ast_log(LOG_DEBUG, "Got remote capabilities from connection %s\n", token);
+ ast_debug(1, "Got remote capabilities from connection %s\n", token);
pvt = find_call_locked(call_reference, token);
if (!pvt)
@@ -2471,7 +2469,7 @@ static void set_peer_capabilities(unsigned call_reference, const char *token, in
for (i = 0; i < 32; ++i) {
if (!prefs->order[i])
break;
- ast_log(LOG_DEBUG, "prefs[%d]=%s:%d\n", i, (prefs->order[i] ? ast_getformatname(1 << (prefs->order[i]-1)) : "<none>"), prefs->framing[i]);
+ ast_debug(1, "prefs[%d]=%s:%d\n", i, (prefs->order[i] ? ast_getformatname(1 << (prefs->order[i]-1)) : "<none>"), prefs->framing[i]);
}
}
if (pvt->rtp)
@@ -2487,7 +2485,7 @@ static void set_local_capabilities(unsigned call_reference, const char *token)
struct ast_codec_pref prefs;
if (h323debug)
- ast_log(LOG_DEBUG, "Setting capabilities for connection %s\n", token);
+ ast_debug(1, "Setting capabilities for connection %s\n", token);
pvt = find_call_locked(call_reference, token);
if (!pvt)
@@ -2500,7 +2498,7 @@ static void set_local_capabilities(unsigned call_reference, const char *token)
h323_set_capabilities(token, capability, dtmfmode, &prefs, pref_codec);
if (h323debug)
- ast_log(LOG_DEBUG, "Capabilities for connection %s is set\n", token);
+ ast_debug(1, "Capabilities for connection %s is set\n", token);
}
static void remote_hold(unsigned call_reference, const char *token, int is_hold)
@@ -2508,7 +2506,7 @@ static void remote_hold(unsigned call_reference, const char *token, int is_hold)
struct oh323_pvt *pvt;
if (h323debug)
- ast_log(LOG_DEBUG, "Setting %shold status for connection %s\n", (is_hold ? "" : "un"), token);
+ ast_debug(1, "Setting %shold status for connection %s\n", (is_hold ? "" : "un"), token);
pvt = find_call_locked(call_reference, token);
if (!pvt)
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 030fd8257..c89ead79f 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -1240,8 +1240,8 @@ static void update_max_trunk(void)
max = x + 1;
}
maxtrunkcall = max;
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "New max trunk callno is %d\n", max);
+ if (iaxdebug)
+ ast_debug(1, "New max trunk callno is %d\n", max);
}
static void update_max_nontrunk(void)
@@ -1254,8 +1254,8 @@ static void update_max_nontrunk(void)
max = x + 1;
}
maxnontrunkcall = max;
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "New max nontrunk callno is %d\n", max);
+ if (iaxdebug)
+ ast_debug(1, "New max nontrunk callno is %d\n", max);
}
static int make_trunk(unsigned short callno, int locked)
@@ -1298,8 +1298,7 @@ static int make_trunk(unsigned short callno, int locked)
ast_log(LOG_WARNING, "Unable to trunk call: Insufficient space\n");
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Made call %d into trunk call %d\n", callno, x);
+ ast_debug(1, "Made call %d into trunk call %d\n", callno, x);
/* We move this call from a non-trunked to a trunked call */
update_max_trunk();
update_max_nontrunk();
@@ -1373,8 +1372,8 @@ static int find_callno(unsigned short callno, unsigned short dcallno, struct soc
iaxs[x] = new_iax(sin, lockpeer, host);
update_max_nontrunk();
if (iaxs[x]) {
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Creating new call structure %d\n", x);
+ if (iaxdebug)
+ ast_debug(1, "Creating new call structure %d\n", x);
iaxs[x]->sockfd = sockfd;
iaxs[x]->addr.sin_port = sin->sin_port;
iaxs[x]->addr.sin_family = sin->sin_family;
@@ -1753,8 +1752,7 @@ static int transmit_trunk(struct iax_frame *f, struct sockaddr_in *sin, int sock
res = sendto(sockfd, f->data, f->datalen, 0,(struct sockaddr *)sin,
sizeof(*sin));
if (res < 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Received error: %s\n", strerror(errno));
+ ast_debug(1, "Received error: %s\n", strerror(errno));
handle_error();
} else
res = 0;
@@ -1771,8 +1769,8 @@ static int send_packet(struct iax_frame *f)
return -1;
/* Called with iaxsl held */
- if (option_debug > 2 && iaxdebug)
- ast_log(LOG_DEBUG, "Sending %d on %d/%d to %s:%d\n", f->ts, callno, iaxs[callno]->peercallno, ast_inet_ntoa(iaxs[callno]->addr.sin_addr), ntohs(iaxs[callno]->addr.sin_port));
+ if (iaxdebug)
+ ast_debug(3, "Sending %d on %d/%d to %s:%d\n", f->ts, callno, iaxs[callno]->peercallno, ast_inet_ntoa(iaxs[callno]->addr.sin_addr), ntohs(iaxs[callno]->addr.sin_port));
if (f->transfer) {
if (iaxdebug)
iax_showframe(f, NULL, 0, &iaxs[callno]->transfer, f->datalen - sizeof(struct ast_iax2_full_hdr));
@@ -1785,8 +1783,8 @@ static int send_packet(struct iax_frame *f)
sizeof(iaxs[callno]->addr));
}
if (res < 0) {
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Received error: %s\n", strerror(errno));
+ if (iaxdebug)
+ ast_debug(1, "Received error: %s\n", strerror(errno));
handle_error();
} else
res = 0;
@@ -2330,8 +2328,8 @@ static void unwrap_timestamp(struct iax_frame *fr)
gotten the update from the main packet. We'll just pretend that we did, and
update the timestamp appropriately. */
fr->ts = ( (iaxs[fr->callno]->last & 0xFFFF0000) + 0x10000) | (fr->ts & 0xFFFF);
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "schedule_delivery: pushed forward timestamp\n");
+ if (iaxdebug)
+ ast_debug(1, "schedule_delivery: pushed forward timestamp\n");
}
if (x > 50000) {
/* Sudden apparent big jump forwards in timestamp:
@@ -2339,8 +2337,8 @@ static void unwrap_timestamp(struct iax_frame *fr)
top-16-bit timestamp that has turned up out of order.
Adjust the timestamp appropriately. */
fr->ts = ( (iaxs[fr->callno]->last & 0xFFFF0000) - 0x10000) | (fr->ts & 0xFFFF);
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "schedule_delivery: pushed back timestamp\n");
+ if (iaxdebug)
+ ast_debug(1, "schedule_delivery: pushed back timestamp\n");
}
}
}
@@ -2474,8 +2472,7 @@ static int schedule_delivery(struct iax_frame *fr, int updatehistory, int fromtr
fr->af.delivery = ast_tvadd(iaxs[fr->callno]->rxcore, ast_samp2tv(fr->ts, 1000));
else {
#if 0
- if (option_debug)
- ast_log(LOG_DEBUG, "schedule_delivery: set delivery to 0 as we don't have an rxcore yet, or frame is from trunk.\n");
+ ast_debug(1, "schedule_delivery: set delivery to 0 as we don't have an rxcore yet, or frame is from trunk.\n");
#endif
fr->af.delivery = ast_tv(0,0);
}
@@ -2682,14 +2679,12 @@ static struct iax2_peer *realtime_peer(const char *peername, struct sockaddr_in
if ((nowtime - regseconds) > IAX_DEFAULT_REG_EXPIRE) {
memset(&peer->addr, 0, sizeof(peer->addr));
realtime_update_peer(peer->name, &peer->addr, 0);
- if (option_debug)
- ast_log(LOG_DEBUG, "realtime_peer: Bah, '%s' is expired (%d/%d/%d)!\n",
- peername, (int)(nowtime - regseconds), (int)regseconds, (int)nowtime);
+ ast_debug(1, "realtime_peer: Bah, '%s' is expired (%d/%d/%d)!\n",
+ peername, (int)(nowtime - regseconds), (int)regseconds, (int)nowtime);
}
else {
- if (option_debug)
- ast_log(LOG_DEBUG, "realtime_peer: Registration for '%s' still active (%d/%d/%d)!\n",
- peername, (int)(nowtime - regseconds), (int)regseconds, (int)nowtime);
+ ast_debug(1, "realtime_peer: Registration for '%s' still active (%d/%d/%d)!\n",
+ peername, (int)(nowtime - regseconds), (int)regseconds, (int)nowtime);
}
}
@@ -3111,8 +3106,8 @@ static int iax2_call(struct ast_channel *c, char *dest, int timeout)
}
} else
ast_log(LOG_WARNING, "OSP token is too long\n");
- } else if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "OSP token is undefined\n");
+ } else if (iaxdebug)
+ ast_debug(1, "OSP token is undefined\n");
/* send the command using the appropriate socket for this peer */
iaxs[callno]->sockfd = cai.sockfd;
@@ -3147,8 +3142,7 @@ static int iax2_hangup(struct ast_channel *c)
memset(&ied, 0, sizeof(ied));
ast_mutex_lock(&iaxsl[callno]);
if (callno && iaxs[callno]) {
- if (option_debug)
- ast_log(LOG_DEBUG, "We're hanging up %s now...\n", c->name);
+ ast_debug(1, "We're hanging up %s now...\n", c->name);
alreadygone = ast_test_flag(iaxs[callno], IAX_ALREADYGONE);
/* Send the hangup unless we have had a transmission error or are already gone */
iax_ie_append_byte(&ied, IAX_IE_CAUSECODE, (unsigned char)c->hangupcause);
@@ -3158,8 +3152,7 @@ static int iax2_hangup(struct ast_channel *c)
iax2_predestroy(callno);
/* If we were already gone to begin with, destroy us now */
if (alreadygone) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Really destroying %s now...\n", c->name);
+ ast_debug(1, "Really destroying %s now...\n", c->name);
iax2_destroy(callno);
}
}
@@ -3397,8 +3390,7 @@ static enum ast_bridge_result iax2_bridge(struct ast_channel *c0, struct ast_cha
static int iax2_answer(struct ast_channel *c)
{
unsigned short callno = PTR_TO_CALLNO(c->tech_pvt);
- if (option_debug)
- ast_log(LOG_DEBUG, "Answering IAX2 call\n");
+ ast_debug(1, "Answering IAX2 call\n");
ast_mutex_lock(&iaxsl[callno]);
if (iaxs[callno])
iax2_ami_channelupdate(iaxs[callno]);
@@ -3412,8 +3404,8 @@ static int iax2_indicate(struct ast_channel *c, int condition, const void *data,
struct chan_iax2_pvt *pvt;
int res = 0;
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Indicating condition %d\n", condition);
+ if (iaxdebug)
+ ast_debug(1, "Indicating condition %d\n", condition);
ast_mutex_lock(&iaxsl[callno]);
pvt = iaxs[callno];
@@ -3453,8 +3445,7 @@ static int iax2_transfer(struct ast_channel *c, const char *dest)
iax_ie_append_str(&ied, IAX_IE_CALLED_NUMBER, tmp);
if (context)
iax_ie_append_str(&ied, IAX_IE_CALLED_CONTEXT, context);
- if (option_debug)
- ast_log(LOG_DEBUG, "Transferring '%s' to '%s'\n", c->name, dest);
+ ast_debug(1, "Transferring '%s' to '%s'\n", c->name, dest);
return send_command_locked(callno, AST_FRAME_IAX, IAX_COMMAND_TRANSFER, 0, ied.buf, ied.pos, -1);
}
@@ -3628,8 +3619,8 @@ static unsigned int calc_timestamp(struct chan_iax2_pvt *p, unsigned int ts, str
/* If we have a time that the frame arrived, always use it to make our timestamp */
if (delivery && !ast_tvzero(*delivery)) {
ms = ast_tvdiff_ms(*delivery, p->offset);
- if (option_debug > 2 && iaxdebug)
- ast_log(LOG_DEBUG, "calc_timestamp: call %d/%d: Timestamp slaved to delivery time\n", p->callno, iaxs[p->callno]->peercallno);
+ if (iaxdebug)
+ ast_debug(3, "calc_timestamp: call %d/%d: Timestamp slaved to delivery time\n", p->callno, iaxs[p->callno]->peercallno);
} else {
ms = ast_tvdiff_ms(ast_tvnow(), p->offset);
if (ms < 0)
@@ -3678,7 +3669,7 @@ static unsigned int calc_timestamp(struct chan_iax2_pvt *p, unsigned int ts, str
* frame size too) */
if (iaxdebug && abs(ms - p->nextpred) > MAX_TIMESTAMP_SKEW )
- ast_log(LOG_DEBUG, "predicted timestamp skew (%u) > max (%u), using real ts instead.\n",
+ ast_debug(1, "predicted timestamp skew (%u) > max (%u), using real ts instead.\n",
abs(ms - p->nextpred), MAX_TIMESTAMP_SKEW);
if (f->samples >= 8) /* check to make sure we dont core dump */
@@ -3721,13 +3712,13 @@ static unsigned int calc_rxstamp(struct chan_iax2_pvt *p, unsigned int offset)
/* Setup rxcore if necessary */
if (ast_tvzero(p->rxcore)) {
p->rxcore = ast_tvnow();
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "calc_rxstamp: call=%d: rxcore set to %d.%6.6d - %dms\n",
+ if (iaxdebug)
+ ast_debug(1, "calc_rxstamp: call=%d: rxcore set to %d.%6.6d - %dms\n",
p->callno, (int)(p->rxcore.tv_sec), (int)(p->rxcore.tv_usec), offset);
p->rxcore = ast_tvsub(p->rxcore, ast_samp2tv(offset, 1000));
#if 1
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "calc_rxstamp: call=%d: works out as %d.%6.6d\n",
+ if (iaxdebug)
+ ast_debug(1, "calc_rxstamp: call=%d: works out as %d.%6.6d\n",
p->callno, (int)(p->rxcore.tv_sec),(int)( p->rxcore.tv_usec));
#endif
}
@@ -3775,8 +3766,7 @@ static struct iax2_trunk_peer *find_tpeer(struct sockaddr_in *sin, int fd)
#ifdef SO_NO_CHECK
setsockopt(tpeer->sockfd, SOL_SOCKET, SO_NO_CHECK, &nochecksums, sizeof(nochecksums));
#endif
- if (option_debug)
- ast_log(LOG_DEBUG, "Created trunk peer for '%s:%d'\n", ast_inet_ntoa(tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port));
+ ast_debug(1, "Created trunk peer for '%s:%d'\n", ast_inet_ntoa(tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port));
AST_LIST_INSERT_TAIL(&tpeers, tpeer, list);
}
}
@@ -3809,8 +3799,7 @@ static int iax2_trunk_queue(struct chan_iax2_pvt *pvt, struct iax_frame *fr)
tpeer->trunkdataalloc += DEFAULT_TRUNKDATA;
tpeer->trunkdata = tmp;
- if (option_debug)
- ast_log(LOG_DEBUG, "Expanded trunk '%s:%d' to %d bytes\n", ast_inet_ntoa(tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port), tpeer->trunkdataalloc);
+ ast_debug(1, "Expanded trunk '%s:%d' to %d bytes\n", ast_inet_ntoa(tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port), tpeer->trunkdataalloc);
} else {
ast_log(LOG_WARNING, "Maximum trunk data space exceeded to %s:%d\n", ast_inet_ntoa(tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port));
ast_mutex_unlock(&tpeer->lock);
@@ -3927,8 +3916,8 @@ static int decode_frame(ast_aes_decrypt_key *dcx, struct ast_iax2_full_hdr *fh,
memcpy_decrypt(workspace, efh->encdata, *datalen - sizeof(struct ast_iax2_full_enc_hdr), dcx);
padding = 16 + (workspace[15] & 0xf);
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Decoding full frame with length %d (padding = %d) (15=%02x)\n", *datalen, padding, workspace[15]);
+ if (iaxdebug)
+ ast_debug(1, "Decoding full frame with length %d (padding = %d) (15=%02x)\n", *datalen, padding, workspace[15]);
if (*datalen < padding + sizeof(struct ast_iax2_full_hdr))
return -1;
@@ -3942,8 +3931,8 @@ static int decode_frame(ast_aes_decrypt_key *dcx, struct ast_iax2_full_hdr *fh,
}
} else {
struct ast_iax2_mini_enc_hdr *efh = (struct ast_iax2_mini_enc_hdr *)fh;
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Decoding mini with length %d\n", *datalen);
+ if (iaxdebug)
+ ast_debug(1, "Decoding mini with length %d\n", *datalen);
if (*datalen < 16 + sizeof(struct ast_iax2_mini_hdr))
return -1;
/* Decrypt */
@@ -3966,24 +3955,24 @@ static int encrypt_frame(ast_aes_encrypt_key *ecx, struct ast_iax2_full_hdr *fh,
return -1;
if (ntohs(fh->scallno) & IAX_FLAG_FULL) {
struct ast_iax2_full_enc_hdr *efh = (struct ast_iax2_full_enc_hdr *)fh;
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Encoding full frame %d/%d with length %d\n", fh->type, fh->csub, *datalen);
+ if (iaxdebug)
+ ast_debug(1, "Encoding full frame %d/%d with length %d\n", fh->type, fh->csub, *datalen);
padding = 16 - ((*datalen - sizeof(struct ast_iax2_full_enc_hdr)) % 16);
padding = 16 + (padding & 0xf);
memcpy(workspace, poo, padding);
memcpy(workspace + padding, efh->encdata, *datalen - sizeof(struct ast_iax2_full_enc_hdr));
workspace[15] &= 0xf0;
workspace[15] |= (padding & 0xf);
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Encoding full frame %d/%d with length %d + %d padding (15=%02x)\n", fh->type, fh->csub, *datalen, padding, workspace[15]);
+ if (iaxdebug)
+ ast_debug(1, "Encoding full frame %d/%d with length %d + %d padding (15=%02x)\n", fh->type, fh->csub, *datalen, padding, workspace[15]);
*datalen += padding;
memcpy_encrypt(efh->encdata, workspace, *datalen - sizeof(struct ast_iax2_full_enc_hdr), ecx);
if (*datalen >= 32 + sizeof(struct ast_iax2_full_enc_hdr))
memcpy(poo, workspace + *datalen - 32, 32);
} else {
struct ast_iax2_mini_enc_hdr *efh = (struct ast_iax2_mini_enc_hdr *)fh;
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Encoding mini frame with length %d\n", *datalen);
+ if (iaxdebug)
+ ast_debug(1, "Encoding mini frame with length %d\n", *datalen);
padding = 16 - ((*datalen - sizeof(struct ast_iax2_mini_enc_hdr)) % 16);
padding = 16 + (padding & 0xf);
memcpy(workspace, poo, padding);
@@ -4787,8 +4776,7 @@ static int iax2_write(struct ast_channel *c, struct ast_frame *f)
/* Simple, just queue for transmission */
res = iax2_send(iaxs[callno], f, 0, -1, 0, 0, 0);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Write error: %s\n", strerror(errno));
+ ast_debug(1, "Write error: %s\n", strerror(errno));
}
}
/* If it's already gone, just return */
@@ -5067,7 +5055,7 @@ static int raw_hangup(struct sockaddr_in *sin, unsigned short src, unsigned shor
#if 0
if (option_debug)
#endif
- ast_log(LOG_DEBUG, "Raw Hangup %s:%d, src=%d, dst=%d\n",
+ ast_debug(1, "Raw Hangup %s:%d, src=%d, dst=%d\n",
ast_inet_ntoa(sin->sin_addr), ntohs(sin->sin_port), src, dst);
return sendto(sockfd, &fh, sizeof(fh), 0, (struct sockaddr *)sin, sizeof(*sin));
}
@@ -5780,8 +5768,7 @@ static void __expire_registry(void *data)
if (!p)
return;
- if (option_debug)
- ast_log(LOG_DEBUG, "Expiring registration for peer '%s'\n", p->name);
+ ast_debug(1, "Expiring registration for peer '%s'\n", p->name);
if (ast_test_flag((&globalflags), IAX_RTUPDATE) && (ast_test_flag(p, IAX_TEMPONLY|IAX_RTCACHEFRIENDS)))
realtime_update_peer(p->name, &p->addr, 0);
manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "Peer: IAX2/%s\r\nPeerStatus: Unregistered\r\nCause: Expired\r\n", p->name);
@@ -6214,8 +6201,7 @@ static int send_trunk(struct iax2_trunk_peer *tpeer, struct timeval *now)
res = transmit_trunk(fr, &tpeer->addr, tpeer->sockfd);
calls = tpeer->calls;
#if 0
- if (option_debug)
- ast_log(LOG_DEBUG, "Trunking %d call chunks in %d bytes to %s:%d, ts=%d\n", calls, fr->datalen, ast_inet_ntoa(tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port), ntohl(mth->ts));
+ ast_debug(1, "Trunking %d call chunks in %d bytes to %s:%d, ts=%d\n", calls, fr->datalen, ast_inet_ntoa(tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port), ntohl(mth->ts));
#endif
/* Reset transmit trunk side data */
tpeer->trunkdatalen = 0;
@@ -6291,8 +6277,7 @@ static int timing_read(int *id, int fd, short events, void *cbdata)
ast_mutex_lock(&drop->lock);
/* Once we have this lock, we're sure nobody else is using it or could use it once we release it,
because by the time they could get tpeerlock, we've already grabbed it */
- if (option_debug)
- ast_log(LOG_DEBUG, "Dropping unused iax2 trunk peer '%s:%d'\n", ast_inet_ntoa(drop->addr.sin_addr), ntohs(drop->addr.sin_port));
+ ast_debug(1, "Dropping unused iax2 trunk peer '%s:%d'\n", ast_inet_ntoa(drop->addr.sin_addr), ntohs(drop->addr.sin_port));
ast_free(drop->trunkdata);
ast_mutex_unlock(&drop->lock);
ast_mutex_destroy(&drop->lock);
@@ -6460,8 +6445,7 @@ static int check_provisioning(struct sockaddr_in *sin, int sockfd, char *si, uns
snprintf(rsi, sizeof(rsi), "si-%s", si);
if (iax_provision_version(&ourver, rsi, 1))
return 0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Service identifier '%s', we think '%08x', they think '%08x'\n", si, ourver, ver);
+ ast_debug(1, "Service identifier '%s', we think '%08x', they think '%08x'\n", si, ourver, ver);
if (ourver != ver)
iax2_provision(sin, sockfd, NULL, rsi, 1);
return 0;
@@ -6881,16 +6865,15 @@ static int socket_process(struct iax2_thread *thread)
iaxs[fr->callno]->peercallno = (unsigned short)(ntohs(mh->callno) & ~IAX_FLAG_FULL);
}
if (ntohs(mh->callno) & IAX_FLAG_FULL) {
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Received packet %d, (%d, %d)\n", fh->oseqno, f.frametype, f.subclass);
+ if (iaxdebug)
+ ast_debug(1, "Received packet %d, (%d, %d)\n", fh->oseqno, f.frametype, f.subclass);
/* Check if it's out of order (and not an ACK or INVAL) */
fr->oseqno = fh->oseqno;
fr->iseqno = fh->iseqno;
fr->ts = ntohl(fh->ts);
#ifdef IAXTESTS
if (test_resync) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Simulating frame ts resync, was %u now %u\n", fr->ts, fr->ts + test_resync);
+ ast_debug(1, "Simulating frame ts resync, was %u now %u\n", fr->ts, fr->ts + test_resync);
fr->ts += test_resync;
}
#endif /* IAXTESTS */
@@ -6923,15 +6906,13 @@ static int socket_process(struct iax2_thread *thread)
(f.subclass != IAX_COMMAND_VNAK)) ||
(f.frametype != AST_FRAME_IAX)) {
/* If it's not an ACK packet, it's out of order. */
- if (option_debug)
- ast_log(LOG_DEBUG, "Packet arrived out of order (expecting %d, got %d) (frametype = %d, subclass = %d)\n",
+ ast_debug(1, "Packet arrived out of order (expecting %d, got %d) (frametype = %d, subclass = %d)\n",
iaxs[fr->callno]->iseqno, fr->oseqno, f.frametype, f.subclass);
if (iaxs[fr->callno]->iseqno > fr->oseqno) {
/* If we've already seen it, ack it XXX There's a border condition here XXX */
if ((f.frametype != AST_FRAME_IAX) ||
((f.subclass != IAX_COMMAND_ACK) && (f.subclass != IAX_COMMAND_INVAL))) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Acking anyway\n");
+ ast_debug(1, "Acking anyway\n");
/* XXX Maybe we should handle its ack to us, but then again, it's probably outdated anyway, and if
we have anything to send, we'll retransmit and get an ACK back anyway XXX */
send_command_immediate(iaxs[fr->callno], AST_FRAME_IAX, IAX_COMMAND_ACK, fr->ts, NULL, 0,fr->iseqno);
@@ -6986,8 +6967,8 @@ static int socket_process(struct iax2_thread *thread)
that it says to */
for (x=iaxs[fr->callno]->rseqno; x != fr->iseqno; x++) {
/* Ack the packet with the given timestamp */
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Cancelling transmission of packet %d\n", x);
+ if (iaxdebug)
+ ast_debug(1, "Cancelling transmission of packet %d\n", x);
call_to_destroy = 0;
AST_LIST_LOCK(&queue);
AST_LIST_TRAVERSE(&queue, cur, list) {
@@ -7001,8 +6982,8 @@ static int socket_process(struct iax2_thread *thread)
}
AST_LIST_UNLOCK(&queue);
if (call_to_destroy) {
- if (iaxdebug && option_debug)
- ast_log(LOG_DEBUG, "Really destroying %d, having been acked on final message\n", call_to_destroy);
+ if (iaxdebug)
+ ast_debug(1, "Really destroying %d, having been acked on final message\n", call_to_destroy);
iax2_destroy(call_to_destroy);
}
}
@@ -7015,8 +6996,7 @@ static int socket_process(struct iax2_thread *thread)
return 1;
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Received iseqno %d not within window %d->%d\n", fr->iseqno, iaxs[fr->callno]->rseqno, iaxs[fr->callno]->oseqno);
+ ast_debug(1, "Received iseqno %d not within window %d->%d\n", fr->iseqno, iaxs[fr->callno]->rseqno, iaxs[fr->callno]->oseqno);
}
}
if (inaddrcmp(&sin, &iaxs[fr->callno]->addr) &&
@@ -7067,8 +7047,7 @@ static int socket_process(struct iax2_thread *thread)
if (f.frametype == AST_FRAME_VOICE) {
if (f.subclass != iaxs[fr->callno]->voiceformat) {
iaxs[fr->callno]->voiceformat = f.subclass;
- if (option_debug)
- ast_log(LOG_DEBUG, "Ooh, voice format changed to %d\n", f.subclass);
+ ast_debug(1, "Ooh, voice format changed to %d\n", f.subclass);
if (iaxs[fr->callno]->owner) {
int orignative;
retryowner:
@@ -7088,8 +7067,7 @@ retryowner:
ast_mutex_unlock(&iaxs[fr->callno]->owner->lock);
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Neat, somebody took away the channel at a magical time but i found it!\n");
+ ast_debug(1, "Neat, somebody took away the channel at a magical time but i found it!\n");
/* Free remote variables (if any) */
if (ies.vars)
ast_variables_destroy(ies.vars);
@@ -7101,8 +7079,7 @@ retryowner:
}
if (f.frametype == AST_FRAME_VIDEO) {
if (f.subclass != iaxs[fr->callno]->videoformat) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Ooh, video format changed to %d\n", f.subclass & ~0x1);
+ ast_debug(1, "Ooh, video format changed to %d\n", f.subclass & ~0x1);
iaxs[fr->callno]->videoformat = f.subclass & ~0x1;
}
}
@@ -7113,8 +7090,8 @@ retryowner:
iaxs[fr->callno]->initid = -1;
}
/* Handle the IAX pseudo frame itself */
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "IAX subclass %d received\n", f.subclass);
+ if (iaxdebug)
+ ast_debug(1, "IAX subclass %d received\n", f.subclass);
/* Update last ts unless the frame's timestamp originated with us. */
if (iaxs[fr->callno]->last < fr->ts &&
@@ -7122,8 +7099,8 @@ retryowner:
f.subclass != IAX_COMMAND_PONG &&
f.subclass != IAX_COMMAND_LAGRP) {
iaxs[fr->callno]->last = fr->ts;
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "For call=%d, set last=%d\n", fr->callno, fr->ts);
+ if (iaxdebug)
+ ast_debug(1, "For call=%d, set last=%d\n", fr->callno, fr->ts);
}
switch(f.subclass) {
@@ -7395,8 +7372,7 @@ retryowner:
break;
case IAX_COMMAND_HANGUP:
ast_set_flag(iaxs[fr->callno], IAX_ALREADYGONE);
- if (option_debug)
- ast_log(LOG_DEBUG, "Immediately destroying %d, having received hangup\n", fr->callno);
+ ast_debug(1, "Immediately destroying %d, having received hangup\n", fr->callno);
/* Set hangup cause according to remote */
if (ies.causecode && iaxs[fr->callno]->owner)
iaxs[fr->callno]->owner->hangupcause = ies.causecode;
@@ -7414,9 +7390,8 @@ retryowner:
ast_log(LOG_WARNING, "Call rejected by %s: %s\n",
ast_inet_ntoa(iaxs[fr->callno]->addr.sin_addr),
ies.cause ? ies.cause : "<Unknown>");
- if (option_debug)
- ast_log(LOG_DEBUG, "Immediately destroying %d, having received reject\n",
- fr->callno);
+ ast_debug(1, "Immediately destroying %d, having received reject\n",
+ fr->callno);
}
/* Send ack immediately, before we destroy */
send_command_immediate(iaxs[fr->callno], AST_FRAME_IAX, IAX_COMMAND_ACK,
@@ -7434,22 +7409,19 @@ retryowner:
if (iax_park(ast_bridged_channel(iaxs[fr->callno]->owner), iaxs[fr->callno]->owner)) {
ast_log(LOG_WARNING, "Failed to park call on '%s'\n", ast_bridged_channel(iaxs[fr->callno]->owner)->name);
} else if (ast_bridged_channel(iaxs[fr->callno]->owner)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Parked call on '%s'\n", ast_bridged_channel(iaxs[fr->callno]->owner)->name);
+ ast_debug(1, "Parked call on '%s'\n", ast_bridged_channel(iaxs[fr->callno]->owner)->name);
}
} else {
if (ast_async_goto(ast_bridged_channel(iaxs[fr->callno]->owner), iaxs[fr->callno]->context, ies.called_number, 1))
ast_log(LOG_WARNING, "Async goto of '%s' to '%s@%s' failed\n", ast_bridged_channel(iaxs[fr->callno]->owner)->name,
ies.called_number, iaxs[fr->callno]->context);
else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Async goto of '%s' to '%s@%s' started\n", ast_bridged_channel(iaxs[fr->callno]->owner)->name,
- ies.called_number, iaxs[fr->callno]->context);
+ ast_debug(1, "Async goto of '%s' to '%s@%s' started\n", ast_bridged_channel(iaxs[fr->callno]->owner)->name,
+ ies.called_number, iaxs[fr->callno]->context);
}
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Async goto not applicable on call %d\n", fr->callno);
+ ast_debug(1, "Async goto not applicable on call %d\n", fr->callno);
}
break;
case IAX_COMMAND_ACCEPT:
@@ -7566,8 +7538,7 @@ retryowner2:
/* And wrap up the qualify call */
iax2_destroy(fr->callno);
peer->callno = 0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Peer %s: got pong, lastms %d, historicms %d, maxms %d\n", peer->name, peer->lastms, peer->historicms, peer->maxms);
+ ast_debug(1, "Peer %s: got pong, lastms %d, historicms %d, maxms %d\n", peer->name, peer->lastms, peer->historicms, peer->maxms);
}
break;
case IAX_COMMAND_LAGRQ:
@@ -7587,8 +7558,8 @@ retryowner2:
/* This is a reply we've been given, actually measure the difference */
ts = calc_timestamp(iaxs[fr->callno], 0, &fr->af);
iaxs[fr->callno]->lag = ts - fr->ts;
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Peer %s lag measured as %dms\n",
+ if (iaxdebug)
+ ast_debug(1, "Peer %s lag measured as %dms\n",
ast_inet_ntoa(iaxs[fr->callno]->addr.sin_addr), iaxs[fr->callno]->lag);
}
break;
@@ -7663,8 +7634,7 @@ retryowner2:
}
if (!format) {
if(!ast_test_flag(iaxs[fr->callno], IAX_CODEC_NOCAP)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "We don't do requested format %s, falling back to peer capability %d\n", ast_getformatname(iaxs[fr->callno]->peerformat), iaxs[fr->callno]->peercapability);
+ ast_debug(1, "We don't do requested format %s, falling back to peer capability %d\n", ast_getformatname(iaxs[fr->callno]->peerformat), iaxs[fr->callno]->peercapability);
format = iaxs[fr->callno]->peercapability & iaxs[fr->callno]->capability;
}
if (!format) {
@@ -7783,15 +7753,12 @@ retryowner2:
break;
case IAX_COMMAND_INVAL:
iaxs[fr->callno]->error = ENOTCONN;
- if (option_debug)
- ast_log(LOG_DEBUG, "Immediately destroying %d, having received INVAL\n", fr->callno);
+ ast_debug(1, "Immediately destroying %d, having received INVAL\n", fr->callno);
iax2_destroy(fr->callno);
- if (option_debug)
- ast_log(LOG_DEBUG, "Destroying call %d\n", fr->callno);
+ ast_debug(1, "Destroying call %d\n", fr->callno);
break;
case IAX_COMMAND_VNAK:
- if (option_debug)
- ast_log(LOG_DEBUG, "Received VNAK: resending outstanding frames\n");
+ ast_debug(1, "Received VNAK: resending outstanding frames\n");
/* Force retransmission */
vnak_retransmit(fr->callno, fr->iseqno);
break;
@@ -7955,8 +7922,7 @@ retryowner2:
send_command(iaxs[fr->callno], AST_FRAME_IAX, IAX_COMMAND_FWDATA, 0, ied0.buf, ied0.pos, -1);
break;
default:
- if (option_debug)
- ast_log(LOG_DEBUG, "Unknown IAX command %d on %d/%d\n", f.subclass, fr->callno, iaxs[fr->callno]->peercallno);
+ ast_debug(1, "Unknown IAX command %d on %d/%d\n", f.subclass, fr->callno, iaxs[fr->callno]->peercallno);
memset(&ied0, 0, sizeof(ied0));
iax_ie_append_byte(&ied0, IAX_IE_IAX_UNKNOWN, f.subclass);
send_command(iaxs[fr->callno], AST_FRAME_IAX, IAX_COMMAND_UNSUPPORT, 0, ied0.buf, ied0.pos, -1);
@@ -8054,8 +8020,8 @@ retryowner2:
/*iaxs[fr->callno]->last = fr->ts; (do it afterwards cos schedule/forward_delivery needs the last ts too)*/
fr->outoforder = 0;
} else {
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Received out of order packet... (type=%d, subclass %d, ts = %d, last = %d)\n", f.frametype, f.subclass, fr->ts, iaxs[fr->callno]->last);
+ if (iaxdebug)
+ ast_debug(1, "Received out of order packet... (type=%d, subclass %d, ts = %d, last = %d)\n", f.frametype, f.subclass, fr->ts, iaxs[fr->callno]->last);
fr->outoforder = -1;
}
duped_fr = iaxfrdup2(fr);
@@ -8065,8 +8031,8 @@ retryowner2:
if (iaxs[fr->callno] && iaxs[fr->callno]->last < fr->ts) {
iaxs[fr->callno]->last = fr->ts;
#if 1
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "For call=%d, set last=%d\n", fr->callno, fr->ts);
+ if (iaxdebug)
+ ast_debug(1, "For call=%d, set last=%d\n", fr->callno, fr->ts);
#endif
}
@@ -8165,8 +8131,8 @@ static void *iax2_process_thread(void *data)
static int iax2_do_register(struct iax2_registry *reg)
{
struct iax_ie_data ied;
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Sending registration request for '%s'\n", reg->username);
+ if (iaxdebug)
+ ast_debug(1, "Sending registration request for '%s'\n", reg->username);
if (reg->dnsmgr &&
((reg->regstate == REG_STATE_TIMEOUT) || !reg->addr.sin_addr.s_addr)) {
@@ -8185,8 +8151,8 @@ static int iax2_do_register(struct iax2_registry *reg)
reg->callno = 0;
}
if (!reg->addr.sin_addr.s_addr) {
- if (option_debug && iaxdebug)
- ast_log(LOG_DEBUG, "Unable to send registration request for '%s' without IP address\n", reg->username);
+ if (iaxdebug)
+ ast_debug(1, "Unable to send registration request for '%s' without IP address\n", reg->username);
/* Setup the next registration attempt */
if (reg->expire > -1)
ast_sched_del(sched, reg->expire);
@@ -8195,14 +8161,13 @@ static int iax2_do_register(struct iax2_registry *reg)
}
if (!reg->callno) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Allocate call number\n");
+ ast_debug(1, "Allocate call number\n");
reg->callno = find_callno(0, 0, &reg->addr, NEW_FORCE, 1, defaultsockfd);
if (reg->callno < 1) {
ast_log(LOG_WARNING, "Unable to create call for registration\n");
return -1;
- } else if (option_debug)
- ast_log(LOG_DEBUG, "Registration created on call %d\n", reg->callno);
+ } else
+ ast_debug(1, "Registration created on call %d\n", reg->callno);
iaxs[reg->callno]->reg = reg;
}
/* Schedule the next registration attempt */
@@ -8239,12 +8204,10 @@ static int iax2_provision(struct sockaddr_in *end, int sockfd, char *dest, const
memset(&cai, 0, sizeof(cai));
- if (option_debug)
- ast_log(LOG_DEBUG, "Provisioning '%s' from template '%s'\n", dest, template);
+ ast_debug(1, "Provisioning '%s' from template '%s'\n", dest, template);
if (iax_provision_build(&provdata, &sig, template, force)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "No provisioning found for template '%s'\n", template);
+ ast_debug(1, "No provisioning found for template '%s'\n", template);
return 0;
}
@@ -8529,8 +8492,8 @@ static void *sched_thread(void *ignore)
pthread_testcancel();
count = ast_sched_runq(sched);
- if (count >= 20 && option_debug)
- ast_log(LOG_DEBUG, "chan_iax2: ast_sched_runq ran %d scheduled tasks all at once\n", count);
+ if (count >= 20)
+ ast_debug(1, "chan_iax2: ast_sched_runq ran %d scheduled tasks all at once\n", count);
}
return NULL;
@@ -8589,14 +8552,14 @@ static void *network_thread(void *ignore)
AST_LIST_UNLOCK(&queue);
pthread_testcancel();
- if (count >= 20 && option_debug)
- ast_log(LOG_DEBUG, "chan_iax2: Sent %d queued outbound frames all at once\n", count);
+ if (count >= 20)
+ ast_debug(1, "chan_iax2: Sent %d queued outbound frames all at once\n", count);
/* Now do the IO, and run scheduled tasks */
res = ast_io_wait(io, wakeup);
if (res >= 0) {
- if (res >= 20 && option_debug)
- ast_log(LOG_DEBUG, "chan_iax2: ast_io_wait ran %d I/Os all at once\n", res);
+ if (res >= 20)
+ ast_debug(1, "chan_iax2: ast_io_wait ran %d I/Os all at once\n", res);
}
}
return NULL;
@@ -8670,8 +8633,7 @@ static int check_srcaddr(struct sockaddr *sa, socklen_t salen)
res = bind(sd, sa, salen);
if (res < 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Can't bind: %s\n", strerror(errno));
+ ast_debug(1, "Can't bind: %s\n", strerror(errno));
close(sd);
return 1;
}
@@ -8750,8 +8712,7 @@ static int peer_set_srcaddr(struct iax2_peer *peer, const char *srcaddr)
srcaddr, peer->name);
return -1;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Using sourceaddress %s for '%s'\n", srcaddr, peer->name);
+ ast_debug(1, "Using sourceaddress %s for '%s'\n", srcaddr, peer->name);
return 0;
}
}
@@ -9808,9 +9769,8 @@ static int cache_get_callno_locked(const char *data)
if (create_addr(pds.peer, &sin, &cai))
return -1;
- if (option_debug)
- ast_log(LOG_DEBUG, "peer: %s, username: %s, password: %s, context: %s\n",
- pds.peer, pds.username, pds.password, pds.context);
+ ast_debug(1, "peer: %s, username: %s, password: %s, context: %s\n",
+ pds.peer, pds.username, pds.password, pds.context);
callno = find_callno(0, 0, &sin, NEW_FORCE, 1, cai.sockfd);
if (callno < 1) {
@@ -10247,17 +10207,15 @@ static int iax2_devicestate(void *data)
if (ast_strlen_zero(pds.peer))
return res;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Checking device state for device %s\n", pds.peer);
+ ast_debug(3, "Checking device state for device %s\n", pds.peer);
/* SLD: FIXME: second call to find_peer during registration */
if (!(p = find_peer(pds.peer, 1)))
return res;
res = AST_DEVICE_UNAVAILABLE;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "iax2_devicestate: Found peer. What's device state of %s? addr=%d, defaddr=%d maxms=%d, lastms=%d\n",
- pds.peer, p->addr.sin_addr.s_addr, p->defaddr.sin_addr.s_addr, p->maxms, p->lastms);
+ ast_debug(3, "iax2_devicestate: Found peer. What's device state of %s? addr=%d, defaddr=%d maxms=%d, lastms=%d\n",
+ pds.peer, p->addr.sin_addr.s_addr, p->defaddr.sin_addr.s_addr, p->maxms, p->lastms);
if ((p->addr.sin_addr.s_addr || p->defaddr.sin_addr.s_addr) &&
(!p->maxms || ((p->lastms > -1) && (p->historicms <= p->maxms)))) {
diff --git a/channels/chan_jingle.c b/channels/chan_jingle.c
index 132362439..3035f8c5b 100644
--- a/channels/chan_jingle.c
+++ b/channels/chan_jingle.c
@@ -407,8 +407,7 @@ static int jingle_answer(struct ast_channel *ast)
struct jingle *client = p->parent;
int res = 0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Answer!\n");
+ ast_debug(1, "Answer!\n");
ast_mutex_lock(&p->lock);
jingle_accept_call(client, p);
ast_mutex_unlock(&p->lock);
@@ -495,8 +494,7 @@ static int jingle_is_answered(struct jingle *client, ikspak *pak)
{
struct jingle_pvt *tmp;
- if (option_debug)
- ast_log(LOG_DEBUG, "The client is %s\n", client->name);
+ ast_debug(1, "The client is %s\n", client->name);
/* Make sure our new call doesn't exist yet */
for (tmp = client->p; tmp; tmp = tmp->next) {
if (iks_find_with_attrib(pak->x, GOOGLE_NODE, GOOGLE_SID, tmp->sid))
@@ -564,8 +562,7 @@ static int jingle_hangup_farend(struct jingle *client, ikspak *pak)
{
struct jingle_pvt *tmp;
- if (option_debug)
- ast_log(LOG_DEBUG, "The client is %s\n", client->name);
+ ast_debug(1, "The client is %s\n", client->name);
/* Make sure our new call doesn't exist yet */
for (tmp = client->p; tmp; tmp = tmp->next) {
if (iks_find_with_attrib(pak->x, GOOGLE_NODE, GOOGLE_SID, tmp->sid))
@@ -710,8 +707,7 @@ static struct jingle_pvt *jingle_alloc(struct jingle *client, const char *from,
struct aji_buddy *buddy;
char idroster[200];
- if (option_debug)
- ast_log(LOG_DEBUG, "The client is %s for alloc\n", client->name);
+ ast_debug(1, "The client is %s for alloc\n", client->name);
if (!sid && !strchr(from, '/')) { /* I started call! */
if (!strcasecmp(client->name, "guest")) {
buddy = ASTOBJ_CONTAINER_FIND(&client->connection->buddies, from);
@@ -1095,8 +1091,7 @@ static struct ast_frame *jingle_rtp_read(struct ast_channel *ast, struct jingle_
/* We already hold the channel lock */
if (f->frametype == AST_FRAME_VOICE) {
if (f->subclass != (p->owner->nativeformats & AST_FORMAT_AUDIO_MASK)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
+ ast_debug(1, "Oooh, format changed to %d\n", f->subclass);
p->owner->nativeformats =
(p->owner->nativeformats & AST_FORMAT_VIDEO_MASK) | f->subclass;
ast_set_read_format(p->owner, p->owner->readformat);
@@ -1104,8 +1099,8 @@ static struct ast_frame *jingle_rtp_read(struct ast_channel *ast, struct jingle_
}
/* if ((ast_test_flag(p, SIP_DTMF) == SIP_DTMF_INBAND) && p->vad) {
f = ast_dsp_process(p->owner, p->vad, f);
- if (option_debug && f && (f->frametype == AST_FRAME_DTMF))
- ast_log(LOG_DEBUG, "* Detected inband DTMF '%c'\n", f->subclass);
+ if (f && (f->frametype == AST_FRAME_DTMF))
+ ast_debug(1, "* Detected inband DTMF '%c'\n", f->subclass);
} */
}
}
@@ -1443,11 +1438,9 @@ static int jingle_parser(void *data, ikspak *pak)
/* New call */
jingle_newcall(client, pak);
} else if (iks_find_with_attrib(pak->x, GOOGLE_NODE, "type", GOOGLE_NEGOTIATE)) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "About to add candidate!\n");
+ ast_debug(3, "About to add candidate!\n");
jingle_add_candidate(client, pak);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Candidate Added!\n");
+ ast_debug(3, "Candidate Added!\n");
} else if (iks_find_with_attrib(pak->x, GOOGLE_NODE, "type", GOOGLE_ACCEPT)) {
jingle_is_answered(client, pak);
} else if (iks_find_with_attrib(pak->x, GOOGLE_NODE, "type", "content-info")) {
diff --git a/channels/chan_local.c b/channels/chan_local.c
index 1fd7f2fae..47b862b37 100644
--- a/channels/chan_local.c
+++ b/channels/chan_local.c
@@ -142,8 +142,7 @@ static int local_devicestate(void *data)
if ((opts = strchr(context, '/')))
*opts = '\0';
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Checking if extension %s@%s exists (devicestate)\n", exten, context);
+ ast_debug(3, "Checking if extension %s@%s exists (devicestate)\n", exten, context);
res = ast_exists_extension(NULL, context, exten, 1, NULL);
if (!res)
@@ -303,8 +302,7 @@ static int local_write(struct ast_channel *ast, struct ast_frame *f)
if (!ast_test_flag(p, LOCAL_ALREADY_MASQED))
res = local_queue_frame(p, isoutbound, f, ast);
else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Not posting to queue since already masked on '%s'\n", ast->name);
+ ast_debug(1, "Not posting to queue since already masked on '%s'\n", ast->name);
res = 0;
}
if (!res)
diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c
index 20b7447de..9c3161b77 100644
--- a/channels/chan_mgcp.c
+++ b/channels/chan_mgcp.c
@@ -490,8 +490,7 @@ static int unalloc_sub(struct mgcp_subchannel *sub)
ast_log(LOG_WARNING, "Trying to unalloc the real channel %s@%s?!?\n", p->name, p->parent->name);
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Released sub %d of channel %s@%s\n", sub->id, p->name, p->parent->name);
+ ast_debug(1, "Released sub %d of channel %s@%s\n", sub->id, p->name, p->parent->name);
sub->owner = NULL;
if (!ast_strlen_zero(sub->cxident)) {
@@ -757,8 +756,7 @@ static int mgcp_postrequest(struct mgcp_endpoint *p, struct mgcp_subchannel *sub
/* XXX Should schedule retransmission XXX */
/* SC
} else
- if (option_debug)
- ast_log(LOG_DEBUG, "Deferring transmission of transaction %d\n", seqno);
+ ast_debug(1, "Deferring transmission of transaction %d\n", seqno);
*/
return 0;
}
@@ -771,8 +769,7 @@ static int send_request(struct mgcp_endpoint *p, struct mgcp_subchannel *sub,
struct mgcp_request **queue, *q, *r, *t;
ast_mutex_t *l;
- if (option_debug)
- ast_log(LOG_DEBUG, "Slow sequence is %d\n", p->slowsequence);
+ ast_debug(1, "Slow sequence is %d\n", p->slowsequence);
if (p->slowsequence) {
queue = &p->cmd_queue;
l = &p->cmd_queue_lock;
@@ -948,17 +945,13 @@ static int mgcp_hangup(struct ast_channel *ast)
struct mgcp_subchannel *sub = ast->tech_pvt;
struct mgcp_endpoint *p = sub->parent;
- if (option_debug) {
- ast_log(LOG_DEBUG, "mgcp_hangup(%s)\n", ast->name);
- }
+ ast_debug(1, "mgcp_hangup(%s)\n", ast->name);
if (!ast->tech_pvt) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Asked to hangup channel not connected\n");
+ ast_debug(1, "Asked to hangup channel not connected\n");
return 0;
}
if (strcmp(sub->magic, MGCP_SUBCHANNEL_MAGIC)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Invalid magic. MGCP subchannel freed up already.\n");
+ ast_debug(1, "Invalid magic. MGCP subchannel freed up already.\n");
return 0;
}
ast_mutex_lock(&sub->lock);
@@ -1210,8 +1203,7 @@ static int mgcp_answer(struct ast_channel *ast)
}
if (ast->_state != AST_STATE_UP) {
ast_setstate(ast, AST_STATE_UP);
- if (option_debug)
- ast_log(LOG_DEBUG, "mgcp_answer(%s)\n", ast->name);
+ ast_debug(1, "mgcp_answer(%s)\n", ast->name);
transmit_notify_request(sub, "");
transmit_modify_request(sub);
}
@@ -1232,8 +1224,7 @@ static struct ast_frame *mgcp_rtp_read(struct mgcp_subchannel *sub)
/* We already hold the channel lock */
if (f->frametype == AST_FRAME_VOICE) {
if (f->subclass != sub->owner->nativeformats) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
+ ast_debug(1, "Oooh, format changed to %d\n", f->subclass);
sub->owner->nativeformats = f->subclass;
ast_set_read_format(sub->owner, sub->owner->readformat);
ast_set_write_format(sub->owner, sub->owner->writeformat);
@@ -1678,20 +1669,17 @@ static struct mgcp_subchannel *find_subchannel_and_lock(char *name, int msgid, s
/* SC */
p = g->endpoints;
while(p) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Searching on %s@%s for subchannel\n",
- p->name, g->name);
+ ast_debug(1, "Searching on %s@%s for subchannel\n",
+ p->name, g->name);
if (msgid) {
#if 0 /* new transport mech */
sub = p->sub;
do {
- if (option_debug)
- ast_log(LOG_DEBUG, "Searching on %s@%s-%d for subchannel with lastout: %d\n",
- p->name, g->name, sub->id, msgid);
+ ast_debug(1, "Searching on %s@%s-%d for subchannel with lastout: %d\n",
+ p->name, g->name, sub->id, msgid);
if (sub->lastout == msgid) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Found subchannel sub%d to handle request %d sub->lastout: %d\n",
- sub->id, msgid, sub->lastout);
+ ast_debug(1, "Found subchannel sub%d to handle request %d sub->lastout: %d\n",
+ sub->id, msgid, sub->lastout);
found = 1;
break;
}
@@ -1707,9 +1695,8 @@ static struct mgcp_subchannel *find_subchannel_and_lock(char *name, int msgid, s
/* SC */
break;
} else if (name && !strcasecmp(p->name, tmp)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Coundn't determine subchannel, assuming current master %s@%s-%d\n",
- p->name, g->name, p->sub->id);
+ ast_debug(1, "Coundn't determine subchannel, assuming current master %s@%s-%d\n",
+ p->name, g->name, p->sub->id);
sub = p->sub;
found = 1;
break;
@@ -2727,8 +2714,7 @@ static void *mgcp_ss(void *data)
timeout = matchdigittimeout;
}
} else if (res == 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "not enough digits (and no ambiguous match)...\n");
+ ast_debug(1, "not enough digits (and no ambiguous match)...\n");
/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_CONGESTION);*/
transmit_notify_request(sub, "G/cg");
/*zt_wait_event(p->subs[index].zfd);*/
@@ -2851,8 +2837,7 @@ static void *mgcp_ss(void *data)
timeout = firstdigittimeout;
} else if (!ast_canmatch_extension(chan, chan->context, p->dtmf_buf, 1, chan->cid.cid_num) &&
((p->dtmf_buf[0] != '*') || (strlen(p->dtmf_buf) > 2))) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Can't match %s from '%s' in context %s\n", p->dtmf_buf, chan->cid.cid_num ? chan->cid.cid_num : "<Unknown Caller>", chan->context);
+ ast_debug(1, "Can't match %s from '%s' in context %s\n", p->dtmf_buf, chan->cid.cid_num ? chan->cid.cid_num : "<Unknown Caller>", chan->context);
break;
}
if (!timeout)
@@ -2865,13 +2850,11 @@ static void *mgcp_ss(void *data)
for (;;) {
res = ast_waitfordigit(chan, to);
if (!res) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Timeout...\n");
+ ast_debug(1, "Timeout...\n");
break;
}
if (res < 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Got hangup...\n");
+ ast_debug(1, "Got hangup...\n");
ast_hangup(chan);
break;
}
@@ -2951,9 +2934,8 @@ static int attempt_transfer(struct mgcp_endpoint *p)
/* Tell the caller not to hangup */
return 1;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Neither %s nor %s are in a bridge, nothing to transfer\n",
- p->sub->owner->name, p->sub->next->owner->name);
+ ast_debug(1, "Neither %s nor %s are in a bridge, nothing to transfer\n",
+ p->sub->owner->name, p->sub->next->owner->name);
p->sub->next->owner->_softhangup |= AST_SOFTHANGUP_DEV;
if (p->sub->next->owner) {
p->sub->next->alreadygone = 1;
@@ -3116,8 +3098,7 @@ static int handle_request(struct mgcp_subchannel *sub, struct mgcp_request *req,
ev = get_header(req, "O");
s = strchr(ev, '/');
if (s) ev = s + 1;
- if (option_debug)
- ast_log(LOG_DEBUG, "Endpoint '%s@%s-%d' observed '%s'\n", p->name, p->parent->name, sub->id, ev);
+ ast_debug(1, "Endpoint '%s@%s-%d' observed '%s'\n", p->name, p->parent->name, sub->id, ev);
/* Keep looking for events unless this was a hangup */
if (strcasecmp(ev, "hu") && strcasecmp(ev, "hd") && strcasecmp(ev, "ping")) {
transmit_notify_request(sub, p->curtone);
@@ -3215,8 +3196,7 @@ static int handle_request(struct mgcp_subchannel *sub, struct mgcp_request *req,
} else if (!strcasecmp(ev, "hu")) {
p->hookstate = MGCP_ONHOOK;
sub->cxmode = MGCP_CX_RECVONLY;
- if (option_debug)
- ast_log(LOG_DEBUG, "MGCP %s@%s Went on hook\n", p->name, p->parent->name);
+ ast_debug(1, "MGCP %s@%s Went on hook\n", p->name, p->parent->name);
/* Do we need to send MDCX before a DLCX ?
if (sub->rtp) {
transmit_modify_request(sub);
@@ -3388,8 +3368,7 @@ static int mgcpsock_read(int *id, int fd, short events, void *ignore)
ast_mutex_lock(&gw->msgs_lock);
for (prev = NULL, cur = gw->msgs; cur; prev = cur, cur = cur->next) {
if (cur->seqno == ident) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Got response back on transaction %d\n", ident);
+ ast_debug(1, "Got response back on transaction %d\n", ident);
if (prev)
prev->next = cur->next;
else
diff --git a/channels/chan_misdn.c b/channels/chan_misdn.c
index 450ee6cc3..e74972aa4 100644
--- a/channels/chan_misdn.c
+++ b/channels/chan_misdn.c
@@ -727,8 +727,7 @@ static void send_digit_to_chan(struct chan_list *cl, char digit )
ast_playtones_start(chan,0,dtmf_tones[15], 0);
else {
/* not handled */
- if (option_debug)
- ast_log(LOG_DEBUG, "Unable to handle DTMF tone '%c' for '%s'\n", digit, chan->name);
+ ast_debug(1, "Unable to handle DTMF tone '%c' for '%s'\n", digit, chan->name);
}
}
/*** CLI HANDLING ***/
@@ -2300,8 +2299,7 @@ static int misdn_hangup(struct ast_channel *ast)
struct misdn_bchannel *bc = NULL;
const char *varcause = NULL;
- if (option_debug)
- ast_log(LOG_DEBUG, "misdn_hangup(%s)\n", ast->name);
+ ast_debug(1, "misdn_hangup(%s)\n", ast->name);
if (!ast || ! (p=MISDN_ASTERISK_TECH_PVT(ast) ) ) return -1;
@@ -2322,8 +2320,7 @@ static int misdn_hangup(struct ast_channel *ast)
CLEAN_CH:
/* between request and call */
- if (option_debug)
- ast_log(LOG_DEBUG, "State Reserved (or nothing) => chanIsAvail\n");
+ ast_debug(1, "State Reserved (or nothing) => chanIsAvail\n");
MISDN_ASTERISK_TECH_PVT(ast) = NULL;
cl_dequeue_chan(&cl_te, p);
@@ -2467,8 +2464,7 @@ static struct ast_frame *process_ast_dsp(struct chan_list *tmp, struct ast_frame
if (!f || (f->frametype != AST_FRAME_DTMF))
return frame;
- if (option_debug)
- ast_log(LOG_DEBUG, "Detected inband DTMF digit: %c\n", f->subclass);
+ ast_debug(1, "Detected inband DTMF digit: %c\n", f->subclass);
if (tmp->faxdetect && (f->subclass == 'f')) {
/* Fax tone -- Handle and return NULL */
@@ -2504,8 +2500,7 @@ static struct ast_frame *process_ast_dsp(struct chan_list *tmp, struct ast_frame
} else
ast_log(LOG_NOTICE, "Fax detected, but no fax extension ctx:%s exten:%s\n", context, ast->exten);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Already in a fax extension, not redirecting\n");
+ ast_debug(1, "Already in a fax extension, not redirecting\n");
}
break;
case 2:
@@ -2513,8 +2508,7 @@ static struct ast_frame *process_ast_dsp(struct chan_list *tmp, struct ast_frame
break;
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Fax already handled\n");
+ ast_debug(1, "Fax already handled\n");
}
}
@@ -2654,10 +2648,10 @@ static int misdn_write(struct ast_channel *ast, struct ast_frame *frame)
{
int i, max = 5 > frame->samples ? frame->samples : 5;
- ast_log(LOG_DEBUG, "write2mISDN %p %d bytes: ", p, frame->samples);
+ ast_debug(1, "write2mISDN %p %d bytes: ", p, frame->samples);
for (i = 0; i < max ; i++)
- ast_log(LOG_DEBUG, "%2.2x ", ((char*) frame->data)[i]);
+ ast_debug(1, "%2.2x ", ((char*) frame->data)[i]);
}
#endif
diff --git a/channels/chan_nbs.c b/channels/chan_nbs.c
index 3fb606f5a..1c342c6fd 100644
--- a/channels/chan_nbs.c
+++ b/channels/chan_nbs.c
@@ -102,8 +102,7 @@ static int nbs_call(struct ast_channel *ast, char *dest, int timeout)
}
/* When we call, it just works, really, there's no destination... Just
ring the phone and wait for someone to answer */
- if (option_debug)
- ast_log(LOG_DEBUG, "Calling %s on %s\n", dest, ast->name);
+ ast_debug(1, "Calling %s on %s\n", dest, ast->name);
/* If we can't connect, return congestion */
if (nbs_connect(p->nbs)) {
@@ -173,8 +172,7 @@ static int nbs_hangup(struct ast_channel *ast)
{
struct nbs_pvt *p;
p = ast->tech_pvt;
- if (option_debug)
- ast_log(LOG_DEBUG, "nbs_hangup(%s)\n", ast->name);
+ ast_debug(1, "nbs_hangup(%s)\n", ast->name);
if (!ast->tech_pvt) {
ast_log(LOG_WARNING, "Asked to hangup channel not connected\n");
return 0;
@@ -200,8 +198,7 @@ static struct ast_frame *nbs_xread(struct ast_channel *ast)
p->fr.delivery.tv_sec = 0;
p->fr.delivery.tv_usec = 0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Returning null frame on %s\n", ast->name);
+ ast_debug(1, "Returning null frame on %s\n", ast->name);
return &p->fr;
}
diff --git a/channels/chan_phone.c b/channels/chan_phone.c
index 31cabd4eb..e33d1a1d2 100644
--- a/channels/chan_phone.c
+++ b/channels/chan_phone.c
@@ -208,8 +208,7 @@ static int phone_indicate(struct ast_channel *chan, int condition, const void *d
{
struct phone_pvt *p = chan->tech_pvt;
int res=-1;
- if (option_debug)
- ast_log(LOG_DEBUG, "Requested indication %d on channel %s\n", condition, chan->name);
+ ast_debug(1, "Requested indication %d on channel %s\n", condition, chan->name);
switch(condition) {
case AST_CONTROL_FLASH:
ioctl(p->fd, IXJCTL_PSTN_SET_STATE, PSTN_ON_HOOK);
@@ -249,7 +248,7 @@ static int phone_digit_end(struct ast_channel *ast, char digit, unsigned int dur
struct phone_pvt *p;
int outdigit;
p = ast->tech_pvt;
- ast_log(LOG_DEBUG, "Dialed %c\n", digit);
+ ast_debug(1, "Dialed %c\n", digit);
switch(digit) {
case '0':
case '1':
@@ -280,7 +279,7 @@ static int phone_digit_end(struct ast_channel *ast, char digit, unsigned int dur
ast_log(LOG_WARNING, "Unknown digit '%c'\n", digit);
return -1;
}
- ast_log(LOG_DEBUG, "Dialed %d\n", outdigit);
+ ast_debug(1, "Dialed %d\n", outdigit);
ioctl(p->fd, PHONE_PLAY_TONE, outdigit);
p->lastformat = -1;
return 0;
@@ -320,8 +319,7 @@ static int phone_call(struct ast_channel *ast, char *dest, int timeout)
ast_log(LOG_WARNING, "phone_call called on %s, neither down nor reserved\n", ast->name);
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Ringing %s on %s (%d)\n", dest, ast->name, ast->fds[0]);
+ ast_debug(1, "Ringing %s on %s (%d)\n", dest, ast->name, ast->fds[0]);
start = IXJ_PHONE_RING_START(cid);
if (start == -1)
@@ -346,8 +344,7 @@ static int phone_hangup(struct ast_channel *ast)
{
struct phone_pvt *p;
p = ast->tech_pvt;
- if (option_debug)
- ast_log(LOG_DEBUG, "phone_hangup(%s)\n", ast->name);
+ ast_debug(1, "phone_hangup(%s)\n", ast->name);
if (!ast->tech_pvt) {
ast_log(LOG_WARNING, "Asked to hangup channel not connected\n");
return 0;
@@ -365,16 +362,13 @@ static int phone_hangup(struct ast_channel *ast)
/* If it's an FXO, hang them up */
if (p->mode == MODE_FXO) {
- if (ioctl(p->fd, PHONE_PSTN_SET_STATE, PSTN_ON_HOOK)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "ioctl(PHONE_PSTN_SET_STATE) failed on %s (%s)\n",ast->name, strerror(errno));
- }
+ if (ioctl(p->fd, PHONE_PSTN_SET_STATE, PSTN_ON_HOOK))
+ ast_debug(1, "ioctl(PHONE_PSTN_SET_STATE) failed on %s (%s)\n",ast->name, strerror(errno));
}
/* If they're off hook, give a busy signal */
if (ioctl(p->fd, PHONE_HOOKSTATE)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Got hunghup, giving busy signal\n");
+ ast_debug(1, "Got hunghup, giving busy signal\n");
ioctl(p->fd, PHONE_BUSY);
p->cpt = 1;
}
@@ -467,18 +461,13 @@ static int phone_answer(struct ast_channel *ast)
p = ast->tech_pvt;
/* In case it's a LineJack, take it off hook */
if (p->mode == MODE_FXO) {
- if (ioctl(p->fd, PHONE_PSTN_SET_STATE, PSTN_OFF_HOOK)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "ioctl(PHONE_PSTN_SET_STATE) failed on %s (%s)\n", ast->name, strerror(errno));
- }
- else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Took linejack off hook\n");
- }
+ if (ioctl(p->fd, PHONE_PSTN_SET_STATE, PSTN_OFF_HOOK))
+ ast_debug(1, "ioctl(PHONE_PSTN_SET_STATE) failed on %s (%s)\n", ast->name, strerror(errno));
+ else
+ ast_debug(1, "Took linejack off hook\n");
}
phone_setup(ast);
- if (option_debug)
- ast_log(LOG_DEBUG, "phone_answer(%s)\n", ast->name);
+ ast_debug(1, "phone_answer(%s)\n", ast->name);
ast->rings = 0;
ast_setstate(ast, AST_STATE_UP);
return 0;
@@ -516,8 +505,7 @@ static struct ast_frame *phone_exception(struct ast_channel *ast)
phonee.bytes = ioctl(p->fd, PHONE_EXCEPTION);
if (phonee.bits.dtmf_ready) {
- if (option_debug)
- ast_log(LOG_DEBUG, "phone_exception(): DTMF\n");
+ ast_debug(1, "phone_exception(): DTMF\n");
/* We've got a digit -- Just handle this nicely and easily */
digit = ioctl(p->fd, PHONE_GET_DTMF_ASCII);
@@ -526,12 +514,10 @@ static struct ast_frame *phone_exception(struct ast_channel *ast)
return &p->fr;
}
if (phonee.bits.hookstate) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Hookstate changed\n");
+ ast_debug(1, "Hookstate changed\n");
res = ioctl(p->fd, PHONE_HOOKSTATE);
/* See if we've gone on hook, if so, notify by returning NULL */
- if (option_debug)
- ast_log(LOG_DEBUG, "New hookstate: %d\n", res);
+ ast_debug(1, "New hookstate: %d\n", res);
if (!res && (p->mode != MODE_FXO))
return NULL;
else {
@@ -943,8 +929,7 @@ static void phone_check_exception(struct phone_pvt *i)
union telephony_exception phonee;
/* XXX Do something XXX */
#if 0
- if (option_debug)
- ast_log(LOG_DEBUG, "Exception!\n");
+ ast_debug(1, "Exception!\n");
#endif
phonee.bytes = ioctl(i->fd, PHONE_EXCEPTION);
if (phonee.bits.dtmf_ready) {
@@ -972,8 +957,7 @@ static void phone_check_exception(struct phone_pvt *i)
/* XXX This should probably be justified better XXX */
} else if (!ast_canmatch_extension(NULL, "default", i->ext, 1, i->cid_num)) {
/* It's not a valid extension, give a busy signal */
- if (option_debug)
- ast_log(LOG_DEBUG, "%s can't match anything in %s or default\n", i->ext, i->context);
+ ast_debug(1, "%s can't match anything in %s or default\n", i->ext, i->context);
ioctl(i->fd, PHONE_BUSY);
i->cpt = 1;
}
@@ -1100,8 +1084,7 @@ static void *do_monitor(void *data)
}
/* Okay, select has finished. Let's see what happened. */
if (res < 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "select return %d: %s\n", res, strerror(errno));
+ ast_debug(1, "select return %d: %s\n", res, strerror(errno));
continue;
}
/* If there are no fd's changed, just continue, it's probably time
@@ -1189,22 +1172,19 @@ static struct phone_pvt *mkif(char *iface, int mode, int txgain, int rxgain)
}
if (mode == MODE_FXO) {
if (ioctl(tmp->fd, IXJCTL_PORT, PORT_PSTN)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Unable to set port to PSTN\n");
+ ast_debug(1, "Unable to set port to PSTN\n");
}
} else {
if (ioctl(tmp->fd, IXJCTL_PORT, PORT_POTS))
if (mode != MODE_FXS)
- ast_log(LOG_DEBUG, "Unable to set port to POTS\n");
+ ast_debug(1, "Unable to set port to POTS\n");
}
ioctl(tmp->fd, PHONE_PLAY_STOP);
ioctl(tmp->fd, PHONE_REC_STOP);
ioctl(tmp->fd, PHONE_RING_STOP);
ioctl(tmp->fd, PHONE_CPT_STOP);
- if (ioctl(tmp->fd, PHONE_PSTN_SET_STATE, PSTN_ON_HOOK)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "ioctl(PHONE_PSTN_SET_STATE) failed on %s (%s)\n",iface, strerror(errno));
- }
+ if (ioctl(tmp->fd, PHONE_PSTN_SET_STATE, PSTN_ON_HOOK))
+ ast_debug(1, "ioctl(PHONE_PSTN_SET_STATE) failed on %s (%s)\n",iface, strerror(errno));
if (echocancel != AEC_OFF)
ioctl(tmp->fd, IXJCTL_AEC_START, echocancel);
if (silencesupression)
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index bd4f57e47..42894d3bc 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -1696,16 +1696,14 @@ static void unref_user(struct sip_user *user)
static void registry_unref(struct sip_registry *reg)
{
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "SIP Registry %s: refcount now %d\n", reg->hostname, reg->refcount - 1);
+ ast_debug(3, "SIP Registry %s: refcount now %d\n", reg->hostname, reg->refcount - 1);
ASTOBJ_UNREF(reg, sip_registry_destroy);
}
/*! \brief Add object reference to SIP registry */
static struct sip_registry *registry_addref(struct sip_registry *reg)
{
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "SIP Registry %s: refcount now %d\n", reg->hostname, reg->refcount + 1);
+ ast_debug(3, "SIP Registry %s: refcount now %d\n", reg->hostname, reg->refcount + 1);
return ASTOBJ_REF(reg); /* Add pointer to registry in packet */
}
@@ -1742,12 +1740,10 @@ static const char *referstatus2str(enum referstatus rstatus)
a dialog */
static void initialize_initreq(struct sip_pvt *p, struct sip_request *req)
{
- if (option_debug) {
- if (p->initreq.headers)
- ast_log(LOG_DEBUG, "Initializing already initialized SIP dialog %s (presumably reinvite)\n", p->callid);
- else
- ast_log(LOG_DEBUG, "Initializing initreq for method %s - callid %s\n", sip_methods[req->method].text, p->callid);
- }
+ if (p->initreq.headers)
+ ast_debug(1, "Initializing already initialized SIP dialog %s (presumably reinvite)\n", p->callid);
+ else
+ ast_debug(1, "Initializing initreq for method %s - callid %s\n", sip_methods[req->method].text, p->callid);
/* Use this as the basis */
copy_request(&p->initreq, req);
parse_request(&p->initreq);
@@ -1758,8 +1754,7 @@ static void initialize_initreq(struct sip_pvt *p, struct sip_request *req)
/*! \brief Encapsulate setting of SIP_ALREADYGONE to be able to trace it with debugging */
static void sip_alreadygone(struct sip_pvt *dialog)
{
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Setting SIP_ALREADYGONE on dialog %s\n", dialog->callid);
+ ast_debug(3, "Setting SIP_ALREADYGONE on dialog %s\n", dialog->callid);
ast_set_flag(&dialog->flags[0], SIP_ALREADYGONE);
}
@@ -1798,19 +1793,19 @@ static struct sip_proxy *proxy_allocate(char *name, char *port, int force)
static struct sip_proxy *obproxy_get(struct sip_pvt *dialog, struct sip_peer *peer)
{
if (peer && peer->outboundproxy) {
- if (option_debug && sipdebug)
- ast_log(LOG_DEBUG, "OBPROXY: Applying peer OBproxy to this call\n");
+ if (sipdebug)
+ ast_debug(1, "OBPROXY: Applying peer OBproxy to this call\n");
append_history(dialog, "OBproxy", "Using peer obproxy %s", peer->outboundproxy->name);
return peer->outboundproxy;
}
if (global_outboundproxy.name[0]) {
- if (option_debug && sipdebug)
- ast_log(LOG_DEBUG, "OBPROXY: Applying global OBproxy to this call\n");
+ if (sipdebug)
+ ast_debug(1, "OBPROXY: Applying global OBproxy to this call\n");
append_history(dialog, "OBproxy", "Using global obproxy %s", global_outboundproxy.name);
return &global_outboundproxy;
}
- if (option_debug && sipdebug)
- ast_log(LOG_DEBUG, "OBPROXY: Not applying OBproxy to this call\n");
+ if (sipdebug)
+ ast_debug(1, "OBPROXY: Not applying OBproxy to this call\n");
return NULL;
}
@@ -1855,30 +1850,30 @@ static unsigned int parse_sip_options(struct sip_pvt *pvt, const char *supported
return 0;
temp = ast_strdupa(supported);
- if (option_debug > 2 && sipdebug)
- ast_log(LOG_DEBUG, "Begin: parsing SIP \"Supported: %s\"\n", supported);
+ if (sipdebug)
+ ast_debug(3, "Begin: parsing SIP \"Supported: %s\"\n", supported);
for (next = temp; next; next = sep) {
found = FALSE;
if ( (sep = strchr(next, ',')) != NULL)
*sep++ = '\0';
next = ast_skip_blanks(next);
- if (option_debug > 2 && sipdebug)
- ast_log(LOG_DEBUG, "Found SIP option: -%s-\n", next);
+ if (sipdebug)
+ ast_debug(3, "Found SIP option: -%s-\n", next);
for (i=0; i < (sizeof(sip_options) / sizeof(sip_options[0])); i++) {
if (!strcasecmp(next, sip_options[i].text)) {
profile |= sip_options[i].id;
found = TRUE;
- if (option_debug > 2 && sipdebug)
- ast_log(LOG_DEBUG, "Matched SIP option: %s\n", next);
+ if (sipdebug)
+ ast_debug(3, "Matched SIP option: %s\n", next);
break;
}
}
- if (!found && option_debug > 2 && sipdebug) {
+ if (!found && sipdebug) {
if (!strncasecmp(next, "x-", 2))
- ast_log(LOG_DEBUG, "Found private SIP option, not supported: %s\n", next);
+ ast_debug(3, "Found private SIP option, not supported: %s\n", next);
else
- ast_log(LOG_DEBUG, "Found no match for SIP option: %s (Please file bug report!)\n", next);
+ ast_debug(3, "Found no match for SIP option: %s (Please file bug report!)\n", next);
}
}
@@ -1986,10 +1981,8 @@ static enum sip_result ast_sip_ouraddrfor(struct in_addr *them, struct in_addr *
ast_log(LOG_NOTICE, "Warning: Re-lookup of '%s' failed!\n", externhost);
}
*us = externip.sin_addr;
- if (option_debug) {
- ast_log(LOG_DEBUG, "Target address %s is not local, substituting externip\n",
- ast_inet_ntoa(*(struct in_addr *)&them->s_addr));
- }
+ ast_debug(1, "Target address %s is not local, substituting externip\n",
+ ast_inet_ntoa(*(struct in_addr *)&them->s_addr));
} else if (bindaddr.sin_addr.s_addr)
*us = bindaddr.sin_addr;
return AST_SUCCESS;
@@ -2042,13 +2035,13 @@ static int retrans_pkt(void *data)
if (pkt->retrans < MAX_RETRANS) {
pkt->retrans++;
if (!pkt->timer_t1) { /* Re-schedule using timer_a and timer_t1 */
- if (sipdebug && option_debug > 3)
- ast_log(LOG_DEBUG, "SIP TIMER: Not rescheduling id #%d:%s (Method %d) (No timer T1)\n", pkt->retransid, sip_methods[pkt->method].text, pkt->method);
+ if (sipdebug)
+ ast_debug(4, "SIP TIMER: Not rescheduling id #%d:%s (Method %d) (No timer T1)\n", pkt->retransid, sip_methods[pkt->method].text, pkt->method);
} else {
int siptimer_a;
- if (sipdebug && option_debug > 3)
- ast_log(LOG_DEBUG, "SIP TIMER: Rescheduling retransmission #%d (%d) %s - %d\n", pkt->retransid, pkt->retrans, sip_methods[pkt->method].text, pkt->method);
+ if (sipdebug)
+ ast_debug(4, "SIP TIMER: Rescheduling retransmission #%d (%d) %s - %d\n", pkt->retransid, pkt->retrans, sip_methods[pkt->method].text, pkt->method);
if (!pkt->timer_a)
pkt->timer_a = 2 ;
else
@@ -2061,8 +2054,7 @@ static int retrans_pkt(void *data)
/* Reschedule re-transmit */
reschedule = siptimer_a;
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "** SIP timers: Rescheduling retransmission %d to %d ms (t1 %d ms (Retrans id #%d)) \n", pkt->retrans +1, siptimer_a, pkt->timer_t1, pkt->retransid);
+ ast_debug(4, "** SIP timers: Rescheduling retransmission %d to %d ms (t1 %d ms (Retrans id #%d)) \n", pkt->retrans +1, siptimer_a, pkt->timer_t1, pkt->retransid);
}
if (sip_debug_test_pvt(pkt->owner)) {
@@ -2119,8 +2111,7 @@ static int retrans_pkt(void *data)
if (pkt->method != SIP_OPTIONS && pkt->method != SIP_REGISTER) {
ast_set_flag(&pkt->owner->flags[0], SIP_NEEDDESTROY);
sip_alreadygone(pkt->owner);
- if (option_debug)
- append_history(pkt->owner, "DialogKill", "Killing this failed dialog immediately");
+ append_history(pkt->owner, "DialogKill", "Killing this failed dialog immediately");
}
}
}
@@ -2176,8 +2167,8 @@ static enum sip_result __sip_reliable_xmit(struct sip_pvt *p, int seqno, int res
/* Schedule retransmission */
pkt->retransid = ast_sched_add_variable(sched, siptimer_a, retrans_pkt, pkt, 1);
- if (option_debug > 3 && sipdebug)
- ast_log(LOG_DEBUG, "*** SIP TIMER: Initalizing retransmit timer on packet: Id #%d\n", pkt->retransid);
+ if (sipdebug)
+ ast_debug(4, "*** SIP TIMER: Initalizing retransmit timer on packet: Id #%d\n", pkt->retransid);
pkt->next = p->packets;
p->packets = pkt;
if (sipmethod == SIP_INVITE) {
@@ -2206,8 +2197,7 @@ static int __sip_autodestruct(void *data)
transmit_state_notify(p, AST_EXTENSION_DEACTIVATED, 1, TRUE); /* Send last notification */
p->subscribed = NONE;
append_history(p, "Subscribestatus", "timeout");
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Re-scheduled destruction of SIP subsription %s\n", p->callid ? p->callid : "<unknown>");
+ ast_debug(3, "Re-scheduled destruction of SIP subsription %s\n", p->callid ? p->callid : "<unknown>");
return 10000; /* Reschedule this destruction so that we know that it's gone */
}
@@ -2222,15 +2212,13 @@ static int __sip_autodestruct(void *data)
ast_log(LOG_WARNING, "Autodestruct on dialog '%s' with owner in place (Method: %s)\n", p->callid, sip_methods[p->method].text);
ast_queue_hangup(p->owner);
} else if (p->refer) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Finally hanging up channel after transfer: %s\n", p->callid);
+ ast_debug(3, "Finally hanging up channel after transfer: %s\n", p->callid);
transmit_request_with_auth(p, SIP_BYE, 0, XMIT_RELIABLE, 1);
append_history(p, "ReferBYE", "Sending BYE on transferer call leg %s", p->callid);
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
} else {
append_history(p, "AutoDestroy", "%s", p->callid);
- if (option_debug)
- ast_log(LOG_DEBUG, "Auto destroying SIP dialog '%s'\n", p->callid);
+ ast_debug(3, "Auto destroying SIP dialog '%s'\n", p->callid);
sip_destroy(p); /* Go ahead and destroy dialog. All attempts to recover is done */
}
return 0;
@@ -2286,13 +2274,12 @@ static void __sip_ack(struct sip_pvt *p, int seqno, int resp, int sipmethod)
if (ast_test_flag(cur, FLAG_RESPONSE) || cur->method == sipmethod) {
msg = "Found";
if (!resp && (seqno == p->pendinginvite)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Acked pending invite %d\n", p->pendinginvite);
+ ast_debug(1, "Acked pending invite %d\n", p->pendinginvite);
p->pendinginvite = 0;
}
if (cur->retransid > -1) {
- if (sipdebug && option_debug > 3)
- ast_log(LOG_DEBUG, "** SIP TIMER: Cancelling retransmit of packet (reply received) Retransid #%d\n", cur->retransid);
+ if (sipdebug)
+ ast_debug(4, "** SIP TIMER: Cancelling retransmit of packet (reply received) Retransid #%d\n", cur->retransid);
ast_sched_del(sched, cur->retransid);
cur->retransid = -1;
}
@@ -2302,9 +2289,8 @@ static void __sip_ack(struct sip_pvt *p, int seqno, int resp, int sipmethod)
}
}
sip_pvt_unlock(p);
- if (option_debug)
- ast_log(LOG_DEBUG, "Stopping retransmission on '%s' of %s %d: Match %s\n",
- p->callid, resp ? "Response" : "Request", seqno, msg);
+ ast_debug(1, "Stopping retransmission on '%s' of %s %d: Match %s\n",
+ p->callid, resp ? "Response" : "Request", seqno, msg);
}
/*! \brief Pretend to ack all packets
@@ -2336,8 +2322,8 @@ static int __sip_semi_ack(struct sip_pvt *p, int seqno, int resp, int sipmethod)
(ast_test_flag(cur, FLAG_RESPONSE) || method_match(sipmethod, cur->data))) {
/* this is our baby */
if (cur->retransid > -1) {
- if (option_debug > 3 && sipdebug)
- ast_log(LOG_DEBUG, "*** SIP TIMER: Cancelling retransmission #%d - %s (got response)\n", cur->retransid, sip_methods[sipmethod].text);
+ if (sipdebug)
+ ast_debug(4, "*** SIP TIMER: Cancelling retransmission #%d - %s (got response)\n", cur->retransid, sip_methods[sipmethod].text);
ast_sched_del(sched, cur->retransid);
cur->retransid = -1;
}
@@ -2345,8 +2331,7 @@ static int __sip_semi_ack(struct sip_pvt *p, int seqno, int resp, int sipmethod)
break;
}
}
- if (option_debug)
- ast_log(LOG_DEBUG, "(Provisional) Stopping retransmission (but retaining packet) on '%s' %s %d: %s\n", p->callid, resp ? "Response" : "Request", seqno, res ? "Not Found" : "Found");
+ ast_debug(1, "(Provisional) Stopping retransmission (but retaining packet) on '%s' %s %d: %s\n", p->callid, resp ? "Response" : "Request", seqno, res ? "Not Found" : "Found");
return res;
}
@@ -2578,8 +2563,8 @@ static int sip_sendhtml(struct ast_channel *chan, int subclass, const char *data
ast_string_field_build(p, url, "<%s>;mode=active", data);
- if (sip_debug_test_pvt(p) && option_debug)
- ast_log(LOG_DEBUG, "Send URL %s, state = %d!\n", data, chan->_state);
+ if (sip_debug_test_pvt(p))
+ ast_debug(1, "Send URL %s, state = %d!\n", data, chan->_state);
switch (chan->_state) {
case AST_STATE_RING:
@@ -2698,8 +2683,7 @@ static void register_peer_exten(struct sip_peer *peer, int onoff)
/*! \brief Destroy peer object from memory */
static void sip_destroy_peer(struct sip_peer *peer)
{
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Destroying SIP peer %s\n", peer->name);
+ ast_debug(3, "Destroying SIP peer %s\n", peer->name);
if (peer->outboundproxy)
ast_free(peer->outboundproxy);
@@ -2731,8 +2715,7 @@ static void sip_destroy_peer(struct sip_peer *peer)
apeerobjs--;
else if (ast_test_flag(&peer->flags[0], SIP_REALTIME)) {
rpeerobjs--;
- if (option_debug > 2)
- ast_log(LOG_DEBUG,"-REALTIME- peer Destroyed. Name: %s. Realtime Peer objects: %d\n", peer->name, rpeerobjs);
+ ast_debug(3,"-REALTIME- peer Destroyed. Name: %s. Realtime Peer objects: %d\n", peer->name, rpeerobjs);
} else
speerobjs--;
clear_realm_authentication(peer->auth);
@@ -2833,8 +2816,7 @@ static struct sip_peer *realtime_peer(const char *newpeername, struct sockaddr_i
return NULL;
}
- if (option_debug > 2)
- ast_log(LOG_DEBUG,"-REALTIME- loading peer from database to memory. Name: %s. Peer objects: %d\n", peer->name, rpeerobjs);
+ ast_debug(3,"-REALTIME- loading peer from database to memory. Name: %s. Peer objects: %d\n", peer->name, rpeerobjs);
if (ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS)) {
/* Cache peer */
@@ -2886,8 +2868,7 @@ static struct sip_peer *find_peer(const char *peer, struct sockaddr_in *sin, int
/*! \brief Remove user object from in-memory storage */
static void sip_destroy_user(struct sip_user *user)
{
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Destroying user object from memory: %s\n", user->name);
+ ast_debug(3, "Destroying user object from memory: %s\n", user->name);
ast_free_ha(user->ha);
if (user->chanvars) {
ast_variables_destroy(user->chanvars);
@@ -2961,23 +2942,19 @@ static void do_setnat(struct sip_pvt *p, int natflags)
const char *mode = natflags ? "On" : "Off";
if (p->rtp) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Setting NAT on RTP to %s\n", mode);
+ ast_debug(1, "Setting NAT on RTP to %s\n", mode);
ast_rtp_setnat(p->rtp, natflags);
}
if (p->vrtp) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Setting NAT on VRTP to %s\n", mode);
+ ast_debug(1, "Setting NAT on VRTP to %s\n", mode);
ast_rtp_setnat(p->vrtp, natflags);
}
if (p->udptl) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Setting NAT on UDPTL to %s\n", mode);
+ ast_debug(1, "Setting NAT on UDPTL to %s\n", mode);
ast_udptl_setnat(p->udptl, natflags);
}
if (p->trtp) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Setting NAT on TRTP to %s\n", mode);
+ ast_debug(1, "Setting NAT on TRTP to %s\n", mode);
ast_rtp_setnat(p->trtp, natflags);
}
}
@@ -3016,8 +2993,7 @@ static int create_addr_from_peer(struct sip_pvt *dialog, struct sip_peer *peer)
else if (ast_udptl_get_error_correction_scheme(dialog->udptl) == UDPTL_ERROR_CORRECTION_NONE )
dialog->t38.capability |= T38FAX_UDP_EC_NONE;
dialog->t38.capability |= T38FAX_RATE_MANAGEMENT_TRANSFERED_TCF;
- if (option_debug > 1)
- ast_log(LOG_DEBUG,"Our T38 capability (%d)\n", dialog->t38.capability);
+ ast_debug(2,"Our T38 capability (%d)\n", dialog->t38.capability);
}
dialog->t38.jointcapability = dialog->t38.capability;
} else if (dialog->udptl) {
@@ -3222,8 +3198,7 @@ static int sip_call(struct ast_channel *ast, char *dest, int timeout)
p->options->replaces = ast_var_value(current);
} else if (!strcasecmp(ast_var_name(current), "T38CALL")) {
p->t38.state = T38_LOCAL_DIRECT;
- if (option_debug)
- ast_log(LOG_DEBUG,"T38State change to %d on channel %s\n", p->t38.state, ast->name);
+ ast_debug(1,"T38State change to %d on channel %s\n", p->t38.state, ast->name);
}
}
@@ -3235,15 +3210,14 @@ static int sip_call(struct ast_channel *ast, char *dest, int timeout)
char buf[BUFSIZ/2];
if (referer) {
- if (sipdebug && option_debug > 2)
- ast_log(LOG_DEBUG, "Call for %s transfered by %s\n", p->username, referer);
+ if (sipdebug)
+ ast_debug(3, "Call for %s transfered by %s\n", p->username, referer);
snprintf(buf, sizeof(buf)-1, "-> %s (via %s)", p->cid_name, referer);
} else
snprintf(buf, sizeof(buf)-1, "-> %s", p->cid_name);
ast_string_field_set(p, cid_name, buf);
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Outgoing Call for %s\n", p->username);
+ ast_debug(1, "Outgoing Call for %s\n", p->username);
res = update_call_counter(p, INC_CALL_RINGING);
@@ -3262,8 +3236,7 @@ static int sip_call(struct ast_channel *ast, char *dest, int timeout)
int xmitres;
p->t38.jointcapability = p->t38.capability;
- if (option_debug > 1)
- ast_log(LOG_DEBUG,"Our T38 capability (%d), joint T38 capability (%d)\n", p->t38.capability, p->t38.jointcapability);
+ ast_debug(2,"Our T38 capability (%d), joint T38 capability (%d)\n", p->t38.capability, p->t38.jointcapability);
xmitres = transmit_invite(p, SIP_INVITE, 1, 2);
if (xmitres == XMIT_ERROR)
return -1;
@@ -3281,15 +3254,13 @@ static int sip_call(struct ast_channel *ast, char *dest, int timeout)
static void sip_registry_destroy(struct sip_registry *reg)
{
/* Really delete */
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Destroying registry entry for %s@%s\n", reg->username, reg->hostname);
+ ast_debug(3, "Destroying registry entry for %s@%s\n", reg->username, reg->hostname);
if (reg->call) {
/* Clear registry before destroying to ensure
we don't get reentered trying to grab the registry lock */
reg->call->registry = NULL;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Destroying active SIP dialog for registry %s@%s\n", reg->username, reg->hostname);
+ ast_debug(3, "Destroying active SIP dialog for registry %s@%s\n", reg->username, reg->hostname);
sip_destroy(reg->call);
}
if (reg->expire > -1)
@@ -3308,13 +3279,12 @@ static void __sip_destroy(struct sip_pvt *p, int lockowner, int lockdialoglist)
struct sip_pvt *cur, *prev = NULL;
struct sip_pkt *cp;
- if (sip_debug_test_pvt(p) || option_debug > 2)
+ if (sip_debug_test_pvt(p))
ast_verbose("Really destroying SIP dialog '%s' Method: %s\n", p->callid, sip_methods[p->method].text);
if (ast_test_flag(&p->flags[0], SIP_INC_COUNT)) {
update_call_counter(p, DEC_CALL_LIMIT);
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "This call did not properly clean up call limits. Call ID %s\n", p->callid);
+ ast_debug(2, "This call did not properly clean up call limits. Call ID %s\n", p->callid);
}
/* Remove link from peer to subscription of MWI */
@@ -3358,8 +3328,7 @@ static void __sip_destroy(struct sip_pvt *p, int lockowner, int lockdialoglist)
if (p->owner) {
if (lockowner)
ast_channel_lock(p->owner);
- if (option_debug)
- ast_log(LOG_DEBUG, "Detaching from %s\n", p->owner->name);
+ ast_debug(1, "Detaching from %s\n", p->owner->name);
p->owner->tech_pvt = NULL;
if (lockowner)
ast_channel_unlock(p->owner);
@@ -3429,8 +3398,7 @@ static int update_call_counter(struct sip_pvt *fup, int event)
struct sip_user *u = NULL;
struct sip_peer *p = NULL;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Updating call counter for %s call\n", outgoing ? "outgoing" : "incoming");
+ ast_debug(3, "Updating call counter for %s call\n", outgoing ? "outgoing" : "incoming");
/* Test if we need to check call limits, in order to avoid
realtime lookups if we do not need it */
@@ -3451,8 +3419,7 @@ static int update_call_counter(struct sip_pvt *fup, int event)
ast_copy_string(name, fup->peername, sizeof(name));
}
if (!p && !u) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "%s is not a local device, no call limit\n", name);
+ ast_debug(2, "%s is not a local device, no call limit\n", name);
return 0;
}
@@ -3473,8 +3440,8 @@ static int update_call_counter(struct sip_pvt *fup, int event)
/* Decrement onhold count if applicable */
if (ast_test_flag(&fup->flags[1], SIP_PAGE2_CALL_ONHOLD) && global_notifyhold)
sip_peer_hold(fup, FALSE);
- if (option_debug > 1 || sipdebug)
- ast_log(LOG_DEBUG, "Call %s %s '%s' removed from call limit %d\n", outgoing ? "to" : "from", u ? "user":"peer", name, *call_limit);
+ if (sipdebug)
+ ast_debug(2, "Call %s %s '%s' removed from call limit %d\n", outgoing ? "to" : "from", u ? "user":"peer", name, *call_limit);
break;
case INC_CALL_RINGING:
@@ -3499,8 +3466,8 @@ static int update_call_counter(struct sip_pvt *fup, int event)
/* Continue */
ast_atomic_fetchadd_int(inuse, +1);
ast_set_flag(&fup->flags[0], SIP_INC_COUNT);
- if (option_debug > 1 || sipdebug) {
- ast_log(LOG_DEBUG, "Call %s %s '%s' is %d out of %d\n", outgoing ? "to" : "from", u ? "user":"peer", name, *inuse, *call_limit);
+ if (sipdebug) {
+ ast_debug(2, "Call %s %s '%s' is %d out of %d\n", outgoing ? "to" : "from", u ? "user":"peer", name, *inuse, *call_limit);
}
break;
@@ -3525,8 +3492,7 @@ static int update_call_counter(struct sip_pvt *fup, int event)
/*! \brief Destroy SIP call structure */
static void sip_destroy(struct sip_pvt *p)
{
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Destroying SIP dialog %s\n", p->callid);
+ ast_debug(3, "Destroying SIP dialog %s\n", p->callid);
__sip_destroy(p, TRUE, TRUE);
}
@@ -3681,8 +3647,7 @@ static const char *hangup_cause2sip(int cause)
case AST_CAUSE_NOTDEFINED:
default:
- if (option_debug)
- ast_log(LOG_DEBUG, "AST hangup cause %d (no match found in SIP)\n", cause);
+ ast_debug(1, "AST hangup cause %d (no match found in SIP)\n", cause);
return NULL;
}
@@ -3701,19 +3666,17 @@ static int sip_hangup(struct ast_channel *ast)
struct ast_channel *oldowner = ast;
if (!p) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Asked to hangup channel that was not connected\n");
+ ast_debug(1, "Asked to hangup channel that was not connected\n");
return 0;
}
if (ast_test_flag(&p->flags[0], SIP_DEFER_BYE_ON_TRANSFER)) {
if (ast_test_flag(&p->flags[0], SIP_INC_COUNT)) {
- if (option_debug && sipdebug)
- ast_log(LOG_DEBUG, "update_call_counter(%s) - decrement call limit counter on hangup\n", p->username);
+ if (sipdebug)
+ ast_debug(1, "update_call_counter(%s) - decrement call limit counter on hangup\n", p->username);
update_call_counter(p, DEC_CALL_LIMIT);
}
- if (option_debug >3)
- ast_log(LOG_DEBUG, "SIP Transfer: Not hanging up right now... Rescheduling hangup for %s.\n", p->callid);
+ ast_debug(4, "SIP Transfer: Not hanging up right now... Rescheduling hangup for %s.\n", p->callid);
if (p->autokillid > -1)
sip_cancel_destroy(p);
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
@@ -3723,21 +3686,18 @@ static int sip_hangup(struct ast_channel *ast)
p->owner = NULL; /* Owner will be gone after we return, so take it away */
return 0;
}
- if (option_debug) {
- if (ast_test_flag(ast, AST_FLAG_ZOMBIE) && p->refer && option_debug)
- ast_log(LOG_DEBUG, "SIP Transfer: Hanging up Zombie channel %s after transfer ... Call-ID: %s\n", ast->name, p->callid);
- else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Hangup call %s, SIP callid %s)\n", ast->name, p->callid);
- }
- }
- if (option_debug && ast_test_flag(ast, AST_FLAG_ZOMBIE))
- ast_log(LOG_DEBUG, "Hanging up zombie call. Be scared.\n");
+ if (ast_test_flag(ast, AST_FLAG_ZOMBIE) && p->refer)
+ ast_debug(1, "SIP Transfer: Hanging up Zombie channel %s after transfer ... Call-ID: %s\n", ast->name, p->callid);
+ else
+ ast_debug(1, "Hangup call %s, SIP callid %s)\n", ast->name, p->callid);
+
+ if (ast_test_flag(ast, AST_FLAG_ZOMBIE))
+ ast_debug(1, "Hanging up zombie call. Be scared.\n");
sip_pvt_lock(p);
if (ast_test_flag(&p->flags[0], SIP_INC_COUNT)) {
- if (option_debug && sipdebug)
- ast_log(LOG_DEBUG, "update_call_counter(%s) - decrement call limit counter on hangup\n", p->username);
+ if (sipdebug)
+ ast_debug(1, "update_call_counter(%s) - decrement call limit counter on hangup\n", p->username);
update_call_counter(p, DEC_CALL_LIMIT);
}
@@ -3751,8 +3711,7 @@ static int sip_hangup(struct ast_channel *ast)
/* In case of re-invites, the call might be UP even though we have an incomplete invite transaction */
if (p->invitestate < INV_COMPLETED && p->owner->_state != AST_STATE_UP) {
needcancel = TRUE;
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "Hanging up channel in state %s (not UP)\n", ast_state2str(ast->_state));
+ ast_debug(4, "Hanging up channel in state %s (not UP)\n", ast_state2str(ast->_state));
}
stop_media_flows(p); /* Immediately stop RTP, VRTP and UDPTL as applicable */
@@ -3889,12 +3848,10 @@ static int sip_answer(struct ast_channel *ast)
try_suggested_sip_codec(p);
ast_setstate(ast, AST_STATE_UP);
- if (option_debug)
- ast_log(LOG_DEBUG, "SIP answering channel: %s\n", ast->name);
+ ast_debug(1, "SIP answering channel: %s\n", ast->name);
if (p->t38.state == T38_PEER_DIRECT) {
p->t38.state = T38_ENABLED;
- if (option_debug > 1)
- ast_log(LOG_DEBUG,"T38State change to %d on channel %s\n", p->t38.state, ast->name);
+ ast_debug(2,"T38State change to %d on channel %s\n", p->t38.state, ast->name);
res = transmit_response_with_t38_sdp(p, "200 OK", &p->initreq, XMIT_CRITICAL);
} else
res = transmit_response_with_sdp(p, "200 OK", &p->initreq, XMIT_CRITICAL);
@@ -4003,10 +3960,10 @@ static int sip_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
int ret = -1;
struct sip_pvt *p;
- if (newchan && ast_test_flag(newchan, AST_FLAG_ZOMBIE) && option_debug)
- ast_log(LOG_DEBUG, "New channel is zombie\n");
- if (oldchan && ast_test_flag(oldchan, AST_FLAG_ZOMBIE) && option_debug)
- ast_log(LOG_DEBUG, "Old channel is zombie\n");
+ if (newchan && ast_test_flag(newchan, AST_FLAG_ZOMBIE))
+ ast_debug(1, "New channel is zombie\n");
+ if (oldchan && ast_test_flag(oldchan, AST_FLAG_ZOMBIE))
+ ast_debug(1, "Old channel is zombie\n");
if (!newchan || !newchan->tech_pvt) {
if (!newchan)
@@ -4026,8 +3983,7 @@ static int sip_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
p->owner = newchan;
ret = 0;
}
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "SIP Fixup: New owner for dialogue %s: %s (Old parent: %s)\n", p->callid, p->owner->name, oldchan->name);
+ ast_debug(3, "SIP Fixup: New owner for dialogue %s: %s (Old parent: %s)\n", p->callid, p->owner->name, oldchan->name);
sip_pvt_unlock(p);
return ret;
@@ -4252,15 +4208,13 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit
/* Set the native formats for audio and merge in video */
tmp->nativeformats = ast_codec_choose(&i->prefs, what, 1) | video | text;
- if (option_debug > 2) {
- char buf[BUFSIZ];
- ast_log(LOG_DEBUG, "*** Our native formats are %s \n", ast_getformatname_multiple(buf, BUFSIZ, tmp->nativeformats));
- ast_log(LOG_DEBUG, "*** Joint capabilities are %s \n", ast_getformatname_multiple(buf, BUFSIZ, i->jointcapability));
- ast_log(LOG_DEBUG, "*** Our capabilities are %s \n", ast_getformatname_multiple(buf, BUFSIZ, i->capability));
- ast_log(LOG_DEBUG, "*** AST_CODEC_CHOOSE formats are %s \n", ast_getformatname_multiple(buf, BUFSIZ, ast_codec_choose(&i->prefs, what, 1)));
- if (i->prefcodec)
- ast_log(LOG_DEBUG, "*** Our preferred formats from the incoming channel are %s \n", ast_getformatname_multiple(buf, BUFSIZ, i->prefcodec));
- }
+ char buf[BUFSIZ];
+ ast_debug(3, "*** Our native formats are %s \n", ast_getformatname_multiple(buf, BUFSIZ, tmp->nativeformats));
+ ast_debug(3, "*** Joint capabilities are %s \n", ast_getformatname_multiple(buf, BUFSIZ, i->jointcapability));
+ ast_debug(3, "*** Our capabilities are %s \n", ast_getformatname_multiple(buf, BUFSIZ, i->capability));
+ ast_debug(3, "*** AST_CODEC_CHOOSE formats are %s \n", ast_getformatname_multiple(buf, BUFSIZ, ast_codec_choose(&i->prefs, what, 1)));
+ if (i->prefcodec)
+ ast_debug(3, "*** Our preferred formats from the incoming channel are %s \n", ast_getformatname_multiple(buf, BUFSIZ, i->prefcodec));
/* XXX Why are we choosing a codec from the native formats?? */
fmt = ast_best_codec(tmp->nativeformats);
@@ -4283,12 +4237,10 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit
needtext = i->jointcapability & AST_FORMAT_TEXT_MASK; /* Inbound call */
}
- if (option_debug > 2) {
- if (needvideo)
- ast_log(LOG_DEBUG, "This channel can handle video! HOLLYWOOD next!\n");
- else
- ast_log(LOG_DEBUG, "This channel will not be able to handle video.\n");
- }
+ if (needvideo)
+ ast_debug(3, "This channel can handle video! HOLLYWOOD next!\n");
+ else
+ ast_debug(3, "This channel will not be able to handle video.\n");
@@ -4566,14 +4518,11 @@ static struct ast_frame *sip_rtp_read(struct ast_channel *ast, struct sip_pvt *p
if (f && f->subclass != (p->owner->nativeformats & AST_FORMAT_AUDIO_MASK)) {
if (!(f->subclass & p->jointcapability)) {
- if (option_debug) {
- ast_log(LOG_DEBUG, "Bogus frame of format '%s' received from '%s'!\n",
- ast_getformatname(f->subclass), p->owner->name);
- }
+ ast_debug(1, "Bogus frame of format '%s' received from '%s'!\n",
+ ast_getformatname(f->subclass), p->owner->name);
return &ast_null_frame;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
+ ast_debug(1, "Oooh, format changed to %d\n", f->subclass);
p->owner->nativeformats = (p->owner->nativeformats & (AST_FORMAT_VIDEO_MASK | AST_FORMAT_TEXT_MASK)) | f->subclass;
ast_set_read_format(p->owner, p->owner->readformat);
ast_set_write_format(p->owner, p->owner->writeformat);
@@ -4583,11 +4532,10 @@ static struct ast_frame *sip_rtp_read(struct ast_channel *ast, struct sip_pvt *p
f = ast_dsp_process(p->owner, p->vad, f);
if (f && f->frametype == AST_FRAME_DTMF) {
if (ast_test_flag(&p->t38.t38support, SIP_PAGE2_T38SUPPORT_UDPTL) && f->subclass == 'f') {
- if (option_debug)
- ast_log(LOG_DEBUG, "Fax CNG detected on %s\n", ast->name);
+ ast_debug(1, "Fax CNG detected on %s\n", ast->name);
*faxdetect = 1;
- } else if (option_debug) {
- ast_log(LOG_DEBUG, "* Detected inband DTMF '%c'\n", f->subclass);
+ } else {
+ ast_debug(1, "* Detected inband DTMF '%c'\n", f->subclass);
}
}
}
@@ -4611,16 +4559,13 @@ static struct ast_frame *sip_read(struct ast_channel *ast)
if (faxdetected && ast_test_flag(&p->t38.t38support, SIP_PAGE2_T38SUPPORT_UDPTL) && (p->t38.state == T38_DISABLED) && !(ast_bridged_channel(ast))) {
if (!ast_test_flag(&p->flags[0], SIP_GOTREFER)) {
if (!p->pendinginvite) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Sending reinvite on SIP (%s) for T.38 negotiation.\n",ast->name);
+ ast_debug(3, "Sending reinvite on SIP (%s) for T.38 negotiation.\n",ast->name);
p->t38.state = T38_LOCAL_REINVITE;
transmit_reinvite_with_sdp(p, TRUE);
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "T38 state changed to %d on channel %s\n", p->t38.state, ast->name);
+ ast_debug(2, "T38 state changed to %d on channel %s\n", p->t38.state, ast->name);
}
} else if (!ast_test_flag(&p->flags[0], SIP_PENDINGBYE)) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Deferring reinvite on SIP (%s) - it will be re-negotiated for T.38\n", ast->name);
+ ast_debug(3, "Deferring reinvite on SIP (%s) - it will be re-negotiated for T.38\n", ast->name);
ast_set_flag(&p->flags[0], SIP_NEEDREINVITE);
}
}
@@ -4799,8 +4744,7 @@ static struct sip_pvt *sip_alloc(ast_string_field callid, struct sockaddr_in *si
p->next = dialoglist;
dialoglist = p;
dialoglist_unlock();
- if (option_debug)
- ast_log(LOG_DEBUG, "Allocating new SIP dialog for %s - %s (%s)\n", callid ? callid : "(No Call-ID)", sip_methods[intended_method].text, p->rtp ? "With RTP" : "No RTP");
+ ast_debug(1, "Allocating new SIP dialog for %s - %s (%s)\n", callid ? callid : "(No Call-ID)", sip_methods[intended_method].text, p->rtp ? "With RTP" : "No RTP");
return p;
}
@@ -4836,19 +4780,16 @@ static struct sip_pvt *find_call(struct sip_request *req, struct sockaddr_in *si
tag = (req->method == SIP_RESPONSE) ? totag : fromtag;
- if (option_debug > 4 )
- ast_log(LOG_DEBUG, "= Looking for Call ID: %s (Checking %s) --From tag %s --To-tag %s \n", callid, req->method==SIP_RESPONSE ? "To" : "From", fromtag, totag);
+ ast_debug(5, "= Looking for Call ID: %s (Checking %s) --From tag %s --To-tag %s \n", callid, req->method==SIP_RESPONSE ? "To" : "From", fromtag, totag);
/* All messages must always have From: tag */
if (ast_strlen_zero(fromtag)) {
- if (option_debug > 4 )
- ast_log(LOG_DEBUG, "%s request has no from tag, dropping callid: %s from: %s\n", sip_methods[req->method].text , callid, from );
+ ast_debug(5, "%s request has no from tag, dropping callid: %s from: %s\n", sip_methods[req->method].text , callid, from );
return NULL;
}
/* reject requests that must always have a To: tag */
if (ast_strlen_zero(totag) && (req->method == SIP_ACK || req->method == SIP_BYE || req->method == SIP_INFO )) {
- if (option_debug > 4)
- ast_log(LOG_DEBUG, "%s must have a to tag. dropping callid: %s from: %s\n", sip_methods[req->method].text , callid, from );
+ ast_debug(5, "%s must have a to tag. dropping callid: %s from: %s\n", sip_methods[req->method].text , callid, from );
return NULL;
}
}
@@ -4865,8 +4806,7 @@ static struct sip_pvt *find_call(struct sip_request *req, struct sockaddr_in *si
found = (!strcmp(p->callid, callid) &&
(!pedanticsipchecking || !tag || ast_strlen_zero(p->theirtag) || !strcmp(p->theirtag, tag))) ;
- if (option_debug > 4)
- ast_log(LOG_DEBUG, "= %s Their Call ID: %s Their Tag %s Our tag: %s\n", found ? "Found" : "No match", p->callid, p->theirtag, p->tag);
+ ast_debug(5, "= %s Their Call ID: %s Their Tag %s Our tag: %s\n", found ? "Found" : "No match", p->callid, p->theirtag, p->tag);
/* If we get a new request within an existing to-tag - check the to tag as well */
if (pedanticsipchecking && found && req->method != SIP_RESPONSE) { /* SIP Request */
@@ -4878,8 +4818,8 @@ static struct sip_pvt *find_call(struct sip_request *req, struct sockaddr_in *si
found = FALSE; /* This is not our packet */
}
}
- if (!found && option_debug > 4)
- ast_log(LOG_DEBUG, "= Being pedantic: This is not our match on request: Call ID: %s Ourtag <null> Totag %s Method %s\n", p->callid, totag, sip_methods[req->method].text);
+ if (!found)
+ ast_debug(5, "= Being pedantic: This is not our match on request: Call ID: %s Ourtag <null> Totag %s Method %s\n", p->callid, totag, sip_methods[req->method].text);
}
@@ -4916,26 +4856,23 @@ static struct sip_pvt *find_call(struct sip_request *req, struct sockaddr_in *si
Sorry, we apologize for the inconvienience
*/
transmit_response_using_temp(callid, sin, 1, intended_method, req, "500 Server internal error");
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "Failed allocating SIP dialog, sending 500 Server internal error and giving up\n");
+ ast_debug(4, "Failed allocating SIP dialog, sending 500 Server internal error and giving up\n");
}
}
return p;
} else if( sip_methods[intended_method].can_create == CAN_CREATE_DIALOG_UNSUPPORTED_METHOD) {
/* A method we do not support, let's take it on the volley */
transmit_response_using_temp(callid, sin, 1, intended_method, req, "501 Method Not Implemented");
- if (option_debug > 1 )
- ast_log(LOG_DEBUG, "Got a request with unsupported SIP method.\n");
+ ast_debug(2, "Got a request with unsupported SIP method.\n");
} else if (intended_method != SIP_RESPONSE && intended_method != SIP_ACK) {
/* This is a request outside of a dialog that we don't know about */
transmit_response_using_temp(callid, sin, 1, intended_method, req, "481 Call leg/transaction does not exist");
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "That's odd... Got a request in unknown dialog. Callid %s\n", callid ? callid : "<unknown>");
+ ast_debug(2, "That's odd... Got a request in unknown dialog. Callid %s\n", callid ? callid : "<unknown>");
}
/* We do not respond to responses for dialogs that we don't know about, we just drop
the session quickly */
- if (option_debug > 1 && intended_method == SIP_RESPONSE)
- ast_log(LOG_DEBUG, "That's odd... Got a response on a call we dont know about. Callid %s\n", callid ? callid : "<unknown>");
+ if (intended_method == SIP_RESPONSE)
+ ast_debug(2, "That's odd... Got a response on a call we dont know about. Callid %s\n", callid ? callid : "<unknown>");
return p;
}
@@ -5079,8 +5016,8 @@ static void parse_request(struct sip_request *req)
*c = '\0';
else if (*c == '\n') { /* end of this line */
*c = '\0';
- if (sipdebug && option_debug > 3)
- ast_log(LOG_DEBUG, "%7s %2d [%3d]: %s\n",
+ if (sipdebug)
+ ast_debug(4, "%7s %2d [%3d]: %s\n",
req->headers < 0 ? "Header" : "Body",
i, (int)strlen(dst[i]), dst[i]);
if (ast_strlen_zero(dst[i]) && req->headers < 0) {
@@ -5099,8 +5036,8 @@ static void parse_request(struct sip_request *req)
but since some devices send without, we'll be generous in what we accept.
*/
if (!ast_strlen_zero(dst[i])) {
- if (sipdebug && option_debug > 3)
- ast_log(LOG_DEBUG, "%7s %2d [%3d]: %s\n",
+ if (sipdebug)
+ ast_debug(4, "%7s %2d [%3d]: %s\n",
req->headers < 0 ? "Header" : "Body",
i, (int)strlen(dst[i]), dst[i]);
i++;
@@ -5368,12 +5305,10 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
if (p->owner && p->lastinvite) {
p->t38.state = T38_PEER_REINVITE; /* T38 Offered in re-invite from remote party */
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>" );
+ ast_debug(2, "T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>" );
} else {
p->t38.state = T38_PEER_DIRECT; /* T38 Offered directly from peer in first invite */
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
+ ast_debug(2, "T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
}
} else
ast_log(LOG_WARNING, "Unsupported SDP media type in offer: %s\n", m);
@@ -5433,11 +5368,11 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
sin.sin_port = htons(udptlportno);
ast_udptl_set_peer(p->udptl, &sin);
if (debug)
- ast_log(LOG_DEBUG,"Peer T.38 UDPTL is at port %s:%d\n",ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
+ ast_debug(1,"Peer T.38 UDPTL is at port %s:%d\n",ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
} else {
ast_udptl_stop(p->udptl);
if (debug)
- ast_log(LOG_DEBUG, "Peer doesn't provide T.38 UDPTL\n");
+ ast_debug(1, "Peer doesn't provide T.38 UDPTL\n");
}
}
@@ -5529,8 +5464,7 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
framing = strtol(tmp, NULL, 10);
if (framing == LONG_MIN || framing == LONG_MAX) {
framing = 0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Can't read framing from SDP: %s\n", a);
+ ast_debug(1, "Can't read framing from SDP: %s\n", a);
}
}
if (framing && last_rtpmap_codec) {
@@ -5542,8 +5476,7 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
format = ast_rtp_codec_getformat(found_rtpmap_codecs[codec_n]);
if (!format) /* non-codec or not found */
continue;
- if (option_debug)
- ast_log(LOG_DEBUG, "Setting framing for %d to %ld\n", format, framing);
+ ast_debug(1, "Setting framing for %d to %ld\n", format, framing);
ast_codec_pref_setsize(pref, format, framing);
}
ast_rtp_codec_setpref(p->rtp, pref);
@@ -5585,12 +5518,10 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
while ((a = get_sdp_iterate(&iterator, req, "a"))[0] != '\0') {
if ((sscanf(a, "T38FaxMaxBuffer:%d", &x) == 1)) {
found = 1;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "MaxBufferSize:%d\n",x);
+ ast_debug(3, "MaxBufferSize:%d\n",x);
} else if ((sscanf(a, "T38MaxBitRate:%d", &x) == 1)) {
found = 1;
- if (option_debug > 2)
- ast_log(LOG_DEBUG,"T38MaxBitRate: %d\n",x);
+ ast_debug(3,"T38MaxBitRate: %d\n",x);
switch (x) {
case 14400:
peert38capability |= T38FAX_RATE_14400 | T38FAX_RATE_12000 | T38FAX_RATE_9600 | T38FAX_RATE_7200 | T38FAX_RATE_4800 | T38FAX_RATE_2400;
@@ -5613,49 +5544,42 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
}
} else if ((sscanf(a, "T38FaxVersion:%d", &x) == 1)) {
found = 1;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "FaxVersion: %d\n",x);
+ ast_debug(3, "FaxVersion: %d\n",x);
if (x == 0)
peert38capability |= T38FAX_VERSION_0;
else if (x == 1)
peert38capability |= T38FAX_VERSION_1;
} else if ((sscanf(a, "T38FaxMaxDatagram:%d", &x) == 1)) {
found = 1;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "FaxMaxDatagram: %d\n",x);
+ ast_debug(3, "FaxMaxDatagram: %d\n",x);
ast_udptl_set_far_max_datagram(p->udptl, x);
ast_udptl_set_local_max_datagram(p->udptl, x);
} else if ((sscanf(a, "T38FaxFillBitRemoval:%d", &x) == 1)) {
found = 1;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "FillBitRemoval: %d\n",x);
+ ast_debug(3, "FillBitRemoval: %d\n",x);
if (x == 1)
peert38capability |= T38FAX_FILL_BIT_REMOVAL;
} else if ((sscanf(a, "T38FaxTranscodingMMR:%d", &x) == 1)) {
found = 1;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Transcoding MMR: %d\n",x);
+ ast_debug(3, "Transcoding MMR: %d\n",x);
if (x == 1)
peert38capability |= T38FAX_TRANSCODING_MMR;
}
if ((sscanf(a, "T38FaxTranscodingJBIG:%d", &x) == 1)) {
found = 1;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Transcoding JBIG: %d\n",x);
+ ast_debug(3, "Transcoding JBIG: %d\n",x);
if (x == 1)
peert38capability |= T38FAX_TRANSCODING_JBIG;
} else if ((sscanf(a, "T38FaxRateManagement:%255s", s) == 1)) {
found = 1;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "RateManagement: %s\n", s);
+ ast_debug(3, "RateManagement: %s\n", s);
if (!strcasecmp(s, "localTCF"))
peert38capability |= T38FAX_RATE_MANAGEMENT_LOCAL_TCF;
else if (!strcasecmp(s, "transferredTCF"))
peert38capability |= T38FAX_RATE_MANAGEMENT_TRANSFERED_TCF;
} else if ((sscanf(a, "T38FaxUdpEC:%255s", s) == 1)) {
found = 1;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "UDP EC: %s\n", s);
+ ast_debug(3, "UDP EC: %s\n", s);
if (!strcasecmp(s, "t38UDPRedundancy")) {
peert38capability |= T38FAX_UDP_EC_REDUNDANCY;
ast_udptl_set_error_correction_scheme(p->udptl, UDPTL_ERROR_CORRECTION_REDUNDANCY);
@@ -5675,14 +5599,13 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
p->t38.jointcapability |= (peert38capability & p->t38.capability); /* Put the lower of our's and peer's speed */
}
if (debug)
- ast_log(LOG_DEBUG, "Our T38 capability = (%d), peer T38 capability (%d), joint T38 capability (%d)\n",
+ ast_debug(1, "Our T38 capability = (%d), peer T38 capability (%d), joint T38 capability (%d)\n",
p->t38.capability,
p->t38.peercapability,
p->t38.jointcapability);
} else {
p->t38.state = T38_DISABLED;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
+ ast_debug(3, "T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
}
/* Now gather all of the codecs that we are asked for: */
@@ -5718,8 +5641,7 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
/* Do NOT Change current setting */
return -1;
} else {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Have T.38 but no audio codecs, accepting offer anyway\n");
+ ast_debug(3, "Have T.38 but no audio codecs, accepting offer anyway\n");
return 0;
}
}
@@ -5771,21 +5693,18 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req)
}
/* Ok, we're going with this offer */
- if (option_debug > 1) {
- char buf[BUFSIZ];
- ast_log(LOG_DEBUG, "We're settling with these formats: %s\n", ast_getformatname_multiple(buf, BUFSIZ, p->jointcapability));
- }
+ char buf[BUFSIZ];
+ ast_debug(2, "We're settling with these formats: %s\n", ast_getformatname_multiple(buf, BUFSIZ, p->jointcapability));
if (!p->owner) /* There's no open channel owning us so we can return here. For a re-invite or so, we proceed */
return 0;
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "We have an owner, now see if we need to change this call\n");
+ ast_debug(4, "We have an owner, now see if we need to change this call\n");
if (!(p->owner->nativeformats & p->jointcapability) && (p->jointcapability & AST_FORMAT_AUDIO_MASK)) {
if (debug) {
char s1[BUFSIZ], s2[BUFSIZ];
- ast_log(LOG_DEBUG, "Oooh, we need to change our audio formats since our peer supports only %s and not %s\n",
+ ast_debug(1, "Oooh, we need to change our audio formats since our peer supports only %s and not %s\n",
ast_getformatname_multiple(s1, BUFSIZ, p->jointcapability),
ast_getformatname_multiple(s2, BUFSIZ, p->owner->nativeformats));
}
@@ -6212,7 +6131,7 @@ static int reqprep(struct sip_request *req, struct sip_pvt *p, int sipmethod, in
if (p->route && !ast_strlen_zero(p->route->hop) && strstr(p->route->hop,";lr") == NULL) {
is_strict = TRUE;
if (sipdebug)
- ast_log(LOG_DEBUG, "Strict routing enforced for session %s\n", p->callid);
+ ast_debug(1, "Strict routing enforced for session %s\n", p->callid);
}
if (sipmethod == SIP_CANCEL)
@@ -6589,32 +6508,25 @@ static int t38_get_rate(int t38cap)
int maxrate = (t38cap & (T38FAX_RATE_14400 | T38FAX_RATE_12000 | T38FAX_RATE_9600 | T38FAX_RATE_7200 | T38FAX_RATE_4800 | T38FAX_RATE_2400));
if (maxrate & T38FAX_RATE_14400) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "T38MaxFaxRate 14400 found\n");
+ ast_debug(2, "T38MaxFaxRate 14400 found\n");
return 14400;
} else if (maxrate & T38FAX_RATE_12000) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "T38MaxFaxRate 12000 found\n");
+ ast_debug(2, "T38MaxFaxRate 12000 found\n");
return 12000;
} else if (maxrate & T38FAX_RATE_9600) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "T38MaxFaxRate 9600 found\n");
+ ast_debug(2, "T38MaxFaxRate 9600 found\n");
return 9600;
} else if (maxrate & T38FAX_RATE_7200) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "T38MaxFaxRate 7200 found\n");
+ ast_debug(2, "T38MaxFaxRate 7200 found\n");
return 7200;
} else if (maxrate & T38FAX_RATE_4800) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "T38MaxFaxRate 4800 found\n");
+ ast_debug(2, "T38MaxFaxRate 4800 found\n");
return 4800;
} else if (maxrate & T38FAX_RATE_2400) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "T38MaxFaxRate 2400 found\n");
+ ast_debug(2, "T38MaxFaxRate 2400 found\n");
return 2400;
} else {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Strange, T38MaxFaxRate NOT found in peers T38 SDP.\n");
+ ast_debug(2, "Strange, T38MaxFaxRate NOT found in peers T38 SDP.\n");
return 0;
}
}
@@ -6665,13 +6577,13 @@ static int add_t38_sdp(struct sip_request *resp, struct sip_pvt *p)
}
if (debug)
- ast_log(LOG_DEBUG, "T.38 UDPTL is at %s port %d\n", ast_inet_ntoa(p->ourip), ntohs(udptlsin.sin_port));
+ ast_debug(1, "T.38 UDPTL is at %s port %d\n", ast_inet_ntoa(p->ourip), ntohs(udptlsin.sin_port));
/* We break with the "recommendation" and send our IP, in order that our
peer doesn't have to ast_gethostbyname() us */
if (debug) {
- ast_log(LOG_DEBUG, "Our T38 capability (%d), peer T38 capability (%d), joint capability (%d)\n",
+ ast_debug(1, "Our T38 capability (%d), peer T38 capability (%d), joint capability (%d)\n",
p->t38.capability,
p->t38.peercapability,
p->t38.jointcapability);
@@ -6841,12 +6753,10 @@ static enum sip_result add_sdp(struct sip_request *resp, struct sip_pvt *p)
capability = p->jointcapability;
- if (option_debug > 1) {
- char codecbuf[BUFSIZ];
- ast_log(LOG_DEBUG, "** Our capability: %s Video flag: %s Text flag: %s\n", ast_getformatname_multiple(codecbuf, sizeof(codecbuf), capability),
- ast_test_flag(&p->flags[0], SIP_NOVIDEO) ? "True" : "False", ast_test_flag(&p->flags[1], SIP_PAGE2_NOTEXT) ? "True" : "False");
- ast_log(LOG_DEBUG, "** Our prefcodec: %s \n", ast_getformatname_multiple(codecbuf, sizeof(codecbuf), p->prefcodec));
- }
+ char codecbuf[BUFSIZ];
+ ast_debug(1, "** Our capability: %s Video flag: %s Text flag: %s\n", ast_getformatname_multiple(codecbuf, sizeof(codecbuf), capability),
+ ast_test_flag(&p->flags[0], SIP_NOVIDEO) ? "True" : "False", ast_test_flag(&p->flags[1], SIP_PAGE2_NOTEXT) ? "True" : "False");
+ ast_debug(1, "** Our prefcodec: %s \n", ast_getformatname_multiple(codecbuf, sizeof(codecbuf), p->prefcodec));
#ifdef WHEN_WE_HAVE_T38_FOR_OTHER_TRANSPORTS
if (ast_test_flag(&p->t38.t38support, SIP_PAGE2_T38SUPPORT_RTP)) {
@@ -6859,10 +6769,9 @@ static enum sip_result add_sdp(struct sip_request *resp, struct sip_pvt *p)
if ((capability & AST_FORMAT_VIDEO_MASK) && !ast_test_flag(&p->flags[0], SIP_NOVIDEO)) {
if (p->vrtp) {
needvideo = TRUE;
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "This call needs video offers!\n");
- } else if (option_debug > 1)
- ast_log(LOG_DEBUG, "This call needs video offers, but there's no video support enabled!\n");
+ ast_debug(2, "This call needs video offers!\n");
+ } else
+ ast_debug(2, "This call needs video offers, but there's no video support enabled!\n");
}
/* Get our media addresses */
@@ -6889,10 +6798,9 @@ static enum sip_result add_sdp(struct sip_request *resp, struct sip_pvt *p)
if (p->trtp) {
if (sipdebug_text) ast_verbose("And we have a text rtp object\n");
needtext = TRUE;
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "This call needs text offers! \n");
- } else if (option_debug > 1)
- ast_log(LOG_DEBUG, "This call needs text offers, but there's no text support enabled ! \n");
+ ast_debug(2, "This call needs text offers! \n");
+ } else
+ ast_debug(2, "This call needs text offers, but there's no text support enabled ! \n");
}
/* Ok, we need text. Let's add what we need for text and set codecs.
@@ -7005,8 +6913,7 @@ static enum sip_result add_sdp(struct sip_request *resp, struct sip_pvt *p)
debug);
}
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "-- Done with adding codecs to SDP\n");
+ ast_debug(3, "-- Done with adding codecs to SDP\n");
if (!p->owner || !ast_internal_timing_enabled(p->owner))
ast_build_string(&a_audio_next, &a_audio_left, "a=silenceSupp:off - - - -\r\n");
@@ -7064,10 +6971,8 @@ static enum sip_result add_sdp(struct sip_request *resp, struct sip_pvt *p)
/* Update lastrtprx when we send our SDP */
p->lastrtprx = p->lastrtptx = time(NULL); /* XXX why both ? */
- if (option_debug > 2) {
- char buf[BUFSIZ];
- ast_log(LOG_DEBUG, "Done building SDP. Settling with this capability: %s\n", ast_getformatname_multiple(buf, BUFSIZ, capability));
- }
+ char buf[BUFSIZ];
+ ast_debug(3, "Done building SDP. Settling with this capability: %s\n", ast_getformatname_multiple(buf, BUFSIZ, capability));
return AST_SUCCESS;
}
@@ -7124,8 +7029,7 @@ static int transmit_response_with_sdp(struct sip_pvt *p, const char *msg, const
respprep(&resp, p, msg, req);
if (p->rtp) {
if (!p->autoframing && !ast_test_flag(&p->flags[0], SIP_OUTGOING)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Setting framing from config on incoming call\n");
+ ast_debug(1, "Setting framing from config on incoming call\n");
ast_rtp_codec_setpref(p->rtp, &p->prefs);
}
try_suggested_sip_codec(p);
@@ -7533,7 +7437,7 @@ static int transmit_invite(struct sip_pvt *p, int sipmethod, int sdp, int init)
add_header(&req, headdup, content);
if (sipdebug)
- ast_log(LOG_DEBUG, "Adding SIP Header \"%s\" with content :%s: \n", headdup, content);
+ ast_debug(1, "Adding SIP Header \"%s\" with content :%s: \n", headdup, content);
}
}
}
@@ -7542,8 +7446,7 @@ static int transmit_invite(struct sip_pvt *p, int sipmethod, int sdp, int init)
if (sdp) {
if (p->udptl && p->t38.state == T38_LOCAL_DIRECT) {
ast_udptl_offered_from_local(p->udptl, 1);
- if (option_debug)
- ast_log(LOG_DEBUG, "T38 is in state %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
+ ast_debug(1, "T38 is in state %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
add_t38_sdp(&req, p);
} else if (p->rtp)
add_sdp(&req, p);
@@ -8010,8 +7913,7 @@ static int transmit_register(struct sip_registry *r, int sipmethod, const char *
ast_sched_del(sched, r->timeout);
}
r->timeout = ast_sched_add(sched, global_reg_timeout * 1000, sip_reg_timeout, r);
- if (option_debug)
- ast_log(LOG_DEBUG, "Scheduled a registration timeout for %s id #%d \n", r->hostname, r->timeout);
+ ast_debug(1, "Scheduled a registration timeout for %s id #%d \n", r->hostname, r->timeout);
}
if (strchr(r->username, '@')) {
@@ -8069,7 +7971,7 @@ static int transmit_register(struct sip_registry *r, int sipmethod, const char *
/* We have auth data to reuse, build a digest header! */
if (sipdebug)
- ast_log(LOG_DEBUG, " >>> Re-using Auth data for %s@%s\n", r->username, r->hostname);
+ ast_debug(1, " >>> Re-using Auth data for %s@%s\n", r->username, r->hostname);
ast_string_field_set(p, realm, r->realm);
ast_string_field_set(p, nonce, r->nonce);
ast_string_field_set(p, domain, r->domain);
@@ -8137,8 +8039,8 @@ static int transmit_refer(struct sip_pvt *p, const char *dest)
char *ttag, *ftag;
char *theirtag = ast_strdupa(p->theirtag);
- if (option_debug || sipdebug)
- ast_log(LOG_DEBUG, "SIP transfer of %s to %s\n", p->callid, dest);
+ if (sipdebug)
+ ast_debug(1, "SIP transfer of %s to %s\n", p->callid, dest);
/* Are we transfering an inbound or outbound call ? */
if (ast_test_flag(&p->flags[0], SIP_OUTGOING)) {
@@ -8315,8 +8217,8 @@ static int expire_register(void *data)
/* Do we need to release this peer from memory?
Only for realtime peers and autocreated peers
*/
- if (option_debug > 2 && ast_test_flag(&peer->flags[0], SIP_REALTIME))
- ast_log(LOG_DEBUG,"-REALTIME- peer expired registration. Name: %s. Realtime peer objects now %d\n", peer->name, rpeerobjs);
+ if (ast_test_flag(&peer->flags[0], SIP_REALTIME))
+ ast_debug(3,"-REALTIME- peer expired registration. Name: %s. Realtime peer objects now %d\n", peer->name, rpeerobjs);
if (ast_test_flag(&peer->flags[1], SIP_PAGE2_SELFDESTRUCT) ||
ast_test_flag(&peer->flags[1], SIP_PAGE2_RTAUTOCLEAR)) {
@@ -8376,9 +8278,8 @@ static void reg_source_db(struct sip_peer *peer)
if (contact)
ast_copy_string(peer->fullcontact, contact, sizeof(peer->fullcontact));
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "SIP Seeding peer from astdb: '%s' at %s@%s:%d for %d\n",
- peer->name, peer->username, ast_inet_ntoa(in), port, expiry);
+ ast_debug(2, "SIP Seeding peer from astdb: '%s' at %s@%s:%d for %d\n",
+ peer->name, peer->username, ast_inet_ntoa(in), port, expiry);
memset(&peer->addr, 0, sizeof(peer->addr));
peer->addr.sin_family = AF_INET;
@@ -8626,8 +8527,7 @@ static void build_route(struct sip_pvt *p, struct sip_request *req, int backward
/* Once a persistant route is set, don't fool with it */
if (p->route && p->route_persistant) {
- if (option_debug)
- ast_log(LOG_DEBUG, "build_route: Retaining previous route: <%s>\n", p->route->hop);
+ ast_debug(1, "build_route: Retaining previous route: <%s>\n", p->route->hop);
return;
}
@@ -8658,8 +8558,7 @@ static void build_route(struct sip_pvt *p, struct sip_request *req, int backward
if ((thishop = ast_malloc(sizeof(*thishop) + len))) {
/* ast_calloc is not needed because all fields are initialized in this block */
ast_copy_string(thishop->hop, rr, len);
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "build_route: Record-Route hop: <%s>\n", thishop->hop);
+ ast_debug(2, "build_route: Record-Route hop: <%s>\n", thishop->hop);
/* Link in */
if (backwards) {
/* Link in at head so they end up in reverse order */
@@ -8687,8 +8586,7 @@ static void build_route(struct sip_pvt *p, struct sip_request *req, int backward
/* Can be multiple Contact headers, comma separated values - we just take the first */
contact = get_header(req, "Contact");
if (!ast_strlen_zero(contact)) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "build_route: Contact hop: %s\n", contact);
+ ast_debug(2, "build_route: Contact hop: %s\n", contact);
/* Look for <: delimited address */
c = strchr(contact, '<');
if (c) {
@@ -9308,8 +9206,7 @@ static int get_destination(struct sip_pvt *p, struct sip_request *oreq)
domain_context[0] = '\0';
if (!check_sip_domain(p->domain, domain_context, sizeof(domain_context))) {
if (!allow_external_domains && (req->method == SIP_INVITE || req->method == SIP_REFER)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Got SIP %s to non-local domain '%s'; refusing request.\n", sip_methods[req->method].text, p->domain);
+ ast_debug(1, "Got SIP %s to non-local domain '%s'; refusing request.\n", sip_methods[req->method].text, p->domain);
return -2;
}
}
@@ -9351,8 +9248,8 @@ static struct sip_pvt *get_sip_pvt_byid_locked(const char *callid, const char *t
struct sip_pvt *sip_pvt_ptr;
- if (option_debug > 3 && totag)
- ast_log(LOG_DEBUG, "Looking for callid %s (fromtag %s totag %s)\n", callid, fromtag ? fromtag : "<no fromtag>", totag ? totag : "<no totag>");
+ if (totag)
+ ast_debug(4, "Looking for callid %s (fromtag %s totag %s)\n", callid, fromtag ? fromtag : "<no fromtag>", totag ? totag : "<no totag>");
/* Search dialogs and find the match */
dialoglist_lock();
@@ -9376,8 +9273,8 @@ static struct sip_pvt *get_sip_pvt_byid_locked(const char *callid, const char *t
continue;
}
- if (option_debug > 3 && totag)
- ast_log(LOG_DEBUG, "Matched %s call - their tag is %s Our tag is %s\n",
+ if (totag)
+ ast_debug(4, "Matched %s call - their tag is %s Our tag is %s\n",
ast_test_flag(&sip_pvt_ptr->flags[0], SIP_OUTGOING) ? "OUTGOING": "INCOMING",
sip_pvt_ptr->theirtag, sip_pvt_ptr->tag);
@@ -9391,8 +9288,8 @@ static struct sip_pvt *get_sip_pvt_byid_locked(const char *callid, const char *t
}
}
dialoglist_unlock();
- if (option_debug > 3 && !sip_pvt_ptr)
- ast_log(LOG_DEBUG, "Found no match for callid %s to-tag %s from-tag %s\n", callid, totag, fromtag);
+ if (!sip_pvt_ptr)
+ ast_debug(4, "Found no match for callid %s to-tag %s from-tag %s\n", callid, totag, fromtag);
return sip_pvt_ptr;
}
@@ -9497,12 +9394,10 @@ static int get_refer_info(struct sip_pvt *transferer, struct sip_request *outgoi
ast_copy_string(referdata->replaces_callid_fromtag, ptr, sizeof(referdata->replaces_callid_fromtag));
}
- if (option_debug > 1) {
- if (!pedanticsipchecking)
- ast_log(LOG_DEBUG,"Attended transfer: Will use Replace-Call-ID : %s (No check of from/to tags)\n", referdata->replaces_callid );
- else
- ast_log(LOG_DEBUG,"Attended transfer: Will use Replace-Call-ID : %s F-tag: %s T-tag: %s\n", referdata->replaces_callid, referdata->replaces_callid_fromtag ? referdata->replaces_callid_fromtag : "<none>", referdata->replaces_callid_totag ? referdata->replaces_callid_totag : "<none>" );
- }
+ if (!pedanticsipchecking)
+ ast_debug(2,"Attended transfer: Will use Replace-Call-ID : %s (No check of from/to tags)\n", referdata->replaces_callid );
+ else
+ ast_debug(2,"Attended transfer: Will use Replace-Call-ID : %s F-tag: %s T-tag: %s\n", referdata->replaces_callid, referdata->replaces_callid_fromtag ? referdata->replaces_callid_fromtag : "<none>", referdata->replaces_callid_totag ? referdata->replaces_callid_totag : "<none>" );
}
}
@@ -9598,8 +9493,7 @@ static int get_also_info(struct sip_pvt *p, struct sip_request *oreq)
}
if (ast_exists_extension(NULL, transfer_context, c, 1, NULL)) {
/* This is a blind transfer */
- if (option_debug)
- ast_log(LOG_DEBUG,"SIP Bye-also transfer to Extension %s@%s \n", c, transfer_context);
+ ast_debug(1,"SIP Bye-also transfer to Extension %s@%s \n", c, transfer_context);
ast_copy_string(referdata->refer_to, c, sizeof(referdata->refer_to));
ast_copy_string(referdata->referred_by, "", sizeof(referdata->referred_by));
ast_copy_string(referdata->refer_contact, "", sizeof(referdata->refer_contact));
@@ -11669,17 +11563,17 @@ static void sip_dump_history(struct sip_pvt *dialog)
return;
}
- ast_log(LOG_DEBUG, "\n---------- SIP HISTORY for '%s' \n", dialog->callid);
+ ast_debug(1, "\n---------- SIP HISTORY for '%s' \n", dialog->callid);
if (dialog->subscribed)
- ast_log(LOG_DEBUG, " * Subscription\n");
+ ast_debug(1, " * Subscription\n");
else
- ast_log(LOG_DEBUG, " * SIP Call\n");
+ ast_debug(1, " * SIP Call\n");
if (dialog->history)
AST_LIST_TRAVERSE(dialog->history, hist, list)
- ast_log(LOG_DEBUG, " %-3.3d. %s\n", ++x, hist->event);
+ ast_debug(1, " %-3.3d. %s\n", ++x, hist->event);
if (!x)
- ast_log(LOG_DEBUG, "Call '%s' has no history\n", dialog->callid);
- ast_log(LOG_DEBUG, "\n---------- END SIP HISTORY for '%s' \n", dialog->callid);
+ ast_debug(1, "Call '%s' has no history\n", dialog->callid);
+ ast_debug(1, "\n---------- END SIP HISTORY for '%s' \n", dialog->callid);
}
@@ -11803,8 +11697,7 @@ static void handle_request_info(struct sip_pvt *p, struct sip_request *req)
}
ast_unlock_call_features();
- if (option_debug)
- ast_log(LOG_DEBUG, "Got a Request to Record the channel, state %s\n", c);
+ ast_debug(1, "Got a Request to Record the channel, state %s\n", c);
transmit_response(p, "200 OK", req);
return;
}
@@ -12015,8 +11908,7 @@ static int do_proxy_auth(struct sip_pvt *p, struct sip_request *req, enum sip_au
p->authtries++;
auth_headers(code, &header, &respheader);
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Auth attempt %d on %s\n", p->authtries, sip_methods[sipmethod].text);
+ ast_debug(2, "Auth attempt %d on %s\n", p->authtries, sip_methods[sipmethod].text);
memset(digest, 0, sizeof(digest));
if (reply_digest(p, req, header, sipmethod, digest, sizeof(digest) )) {
/* No way to authenticate */
@@ -12138,7 +12030,7 @@ static int build_reply_digest(struct sip_pvt *p, int method, char* digest, int d
secret = auth->secret;
md5secret = auth->md5secret;
if (sipdebug)
- ast_log(LOG_DEBUG,"Using realm %s authentication for call %s\n", p->realm, p->callid);
+ ast_debug(1,"Using realm %s authentication for call %s\n", p->realm, p->callid);
} else {
/* No authentication, use peer or register= config */
username = p->authname;
@@ -12545,8 +12437,7 @@ static void parse_moved_contact(struct sip_pvt *p, struct sip_request *req)
e = strchr(s, '/');
if (e)
*e = '\0';
- if (option_debug)
- ast_log(LOG_DEBUG, "Found promiscuous redirection to 'SIP/%s'\n", s);
+ ast_debug(2, "Found promiscuous redirection to 'SIP/%s'\n", s);
if (p->owner)
ast_string_field_build(p->owner, call_forward, "SIP/%s", s);
} else {
@@ -12567,8 +12458,7 @@ static void parse_moved_contact(struct sip_pvt *p, struct sip_request *req)
e = strchr(s, ';'); /* And username ; parameters? */
if (e)
*e = '\0';
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Received 302 Redirect to extension '%s' (domain %s)\n", s, domain);
+ ast_debug(2, "Received 302 Redirect to extension '%s' (domain %s)\n", s, domain);
if (p->owner) {
pbx_builtin_setvar_helper(p->owner, "SIPDOMAIN", domain);
ast_string_field_set(p->owner, call_forward, s);
@@ -12590,8 +12480,7 @@ static void check_pendings(struct sip_pvt *p)
ast_clear_flag(&p->flags[0], SIP_PENDINGBYE);
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
} else if (ast_test_flag(&p->flags[0], SIP_NEEDREINVITE)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Sending pending reinvite on '%s'\n", p->callid);
+ ast_debug(2, "Sending pending reinvite on '%s'\n", p->callid);
/* Didn't get to reinvite yet, so do it now */
transmit_reinvite_with_sdp(p, FALSE);
ast_clear_flag(&p->flags[0], SIP_NEEDREINVITE);
@@ -12607,16 +12496,13 @@ static void handle_response_invite(struct sip_pvt *p, int resp, char *rest, stru
int reinvite = (p->owner && p->owner->_state == AST_STATE_UP);
struct ast_channel *bridgepeer = NULL;
- if (option_debug > 3) {
- if (reinvite)
- ast_log(LOG_DEBUG, "SIP response %d to RE-invite on %s call %s\n", resp, outgoing ? "outgoing" : "incoming", p->callid);
- else
- ast_log(LOG_DEBUG, "SIP response %d to standard invite\n", resp);
- }
+ if (reinvite)
+ ast_debug(4, "SIP response %d to RE-invite on %s call %s\n", resp, outgoing ? "outgoing" : "incoming", p->callid);
+ else
+ ast_debug(4, "SIP response %d to standard invite\n", resp);
if (ast_test_flag(&p->flags[0], SIP_ALREADYGONE)) { /* This call is already gone */
- if (option_debug)
- ast_log(LOG_DEBUG, "Got response on call that is already terminated: %s (ignoring)\n", p->callid);
+ ast_debug(1, "Got response on call that is already terminated: %s (ignoring)\n", p->callid);
return;
}
@@ -12741,31 +12627,25 @@ static void handle_response_invite(struct sip_pvt *p, int resp, char *rest, stru
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
}
} else {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Strange... The other side of the bridge does not have a udptl struct\n");
+ ast_debug(2, "Strange... The other side of the bridge does not have a udptl struct\n");
sip_pvt_lock(bridgepvt);
bridgepvt->t38.state = T38_DISABLED;
sip_pvt_unlock(bridgepvt);
- if (option_debug)
- ast_log(LOG_DEBUG,"T38 state changed to %d on channel %s\n", bridgepvt->t38.state, bridgepeer->tech->type);
+ ast_debug(1,"T38 state changed to %d on channel %s\n", bridgepvt->t38.state, bridgepeer->tech->type);
p->t38.state = T38_DISABLED;
- if (option_debug > 1)
- ast_log(LOG_DEBUG,"T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
+ ast_debug(2,"T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
}
} else {
/* Other side is not a SIP channel */
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Strange... The other side of the bridge is not a SIP channel\n");
+ ast_debug(2, "Strange... The other side of the bridge is not a SIP channel\n");
p->t38.state = T38_DISABLED;
- if (option_debug > 1)
- ast_log(LOG_DEBUG,"T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
+ ast_debug(2,"T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
}
}
if ((p->t38.state == T38_LOCAL_REINVITE) || (p->t38.state == T38_LOCAL_DIRECT)) {
/* If there was T38 reinvite and we are supposed to answer with 200 OK than this should set us to T38 negotiated mode */
p->t38.state = T38_ENABLED;
- if (option_debug)
- ast_log(LOG_DEBUG, "T38 changed state to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
+ ast_debug(1, "T38 changed state to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
}
if (!ast_test_flag(req, SIP_PKT_IGNORE) && p->owner) {
@@ -12916,8 +12796,7 @@ static void handle_response_refer(struct sip_pvt *p, int resp, char *rest, struc
/* The transferee is now sending INVITE to target */
p->refer->status = REFER_ACCEPTED;
/* Now wait for next message */
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Got 202 accepted on transfer\n");
+ ast_debug(3, "Got 202 accepted on transfer\n");
/* We should hang along, waiting for NOTIFY's here */
break;
@@ -13042,11 +12921,9 @@ static int handle_response_register(struct sip_pvt *p, int resp, char *rest, str
r->regtime = time(NULL); /* Reset time of last succesful registration */
manager_event(EVENT_FLAG_SYSTEM, "Registry", "ChannelType: SIP\r\nDomain: %s\r\nStatus: %s\r\n", r->hostname, regstate2str(r->regstate));
r->regattempts = 0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Registration successful\n");
+ ast_debug(1, "Registration successful\n");
if (r->timeout > -1) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Cancelling timeout %d\n", r->timeout);
+ ast_debug(1, "Cancelling timeout %d\n", r->timeout);
ast_sched_del(sched, r->timeout);
}
r->timeout=-1;
@@ -13240,8 +13117,8 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_
if (!p->refer) {
ast_log(LOG_WARNING, "Notify answer on an owned channel? - %s\n", p->owner->name);
ast_queue_hangup(p->owner);
- } else if (option_debug > 3)
- ast_log(LOG_DEBUG, "Got OK on REFER Notify message\n");
+ } else
+ ast_debug(4, "Got OK on REFER Notify message\n");
} else {
if (p->subscribed == NONE)
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
@@ -13308,8 +13185,7 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_
res = handle_response_register(p, resp, rest, req, seqno);
else if (sipmethod == SIP_BYE) {
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
- if (option_debug)
- ast_log(LOG_DEBUG, "Got timeout on bye. Thanks for the answer. Now, kill this call\n");
+ ast_debug(4, "Got timeout on bye. Thanks for the answer. Now, kill this call\n");
} else {
if (owner)
ast_queue_control(p->owner, AST_CONTROL_CONGESTION);
@@ -13346,8 +13222,7 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_
if (sipmethod == SIP_INVITE)
handle_response_invite(p, resp, rest, req, seqno);
else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Got 491 on %s, unspported. Call ID %s\n", sip_methods[sipmethod].text, p->callid);
+ ast_debug(1, "Got 491 on %s, unspported. Call ID %s\n", sip_methods[sipmethod].text, p->callid);
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
}
break;
@@ -13393,8 +13268,7 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_
is yet another failure of not having a layer 2 (again, YAY
IETF for thinking ahead). So we treat this as a call
forward and hope we end up at the right place... */
- if (option_debug)
- ast_log(LOG_DEBUG, "Hairpin detected, setting up call forward for what it's worth\n");
+ ast_debug(1, "Hairpin detected, setting up call forward for what it's worth\n");
if (p->owner)
ast_string_field_build(p->owner, call_forward,
"Local/%s@%s", p->username, p->context);
@@ -13461,16 +13335,14 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_
if (sipmethod == SIP_INVITE) {
handle_response_invite(p, resp, rest, req, seqno);
} else if (sipmethod == SIP_CANCEL) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Got 200 OK on CANCEL\n");
+ ast_debug(1, "Got 200 OK on CANCEL\n");
/* Wait for 487, then destroy */
} else if (sipmethod == SIP_NOTIFY) {
/* They got the notify, this is the end */
if (p->owner) {
if (p->refer) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Got 200 OK on NOTIFY for transfer\n");
+ ast_debug(1, "Got 200 OK on NOTIFY for transfer\n");
} else
ast_log(LOG_WARNING, "Notify answer on an owned channel?\n");
/* ast_queue_hangup(p->owner); Disabled */
@@ -13512,7 +13384,7 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_
} else if (sipmethod == SIP_BYE) {
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
} else if (sipdebug) {
- ast_log (LOG_DEBUG, "Remote host can't match request %s to call '%s'. Giving up\n", sip_methods[sipmethod].text, p->callid);
+ ast_debug(1, "Remote host can't match request %s to call '%s'. Giving up\n", sip_methods[sipmethod].text, p->callid);
}
break;
case 501: /* Not Implemented */
@@ -13579,8 +13451,7 @@ static void *sip_park_thread(void *stuff)
ast_log(LOG_ERROR, "Missing channels for parking! Transferer %s Transferee %s\n", transferer ? "<available>" : "<missing>", transferee ? "<available>" : "<missing>" );
return NULL;
}
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "SIP Park: Transferer channel %s, Transferee %s\n", transferer->name, transferee->name);
+ ast_debug(4, "SIP Park: Transferer channel %s, Transferee %s\n", transferer->name, transferee->name);
ast_channel_lock(transferee);
if (ast_do_masquerade(transferee)) {
@@ -13613,13 +13484,11 @@ static void *sip_park_thread(void *stuff)
transmit_notify_with_sipfrag(transferer->tech_pvt, d->seqno, "200 OK", TRUE);
transferer->hangupcause = AST_CAUSE_NORMAL_CLEARING;
ast_hangup(transferer); /* This will cause a BYE */
- if (option_debug)
- ast_log(LOG_DEBUG, "SIP Call parked on extension '%d'\n", ext);
+ ast_debug(1, "SIP Call parked on extension '%d'\n", ext);
} else {
transmit_notify_with_sipfrag(transferer->tech_pvt, d->seqno, "503 Service Unavailable", TRUE);
append_history(transferer->tech_pvt, "SIPpark","Parking failed\n");
- if (option_debug)
- ast_log(LOG_DEBUG, "SIP Call parked failed \n");
+ ast_debug(1, "SIP Call parked failed \n");
/* Do not hangup call */
}
return NULL;
@@ -13687,12 +13556,10 @@ static int sip_park(struct ast_channel *chan1, struct ast_channel *chan2, struct
ast_channel_unlock(transferer);
if (!transferer || !transferee) {
if (!transferer) {
- if (option_debug)
- ast_log(LOG_DEBUG, "No transferer channel, giving up parking\n");
+ ast_debug(1, "No transferer channel, giving up parking\n");
}
if (!transferee) {
- if (option_debug)
- ast_log(LOG_DEBUG, "No transferee channel, giving up parking\n");
+ ast_debug(1, "No transferee channel, giving up parking\n");
}
return -1;
}
@@ -13737,40 +13604,36 @@ static int attempt_transfer(struct sip_dual *transferer, struct sip_dual *target
/* We will try to connect the transferee with the target and hangup
all channels to the transferer */
- if (option_debug > 3) {
- ast_log(LOG_DEBUG, "Sip transfer:--------------------\n");
- if (transferer->chan1)
- ast_log(LOG_DEBUG, "-- Transferer to PBX channel: %s State %s\n", transferer->chan1->name, ast_state2str(transferer->chan1->_state));
- else
- ast_log(LOG_DEBUG, "-- No transferer first channel - odd??? \n");
- if (target->chan1)
- ast_log(LOG_DEBUG, "-- Transferer to PBX second channel (target): %s State %s\n", target->chan1->name, ast_state2str(target->chan1->_state));
- else
- ast_log(LOG_DEBUG, "-- No target first channel ---\n");
- if (transferer->chan2)
- ast_log(LOG_DEBUG, "-- Bridged call to transferee: %s State %s\n", transferer->chan2->name, ast_state2str(transferer->chan2->_state));
- else
- ast_log(LOG_DEBUG, "-- No bridged call to transferee\n");
- if (target->chan2)
- ast_log(LOG_DEBUG, "-- Bridged call to transfer target: %s State %s\n", target->chan2 ? target->chan2->name : "<none>", target->chan2 ? ast_state2str(target->chan2->_state) : "(none)");
- else
- ast_log(LOG_DEBUG, "-- No target second channel ---\n");
- ast_log(LOG_DEBUG, "-- END Sip transfer:--------------------\n");
- }
+ ast_debug(4, "Sip transfer:--------------------\n");
+ if (transferer->chan1)
+ ast_debug(4, "-- Transferer to PBX channel: %s State %s\n", transferer->chan1->name, ast_state2str(transferer->chan1->_state));
+ else
+ ast_debug(4, "-- No transferer first channel - odd??? \n");
+ if (target->chan1)
+ ast_debug(4, "-- Transferer to PBX second channel (target): %s State %s\n", target->chan1->name, ast_state2str(target->chan1->_state));
+ else
+ ast_debug(4, "-- No target first channel ---\n");
+ if (transferer->chan2)
+ ast_debug(4, "-- Bridged call to transferee: %s State %s\n", transferer->chan2->name, ast_state2str(transferer->chan2->_state));
+ else
+ ast_debug(4, "-- No bridged call to transferee\n");
+ if (target->chan2)
+ ast_debug(4, "-- Bridged call to transfer target: %s State %s\n", target->chan2 ? target->chan2->name : "<none>", target->chan2 ? ast_state2str(target->chan2->_state) : "(none)");
+ else
+ ast_debug(4, "-- No target second channel ---\n");
+ ast_debug(4, "-- END Sip transfer:--------------------\n");
if (transferer->chan2) { /* We have a bridge on the transferer's channel */
peera = transferer->chan1; /* Transferer - PBX -> transferee channel * the one we hangup */
peerb = target->chan1; /* Transferer - PBX -> target channel - This will get lost in masq */
peerc = transferer->chan2; /* Asterisk to Transferee */
peerd = target->chan2; /* Asterisk to Target */
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "SIP transfer: Four channels to handle\n");
+ ast_debug(3, "SIP transfer: Four channels to handle\n");
} else if (target->chan2) { /* Transferer has no bridge (IVR), but transferee */
peera = target->chan1; /* Transferer to PBX -> target channel */
peerb = transferer->chan1; /* Transferer to IVR*/
peerc = target->chan2; /* Asterisk to Target */
peerd = transferer->chan2; /* Nothing */
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "SIP transfer: Three channels to handle\n");
+ ast_debug(3, "SIP transfer: Three channels to handle\n");
}
if (peera && peerb && peerc && (peerb != peerc)) {
@@ -13793,13 +13656,12 @@ static int attempt_transfer(struct sip_dual *transferer, struct sip_dual *target
peerb->cdr = peerc->cdr;
peerc->cdr = NULL;
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "SIP transfer: trying to masquerade %s into %s\n", peerc->name, peerb->name);
+ ast_debug(4, "SIP transfer: trying to masquerade %s into %s\n", peerc->name, peerb->name);
if (ast_channel_masquerade(peerb, peerc)) {
ast_log(LOG_WARNING, "Failed to masquerade %s into %s\n", peerb->name, peerc->name);
res = -1;
} else
- ast_log(LOG_DEBUG, "SIP transfer: Succeeded to masquerade channels.\n");
+ ast_debug(4, "SIP transfer: Succeeded to masquerade channels.\n");
return res;
} else {
ast_log(LOG_NOTICE, "SIP Transfer attempted with no appropriate bridged calls to transfer\n");
@@ -13849,8 +13711,8 @@ static int handle_request_notify(struct sip_pvt *p, struct sip_request *req, str
eventid = sep;
}
- if (option_debug > 1 && sipdebug)
- ast_log(LOG_DEBUG, "Got NOTIFY Event: %s\n", event);
+ if (sipdebug)
+ ast_debug(2, "Got NOTIFY Event: %s\n", event);
if (strcmp(event, "refer")) {
/* We don't understand this event. */
@@ -13910,8 +13772,7 @@ static int handle_request_notify(struct sip_pvt *p, struct sip_request *req, str
If there are several REFERs in the same dialog, we need to
match the ID of the event header...
*/
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "* SIP Transfer NOTIFY Attachment: \n---%s\n---\n", buf);
+ ast_debug(3, "* SIP Transfer NOTIFY Attachment: \n---%s\n---\n", buf);
cmd = ast_skip_blanks(buf);
code = cmd;
/* We are at SIP/2.0 */
@@ -14007,20 +13868,17 @@ static int handle_invite_replaces(struct sip_pvt *p, struct sip_request *req, in
if (!(targetcall = ast_bridged_channel(replacecall))) {
/* We have no bridge */
if (!earlyreplace) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, " Attended transfer attempted to replace call with no bridge (maybe ringing). Channel %s!\n", replacecall->name);
+ ast_debug(2, " Attended transfer attempted to replace call with no bridge (maybe ringing). Channel %s!\n", replacecall->name);
oneleggedreplace = 1;
}
}
- if (option_debug > 3 && targetcall && targetcall->_state == AST_STATE_RINGING)
- ast_log(LOG_DEBUG, "SIP transfer: Target channel is in ringing state\n");
+ if (targetcall && targetcall->_state == AST_STATE_RINGING)
+ ast_debug(4, "SIP transfer: Target channel is in ringing state\n");
- if (option_debug > 3) {
- if (targetcall)
- ast_log(LOG_DEBUG, "SIP transfer: Invite Replace incoming channel should bridge to channel %s while hanging up channel %s\n", targetcall->name, replacecall->name);
- else
- ast_log(LOG_DEBUG, "SIP transfer: Invite Replace incoming channel should replace and hang up channel %s (one call leg)\n", replacecall->name);
- }
+ if (targetcall)
+ ast_debug(4, "SIP transfer: Invite Replace incoming channel should bridge to channel %s while hanging up channel %s\n", targetcall->name, replacecall->name);
+ else
+ ast_debug(4, "SIP transfer: Invite Replace incoming channel should replace and hang up channel %s (one call leg)\n", replacecall->name);
if (ast_test_flag(req, SIP_PKT_IGNORE)) {
ast_log(LOG_NOTICE, "Ignoring this INVITE with replaces in a stupid way.\n");
@@ -14068,8 +13926,7 @@ static int handle_invite_replaces(struct sip_pvt *p, struct sip_request *req, in
/* Stop music on hold and other generators */
ast_quiet_chan(replacecall);
ast_quiet_chan(targetcall);
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "Invite/Replaces: preparing to masquerade %s into %s\n", c->name, replacecall->name);
+ ast_debug(4, "Invite/Replaces: preparing to masquerade %s into %s\n", c->name, replacecall->name);
/* Unlock clone, but not original (replacecall) */
ast_channel_unlock(c);
@@ -14082,8 +13939,8 @@ static int handle_invite_replaces(struct sip_pvt *p, struct sip_request *req, in
/* Prepare the masquerade - if this does not happen, we will be gone */
if(ast_channel_masquerade(replacecall, c))
ast_log(LOG_ERROR, "Failed to masquerade C into Replacecall\n");
- else if (option_debug > 3)
- ast_log(LOG_DEBUG, "Invite/Replaces: Going to masquerade %s into %s\n", c->name, replacecall->name);
+ else
+ ast_debug(4, "Invite/Replaces: Going to masquerade %s into %s\n", c->name, replacecall->name);
/* The masquerade will happen as soon as someone reads a frame from the channel */
@@ -14096,8 +13953,7 @@ static int handle_invite_replaces(struct sip_pvt *p, struct sip_request *req, in
if ((f = ast_read(replacecall))) { /* Force the masq to happen */
ast_frfree(f);
f = NULL;
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "Invite/Replace: Could successfully read frame from RING channel!\n");
+ ast_debug(4, "Invite/Replace: Could successfully read frame from RING channel!\n");
} else {
ast_log(LOG_WARNING, "Invite/Replace: Could not read frame from RING channel \n");
}
@@ -14108,8 +13964,7 @@ static int handle_invite_replaces(struct sip_pvt *p, struct sip_request *req, in
/* Masq ok */
ast_frfree(f);
f = NULL;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Invite/Replace: Could successfully read frame from channel! Masq done.\n");
+ ast_debug(3, "Invite/Replace: Could successfully read frame from channel! Masq done.\n");
} else {
ast_log(LOG_WARNING, "Invite/Replace: Could not read frame from channel. Transfer failed\n");
}
@@ -14118,23 +13973,21 @@ static int handle_invite_replaces(struct sip_pvt *p, struct sip_request *req, in
sip_pvt_unlock(p->refer->refer_call);
ast_setstate(c, AST_STATE_DOWN);
- if (option_debug > 3) {
- struct ast_channel *test;
- ast_log(LOG_DEBUG, "After transfer:----------------------------\n");
- ast_log(LOG_DEBUG, " -- C: %s State %s\n", c->name, ast_state2str(c->_state));
- if (replacecall)
- ast_log(LOG_DEBUG, " -- replacecall: %s State %s\n", replacecall->name, ast_state2str(replacecall->_state));
- if (p->owner) {
- ast_log(LOG_DEBUG, " -- P->owner: %s State %s\n", p->owner->name, ast_state2str(p->owner->_state));
- test = ast_bridged_channel(p->owner);
- if (test)
- ast_log(LOG_DEBUG, " -- Call bridged to P->owner: %s State %s\n", test->name, ast_state2str(test->_state));
- else
- ast_log(LOG_DEBUG, " -- No call bridged to C->owner \n");
- } else
- ast_log(LOG_DEBUG, " -- No channel yet \n");
- ast_log(LOG_DEBUG, "End After transfer:----------------------------\n");
- }
+ struct ast_channel *test;
+ ast_debug(4, "After transfer:----------------------------\n");
+ ast_debug(4, " -- C: %s State %s\n", c->name, ast_state2str(c->_state));
+ if (replacecall)
+ ast_debug(4, " -- replacecall: %s State %s\n", replacecall->name, ast_state2str(replacecall->_state));
+ if (p->owner) {
+ ast_debug(4, " -- P->owner: %s State %s\n", p->owner->name, ast_state2str(p->owner->_state));
+ test = ast_bridged_channel(p->owner);
+ if (test)
+ ast_debug(4, " -- Call bridged to P->owner: %s State %s\n", test->name, ast_state2str(test->_state));
+ else
+ ast_debug(4, " -- No call bridged to C->owner \n");
+ } else
+ ast_debug(4, " -- No channel yet \n");
+ ast_debug(4, "End After transfer:----------------------------\n");
ast_channel_unlock(p->owner); /* Unlock new owner */
sip_pvt_unlock(p); /* Unlock SIP structure */
@@ -14201,8 +14054,7 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
if (!ast_test_flag(req, SIP_PKT_IGNORE) && p->pendinginvite) {
/* We already have a pending invite. Sorry. You are on hold. */
transmit_response(p, "491 Request Pending", req);
- if (option_debug)
- ast_log(LOG_DEBUG, "Got INVITE on call where we already have pending INVITE, deferring that - %s\n", p->callid);
+ ast_debug(1, "Got INVITE on call where we already have pending INVITE, deferring that - %s\n", p->callid);
/* Don't destroy dialog here */
return 0;
}
@@ -14217,15 +14069,14 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
int error = 0;
if (p->owner) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "INVITE w Replaces on existing call? Refusing action. [%s]\n", p->callid);
+ ast_debug(3, "INVITE w Replaces on existing call? Refusing action. [%s]\n", p->callid);
transmit_response(p, "400 Bad request", req); /* The best way to not not accept the transfer */
/* Do not destroy existing call */
return -1;
}
- if (sipdebug && option_debug > 2)
- ast_log(LOG_DEBUG, "INVITE part of call transfer. Replaces [%s]\n", p_replaces);
+ if (sipdebug)
+ ast_debug(3, "INVITE part of call transfer. Replaces [%s]\n", p_replaces);
/* Create a buffer we can manipulate */
replace_id = ast_strdupa(p_replaces);
ast_uri_decode(replace_id);
@@ -14260,8 +14111,8 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
}
}
- if (sipdebug && option_debug > 3)
- ast_log(LOG_DEBUG,"Invite/replaces: Will use Replace-Call-ID : %s Fromtag: %s Totag: %s\n", replace_id, fromtag ? fromtag : "<no from tag>", totag ? totag : "<no to tag>");
+ if (sipdebug)
+ ast_debug(4,"Invite/replaces: Will use Replace-Call-ID : %s Fromtag: %s Totag: %s\n", replace_id, fromtag ? fromtag : "<no from tag>", totag ? totag : "<no to tag>");
/* Try to find call that we are replacing
@@ -14326,8 +14177,8 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
check_via(p, req);
copy_request(&p->initreq, req); /* Save this INVITE as the transaction basis */
- if (sipdebug && option_debug)
- ast_log(LOG_DEBUG, "Initializing initreq for method %s - callid %s\n", sip_methods[req->method].text, p->callid);
+ if (sipdebug)
+ ast_debug(1, "Initializing initreq for method %s - callid %s\n", sip_methods[req->method].text, p->callid);
if (!p->owner) { /* Not a re-invite */
if (debug)
ast_verbose("Using INVITE request as basis request - %s\n", p->callid);
@@ -14346,8 +14197,7 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
}
} else {
p->jointcapability = p->capability;
- if (option_debug)
- ast_log(LOG_DEBUG, "Hm.... No sdp for the moment\n");
+ ast_debug(1, "Hm.... No sdp for the moment\n");
}
if (!ast_test_flag(&p->flags[0], SIP_NO_HISTORY)) /* This is a response, note what it was for */
append_history(p, "ReInv", "Re-invite received");
@@ -14385,14 +14235,12 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
transmit_response_reliable(p, "488 Not acceptable here", req);
p->invitestate = INV_COMPLETED;
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
- if (option_debug)
- ast_log(LOG_DEBUG, "No compatible codecs for this SIP call.\n");
+ ast_debug(1, "No compatible codecs for this SIP call.\n");
return -1;
}
} else { /* No SDP in invite, call control session */
p->jointcapability = p->capability;
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "No SDP in Invite, third party call control\n");
+ ast_debug(2, "No SDP in Invite, third party call control\n");
}
/* Queue NULL frame to prod ast_rtp_bridge if appropriate */
@@ -14407,8 +14255,7 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
/* Check number of concurrent calls -vs- incoming limit HERE */
- if (option_debug)
- ast_log(LOG_DEBUG, "Checking SIP call limits for device %s\n", p->username);
+ ast_debug(1, "Checking SIP call limits for device %s\n", p->username);
if ((res = update_call_counter(p, INC_CALL_LIMIT))) {
if (res < 0) {
ast_log(LOG_NOTICE, "Failed to place call for user %s, too many calls\n", p->username);
@@ -14458,11 +14305,11 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
}
}
} else {
- if (option_debug > 1 && sipdebug) {
+ if (sipdebug) {
if (!ast_test_flag(req, SIP_PKT_IGNORE))
- ast_log(LOG_DEBUG, "Got a SIP re-invite for call %s\n", p->callid);
+ ast_debug(2, "Got a SIP re-invite for call %s\n", p->callid);
else
- ast_log(LOG_DEBUG, "Got a SIP re-transmit of INVITE for call %s\n", p->callid);
+ ast_debug(2, "Got a SIP re-transmit of INVITE for call %s\n", p->callid);
}
reinvite = 1;
c = p->owner;
@@ -14473,8 +14320,8 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
if (replace_id) { /* Attended transfer or call pickup - we're the target */
/* Go and take over the target call */
- if (sipdebug && option_debug > 3)
- ast_log(LOG_DEBUG, "Sending this call to the invite/replcaes handler %s\n", p->callid);
+ if (sipdebug)
+ ast_debug(4, "Sending this call to the invite/replcaes handler %s\n", p->callid);
return handle_invite_replaces(p, req, debug, ast_test_flag(req, SIP_PKT_IGNORE), seqno, sin);
}
@@ -14482,8 +14329,7 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
if (c) { /* We have a call -either a new call or an old one (RE-INVITE) */
switch(c->_state) {
case AST_STATE_DOWN:
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "%s: New call is still down.... Trying... \n", c->name);
+ ast_debug(2, "%s: New call is still down.... Trying... \n", c->name);
transmit_response(p, "100 Trying", req);
p->invitestate = INV_PROCEEDING;
ast_setstate(c, AST_STATE_RING);
@@ -14556,8 +14402,7 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
p->invitestate = INV_PROCEEDING;
break;
case AST_STATE_UP:
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "%s: This call is UP.... \n", c->name);
+ ast_debug(2, "%s: This call is UP.... \n", c->name);
if (p->t38.state == T38_PEER_REINVITE) {
struct ast_channel *bridgepeer = NULL;
@@ -14577,8 +14422,7 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
sip_pvt_lock(bridgepvt);
bridgepvt->t38.state = T38_DISABLED;
sip_pvt_unlock(bridgepvt);
- if (option_debug > 1)
- ast_log(LOG_DEBUG,"T38 state changed to %d on channel %s\n", bridgepvt->t38.state, bridgepeer->name);
+ ast_debug(2,"T38 state changed to %d on channel %s\n", bridgepvt->t38.state, bridgepeer->name);
if (ast_test_flag(req, SIP_PKT_IGNORE))
transmit_response(p, "488 Not acceptable here", req);
else
@@ -14589,8 +14433,7 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
/* The other side is already setup for T.38 most likely so we need to acknowledge this too */
transmit_response_with_t38_sdp(p, "200 OK", req, XMIT_CRITICAL);
p->t38.state = T38_ENABLED;
- if (option_debug)
- ast_log(LOG_DEBUG, "T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
+ ast_debug(1, "T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
}
} else {
/* Other side is not a SIP channel */
@@ -14599,8 +14442,7 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
else
transmit_response_reliable(p, "488 Not acceptable here", req);
p->t38.state = T38_DISABLED;
- if (option_debug > 1)
- ast_log(LOG_DEBUG,"T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
+ ast_debug(2,"T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
if (!p->lastinvite) /* Only destroy if this is *not* a re-invite */
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
@@ -14609,8 +14451,7 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
/* we are not bridged in a call */
transmit_response_with_t38_sdp(p, "200 OK", req, XMIT_CRITICAL);
p->t38.state = T38_ENABLED;
- if (option_debug)
- ast_log(LOG_DEBUG,"T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
+ ast_debug(1,"T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
}
} else if (p->t38.state == T38_DISABLED) { /* Channel doesn't have T38 offered or enabled */
int sendok = TRUE;
@@ -14692,8 +14533,7 @@ static int local_attended_transfer(struct sip_pvt *transferer, struct sip_dual *
return -1;
}
/* Fall through for remote transfers that we did not find locally */
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "SIP attended transfer: Not our call - generating INVITE with replaces\n");
+ ast_debug(3, "SIP attended transfer: Not our call - generating INVITE with replaces\n");
return 0;
}
@@ -14701,8 +14541,7 @@ static int local_attended_transfer(struct sip_pvt *transferer, struct sip_dual *
transmit_response(transferer, "202 Accepted", req);
append_history(transferer, "Xfer", "Refer accepted");
if (!targetcall_pvt->owner) { /* No active channel */
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "SIP attended transfer: Error: No owner of target call\n");
+ ast_debug(4, "SIP attended transfer: Error: No owner of target call\n");
/* Cancel transfer */
transmit_notify_with_sipfrag(transferer, seqno, "503 Service Unavailable", TRUE);
append_history(transferer, "Xfer", "Refer failed");
@@ -14719,22 +14558,20 @@ static int local_attended_transfer(struct sip_pvt *transferer, struct sip_dual *
if (!target.chan2 || !(target.chan2->_state == AST_STATE_UP || target.chan2->_state == AST_STATE_RINGING) ) {
/* Wrong state of new channel */
- if (option_debug > 3) {
- if (target.chan2)
- ast_log(LOG_DEBUG, "SIP attended transfer: Error: Wrong state of target call: %s\n", ast_state2str(target.chan2->_state));
- else if (target.chan1->_state != AST_STATE_RING)
- ast_log(LOG_DEBUG, "SIP attended transfer: Error: No target channel\n");
- else
- ast_log(LOG_DEBUG, "SIP attended transfer: Attempting transfer in ringing state\n");
- }
+ if (target.chan2)
+ ast_debug(4, "SIP attended transfer: Error: Wrong state of target call: %s\n", ast_state2str(target.chan2->_state));
+ else if (target.chan1->_state != AST_STATE_RING)
+ ast_debug(4, "SIP attended transfer: Error: No target channel\n");
+ else
+ ast_debug(4, "SIP attended transfer: Attempting transfer in ringing state\n");
}
/* Transfer */
- if (option_debug > 3 && sipdebug) {
+ if (sipdebug) {
if (current->chan2) /* We have two bridges */
- ast_log(LOG_DEBUG, "SIP attended transfer: trying to bridge %s and %s\n", target.chan1->name, current->chan2->name);
+ ast_debug(4, "SIP attended transfer: trying to bridge %s and %s\n", target.chan1->name, current->chan2->name);
else /* One bridge, propably transfer of IVR/voicemail etc */
- ast_log(LOG_DEBUG, "SIP attended transfer: trying to make %s take over (masq) %s\n", target.chan1->name, current->chan1->name);
+ ast_debug(4, "SIP attended transfer: trying to make %s take over (masq) %s\n", target.chan1->name, current->chan1->name);
}
ast_set_flag(&transferer->flags[0], SIP_DEFER_BYE_ON_TRANSFER); /* Delay hangup */
@@ -14759,8 +14596,7 @@ static int local_attended_transfer(struct sip_pvt *transferer, struct sip_dual *
append_history(transferer, "Xfer", "Refer succeeded");
transferer->refer->status = REFER_200OK;
if (targetcall_pvt->owner) {
- if (option_debug)
- ast_log(LOG_DEBUG, "SIP attended transfer: Unlocking channel %s\n", targetcall_pvt->owner->name);
+ ast_debug(1, "SIP attended transfer: Unlocking channel %s\n", targetcall_pvt->owner->name);
ast_channel_unlock(targetcall_pvt->owner);
}
}
@@ -14844,8 +14680,7 @@ static int handle_request_refer(struct sip_pvt *p, struct sip_request *req, int
if (!p->owner) {
/* This is a REFER outside of an existing SIP dialog */
/* We can't handle that, so decline it */
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Call %s: Declined REFER, outside of dialog...\n", p->callid);
+ ast_debug(3, "Call %s: Declined REFER, outside of dialog...\n", p->callid);
transmit_response(p, "603 Declined (No dialog)", req);
if (!ast_test_flag(req, SIP_PKT_IGNORE)) {
append_history(p, "Xfer", "Refer failed. Outside of dialog.");
@@ -14888,14 +14723,14 @@ static int handle_request_refer(struct sip_pvt *p, struct sip_request *req, int
case -2: /* Syntax error */
transmit_response(p, "400 Bad Request (Refer-to missing)", req);
append_history(p, "Xfer", "Refer failed. Refer-to missing.");
- if (ast_test_flag(req, SIP_PKT_DEBUG) && option_debug)
- ast_log(LOG_DEBUG, "SIP transfer to black hole can't be handled (no refer-to: )\n");
+ if (ast_test_flag(req, SIP_PKT_DEBUG))
+ ast_debug(1, "SIP transfer to black hole can't be handled (no refer-to: )\n");
break;
case -3:
transmit_response(p, "603 Declined (Non sip: uri)", req);
append_history(p, "Xfer", "Refer failed. Non SIP uri");
- if (ast_test_flag(req, SIP_PKT_DEBUG) && option_debug)
- ast_log(LOG_DEBUG, "SIP transfer to non-SIP uri denied\n");
+ if (ast_test_flag(req, SIP_PKT_DEBUG))
+ ast_debug(1, "SIP transfer to non-SIP uri denied\n");
break;
default:
/* Refer-to extension not found, fake a failed transfer */
@@ -14903,8 +14738,8 @@ static int handle_request_refer(struct sip_pvt *p, struct sip_request *req, int
append_history(p, "Xfer", "Refer failed. Bad extension.");
transmit_notify_with_sipfrag(p, seqno, "404 Not found", TRUE);
ast_clear_flag(&p->flags[0], SIP_GOTREFER);
- if (ast_test_flag(req, SIP_PKT_DEBUG) && option_debug)
- ast_log(LOG_DEBUG, "SIP transfer to bad extension: %s\n", p->refer->refer_to);
+ if (ast_test_flag(req, SIP_PKT_DEBUG))
+ ast_debug(1, "SIP transfer to bad extension: %s\n", p->refer->refer_to);
break;
}
return 0;
@@ -14915,14 +14750,14 @@ static int handle_request_refer(struct sip_pvt *p, struct sip_request *req, int
/* If we do not support SIP domains, all transfers are local */
if (allow_external_domains && check_sip_domain(p->refer->refer_to_domain, NULL, 0)) {
p->refer->localtransfer = 1;
- if (sipdebug && option_debug > 2)
- ast_log(LOG_DEBUG, "This SIP transfer is local : %s\n", p->refer->refer_to_domain);
+ if (sipdebug)
+ ast_debug(3, "This SIP transfer is local : %s\n", p->refer->refer_to_domain);
} else if (AST_LIST_EMPTY(&domain_list)) {
/* This PBX don't bother with SIP domains, so all transfers are local */
p->refer->localtransfer = 1;
} else
- if (sipdebug && option_debug > 2)
- ast_log(LOG_DEBUG, "This SIP transfer is to a remote SIP extension (remote domain %s)\n", p->refer->refer_to_domain);
+ if (sipdebug)
+ ast_debug(3, "This SIP transfer is to a remote SIP extension (remote domain %s)\n", p->refer->refer_to_domain);
/* Is this a repeat of a current request? Ignore it */
/* Don't know what else to do right now. */
@@ -14960,15 +14795,15 @@ static int handle_request_refer(struct sip_pvt *p, struct sip_request *req, int
/* Find the other part of the bridge (2) - transferee */
current.chan2 = ast_bridged_channel(current.chan1);
- if (sipdebug && option_debug > 2)
- ast_log(LOG_DEBUG, "SIP %s transfer: Transferer channel %s, transferee channel %s\n", p->refer->attendedtransfer ? "attended" : "blind", current.chan1->name, current.chan2 ? current.chan2->name : "<none>");
+ if (sipdebug)
+ ast_debug(3, "SIP %s transfer: Transferer channel %s, transferee channel %s\n", p->refer->attendedtransfer ? "attended" : "blind", current.chan1->name, current.chan2 ? current.chan2->name : "<none>");
if (!current.chan2 && !p->refer->attendedtransfer) {
/* No bridged channel, propably IVR or echo or similar... */
/* Guess we should masquerade or something here */
/* Until we figure it out, refuse transfer of such calls */
- if (sipdebug && option_debug > 2)
- ast_log(LOG_DEBUG,"Refused SIP transfer on non-bridged channel.\n");
+ if (sipdebug)
+ ast_debug(3,"Refused SIP transfer on non-bridged channel.\n");
p->refer->status = REFER_FAILED;
append_history(p, "Xfer", "Refer failed. Non-bridged channel.");
transmit_response(p, "603 Declined", req);
@@ -14976,8 +14811,8 @@ static int handle_request_refer(struct sip_pvt *p, struct sip_request *req, int
}
if (current.chan2) {
- if (sipdebug && option_debug > 3)
- ast_log(LOG_DEBUG, "Got SIP transfer, applying to bridged peer '%s'\n", current.chan2->name);
+ if (sipdebug)
+ ast_debug(4, "Got SIP transfer, applying to bridged peer '%s'\n", current.chan2->name);
ast_queue_control(current.chan1, AST_CONTROL_UNHOLD);
}
@@ -14989,8 +14824,8 @@ static int handle_request_refer(struct sip_pvt *p, struct sip_request *req, int
if ((res = local_attended_transfer(p, &current, req, seqno)))
return res; /* We're done with the transfer */
/* Fall through for remote transfers that we did not find locally */
- if (sipdebug && option_debug > 3)
- ast_log(LOG_DEBUG, "SIP attended transfer: Still not our call - generating INVITE with replaces\n");
+ if (sipdebug)
+ ast_debug(4, "SIP attended transfer: Still not our call - generating INVITE with replaces\n");
/* Fallthrough if we can't find the call leg internally */
}
@@ -15004,8 +14839,8 @@ static int handle_request_refer(struct sip_pvt *p, struct sip_request *req, int
ast_clear_flag(&p->flags[0], SIP_GOTREFER);
p->refer->status = REFER_200OK;
append_history(p, "Xfer", "REFER to call parking.");
- if (sipdebug && option_debug > 3)
- ast_log(LOG_DEBUG, "SIP transfer to parking: trying to park %s. Parked by %s\n", current.chan2->name, current.chan1->name);
+ if (sipdebug)
+ ast_debug(4, "SIP transfer to parking: trying to park %s. Parked by %s\n", current.chan2->name, current.chan1->name);
sip_park(current.chan2, current.chan1, req, seqno);
return res;
}
@@ -15014,8 +14849,7 @@ static int handle_request_refer(struct sip_pvt *p, struct sip_request *req, int
transmit_response(p, "202 Accepted", req);
if (current.chan1 && current.chan2) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "chan1->name: %s\n", current.chan1->name);
+ ast_debug(3, "chan1->name: %s\n", current.chan1->name);
pbx_builtin_setvar_helper(current.chan1, "BLINDTRANSFER", current.chan2->name);
}
if (current.chan2) {
@@ -15077,8 +14911,7 @@ static int handle_request_refer(struct sip_pvt *p, struct sip_request *req, int
if (!res) {
/* Success - we have a new channel */
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "%s transfer succeeded. Telling transferer.\n", p->refer->attendedtransfer? "Attended" : "Blind");
+ ast_debug(3, "%s transfer succeeded. Telling transferer.\n", p->refer->attendedtransfer? "Attended" : "Blind");
transmit_notify_with_sipfrag(p, seqno, "200 Ok", TRUE);
if (p->refer->localtransfer)
p->refer->status = REFER_200OK;
@@ -15091,8 +14924,7 @@ static int handle_request_refer(struct sip_pvt *p, struct sip_request *req, int
res = 0;
} else {
ast_clear_flag(&p->flags[0], SIP_DEFER_BYE_ON_TRANSFER); /* Don't delay hangup */
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "%s transfer failed. Resuming original call.\n", p->refer->attendedtransfer? "Attended" : "Blind");
+ ast_debug(3, "%s transfer failed. Resuming original call.\n", p->refer->attendedtransfer? "Attended" : "Blind");
append_history(p, "Xfer", "Refer failed.");
/* Failure of some kind */
p->refer->status = REFER_FAILED;
@@ -15114,8 +14946,7 @@ static int handle_request_cancel(struct sip_pvt *p, struct sip_request *req)
if (p->owner && p->owner->_state == AST_STATE_UP) {
/* This call is up, cancel is ignored, we need a bye */
transmit_response(p, "200 OK", req);
- if (option_debug)
- ast_log(LOG_DEBUG, "Got CANCEL on an answered call. Ignoring... \n");
+ ast_debug(1, "Got CANCEL on an answered call. Ignoring... \n");
return 0;
}
@@ -15217,8 +15048,8 @@ static int handle_request_bye(struct sip_pvt *p, struct sip_request *req)
p->invitestate = INV_TERMINATED;
copy_request(&p->initreq, req);
- if (sipdebug && option_debug)
- ast_log(LOG_DEBUG, "Initializing initreq for method %s - callid %s\n", sip_methods[req->method].text, p->callid);
+ if (sipdebug)
+ ast_debug(1, "Initializing initreq for method %s - callid %s\n", sip_methods[req->method].text, p->callid);
check_via(p, req);
sip_alreadygone(p);
@@ -15274,12 +15105,10 @@ static int handle_request_bye(struct sip_pvt *p, struct sip_request *req)
}
} else if (p->owner) {
ast_queue_hangup(p->owner);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Received bye, issuing owner hangup\n");
+ ast_debug(3, "Received bye, issuing owner hangup\n");
} else {
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Received bye, no owner, selfdestruct soon.\n");
+ ast_debug(3, "Received bye, no owner, selfdestruct soon.\n");
}
transmit_response(p, "200 OK", req);
@@ -15317,16 +15146,13 @@ static int handle_request_subscribe(struct sip_pvt *p, struct sip_request *req,
/* For transfers, this could happen, but since we haven't seen it happening, let us just refuse this */
transmit_response(p, "403 Forbidden (within dialog)", req);
/* Do not destroy session, since we will break the call if we do */
- if (option_debug)
- ast_log(LOG_DEBUG, "Got a subscription within the context of another call, can't handle that - %s (Method %s)\n", p->callid, sip_methods[p->initreq.method].text);
+ ast_debug(1, "Got a subscription within the context of another call, can't handle that - %s (Method %s)\n", p->callid, sip_methods[p->initreq.method].text);
return 0;
} else if (ast_test_flag(req, SIP_PKT_DEBUG)) {
- if (option_debug) {
- if (resubscribe)
- ast_log(LOG_DEBUG, "Got a re-subscribe on existing subscription %s\n", p->callid);
- else
- ast_log(LOG_DEBUG, "Got a new subscription %s (possibly with auth)\n", p->callid);
- }
+ if (resubscribe)
+ ast_debug(1, "Got a re-subscribe on existing subscription %s\n", p->callid);
+ else
+ ast_debug(1, "Got a new subscription %s (possibly with auth)\n", p->callid);
}
}
@@ -15345,8 +15171,8 @@ static int handle_request_subscribe(struct sip_pvt *p, struct sip_request *req,
ast_verbose("Creating new subscription\n");
copy_request(&p->initreq, req);
- if (option_debug > 3 && sipdebug)
- ast_log(LOG_DEBUG, "Initializing initreq for method %s - callid %s\n", sip_methods[req->method].text, p->callid);
+ if (sipdebug)
+ ast_debug(4, "Initializing initreq for method %s - callid %s\n", sip_methods[req->method].text, p->callid);
check_via(p, req);
} else if (ast_test_flag(req, SIP_PKT_DEBUG) && ast_test_flag(req, SIP_PKT_IGNORE))
ast_verbose("Ignoring this SUBSCRIBE request\n");
@@ -15354,8 +15180,7 @@ static int handle_request_subscribe(struct sip_pvt *p, struct sip_request *req,
/* Find parameters to Event: header value and remove them for now */
if (ast_strlen_zero(eventheader)) {
transmit_response(p, "489 Bad Event", req);
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Received SIP subscribe for unknown event package: <none>\n");
+ ast_debug(2, "Received SIP subscribe for unknown event package: <none>\n");
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
return 0;
}
@@ -15468,8 +15293,7 @@ static int handle_request_subscribe(struct sip_pvt *p, struct sip_request *req,
if (!ast_strlen_zero(accept) && strcmp(accept, "application/simple-message-summary")) {
/* Format requested that we do not support */
transmit_response(p, "406 Not Acceptable", req);
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Received SIP mailbox subscription for unknown format: %s\n", accept);
+ ast_debug(2, "Received SIP mailbox subscription for unknown format: %s\n", accept);
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
if (authpeer)
unref_peer(authpeer);
@@ -15503,8 +15327,7 @@ static int handle_request_subscribe(struct sip_pvt *p, struct sip_request *req,
/* Do not release authpeer here */
} else { /* At this point, Asterisk does not understand the specified event */
transmit_response(p, "489 Bad Event", req);
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Received SIP subscribe for unknown event package: %s\n", event);
+ ast_debug(2, "Received SIP subscribe for unknown event package: %s\n", event);
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
if (authpeer)
unref_peer(authpeer);
@@ -15526,11 +15349,11 @@ static int handle_request_subscribe(struct sip_pvt *p, struct sip_request *req,
if (p->expiry < min_expiry && p->expiry > 0)
p->expiry = min_expiry;
- if (sipdebug || option_debug > 1) {
+ if (sipdebug) {
if (p->subscribed == MWI_NOTIFICATION && p->relatedpeer)
- ast_log(LOG_DEBUG, "Adding subscription for mailbox notification - peer %s Mailbox %s\n", p->relatedpeer->name, p->relatedpeer->mailbox);
+ ast_debug(2, "Adding subscription for mailbox notification - peer %s Mailbox %s\n", p->relatedpeer->name, p->relatedpeer->mailbox);
else
- ast_log(LOG_DEBUG, "Adding subscription for extension %s context %s for peer %s\n", p->exten, p->context, p->username);
+ ast_debug(2, "Adding subscription for extension %s context %s for peer %s\n", p->exten, p->context, p->username);
}
if (p->autokillid > -1)
sip_cancel_destroy(p); /* Remove subscription expiry for renewals */
@@ -15600,8 +15423,8 @@ static int handle_request_register(struct sip_pvt *p, struct sip_request *req, s
/* Use this as the basis */
copy_request(&p->initreq, req);
- if (option_debug > 3 && sipdebug)
- ast_log(LOG_DEBUG, "Initializing initreq for method %s - callid %s\n", sip_methods[req->method].text, p->callid);
+ if (sipdebug)
+ ast_debug(4, "Initializing initreq for method %s - callid %s\n", sip_methods[req->method].text, p->callid);
check_via(p, req);
if ((res = register_verify(p, sin, req, e)) < 0) {
const char *reason;
@@ -15697,8 +15520,7 @@ static int handle_request(struct sip_pvt *p, struct sip_request *req, struct soc
within an existing dialog */
/* Response to our request -- Do some sanity checks */
if (p->ocseq < seqno) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Ignoring out of order response %d (expecting %d)\n", seqno, p->ocseq);
+ ast_debug(1, "Ignoring out of order response %d (expecting %d)\n", seqno, p->ocseq);
return -1;
} else if (p->ocseq != seqno) {
/* ignore means "don't do anything with it" but still have to
@@ -15728,12 +15550,10 @@ static int handle_request(struct sip_pvt *p, struct sip_request *req, struct soc
*/
p->method = req->method; /* Find out which SIP method they are using */
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "**** Received %s (%d) - Command in SIP %s\n", sip_methods[p->method].text, sip_methods[p->method].id, cmd);
+ ast_debug(4, "**** Received %s (%d) - Command in SIP %s\n", sip_methods[p->method].text, sip_methods[p->method].id, cmd);
if (p->icseq && (p->icseq > seqno)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Ignoring too old SIP packet packet %d (expecting >= %d)\n", seqno, p->icseq);
+ ast_debug(1, "Ignoring too old SIP packet packet %d (expecting >= %d)\n", seqno, p->icseq);
if (req->method != SIP_ACK)
transmit_response(p, "503 Server error", req); /* We must respond according to RFC 3261 sec 12.2 */
return -1;
@@ -15745,8 +15565,7 @@ static int handle_request(struct sip_pvt *p, struct sip_request *req, struct soc
respond appropriately. We do this if we receive a repeat of
the last sequence number */
ast_set_flag(req, SIP_PKT_IGNORE);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Ignoring SIP message because of retransmit (%s Seqno %d, ours %d)\n", sip_methods[p->method].text, p->icseq, seqno);
+ ast_debug(3, "Ignoring SIP message because of retransmit (%s Seqno %d, ours %d)\n", sip_methods[p->method].text, p->icseq, seqno);
}
if (seqno >= p->icseq)
@@ -15778,8 +15597,7 @@ static int handle_request(struct sip_pvt *p, struct sip_request *req, struct soc
transmit_response(p, "481 Call/Transaction Does Not Exist", req);
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Got ACK for unknown dialog... strange.\n");
+ ast_debug(1, "Got ACK for unknown dialog... strange.\n");
}
return res;
}
@@ -15884,8 +15702,8 @@ static int sipsock_read(int *id, int fd, short events, void *ignore)
ast_log(LOG_WARNING, "Recv error: %s\n", strerror(errno));
return 1;
}
- if (option_debug && res == sizeof(req.data)) {
- ast_log(LOG_DEBUG, "Received packet exceeds buffer. Data is possibly lost\n");
+ if (res == sizeof(req.data)) {
+ ast_debug(1, "Received packet exceeds buffer. Data is possibly lost\n");
req.data[sizeof(req.data) - 1] = '\0';
} else
req.data[res] = '\0';
@@ -15913,8 +15731,7 @@ static int sipsock_read(int *id, int fd, short events, void *ignore)
/* Find the active SIP dialog or create a new one */
p = find_call(&req, &sin, req.method); /* returns p locked */
if (p == NULL) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Invalid SIP message - rejected , no callid, len %d\n", req.len);
+ ast_debug(1, "Invalid SIP message - rejected , no callid, len %d\n", req.len);
ast_mutex_unlock(&netlock);
return 1;
}
@@ -15922,8 +15739,7 @@ static int sipsock_read(int *id, int fd, short events, void *ignore)
/* becaues this is deadlock-prone, we need to try and unlock if failed */
if (!p->owner || !ast_channel_trylock(p->owner))
break; /* locking succeeded */
- if (option_debug)
- ast_log(LOG_DEBUG, "Failed to grab owner channel lock, trying again. (SIP call %s)\n", p->callid);
+ ast_debug(1, "Failed to grab owner channel lock, trying again. (SIP call %s)\n", p->callid);
sip_pvt_unlock(p);
ast_mutex_unlock(&netlock);
/* Sleep for a very short amount of time */
@@ -15947,8 +15763,7 @@ static int sipsock_read(int *id, int fd, short events, void *ignore)
nounlock = 0;
if (handle_request(p, &req, &sin, &recount, &nounlock) == -1) {
/* Request failed */
- if (option_debug)
- ast_log(LOG_DEBUG, "SIP message could not be handled, bad request: %-70.70s\n", p->callid[0] ? p->callid : "<no callid>");
+ ast_debug(1, "SIP message could not be handled, bad request: %-70.70s\n", p->callid[0] ? p->callid : "<no callid>");
}
if (p->owner && !nounlock)
@@ -16153,13 +15968,13 @@ restartsearch:
if ((res < 0) || (res > 1000))
res = 1000;
res = ast_io_wait(io, res);
- if (option_debug && res > 20)
- ast_log(LOG_DEBUG, "chan_sip: ast_io_wait ran %d all at once\n", res);
+ if (res > 20)
+ ast_debug(1, "chan_sip: ast_io_wait ran %d all at once\n", res);
ast_mutex_lock(&monlock);
if (res >= 0) {
res = ast_sched_runq(sched);
- if (option_debug && res >= 20)
- ast_log(LOG_DEBUG, "chan_sip: ast_sched_runq ran %d all at once\n", res);
+ if (res >= 20)
+ ast_debug(1, "chan_sip: ast_sched_runq ran %d all at once\n", res);
}
ast_mutex_unlock(&monlock);
}
@@ -16331,8 +16146,7 @@ static int sip_devicestate(void *data)
if ((tmp = strchr(host, '@')))
host = tmp + 1;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Checking device state for peer %s\n", host);
+ ast_debug(3, "Checking device state for peer %s\n", host);
if ((p = find_peer(host, NULL, 1))) {
if (p->addr.sin_addr.s_addr || p->defaddr.sin_addr.s_addr) {
@@ -16400,8 +16214,7 @@ static struct ast_channel *sip_request_call(const char *type, int format, void *
*cause = AST_CAUSE_BEARERCAPABILITY_NOTAVAIL; /* Can't find codec to connect to host */
return NULL;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Asked to create a SIP channel with formats: %s\n", ast_getformatname_multiple(tmp, sizeof(tmp), oldformat));
+ ast_debug(1, "Asked to create a SIP channel with formats: %s\n", ast_getformatname_multiple(tmp, sizeof(tmp), oldformat));
if (!(p = sip_alloc(NULL, NULL, 0, SIP_INVITE))) {
ast_log(LOG_ERROR, "Unable to build sip pvt data for '%s' (Out of memory or socket error)\n", dest);
@@ -16432,8 +16245,7 @@ static struct ast_channel *sip_request_call(const char *type, int format, void *
if (create_addr(p, host)) {
*cause = AST_CAUSE_UNREGISTERED;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Cant create SIP call - target device not registred\n");
+ ast_debug(3, "Cant create SIP call - target device not registred\n");
sip_destroy(p);
return NULL;
}
@@ -16631,7 +16443,7 @@ static int add_sip_domain(const char *domain, const enum domain_mode mode, const
AST_LIST_UNLOCK(&domain_list);
if (sipdebug)
- ast_log(LOG_DEBUG, "Added local SIP domain '%s'\n", domain);
+ ast_debug(1, "Added local SIP domain '%s'\n", domain);
return 1;
}
@@ -16681,8 +16493,7 @@ static struct sip_auth *add_realm_authentication(struct sip_auth *authlist, char
if (ast_strlen_zero(configuration))
return authlist;
- if (option_debug)
- ast_log(LOG_DEBUG, "Auth config :: %s\n", configuration);
+ ast_debug(1, "Auth config :: %s\n", configuration);
ast_copy_string(authcopy, configuration, sizeof(authcopy));
stringp = authcopy;
@@ -16984,8 +16795,7 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, str
if (realtime) {
rpeerobjs++;
- if (option_debug > 2)
- ast_log(LOG_DEBUG,"-REALTIME- peer built. Name: %s. Peer objects: %d\n", name, rpeerobjs);
+ ast_debug(3,"-REALTIME- peer built. Name: %s. Peer objects: %d\n", name, rpeerobjs);
} else
speerobjs++;
ASTOBJ_INIT(peer);
@@ -17193,8 +17003,7 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, str
if ((nowtime - regseconds) > 0) {
destroy_association(peer);
memset(&peer->addr, 0, sizeof(peer->addr));
- if (option_debug)
- ast_log(LOG_DEBUG, "Bah, we're expired (%d/%d/%d)!\n", (int)(nowtime - regseconds), (int)regseconds, (int)nowtime);
+ ast_debug(1, "Bah, we're expired (%d/%d/%d)!\n", (int)(nowtime - regseconds), (int)regseconds, (int)nowtime);
}
}
ast_copy_flags(&peer->flags[0], &peerflags[0], mask[0].flags);
@@ -17380,8 +17189,7 @@ static int reload_config(enum channelreloadreason reason)
ast_copy_string(global_realm, v->value, sizeof(global_realm));
} else if (!strcasecmp(v->name, "useragent")) {
ast_copy_string(global_useragent, v->value, sizeof(global_useragent));
- if (option_debug)
- ast_log(LOG_DEBUG, "Setting SIP channel User-Agent Name to %s\n", global_useragent);
+ ast_debug(1, "Setting SIP channel User-Agent Name to %s\n", global_useragent);
} else if (!strcasecmp(v->name, "allowtransfer")) {
global_allowtransfer = ast_true(v->value) ? TRANSFER_OPENFORALL : TRANSFER_CLOSED;
} else if (!strcasecmp(v->name, "rtcachefriends")) {
@@ -17563,8 +17371,8 @@ static int reload_config(enum channelreloadreason reason)
if (context)
*context++ = '\0';
- if (option_debug && ast_strlen_zero(context))
- ast_log(LOG_DEBUG, "No context specified at line %d for domain '%s'\n", v->lineno, domain);
+ if (ast_strlen_zero(context))
+ ast_debug(1, "No context specified at line %d for domain '%s'\n", v->lineno, domain);
if (ast_strlen_zero(domain))
ast_log(LOG_WARNING, "Empty domain specified at line %d\n", v->lineno);
else
@@ -17837,14 +17645,10 @@ static int sip_set_udptl_peer(struct ast_channel *chan, struct ast_udptl *udptl)
memset(&p->udptlredirip, 0, sizeof(p->udptlredirip));
if (!ast_test_flag(&p->flags[0], SIP_GOTREFER)) {
if (!p->pendinginvite) {
- if (option_debug > 2) {
- ast_log(LOG_DEBUG, "Sending reinvite on SIP '%s' - It's UDPTL soon redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(udptl ? p->udptlredirip.sin_addr : p->ourip), udptl ? ntohs(p->udptlredirip.sin_port) : 0);
- }
+ ast_debug(3, "Sending reinvite on SIP '%s' - It's UDPTL soon redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(udptl ? p->udptlredirip.sin_addr : p->ourip), udptl ? ntohs(p->udptlredirip.sin_port) : 0);
transmit_reinvite_with_sdp(p, TRUE);
} else if (!ast_test_flag(&p->flags[0], SIP_PENDINGBYE)) {
- if (option_debug > 2) {
- ast_log(LOG_DEBUG, "Deferring reinvite on SIP '%s' - It's UDPTL will be redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(udptl ? p->udptlredirip.sin_addr : p->ourip), udptl ? ntohs(p->udptlredirip.sin_port) : 0);
- }
+ ast_debug(3, "Deferring reinvite on SIP '%s' - It's UDPTL will be redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(udptl ? p->udptlredirip.sin_addr : p->ourip), udptl ? ntohs(p->udptlredirip.sin_port) : 0);
ast_set_flag(&p->flags[0], SIP_NEEDREINVITE);
}
}
@@ -17893,20 +17697,16 @@ static int sip_handle_t38_reinvite(struct ast_channel *chan, struct sip_pvt *pvt
}
if (!ast_test_flag(&p->flags[0], SIP_GOTREFER)) {
if (!p->pendinginvite) {
- if (option_debug > 2) {
- if (flag)
- ast_log(LOG_DEBUG, "Sending reinvite on SIP '%s' - It's UDPTL soon redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(p->udptlredirip.sin_addr), ntohs(p->udptlredirip.sin_port));
- else
- ast_log(LOG_DEBUG, "Sending reinvite on SIP '%s' - It's UDPTL soon redirected to us (IP %s)\n", p->callid, ast_inet_ntoa(p->ourip));
- }
+ if (flag)
+ ast_debug(3, "Sending reinvite on SIP '%s' - It's UDPTL soon redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(p->udptlredirip.sin_addr), ntohs(p->udptlredirip.sin_port));
+ else
+ ast_debug(3, "Sending reinvite on SIP '%s' - It's UDPTL soon redirected to us (IP %s)\n", p->callid, ast_inet_ntoa(p->ourip));
transmit_reinvite_with_sdp(p, TRUE);
} else if (!ast_test_flag(&p->flags[0], SIP_PENDINGBYE)) {
- if (option_debug > 2) {
- if (flag)
- ast_log(LOG_DEBUG, "Deferring reinvite on SIP '%s' - It's UDPTL will be redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(p->udptlredirip.sin_addr), ntohs(p->udptlredirip.sin_port));
- else
- ast_log(LOG_DEBUG, "Deferring reinvite on SIP '%s' - It's UDPTL will be redirected to us (IP %s)\n", p->callid, ast_inet_ntoa(p->ourip));
- }
+ if (flag)
+ ast_debug(3, "Deferring reinvite on SIP '%s' - It's UDPTL will be redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(p->udptlredirip.sin_addr), ntohs(p->udptlredirip.sin_port));
+ else
+ ast_debug(3, "Deferring reinvite on SIP '%s' - It's UDPTL will be redirected to us (IP %s)\n", p->callid, ast_inet_ntoa(p->ourip));
ast_set_flag(&p->flags[0], SIP_NEEDREINVITE);
}
}
@@ -17921,18 +17721,14 @@ static int sip_handle_t38_reinvite(struct ast_channel *chan, struct sip_pvt *pvt
} else {
memset(&p->udptlredirip, 0, sizeof(p->udptlredirip));
}
- if (option_debug > 2) {
- if (flag)
- ast_log(LOG_DEBUG, "Responding 200 OK on SIP '%s' - It's UDPTL soon redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(p->udptlredirip.sin_addr), ntohs(p->udptlredirip.sin_port));
- else
- ast_log(LOG_DEBUG, "Responding 200 OK on SIP '%s' - It's UDPTL soon redirected to us (IP %s)\n", p->callid, ast_inet_ntoa(p->ourip));
- }
+ if (flag)
+ ast_debug(3, "Responding 200 OK on SIP '%s' - It's UDPTL soon redirected to IP %s:%d\n", p->callid, ast_inet_ntoa(p->udptlredirip.sin_addr), ntohs(p->udptlredirip.sin_port));
+ else
+ ast_debug(3, "Responding 200 OK on SIP '%s' - It's UDPTL soon redirected to us (IP %s)\n", p->callid, ast_inet_ntoa(p->ourip));
pvt->t38.state = T38_ENABLED;
p->t38.state = T38_ENABLED;
- if (option_debug > 1) {
- ast_log(LOG_DEBUG, "T38 changed state to %d on channel %s\n", pvt->t38.state, pvt->owner ? pvt->owner->name : "<none>");
- ast_log(LOG_DEBUG, "T38 changed state to %d on channel %s\n", p->t38.state, chan ? chan->name : "<none>");
- }
+ ast_debug(2, "T38 changed state to %d on channel %s\n", pvt->t38.state, pvt->owner ? pvt->owner->name : "<none>");
+ ast_debug(2, "T38 changed state to %d on channel %s\n", p->t38.state, chan ? chan->name : "<none>");
transmit_response_with_t38_sdp(p, "200 OK", &p->initreq, XMIT_CRITICAL);
p->lastrtprx = p->lastrtptx = time(NULL);
sip_pvt_unlock(p);
@@ -18080,17 +17876,12 @@ static int sip_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struc
if (chan->_state != AST_STATE_UP) { /* We are in early state */
if (!ast_test_flag(&p->flags[0], SIP_NO_HISTORY))
append_history(p, "ExtInv", "Initial invite sent with remote bridge proposal.");
- if (option_debug)
- ast_log(LOG_DEBUG, "Early remote bridge setting SIP '%s' - Sending media to %s\n", p->callid, ast_inet_ntoa(rtp ? p->redirip.sin_addr : p->ourip));
+ ast_debug(1, "Early remote bridge setting SIP '%s' - Sending media to %s\n", p->callid, ast_inet_ntoa(rtp ? p->redirip.sin_addr : p->ourip));
} else if (!p->pendinginvite) { /* We are up, and have no outstanding invite */
- if (option_debug > 2) {
- ast_log(LOG_DEBUG, "Sending reinvite on SIP '%s' - It's audio soon redirected to IP %s\n", p->callid, ast_inet_ntoa(rtp ? p->redirip.sin_addr : p->ourip));
- }
+ ast_debug(3, "Sending reinvite on SIP '%s' - It's audio soon redirected to IP %s\n", p->callid, ast_inet_ntoa(rtp ? p->redirip.sin_addr : p->ourip));
transmit_reinvite_with_sdp(p, FALSE);
} else if (!ast_test_flag(&p->flags[0], SIP_PENDINGBYE)) {
- if (option_debug > 2) {
- ast_log(LOG_DEBUG, "Deferring reinvite on SIP '%s' - It's audio will be redirected to IP %s\n", p->callid, ast_inet_ntoa(rtp ? p->redirip.sin_addr : p->ourip));
- }
+ ast_debug(3, "Deferring reinvite on SIP '%s' - It's audio will be redirected to IP %s\n", p->callid, ast_inet_ntoa(rtp ? p->redirip.sin_addr : p->ourip));
/* We have a pending Invite. Send re-invite when we're done with the invite */
ast_set_flag(&p->flags[0], SIP_NEEDREINVITE);
}
@@ -18197,7 +17988,7 @@ static int sip_addheader(struct ast_channel *chan, void *data)
if (ok) {
pbx_builtin_setvar_helper (chan, varbuf, inbuf);
if (sipdebug)
- ast_log(LOG_DEBUG,"SIP Header added \"%s\" as %s\n", inbuf, varbuf);
+ ast_debug(1,"SIP Header added \"%s\" as %s\n", inbuf, varbuf);
} else {
ast_log(LOG_WARNING, "Too many SIP headers added, max 50\n");
}
@@ -18318,8 +18109,7 @@ static void sip_send_all_registers(void)
/*! \brief Reload module */
static int sip_do_reload(enum channelreloadreason reason)
{
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "--------------- SIP reload started\n");
+ ast_debug(4, "--------------- SIP reload started\n");
clear_realm_authentication(authl);
clear_sip_domains();
@@ -18330,8 +18120,7 @@ static int sip_do_reload(enum channelreloadreason reason)
ASTOBJ_CONTAINER_TRAVERSE(&regl, 1, do {
ASTOBJ_RDLOCK(iterator);
if (iterator->call) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Destroying active SIP dialog for registry %s@%s\n", iterator->username, iterator->hostname);
+ ast_debug(3, "Destroying active SIP dialog for registry %s@%s\n", iterator->username, iterator->hostname);
/* This will also remove references to the registry */
sip_destroy(iterator->call);
}
@@ -18341,18 +18130,15 @@ static int sip_do_reload(enum channelreloadreason reason)
/* Then, actually destroy users and registry */
ASTOBJ_CONTAINER_DESTROYALL(&userl, sip_destroy_user);
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "--------------- Done destroying user list\n");
+ ast_debug(4, "--------------- Done destroying user list\n");
ASTOBJ_CONTAINER_DESTROYALL(&regl, sip_registry_destroy);
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "--------------- Done destroying registry list\n");
+ ast_debug(4, "--------------- Done destroying registry list\n");
ASTOBJ_CONTAINER_MARKALL(&peerl);
reload_config(reason);
/* Prune peers who still are supposed to be deleted */
ASTOBJ_CONTAINER_PRUNE_MARKED(&peerl, sip_destroy_peer);
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "--------------- Done destroying pruned peers\n");
+ ast_debug(4, "--------------- Done destroying pruned peers\n");
/* Send qualify (OPTIONS) to all peers */
sip_poke_all_peers();
@@ -18360,8 +18146,7 @@ static int sip_do_reload(enum channelreloadreason reason)
/* Register with all services */
sip_send_all_registers();
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "--------------- SIP reload done\n");
+ ast_debug(4, "--------------- SIP reload done\n");
return 0;
}
diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c
index 8bff31cb6..8ba5b0223 100644
--- a/channels/chan_skinny.c
+++ b/channels/chan_skinny.c
@@ -2462,8 +2462,7 @@ static void *skinny_ss(void *data)
timeout = matchdigittimeout;
}
} else if (res == 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Not enough digits (%s) (and no ambiguous match)...\n", d->exten);
+ ast_debug(1, "Not enough digits (%s) (and no ambiguous match)...\n", d->exten);
transmit_tone(s, SKINNY_REORDER);
if (sub->owner && sub->owner->_state != AST_STATE_UP) {
ast_indicate(c, -1);
@@ -2552,8 +2551,7 @@ static int skinny_hangup(struct ast_channel *ast)
struct skinnysession *s;
if (!sub) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Asked to hangup channel not connected\n");
+ ast_debug(1, "Asked to hangup channel not connected\n");
return 0;
}
l = sub->parent;
@@ -2657,8 +2655,7 @@ static struct ast_frame *skinny_rtp_read(struct skinny_subchannel *sub)
/* We already hold the channel lock */
if (f->frametype == AST_FRAME_VOICE) {
if (f->subclass != ast->nativeformats) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
+ ast_debug(1, "Oooh, format changed to %d\n", f->subclass);
ast->nativeformats = f->subclass;
ast_set_read_format(ast, ast->readformat);
ast_set_write_format(ast, ast->writeformat);
@@ -3383,8 +3380,7 @@ static int handle_stimulus_message(struct skinny_req *req, struct skinnysession
ast_setstate(sub->owner, AST_STATE_UP);
} else {
if (sub && sub->owner) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Current subchannel [%s] already has owner\n", sub->owner->name);
+ ast_debug(1, "Current subchannel [%s] already has owner\n", sub->owner->name);
} else {
c = skinny_new(l, AST_STATE_DOWN);
if (c) {
@@ -3463,8 +3459,7 @@ static int handle_offhook_message(struct skinny_req *req, struct skinnysession *
ast_setstate(sub->owner, AST_STATE_UP);
} else {
if (sub && sub->owner) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Current sub [%s] already has owner\n", sub->owner->name);
+ ast_debug(1, "Current sub [%s] already has owner\n", sub->owner->name);
} else {
c = skinny_new(l, AST_STATE_DOWN);
if (c) {
diff --git a/channels/chan_vpb.cc b/channels/chan_vpb.cc
index 748f58f7b..a89701a6a 100644
--- a/channels/chan_vpb.cc
+++ b/channels/chan_vpb.cc
@@ -536,7 +536,7 @@ static enum ast_bridge_result ast_vpb_bridge(struct ast_channel *c0, struct ast_
res = AST_BRIDGE_RETRY;
break;
}
- ast_log(LOG_DEBUG, "%s: vpb_bridge: Empty frame read...\n",p0->dev);
+ ast_debug(1, "%s: vpb_bridge: Empty frame read...\n",p0->dev);
/* check for hangup / whentohangup */
if (ast_check_hangup(c0) || ast_check_hangup(c1))
break;
@@ -548,7 +548,7 @@ static enum ast_bridge_result ast_vpb_bridge(struct ast_channel *c0, struct ast_
((who == c1) && (flags & AST_BRIDGE_DTMF_CHANNEL_1))))) {
*fo = f;
*rc = who;
- ast_log(LOG_DEBUG, "%s: vpb_bridge: Got a [%s]\n",p0->dev, f ? "digit" : "hangup");
+ ast_debug(1, "%s: vpb_bridge: Got a [%s]\n",p0->dev, f ? "digit" : "hangup");
/*
if ((c0->tech_pvt == pvt0) && (!c0->_softhangup)) {
if (pr0->set_rtp_peer(c0, NULL, NULL, 0))
@@ -930,9 +930,9 @@ static inline int monitor_handle_owned(struct vpb_pvt *p, VPB_EVENT *e)
} else
ast_log(LOG_NOTICE, "Fax detected, but no fax extension\n");
} else
- ast_log(LOG_DEBUG, "Already in a fax extension, not redirecting\n");
+ ast_debug(1, "Already in a fax extension, not redirecting\n");
} else
- ast_log(LOG_DEBUG, "Fax already handled\n");
+ ast_debug(1, "Fax already handled\n");
}
else if (e->data == VPB_GRUNT) {
@@ -1799,7 +1799,7 @@ static int vpb_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
if (option_verbose > 3) ast_verbose("%s: LOCKING count[%d] owner[%d] \n", p->dev, p->lock.__m_count,p->lock.__m_owner);
*/
ast_mutex_lock(&p->lock);
- ast_log(LOG_DEBUG, "New owner for channel %s is %s\n", p->dev, newchan->name);
+ ast_debug(1, "New owner for channel %s is %s\n", p->dev, newchan->name);
if (p->owner == oldchan) {
p->owner = newchan;
@@ -1957,7 +1957,7 @@ static int vpb_call(struct ast_channel *ast, char *dest, int timeout)
#endif
if (res != VPB_OK) {
- ast_log(LOG_DEBUG, "Call on %s to %s failed: %s\n", ast->name, s, vpb_strerror(res));
+ ast_debug(1, "Call on %s to %s failed: %s\n", ast->name, s, vpb_strerror(res));
res = -1;
} else
res = 0;
@@ -2278,7 +2278,7 @@ static int vpb_write(struct ast_channel *ast, struct ast_frame *frame)
/* ast_mutex_unlock(&p->lock); */
return 0;
}
-/* ast_log(LOG_DEBUG, "%s: vpb_write: Checked frame type..\n", p->dev); */
+/* ast_debug(1, "%s: vpb_write: Checked frame type..\n", p->dev); */
fmt = ast2vpbformat(frame->subclass);
@@ -2288,20 +2288,20 @@ static int vpb_write(struct ast_channel *ast, struct ast_frame *frame)
}
tdiff = ast_tvdiff_ms(ast_tvnow(), p->lastplay);
- ast_log(LOG_DEBUG, "%s: vpb_write: time since last play(%d) \n", p->dev, tdiff);
+ ast_debug(1, "%s: vpb_write: time since last play(%d) \n", p->dev, tdiff);
if (tdiff < (VPB_SAMPLES/8 - 1)){
- ast_log(LOG_DEBUG, "%s: vpb_write: Asked to play too often (%d) (%d)\n", p->dev, tdiff,frame->datalen);
+ ast_debug(1, "%s: vpb_write: Asked to play too often (%d) (%d)\n", p->dev, tdiff,frame->datalen);
// return 0;
}
p->lastplay = ast_tvnow();
/*
- ast_log(LOG_DEBUG, "%s: vpb_write: Checked frame format..\n", p->dev);
+ ast_debug(1, "%s: vpb_write: Checked frame format..\n", p->dev);
*/
ast_mutex_lock(&p->play_lock);
/*
- ast_log(LOG_DEBUG, "%s: vpb_write: Got play lock..\n", p->dev);
+ ast_debug(1, "%s: vpb_write: Got play lock..\n", p->dev);
*/
/* Check if we have set up the play_buf */
@@ -2329,8 +2329,8 @@ static int vpb_write(struct ast_channel *ast, struct ast_frame *frame)
if( p->txswgain > MAX_VPB_GAIN )
a_gain_vector(p->txswgain - MAX_VPB_GAIN , (short*)frame->data, frame->datalen/sizeof(short));
-/* ast_log(LOG_DEBUG, "%s: vpb_write: Applied gain..\n", p->dev); */
-/* ast_log(LOG_DEBUG, "%s: vpb_write: play_buf_time %d\n", p->dev, p->play_buf_time); */
+/* ast_debug(1, "%s: vpb_write: Applied gain..\n", p->dev); */
+/* ast_debug(1, "%s: vpb_write: play_buf_time %d\n", p->dev, p->play_buf_time); */
if ((p->read_state == 1)&&(p->play_buf_time<5)){
play_buf_time_start = ast_tvnow();
@@ -2344,7 +2344,7 @@ static int vpb_write(struct ast_channel *ast, struct ast_frame *frame)
}
else {
p->chuck_count++;
- ast_log(LOG_DEBUG, "%s: vpb_write: Tossed data away, tooooo much data!![%d]\n", p->dev,p->chuck_count);
+ ast_debug(1, "%s: vpb_write: Tossed data away, tooooo much data!![%d]\n", p->dev,p->chuck_count);
p->play_buf_time=0;
}
@@ -2473,11 +2473,11 @@ static void *do_chanreads(void *pvt)
/* afmt = (p->owner) ? p->owner->rawreadformat : AST_FORMAT_SLINEAR; */
if (p->owner){
afmt = p->owner->rawreadformat;
-/* ast_log(LOG_DEBUG,"%s: Record using owner format [%s]\n", p->dev, ast2vpbformatname(afmt)); */
+/* ast_debug(1,"%s: Record using owner format [%s]\n", p->dev, ast2vpbformatname(afmt)); */
}
else {
afmt = AST_FORMAT_SLINEAR;
-/* ast_log(LOG_DEBUG,"%s: Record using default format [%s]\n", p->dev, ast2vpbformatname(afmt)); */
+/* ast_debug(1,"%s: Record using default format [%s]\n", p->dev, ast2vpbformatname(afmt)); */
}
fmt = ast2vpbformat(afmt);
if (fmt < 0) {
@@ -2525,7 +2525,7 @@ static void *do_chanreads(void *pvt)
if ((use_ast_dtmfdet)&&(p->vad)){
fr = ast_dsp_process(p->owner,p->vad,fr);
if (fr && (fr->frametype == AST_FRAME_DTMF))
- ast_log(LOG_DEBUG, "%s: chanreads: Detected DTMF '%c'\n",p->dev, fr->subclass);
+ ast_debug(1, "%s: chanreads: Detected DTMF '%c'\n",p->dev, fr->subclass);
if (fr->subclass == 'm'){
/* conf mute request */
fr->frametype = AST_FRAME_NULL;
diff --git a/channels/chan_zap.c b/channels/chan_zap.c
index 69d5aa297..918da3602 100644
--- a/channels/chan_zap.c
+++ b/channels/chan_zap.c
@@ -976,8 +976,7 @@ static void swap_subs(struct zt_pvt *p, int a, int b)
int tinthreeway;
struct ast_channel *towner;
- if (option_debug)
- ast_log(LOG_DEBUG, "Swapping %d and %d\n", a, b);
+ ast_debug(1, "Swapping %d and %d\n", a, b);
tchan = p->subs[a].chan;
towner = p->subs[a].owner;
@@ -1080,8 +1079,7 @@ static int alloc_sub(struct zt_pvt *p, int x)
p->subs[x].zfd = -1;
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Allocated %s subchannel on FD %d channel %d\n", subnames[x], p->subs[x].zfd, p->subs[x].chan);
+ ast_debug(1, "Allocated %s subchannel on FD %d channel %d\n", subnames[x], p->subs[x].zfd, p->subs[x].chan);
return 0;
} else
ast_log(LOG_WARNING, "Unable to open pseudo channel: %s\n", strerror(errno));
@@ -1097,8 +1095,7 @@ static int unalloc_sub(struct zt_pvt *p, int x)
ast_log(LOG_WARNING, "Trying to unalloc the real channel %d?!?\n", p->channel);
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Released sub %d of channel %d\n", x, p->channel);
+ ast_debug(1, "Released sub %d of channel %d\n", x, p->channel);
if (p->subs[x].zfd > -1) {
zt_close(p->subs[x].zfd);
}
@@ -1153,8 +1150,7 @@ static int zt_digit_begin(struct ast_channel *chan, char digit)
ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", pvt->span);
} else if (strlen(pvt->dialdest) < sizeof(pvt->dialdest) - 1) {
int res;
- if (option_debug)
- ast_log(LOG_DEBUG, "Queueing digit '%c' since setup_ack not yet received\n", digit);
+ ast_debug(1, "Queueing digit '%c' since setup_ack not yet received\n", digit);
res = strlen(pvt->dialdest);
pvt->dialdest[res++] = digit;
pvt->dialdest[res] = '\0';
@@ -1179,8 +1175,7 @@ static int zt_digit_begin(struct ast_channel *chan, char digit)
else
pvt->dialing = 1;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Started VLDTMF digit '%c'\n", digit);
+ ast_debug(1, "Started VLDTMF digit '%c'\n", digit);
pvt->dialing = 1;
pvt->begindigit = digit;
}
@@ -1215,8 +1210,7 @@ static int zt_digit_end(struct ast_channel *chan, char digit, unsigned int durat
if (pvt->begindigit) {
x = -1;
- if (option_debug)
- ast_log(LOG_DEBUG, "Ending VLDTMF digit '%c'\n", digit);
+ ast_debug(1, "Ending VLDTMF digit '%c'\n", digit);
res = ioctl(pvt->subs[SUB_REAL].zfd, ZT_SENDTONE, &x);
pvt->dialing = 0;
pvt->begindigit = 0;
@@ -1390,8 +1384,7 @@ static int conf_add(struct zt_pvt *p, struct zt_subchannel *c, int index, int sl
p->confno = zi.confno;
}
memcpy(&c->curconf, &zi, sizeof(c->curconf));
- if (option_debug)
- ast_log(LOG_DEBUG, "Added %d to conference %d/%d\n", c->zfd, c->curconf.confmode, c->curconf.confno);
+ ast_debug(1, "Added %d to conference %d/%d\n", c->zfd, c->curconf.confmode, c->curconf.confno);
return 0;
}
@@ -1423,8 +1416,7 @@ static int conf_del(struct zt_pvt *p, struct zt_subchannel *c, int index)
ast_log(LOG_WARNING, "Failed to drop %d from conference %d/%d\n", c->zfd, c->curconf.confmode, c->curconf.confno);
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Removed %d from conference %d/%d\n", c->zfd, c->curconf.confmode, c->curconf.confno);
+ ast_debug(1, "Removed %d from conference %d/%d\n", c->zfd, c->curconf.confmode, c->curconf.confno);
memcpy(&c->curconf, &zi, sizeof(c->curconf));
return 0;
}
@@ -1538,8 +1530,7 @@ static int update_conf(struct zt_pvt *p)
Kill it. */
p->confno = -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Updated conferencing on %d, with %d conference users\n", p->channel, needconf);
+ ast_debug(1, "Updated conferencing on %d, with %d conference users\n", p->channel, needconf);
return 0;
}
@@ -1550,13 +1541,11 @@ static void zt_enable_ec(struct zt_pvt *p)
if (!p)
return;
if (p->echocanon) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Echo cancellation already on\n");
+ ast_debug(1, "Echo cancellation already on\n");
return;
}
if (p->digital) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Echo cancellation isn't required on digital connection\n");
+ ast_debug(1, "Echo cancellation isn't required on digital connection\n");
return;
}
if (p->echocancel) {
@@ -1572,11 +1561,10 @@ static void zt_enable_ec(struct zt_pvt *p)
ast_log(LOG_WARNING, "Unable to enable echo cancellation on channel %d\n", p->channel);
else {
p->echocanon = 1;
- if (option_debug)
- ast_log(LOG_DEBUG, "Enabled echo cancellation on channel %d\n", p->channel);
+ ast_debug(1, "Enabled echo cancellation on channel %d\n", p->channel);
}
- } else if (option_debug)
- ast_log(LOG_DEBUG, "No echo cancellation requested\n");
+ } else
+ ast_debug(1, "No echo cancellation requested\n");
}
static void zt_train_ec(struct zt_pvt *p)
@@ -1588,14 +1576,10 @@ static void zt_train_ec(struct zt_pvt *p)
res = ioctl(p->subs[SUB_REAL].zfd, ZT_ECHOTRAIN, &x);
if (res)
ast_log(LOG_WARNING, "Unable to request echo training on channel %d\n", p->channel);
- else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Engaged echo training on channel %d\n", p->channel);
- }
- } else {
- if (option_debug)
- ast_log(LOG_DEBUG, "No echo training requested\n");
- }
+ else
+ ast_debug(1, "Engaged echo training on channel %d\n", p->channel);
+ } else
+ ast_debug(1, "No echo training requested\n");
}
static void zt_disable_ec(struct zt_pvt *p)
@@ -1607,8 +1591,8 @@ static void zt_disable_ec(struct zt_pvt *p)
res = ioctl(p->subs[SUB_REAL].zfd, ZT_ECHOCANCEL, &x);
if (res)
ast_log(LOG_WARNING, "Unable to disable echo cancellation on channel %d\n", p->channel);
- else if (option_debug)
- ast_log(LOG_DEBUG, "disabled echo cancellation on channel %d\n", p->channel);
+ else
+ ast_debug(1, "disabled echo cancellation on channel %d\n", p->channel);
}
p->echocanon = 0;
}
@@ -1690,8 +1674,7 @@ static int set_actual_txgain(int fd, int chan, float gain, int law)
g.chan = chan;
res = ioctl(fd, ZT_GETGAINS, &g);
if (res) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Failed to read gains: %s\n", strerror(errno));
+ ast_debug(1, "Failed to read gains: %s\n", strerror(errno));
return res;
}
@@ -1709,8 +1692,7 @@ static int set_actual_rxgain(int fd, int chan, float gain, int law)
g.chan = chan;
res = ioctl(fd, ZT_GETGAINS, &g);
if (res) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Failed to read gains: %s\n", strerror(errno));
+ ast_debug(1, "Failed to read gains: %s\n", strerror(errno));
return res;
}
@@ -1803,8 +1785,7 @@ static int save_conference(struct zt_pvt *p)
ast_log(LOG_WARNING, "Unable to set conference info: %s\n", strerror(errno));
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Disabled conferencing\n");
+ ast_debug(1, "Disabled conferencing\n");
return 0;
}
@@ -1819,8 +1800,7 @@ static int restore_conference(struct zt_pvt *p)
return -1;
}
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Restored conferencing\n");
+ ast_debug(1, "Restored conferencing\n");
return 0;
}
@@ -2008,8 +1988,7 @@ static int zt_call(struct ast_channel *ast, char *rdest, int timeout)
if (c) {
p->dop.op = ZT_DIAL_OP_REPLACE;
snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "Tw%s", c);
- if (option_debug)
- ast_log(LOG_DEBUG, "FXO: setup deferred dialstring: %s\n", c);
+ ast_debug(1, "FXO: setup deferred dialstring: %s\n", c);
} else {
p->dop.dialstr[0] = '\0';
}
@@ -2101,8 +2080,7 @@ static int zt_call(struct ast_channel *ast, char *rdest, int timeout)
#ifdef HAVE_PRI
}
#endif
- if (option_debug)
- ast_log(LOG_DEBUG, "Dialing '%s'\n", c);
+ ast_debug(1, "Dialing '%s'\n", c);
p->dop.op = ZT_DIAL_OP_REPLACE;
c += p->stripmsd;
@@ -2177,10 +2155,9 @@ static int zt_call(struct ast_channel *ast, char *rdest, int timeout)
ast_mutex_unlock(&p->lock);
return -1;
}
- } else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Deferring dialing...\n");
- }
+ } else
+ ast_debug(1, "Deferring dialing...\n");
+
p->dialing = 1;
if (ast_strlen_zero(c))
p->dialednone = 1;
@@ -2196,8 +2173,7 @@ static int zt_call(struct ast_channel *ast, char *rdest, int timeout)
p->dialdest[0] = '\0';
break;
default:
- if (option_debug)
- ast_log(LOG_DEBUG, "not yet implemented\n");
+ ast_debug(1, "not yet implemented\n");
ast_mutex_unlock(&p->lock);
return -1;
}
@@ -2298,13 +2274,11 @@ static int zt_call(struct ast_channel *ast, char *rdest, int timeout)
}
if (p->bearer || (mysig == SIG_FXSKS)) {
if (p->bearer) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Oooh, I have a bearer on %d (%d:%d)\n", PVT_TO_CHANNEL(p->bearer), p->bearer->logicalspan, p->bearer->channel);
+ ast_debug(1, "Oooh, I have a bearer on %d (%d:%d)\n", PVT_TO_CHANNEL(p->bearer), p->bearer->logicalspan, p->bearer->channel);
p->bearer->call = p->call;
- } else {
- if (option_debug)
- ast_log(LOG_DEBUG, "I'm being setup with no bearer right now...\n");
- }
+ } else
+ ast_debug(1, "I'm being setup with no bearer right now...\n");
+
pri_set_crv(p->pri->pri, p->call, p->channel, 0);
}
p->digital = IS_DIGITAL(ast->transfercapability);
@@ -2495,24 +2469,21 @@ static int zap_send_keypad_facility_exec(struct ast_channel *chan, void *data)
char *digits = (char *) data;
if (ast_strlen_zero(digits)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "No digit string sent to application!\n");
+ ast_debug(1, "No digit string sent to application!\n");
return -1;
}
p = (struct zt_pvt *)chan->tech_pvt;
if (!p) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Unable to find technology private\n");
+ ast_debug(1, "Unable to find technology private\n");
return -1;
}
ast_mutex_lock(&p->lock);
if (!p->pri || !p->call) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Unable to find pri or call on channel!\n");
+ ast_debug(1, "Unable to find pri or call on channel!\n");
ast_mutex_unlock(&p->lock);
return -1;
}
@@ -2521,8 +2492,7 @@ static int zap_send_keypad_facility_exec(struct ast_channel *chan, void *data)
pri_keypad_facility(p->pri->pri, p->call, digits);
pri_rel(p->pri);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Unable to grab pri to send keypad facility!\n");
+ ast_debug(1, "Unable to grab pri to send keypad facility!\n");
ast_mutex_unlock(&p->lock);
return -1;
}
@@ -2621,8 +2591,7 @@ static int zt_hangup(struct ast_channel *ast)
struct zt_pvt *prev = NULL;
ZT_PARAMS par;
- if (option_debug)
- ast_log(LOG_DEBUG, "zt_hangup(%s)\n", ast->name);
+ ast_debug(1, "zt_hangup(%s)\n", ast->name);
if (!ast->tech_pvt) {
ast_log(LOG_WARNING, "Asked to hangup channel not connected\n");
return 0;
@@ -2655,9 +2624,8 @@ static int zt_hangup(struct ast_channel *ast)
if (p->exten)
p->exten[0] = '\0';
- if (option_debug)
- ast_log(LOG_DEBUG, "Hangup: channel: %d index = %d, normal = %d, callwait = %d, thirdcall = %d\n",
- p->channel, index, p->subs[SUB_REAL].zfd, p->subs[SUB_CALLWAIT].zfd, p->subs[SUB_THREEWAY].zfd);
+ ast_debug(1, "Hangup: channel: %d index = %d, normal = %d, callwait = %d, thirdcall = %d\n",
+ p->channel, index, p->subs[SUB_REAL].zfd, p->subs[SUB_CALLWAIT].zfd, p->subs[SUB_THREEWAY].zfd);
p->ignoredtmf = 0;
if (index > -1) {
@@ -2674,32 +2642,27 @@ static int zt_hangup(struct ast_channel *ast)
zt_setlinear(p->subs[index].zfd, 0);
if (index == SUB_REAL) {
if ((p->subs[SUB_CALLWAIT].zfd > -1) && (p->subs[SUB_THREEWAY].zfd > -1)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Normal call hung up with both three way call and a call waiting call in place?\n");
+ ast_debug(1, "Normal call hung up with both three way call and a call waiting call in place?\n");
if (p->subs[SUB_CALLWAIT].inthreeway) {
/* We had flipped over to answer a callwait and now it's gone */
- if (option_debug)
- ast_log(LOG_DEBUG, "We were flipped over to the callwait, moving back and unowning.\n");
+ ast_debug(1, "We were flipped over to the callwait, moving back and unowning.\n");
/* Move to the call-wait, but un-own us until they flip back. */
swap_subs(p, SUB_CALLWAIT, SUB_REAL);
unalloc_sub(p, SUB_CALLWAIT);
p->owner = NULL;
} else {
/* The three way hung up, but we still have a call wait */
- if (option_debug)
- ast_log(LOG_DEBUG, "We were in the threeway and have a callwait still. Ditching the threeway.\n");
+ ast_debug(1, "We were in the threeway and have a callwait still. Ditching the threeway.\n");
swap_subs(p, SUB_THREEWAY, SUB_REAL);
unalloc_sub(p, SUB_THREEWAY);
if (p->subs[SUB_REAL].inthreeway) {
/* This was part of a three way call. Immediately make way for
another call */
- if (option_debug)
- ast_log(LOG_DEBUG, "Call was complete, setting owner to former third call\n");
+ ast_debug(1, "Call was complete, setting owner to former third call\n");
p->owner = p->subs[SUB_REAL].owner;
} else {
/* This call hasn't been completed yet... Set owner to NULL */
- if (option_debug)
- ast_log(LOG_DEBUG, "Call was incomplete, setting owner to NULL\n");
+ ast_debug(1, "Call was incomplete, setting owner to NULL\n");
p->owner = NULL;
}
p->subs[SUB_REAL].inthreeway = 0;
@@ -2719,13 +2682,11 @@ static int zt_hangup(struct ast_channel *ast)
if (p->subs[SUB_REAL].inthreeway) {
/* This was part of a three way call. Immediately make way for
another call */
- if (option_debug)
- ast_log(LOG_DEBUG, "Call was complete, setting owner to former third call\n");
+ ast_debug(1, "Call was complete, setting owner to former third call\n");
p->owner = p->subs[SUB_REAL].owner;
} else {
/* This call hasn't been completed yet... Set owner to NULL */
- if (option_debug)
- ast_log(LOG_DEBUG, "Call was incomplete, setting owner to NULL\n");
+ ast_debug(1, "Call was incomplete, setting owner to NULL\n");
p->owner = NULL;
}
p->subs[SUB_REAL].inthreeway = 0;
@@ -2828,8 +2789,7 @@ static int zt_hangup(struct ast_channel *ast)
if (p->call && (!p->bearer || (p->bearer->call == p->call))) {
if (!pri_grab(p, p->pri)) {
if (p->alreadyhungup) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Already hungup... Calling hangup once, and clearing call\n");
+ ast_debug(1, "Already hungup... Calling hangup once, and clearing call\n");
#ifdef SUPPORT_USERUSER
pri_call_set_useruser(p->call, useruser);
@@ -2842,8 +2802,7 @@ static int zt_hangup(struct ast_channel *ast)
} else {
const char *cause = pbx_builtin_getvar_helper(ast,"PRI_CAUSE");
int icause = ast->hangupcause ? ast->hangupcause : -1;
- if (option_debug)
- ast_log(LOG_DEBUG, "Not yet hungup... Calling hangup once with icause, and clearing call\n");
+ ast_debug(1, "Not yet hungup... Calling hangup once with icause, and clearing call\n");
#ifdef SUPPORT_USERUSER
pri_call_set_useruser(p->call, useruser);
@@ -2867,8 +2826,7 @@ static int zt_hangup(struct ast_channel *ast)
}
} else {
if (p->bearer)
- if (option_debug)
- ast_log(LOG_DEBUG, "Bearer call is %p, while ours is still %p\n", p->bearer->call, p->call);
+ ast_debug(1, "Bearer call is %p, while ours is still %p\n", p->bearer->call, p->call);
p->call = NULL;
res = 0;
}
@@ -2886,8 +2844,7 @@ static int zt_hangup(struct ast_channel *ast)
res = ioctl(p->subs[SUB_REAL].zfd, ZT_GET_PARAMS, &par);
if (!res) {
#if 0
- if (option_debug)
- ast_log(LOG_DEBUG, "Hanging up channel %d, offhook = %d\n", p->channel, par.rxisoffhook);
+ ast_debug(1, "Hanging up channel %d, offhook = %d\n", p->channel, par.rxisoffhook);
#endif
/* If they're off hook, try playing congestion */
if ((par.rxisoffhook) && (!(p->radio || (p->oprmode < 0))))
@@ -2932,8 +2889,7 @@ static int zt_hangup(struct ast_channel *ast)
}
#ifdef HAVE_PRI
if (p->bearer) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Freeing up bearer channel %d\n", p->bearer->channel);
+ ast_debug(1, "Freeing up bearer channel %d\n", p->bearer->channel);
/* Free up the bearer channel as well, and
don't use its file descriptor anymore */
update_conf(p->bearer);
@@ -3016,8 +2972,7 @@ static int zt_answer(struct ast_channel *ast)
case SIG_FXOGS:
case SIG_FXOKS:
/* Pick up the line */
- if (option_debug)
- ast_log(LOG_DEBUG, "Took %s off hook\n", ast->name);
+ ast_debug(1, "Took %s off hook\n", ast->name);
if (p->hanguponpolarityswitch) {
gettimeofday(&p->polaritydelaytv, NULL);
}
@@ -3026,8 +2981,7 @@ static int zt_answer(struct ast_channel *ast)
p->dialing = 0;
if ((index == SUB_REAL) && p->subs[SUB_THREEWAY].inthreeway) {
if (oldstate == AST_STATE_RINGING) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Finally swapping real and threeway\n");
+ ast_debug(1, "Finally swapping real and threeway\n");
tone_zone_play_tone(p->subs[SUB_THREEWAY].zfd, -1);
swap_subs(p, SUB_THREEWAY, SUB_REAL);
p->owner = p->subs[SUB_REAL].owner;
@@ -3098,8 +3052,7 @@ static int zt_setoption(struct ast_channel *chan, int option, void *data, int da
ast_log(LOG_WARNING, "No index in TXGAIN?\n");
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Setting actual tx gain on %s to %f\n", chan->name, p->txgain + (float) *scp);
+ ast_debug(1, "Setting actual tx gain on %s to %f\n", chan->name, p->txgain + (float) *scp);
return set_actual_txgain(p->subs[index].zfd, 0, p->txgain + (float) *scp, p->law);
case AST_OPTION_RXGAIN:
scp = (signed char *) data;
@@ -3108,8 +3061,7 @@ static int zt_setoption(struct ast_channel *chan, int option, void *data, int da
ast_log(LOG_WARNING, "No index in RXGAIN?\n");
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Setting actual rx gain on %s to %f\n", chan->name, p->rxgain + (float) *scp);
+ ast_debug(1, "Setting actual rx gain on %s to %f\n", chan->name, p->rxgain + (float) *scp);
return set_actual_rxgain(p->subs[index].zfd, 0, p->rxgain + (float) *scp, p->law);
case AST_OPTION_TONE_VERIFY:
if (!p->dsp)
@@ -3117,18 +3069,15 @@ static int zt_setoption(struct ast_channel *chan, int option, void *data, int da
cp = (char *) data;
switch (*cp) {
case 1:
- if (option_debug)
- ast_log(LOG_DEBUG, "Set option TONE VERIFY, mode: MUTECONF(1) on %s\n",chan->name);
+ ast_debug(1, "Set option TONE VERIFY, mode: MUTECONF(1) on %s\n",chan->name);
ast_dsp_digitmode(p->dsp,DSP_DIGITMODE_MUTECONF | p->dtmfrelax); /* set mute mode if desired */
break;
case 2:
- if (option_debug)
- ast_log(LOG_DEBUG, "Set option TONE VERIFY, mode: MUTECONF/MAX(2) on %s\n",chan->name);
+ ast_debug(1, "Set option TONE VERIFY, mode: MUTECONF/MAX(2) on %s\n",chan->name);
ast_dsp_digitmode(p->dsp,DSP_DIGITMODE_MUTECONF | DSP_DIGITMODE_MUTEMAX | p->dtmfrelax); /* set mute mode if desired */
break;
default:
- if (option_debug)
- ast_log(LOG_DEBUG, "Set option TONE VERIFY, mode: OFF(0) on %s\n",chan->name);
+ ast_debug(1, "Set option TONE VERIFY, mode: OFF(0) on %s\n",chan->name);
ast_dsp_digitmode(p->dsp,DSP_DIGITMODE_DTMF | p->dtmfrelax); /* set mute mode if desired */
break;
}
@@ -3138,16 +3087,14 @@ static int zt_setoption(struct ast_channel *chan, int option, void *data, int da
cp = (char *) data;
p->mate = 0;
if (!*cp) { /* turn it off */
- if (option_debug)
- ast_log(LOG_DEBUG, "Set option TDD MODE, value: OFF(0) on %s\n",chan->name);
+ ast_debug(1, "Set option TDD MODE, value: OFF(0) on %s\n",chan->name);
if (p->tdd)
tdd_free(p->tdd);
p->tdd = 0;
break;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Set option TDD MODE, value: %s(%d) on %s\n",
- (*cp == 2) ? "MATE" : "ON", (int) *cp, chan->name);
+ ast_debug(1, "Set option TDD MODE, value: %s(%d) on %s\n",
+ (*cp == 2) ? "MATE" : "ON", (int) *cp, chan->name);
zt_disable_ec(p);
/* otherwise, turn it on */
if (!p->didtdd) { /* if havent done it yet */
@@ -3176,23 +3123,20 @@ static int zt_setoption(struct ast_channel *chan, int option, void *data, int da
fds[0].revents = 0;
res = poll(fds, 1, -1);
if (!res) {
- if (option_debug)
- ast_log(LOG_DEBUG, "poll (for write) ret. 0 on channel %d\n", p->channel);
+ ast_debug(1, "poll (for write) ret. 0 on channel %d\n", p->channel);
continue;
}
/* if got exception */
if (fds[0].revents & POLLPRI)
return -1;
if (!(fds[0].revents & POLLOUT)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "write fd not ready on channel %d\n", p->channel);
+ ast_debug(1, "write fd not ready on channel %d\n", p->channel);
continue;
}
res = write(fd, buf, size);
if (res != size) {
if (res == -1) return -1;
- if (option_debug)
- ast_log(LOG_DEBUG, "Write returned %d (%s) on channel %d\n", res, strerror(errno), p->channel);
+ ast_debug(1, "Write returned %d (%s) on channel %d\n", res, strerror(errno), p->channel);
break;
}
len -= size;
@@ -3215,21 +3159,18 @@ static int zt_setoption(struct ast_channel *chan, int option, void *data, int da
if (!p->dsp)
break;
cp = (char *) data;
- if (option_debug)
- ast_log(LOG_DEBUG, "Set option RELAX DTMF, value: %s(%d) on %s\n",
- *cp ? "ON" : "OFF", (int) *cp, chan->name);
+ ast_debug(1, "Set option RELAX DTMF, value: %s(%d) on %s\n",
+ *cp ? "ON" : "OFF", (int) *cp, chan->name);
ast_dsp_digitmode(p->dsp, ((*cp) ? DSP_DIGITMODE_RELAXDTMF : DSP_DIGITMODE_DTMF) | p->dtmfrelax);
break;
case AST_OPTION_AUDIO_MODE: /* Set AUDIO mode (or not) */
cp = (char *) data;
if (!*cp) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Set option AUDIO MODE, value: OFF(0) on %s\n", chan->name);
+ ast_debug(1, "Set option AUDIO MODE, value: OFF(0) on %s\n", chan->name);
x = 0;
zt_disable_ec(p);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Set option AUDIO MODE, value: ON(1) on %s\n", chan->name);
+ ast_debug(1, "Set option AUDIO MODE, value: ON(1) on %s\n", chan->name);
x = 1;
}
if (ioctl(p->subs[SUB_REAL].zfd, ZT_AUDIOMODE, &x) == -1)
@@ -3248,19 +3189,16 @@ static int zt_setoption(struct ast_channel *chan, int option, void *data, int da
pp->oprmode = oprmode->mode;
p->oprmode = -oprmode->mode;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Set Operator Services mode, value: %d on %s/%s\n",
- oprmode->mode, chan->name,oprmode->peer->name);
+ ast_debug(1, "Set Operator Services mode, value: %d on %s/%s\n",
+ oprmode->mode, chan->name,oprmode->peer->name);
break;
case AST_OPTION_ECHOCAN:
cp = (char *) data;
if (*cp) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Enabling echo cancelation on %s\n", chan->name);
+ ast_debug(1, "Enabling echo cancelation on %s\n", chan->name);
zt_enable_ec(p);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Disabling echo cancelation on %s\n", chan->name);
+ ast_debug(1, "Disabling echo cancelation on %s\n", chan->name);
zt_disable_ec(p);
}
break;
@@ -3311,8 +3249,7 @@ static void zt_unlink(struct zt_pvt *slave, struct zt_pvt *master, int needlock)
if (master->slaves[x]) {
if (!slave || (master->slaves[x] == slave)) {
/* Take slave out of the conference */
- if (option_debug)
- ast_log(LOG_DEBUG, "Unlinking slave %d from %d\n", master->slaves[x]->channel, master->channel);
+ ast_debug(1, "Unlinking slave %d from %d\n", master->slaves[x]->channel, master->channel);
conf_del(master, &master->slaves[x]->subs[SUB_REAL], SUB_REAL);
conf_del(master->slaves[x], &master->subs[SUB_REAL], SUB_REAL);
master->slaves[x]->master = NULL;
@@ -3368,8 +3305,7 @@ static void zt_link(struct zt_pvt *slave, struct zt_pvt *master) {
ast_log(LOG_WARNING, "Replacing master %d with new master, %d\n", slave->master->channel, master->channel);
slave->master = master;
- if (option_debug)
- ast_log(LOG_DEBUG, "Making %d slave to master %d at %d\n", slave->channel, master->channel, x);
+ ast_debug(1, "Making %d slave to master %d at %d\n", slave->channel, master->channel, x);
}
static void disable_dtmf_detect(struct zt_pvt *p)
@@ -3532,9 +3468,8 @@ static enum ast_bridge_result zt_bridge(struct ast_channel *c0, struct ast_chann
nothingok = 0;
}
}
- if (option_debug)
- ast_log(LOG_DEBUG, "master: %d, slave: %d, nothingok: %d\n",
- master ? master->channel : 0, slave ? slave->channel : 0, nothingok);
+ ast_debug(1, "master: %d, slave: %d, nothingok: %d\n",
+ master ? master->channel : 0, slave ? slave->channel : 0, nothingok);
if (master && slave) {
/* Stop any tones, or play ringtone as appropriate. If they're bridged
in an active threeway call with a channel that is ringing, we should
@@ -3544,13 +3479,11 @@ static enum ast_bridge_result zt_bridge(struct ast_channel *c0, struct ast_chann
p1->subs[SUB_REAL].owner &&
p1->subs[SUB_REAL].inthreeway &&
(p1->subs[SUB_REAL].owner->_state == AST_STATE_RINGING)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Playing ringback on %s since %s is in a ringing three-way\n", c0->name, c1->name);
+ ast_debug(1, "Playing ringback on %s since %s is in a ringing three-way\n", c0->name, c1->name);
tone_zone_play_tone(p0->subs[oi0].zfd, ZT_TONE_RINGTONE);
os1 = p1->subs[SUB_REAL].owner->_state;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Stopping tones on %d/%d talking to %d/%d\n", p0->channel, oi0, p1->channel, oi1);
+ ast_debug(1, "Stopping tones on %d/%d talking to %d/%d\n", p0->channel, oi0, p1->channel, oi1);
tone_zone_play_tone(p0->subs[oi0].zfd, -1);
}
if ((oi0 == SUB_THREEWAY) &&
@@ -3558,13 +3491,11 @@ static enum ast_bridge_result zt_bridge(struct ast_channel *c0, struct ast_chann
p0->subs[SUB_REAL].owner &&
p0->subs[SUB_REAL].inthreeway &&
(p0->subs[SUB_REAL].owner->_state == AST_STATE_RINGING)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Playing ringback on %s since %s is in a ringing three-way\n", c1->name, c0->name);
+ ast_debug(1, "Playing ringback on %s since %s is in a ringing three-way\n", c1->name, c0->name);
tone_zone_play_tone(p1->subs[oi1].zfd, ZT_TONE_RINGTONE);
os0 = p0->subs[SUB_REAL].owner->_state;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Stopping tones on %d/%d talking to %d/%d\n", p1->channel, oi1, p0->channel, oi0);
+ ast_debug(1, "Stopping tones on %d/%d talking to %d/%d\n", p1->channel, oi1, p0->channel, oi0);
tone_zone_play_tone(p1->subs[oi0].zfd, -1);
}
if ((oi0 == SUB_REAL) && (oi1 == SUB_REAL)) {
@@ -3637,9 +3568,8 @@ static enum ast_bridge_result zt_bridge(struct ast_channel *c0, struct ast_chann
(t1 != p1->subs[SUB_REAL].inthreeway) ||
(oi0 != i0) ||
(oi1 != i1)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Something changed out on %d/%d to %d/%d, returning -3 to restart\n",
- op0->channel, oi0, op1->channel, oi1);
+ ast_debug(1, "Something changed out on %d/%d to %d/%d, returning -3 to restart\n",
+ op0->channel, oi0, op1->channel, oi1);
res = AST_BRIDGE_RETRY;
goto return_from_bridge;
}
@@ -3657,8 +3587,7 @@ static enum ast_bridge_result zt_bridge(struct ast_channel *c0, struct ast_chann
who = ast_waitfor_n(priority ? c0_priority : c1_priority, 2, &timeoutms);
if (!who) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Ooh, empty read...\n");
+ ast_debug(1, "Ooh, empty read...\n");
continue;
}
f = ast_read(who);
@@ -3709,8 +3638,7 @@ static int zt_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
struct zt_pvt *p = newchan->tech_pvt;
int x;
ast_mutex_lock(&p->lock);
- if (option_debug)
- ast_log(LOG_DEBUG, "New owner for channel %d is %s\n", p->channel, newchan->name);
+ ast_debug(1, "New owner for channel %d is %s\n", p->channel, newchan->name);
if (p->owner == oldchan) {
p->owner = newchan;
}
@@ -3829,9 +3757,8 @@ static int attempt_transfer(struct zt_pvt *p)
/* Tell the caller not to hangup */
return 1;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Neither %s nor %s are in a bridge, nothing to transfer\n",
- p->subs[SUB_REAL].owner->name, p->subs[SUB_THREEWAY].owner->name);
+ ast_debug(1, "Neither %s nor %s are in a bridge, nothing to transfer\n",
+ p->subs[SUB_REAL].owner->name, p->subs[SUB_THREEWAY].owner->name);
p->subs[SUB_THREEWAY].owner->_softhangup |= AST_SOFTHANGUP_DEV;
return -1;
}
@@ -3879,12 +3806,10 @@ static void zt_handle_dtmfup(struct ast_channel *ast, int index, struct ast_fram
struct zt_pvt *p = ast->tech_pvt;
struct ast_frame *f = *dest;
- if (option_debug)
- ast_log(LOG_DEBUG, "DTMF digit: %c on %s\n", f->subclass, ast->name);
+ ast_debug(1, "DTMF digit: %c on %s\n", f->subclass, ast->name);
if (p->confirmanswer) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Confirm answer on %s!\n", ast->name);
+ ast_debug(1, "Confirm answer on %s!\n", ast->name);
/* Upon receiving a DTMF digit, consider this an answer confirmation instead
of a DTMF digit */
p->subs[index].f.frametype = AST_FRAME_CONTROL;
@@ -3894,8 +3819,7 @@ static void zt_handle_dtmfup(struct ast_channel *ast, int index, struct ast_fram
p->confirmanswer = 0;
} else if (p->callwaitcas) {
if ((f->subclass == 'A') || (f->subclass == 'D')) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Got some DTMF, but it's for the CAS\n");
+ ast_debug(1, "Got some DTMF, but it's for the CAS\n");
if (p->cidspill)
ast_free(p->cidspill);
send_cwcidspill(p);
@@ -3921,10 +3845,10 @@ static void zt_handle_dtmfup(struct ast_channel *ast, int index, struct ast_fram
ast_log(LOG_WARNING, "Failed to async goto '%s' into fax of '%s'\n", ast->name, target_context);
} else
ast_log(LOG_NOTICE, "Fax detected, but no fax extension\n");
- } else if (option_debug)
- ast_log(LOG_DEBUG, "Already in a fax extension, not redirecting\n");
- } else if (option_debug)
- ast_log(LOG_DEBUG, "Fax already handled\n");
+ } else
+ ast_debug(1, "Already in a fax extension, not redirecting\n");
+ } else
+ ast_debug(1, "Fax already handled\n");
zt_confmute(p, 0);
p->subs[index].f.frametype = AST_FRAME_NULL;
p->subs[index].f.subclass = 0;
@@ -3977,13 +3901,11 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
} else
res = zt_get_event(p->subs[index].zfd);
- if (option_debug)
- ast_log(LOG_DEBUG, "Got event %s(%d) on channel %d (index %d)\n", event2str(res), res, p->channel, index);
+ ast_debug(1, "Got event %s(%d) on channel %d (index %d)\n", event2str(res), res, p->channel, index);
if (res & (ZT_EVENT_PULSEDIGIT | ZT_EVENT_DTMFUP)) {
p->pulsedial = (res & ZT_EVENT_PULSEDIGIT) ? 1 : 0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Detected %sdigit '%c'\n", p->pulsedial ? "pulse ": "", res & 0xff);
+ ast_debug(1, "Detected %sdigit '%c'\n", p->pulsedial ? "pulse ": "", res & 0xff);
#ifdef HAVE_PRI
if (!p->proceeding && p->sig == SIG_PRI && p->pri && (p->pri->overlapdial & ZAP_OVERLAPDIAL_INCOMING)) {
/* absorb event */
@@ -3999,8 +3921,7 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
}
if (res & ZT_EVENT_DTMFDOWN) {
- if (option_debug)
- ast_log(LOG_DEBUG, "DTMF Down '%c'\n", res & 0xff);
+ ast_debug(1, "DTMF Down '%c'\n", res & 0xff);
/* Mute conference */
zt_confmute(p, 1);
p->subs[index].f.frametype = AST_FRAME_DTMF_BEGIN;
@@ -4027,8 +3948,7 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
if (p->inalarm) break;
if ((p->radio || (p->oprmode < 0))) break;
if (ioctl(p->subs[index].zfd,ZT_DIALING,&x) == -1) {
- if (option_debug)
- ast_log(LOG_DEBUG, "ZT_DIALING ioctl failed on %s\n",ast->name);
+ ast_debug(1, "ZT_DIALING ioctl failed on %s\n",ast->name);
return NULL;
}
if (!x) { /* if not still dialing in driver */
@@ -4055,8 +3975,7 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
}
if (ast->_state == AST_STATE_DIALING) {
if ((p->callprogress & 1) && CANPROGRESSDETECT(p) && p->dsp && p->outgoing) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Done dialing, but waiting for progress detection before doing more...\n");
+ ast_debug(1, "Done dialing, but waiting for progress detection before doing more...\n");
} else if (p->confirmanswer || (!p->dialednone && ((mysig == SIG_EM) || (mysig == SIG_EM_E1) || (mysig == SIG_EMWINK) || (mysig == SIG_FEATD) || (mysig == SIG_FEATDMF_TA) || (mysig == SIG_FEATDMF) || (mysig == SIG_E911) || (mysig == SIG_FGC_CAMA) || (mysig == SIG_FGC_CAMAMF) || (mysig == SIG_FEATB) || (mysig == SIG_SF) || (mysig == SIG_SFWINK) || (mysig == SIG_SF_FEATD) || (mysig == SIG_SF_FEATDMF) || (mysig == SIG_SF_FEATB)))) {
ast_setstate(ast, AST_STATE_RINGING);
} else if (!p->answeronpolarityswitch) {
@@ -4174,16 +4093,14 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
return NULL;
}
mssinceflash = ast_tvdiff_ms(ast_tvnow(), p->flashtime);
- if (option_debug)
- ast_log(LOG_DEBUG, "Last flash was %d ms ago\n", mssinceflash);
+ ast_debug(1, "Last flash was %d ms ago\n", mssinceflash);
if (mssinceflash < MIN_MS_SINCE_FLASH) {
/* It hasn't been long enough since the last flashook. This is probably a bounce on
hanging up. Hangup both channels now */
if (p->subs[SUB_THREEWAY].owner)
ast_queue_hangup(p->subs[SUB_THREEWAY].owner);
p->subs[SUB_THREEWAY].owner->_softhangup |= AST_SOFTHANGUP_DEV;
- if (option_debug)
- ast_log(LOG_DEBUG, "Looks like a bounced flash, hanging up both calls on %d\n", p->channel);
+ ast_debug(1, "Looks like a bounced flash, hanging up both calls on %d\n", p->channel);
ast_mutex_unlock(&p->subs[SUB_THREEWAY].owner->lock);
} else if ((ast->pbx) || (ast->_state == AST_STATE_UP)) {
if (p->transfer) {
@@ -4291,8 +4208,7 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
p->subs[index].f.subclass = AST_CONTROL_ANSWER;
/* Make sure it stops ringing */
zt_set_hook(p->subs[index].zfd, ZT_OFFHOOK);
- if (option_debug)
- ast_log(LOG_DEBUG, "channel %d answered\n", p->channel);
+ ast_debug(1, "channel %d answered\n", p->channel);
if (p->cidspill) {
/* Cancel any running CallerID spill */
ast_free(p->cidspill);
@@ -4312,8 +4228,7 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
p->dop.dialstr[0] = '\0';
return NULL;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Sent FXO deferred digit string: %s\n", p->dop.dialstr);
+ ast_debug(1, "Sent FXO deferred digit string: %s\n", p->dop.dialstr);
p->subs[index].f.frametype = AST_FRAME_NULL;
p->subs[index].f.subclass = 0;
p->dialing = 1;
@@ -4328,8 +4243,7 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
ast->rings = 1;
p->subs[index].f.frametype = AST_FRAME_CONTROL;
p->subs[index].f.subclass = AST_CONTROL_OFFHOOK;
- if (option_debug)
- ast_log(LOG_DEBUG, "channel %d picked up\n", p->channel);
+ ast_debug(1, "channel %d picked up\n", p->channel);
return &p->subs[index].f;
case AST_STATE_UP:
/* Make sure it stops ringing */
@@ -4359,10 +4273,9 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
/* If we get a ring then we cannot be in
* reversed polarity. So we reset to idle */
- if (option_debug)
- ast_log(LOG_DEBUG, "Setting IDLE polarity due "
- "to ring. Old polarity was %d\n",
- p->polarity);
+ ast_debug(1, "Setting IDLE polarity due "
+ "to ring. Old polarity was %d\n",
+ p->polarity);
p->polarity = POLARITY_IDLE;
/* Fall through */
@@ -4384,13 +4297,11 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
if (ast->_state == AST_STATE_PRERING)
ast_setstate(ast, AST_STATE_RING);
if ((ast->_state == AST_STATE_DOWN) || (ast->_state == AST_STATE_RING)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Ring detected\n");
+ ast_debug(1, "Ring detected\n");
p->subs[index].f.frametype = AST_FRAME_CONTROL;
p->subs[index].f.subclass = AST_CONTROL_RING;
} else if (p->outgoing && ((ast->_state == AST_STATE_RINGING) || (ast->_state == AST_STATE_DIALING))) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Line answered\n");
+ ast_debug(1, "Line answered\n");
if (p->confirmanswer) {
p->subs[index].f.frametype = AST_FRAME_NULL;
p->subs[index].f.subclass = 0;
@@ -4472,9 +4383,8 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
case SIG_FXOLS:
case SIG_FXOGS:
case SIG_FXOKS:
- if (option_debug)
- ast_log(LOG_DEBUG, "Winkflash, index: %d, normal: %d, callwait: %d, thirdcall: %d\n",
- index, p->subs[SUB_REAL].zfd, p->subs[SUB_CALLWAIT].zfd, p->subs[SUB_THREEWAY].zfd);
+ ast_debug(1, "Winkflash, index: %d, normal: %d, callwait: %d, thirdcall: %d\n",
+ index, p->subs[SUB_REAL].zfd, p->subs[SUB_CALLWAIT].zfd, p->subs[SUB_THREEWAY].zfd);
p->callwaitcas = 0;
if (index != SUB_REAL) {
@@ -4487,8 +4397,7 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
swap_subs(p, SUB_REAL, SUB_CALLWAIT);
tone_zone_play_tone(p->subs[SUB_REAL].zfd, -1);
p->owner = p->subs[SUB_REAL].owner;
- if (option_debug)
- ast_log(LOG_DEBUG, "Making %s the new owner\n", p->owner->name);
+ ast_debug(1, "Making %s the new owner\n", p->owner->name);
if (p->owner->_state == AST_STATE_RINGING) {
ast_setstate(p->owner, AST_STATE_UP);
p->subs[SUB_REAL].needanswer = 1;
@@ -4528,8 +4437,7 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
if (!((ast->pbx) ||
(ast->_state == AST_STATE_UP) ||
(ast->_state == AST_STATE_RING))) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Flash when call not up or ringing\n");
+ ast_debug(1, "Flash when call not up or ringing\n");
goto winkflashdone;
}
if (alloc_sub(p, SUB_THREEWAY)) {
@@ -4577,8 +4485,7 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
/* Already have a 3 way call */
if (p->subs[SUB_THREEWAY].inthreeway) {
/* Call is already up, drop the last person */
- if (option_debug)
- ast_log(LOG_DEBUG, "Got flash with three way call up, dropping last call on %d\n", p->channel);
+ ast_debug(1, "Got flash with three way call up, dropping last call on %d\n", p->channel);
/* If the primary call isn't answered yet, use it */
if ((p->subs[SUB_REAL].owner->_state != AST_STATE_UP) && (p->subs[SUB_THREEWAY].owner->_state == AST_STATE_UP)) {
/* Swap back -- we're dropping the real 3-way that isn't finished yet*/
@@ -4611,8 +4518,7 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
p->subs[otherindex].needunhold = 1;
p->owner = p->subs[SUB_REAL].owner;
if (ast->_state == AST_STATE_RINGING) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Enabling ringtone on real and threeway\n");
+ ast_debug(1, "Enabling ringtone on real and threeway\n");
res = tone_zone_play_tone(p->subs[SUB_REAL].zfd, ZT_TONE_RINGTONE);
res = tone_zone_play_tone(p->subs[SUB_THREEWAY].zfd, ZT_TONE_RINGTONE);
}
@@ -4644,16 +4550,15 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
case SIG_FXSGS:
if (option_debug) {
if (p->dialing)
- ast_log(LOG_DEBUG, "Ignoring wink on channel %d\n", p->channel);
+ ast_debug(1, "Ignoring wink on channel %d\n", p->channel);
else
- ast_log(LOG_DEBUG, "Got wink in weird state %d on channel %d\n", ast->_state, p->channel);
+ ast_debug(1, "Got wink in weird state %d on channel %d\n", ast->_state, p->channel);
}
break;
case SIG_FEATDMF_TA:
switch (p->whichwink) {
case 0:
- if (option_debug)
- ast_log(LOG_DEBUG, "ANI2 set to '%d' and ANI is '%s'\n", p->owner->cid.cid_ani2, p->owner->cid.cid_ani);
+ ast_debug(1, "ANI2 set to '%d' and ANI is '%s'\n", p->owner->cid.cid_ani2, p->owner->cid.cid_ani);
snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*%d%s#", p->owner->cid.cid_ani2, p->owner->cid.cid_ani);
break;
case 1:
@@ -4679,10 +4584,9 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
ast_log(LOG_WARNING, "Unable to initiate dialing on trunk channel %d\n", p->channel);
p->dop.dialstr[0] = '\0';
return NULL;
- } else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Sent deferred digit string: %s\n", p->dop.dialstr);
- }
+ } else
+ ast_debug(1, "Sent deferred digit string: %s\n", p->dop.dialstr);
+
p->dop.dialstr[0] = '\0';
break;
default:
@@ -4709,10 +4613,9 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
ast_log(LOG_WARNING, "Unable to initiate dialing on trunk channel %d\n", p->channel);
p->dop.dialstr[0] = '\0';
return NULL;
- } else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Sent deferred digit string: %s\n", p->dop.dialstr);
- }
+ } else
+ ast_debug(1, "Sent deferred digit string: %s\n", p->dop.dialstr);
+
p->dop.dialstr[0] = '\0';
p->dop.op = ZT_DIAL_OP_REPLACE;
break;
@@ -4724,8 +4627,7 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
case SIG_FEATB:
case SIG_SF_FEATDMF:
case SIG_SF_FEATB:
- if (option_debug)
- ast_log(LOG_DEBUG, "Got hook complete in MF FGD, waiting for wink now on channel %d\n",p->channel);
+ ast_debug(1, "Got hook complete in MF FGD, waiting for wink now on channel %d\n",p->channel);
break;
default:
break;
@@ -4743,16 +4645,14 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
if (p->answeronpolarityswitch &&
((ast->_state == AST_STATE_DIALING) ||
(ast->_state == AST_STATE_RINGING))) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Answering on polarity switch!\n");
+ ast_debug(1, "Answering on polarity switch!\n");
ast_setstate(p->owner, AST_STATE_UP);
if (p->hanguponpolarityswitch) {
gettimeofday(&p->polaritydelaytv, NULL);
}
- } else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Ignore switch to REVERSED Polarity on channel %d, state %d\n", p->channel, ast->_state);
- }
+ } else
+ ast_debug(1, "Ignore switch to REVERSED Polarity on channel %d, state %d\n", p->channel, ast->_state);
+
}
/* Removed else statement from here as it was preventing hangups from ever happening*/
/* Added AST_STATE_RING in if statement below to deal with calling party hangups that take place when ringing */
@@ -4761,30 +4661,24 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
(p->polarity == POLARITY_REV) &&
((ast->_state == AST_STATE_UP) || (ast->_state == AST_STATE_RING)) ) {
/* Added log_debug information below to provide a better indication of what is going on */
- if (option_debug)
- ast_log(LOG_DEBUG, "Polarity Reversal event occured - DEBUG 1: channel %d, state %d, pol= %d, aonp= %d, honp= %d, pdelay= %d, tv= %d\n", p->channel, ast->_state, p->polarity, p->answeronpolarityswitch, p->hanguponpolarityswitch, p->polarityonanswerdelay, ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) );
+ ast_debug(1, "Polarity Reversal event occured - DEBUG 1: channel %d, state %d, pol= %d, aonp= %d, honp= %d, pdelay= %d, tv= %d\n", p->channel, ast->_state, p->polarity, p->answeronpolarityswitch, p->hanguponpolarityswitch, p->polarityonanswerdelay, ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) );
if (ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) > p->polarityonanswerdelay) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Polarity Reversal detected and now Hanging up on channel %d\n", p->channel);
+ ast_debug(1, "Polarity Reversal detected and now Hanging up on channel %d\n", p->channel);
ast_softhangup(p->owner, AST_SOFTHANGUP_EXPLICIT);
p->polarity = POLARITY_IDLE;
- } else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Polarity Reversal detected but NOT hanging up (too close to answer event) on channel %d, state %d\n", p->channel, ast->_state);
- }
+ } else
+ ast_debug(1, "Polarity Reversal detected but NOT hanging up (too close to answer event) on channel %d, state %d\n", p->channel, ast->_state);
+
} else {
p->polarity = POLARITY_IDLE;
- if (option_debug)
- ast_log(LOG_DEBUG, "Ignoring Polarity switch to IDLE on channel %d, state %d\n", p->channel, ast->_state);
+ ast_debug(1, "Ignoring Polarity switch to IDLE on channel %d, state %d\n", p->channel, ast->_state);
}
/* Added more log_debug information below to provide a better indication of what is going on */
- if (option_debug)
- ast_log(LOG_DEBUG, "Polarity Reversal event occured - DEBUG 2: channel %d, state %d, pol= %d, aonp= %d, honp= %d, pdelay= %d, tv= %d\n", p->channel, ast->_state, p->polarity, p->answeronpolarityswitch, p->hanguponpolarityswitch, p->polarityonanswerdelay, ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) );
+ ast_debug(1, "Polarity Reversal event occured - DEBUG 2: channel %d, state %d, pol= %d, aonp= %d, honp= %d, pdelay= %d, tv= %d\n", p->channel, ast->_state, p->polarity, p->answeronpolarityswitch, p->hanguponpolarityswitch, p->polarityonanswerdelay, ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) );
break;
default:
- if (option_debug)
- ast_log(LOG_DEBUG, "Dunno what to do with event %d on channel %d\n", res, p->channel);
+ ast_debug(1, "Dunno what to do with event %d on channel %d\n", res, p->channel);
}
return &p->subs[index].f;
}
@@ -4825,8 +4719,7 @@ static struct ast_frame *__zt_exception(struct ast_channel *ast)
/* Switch to real if there is one and this isn't something really silly... */
if ((res != ZT_EVENT_RINGEROFF) && (res != ZT_EVENT_RINGERON) &&
(res != ZT_EVENT_HOOKCOMPLETE)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Restoring owner of channel %d on event %d\n", p->channel, res);
+ ast_debug(1, "Restoring owner of channel %d on event %d\n", p->channel, res);
p->owner = p->subs[SUB_REAL].owner;
if (p->owner && ast_bridged_channel(p->owner))
ast_queue_control(p->owner, AST_CONTROL_UNHOLD);
@@ -4885,8 +4778,8 @@ static struct ast_frame *__zt_exception(struct ast_channel *ast)
f = &p->subs[index].f;
return f;
}
- if (!(p->radio || (p->oprmode < 0)) && option_debug)
- ast_log(LOG_DEBUG, "Exception on %d, channel %d\n", ast->fds[0],p->channel);
+ if (!(p->radio || (p->oprmode < 0)))
+ ast_debug(1, "Exception on %d, channel %d\n", ast->fds[0],p->channel);
/* If it's not us, return NULL immediately */
if (ast != p->owner) {
ast_log(LOG_WARNING, "We're %s, not %s\n", ast->name, p->owner->name);
@@ -5029,8 +4922,7 @@ static struct ast_frame *zt_read(struct ast_channel *ast)
p->subs[index].f.frametype = AST_FRAME_CONTROL;
p->subs[index].f.subclass = AST_CONTROL_HOLD;
ast_mutex_unlock(&p->lock);
- if (option_debug)
- ast_log(LOG_DEBUG, "Sending hold on '%s'\n", ast->name);
+ ast_debug(1, "Sending hold on '%s'\n", ast->name);
return &p->subs[index].f;
}
@@ -5040,8 +4932,7 @@ static struct ast_frame *zt_read(struct ast_channel *ast)
p->subs[index].f.frametype = AST_FRAME_CONTROL;
p->subs[index].f.subclass = AST_CONTROL_UNHOLD;
ast_mutex_unlock(&p->lock);
- if (option_debug)
- ast_log(LOG_DEBUG, "Sending unhold on '%s'\n", ast->name);
+ ast_debug(1, "Sending unhold on '%s'\n", ast->name);
return &p->subs[index].f;
}
@@ -5086,8 +4977,7 @@ static struct ast_frame *zt_read(struct ast_channel *ast)
return f;
}
if (res != (p->subs[index].linear ? READ_SIZE * 2 : READ_SIZE)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Short read (%d/%d), must be an event...\n", res, p->subs[index].linear ? READ_SIZE * 2 : READ_SIZE);
+ ast_debug(1, "Short read (%d/%d), must be an event...\n", res, p->subs[index].linear ? READ_SIZE * 2 : READ_SIZE);
f = __zt_exception(ast);
ast_mutex_unlock(&p->lock);
return f;
@@ -5097,8 +4987,7 @@ static struct ast_frame *zt_read(struct ast_channel *ast)
c = tdd_feed(p->tdd,readbuf,READ_SIZE);
if (c < 0) {
- if (option_debug)
- ast_log(LOG_DEBUG,"tdd_feed failed\n");
+ ast_debug(1,"tdd_feed failed\n");
ast_mutex_unlock(&p->lock);
return NULL;
}
@@ -5146,8 +5035,7 @@ static struct ast_frame *zt_read(struct ast_channel *ast)
p->subs[index].f.offset = AST_FRIENDLY_OFFSET;
p->subs[index].f.data = p->subs[index].buffer + AST_FRIENDLY_OFFSET / sizeof(p->subs[index].buffer[0]);
#if 0
- if (option_debug)
- ast_log(LOG_DEBUG, "Read %d of voice on %s\n", p->subs[index].f.datalen, ast->name);
+ ast_debug(1, "Read %d of voice on %s\n", p->subs[index].f.datalen, ast->name);
#endif
if (p->dialing || /* Transmitting something */
(index && (ast->_state != AST_STATE_UP)) || /* Three-way or callwait that isn't up */
@@ -5214,8 +5102,7 @@ static int my_zt_write(struct zt_pvt *p, unsigned char *buf, int len, int index,
size = (linear ? READ_SIZE * 2 : READ_SIZE);
res = write(fd, buf, size);
if (res != size) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Write returned %d (%s) on channel %d\n", res, strerror(errno), p->channel);
+ ast_debug(1, "Write returned %d (%s) on channel %d\n", res, strerror(errno), p->channel);
return sent;
}
len -= size;
@@ -5265,18 +5152,15 @@ static int zt_write(struct ast_channel *ast, struct ast_frame *frame)
return -1;
}
if (p->dialing) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Dropping frame since I'm still dialing on %s...\n",ast->name);
+ ast_debug(1, "Dropping frame since I'm still dialing on %s...\n",ast->name);
return 0;
}
if (!p->owner) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Dropping frame since there is no active owner on %s...\n",ast->name);
+ ast_debug(1, "Dropping frame since there is no active owner on %s...\n",ast->name);
return 0;
}
if (p->cidspill) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Dropping frame since I've still got a callerid spill\n");
+ ast_debug(1, "Dropping frame since I've still got a callerid spill\n");
return 0;
}
/* Return if it's not valid data */
@@ -5320,8 +5204,7 @@ static int zt_indicate(struct ast_channel *chan, int condition, const void *data
int func = ZT_FLASH;
ast_mutex_lock(&p->lock);
index = zt_get_index(chan, p, 0);
- if (option_debug)
- ast_log(LOG_DEBUG, "Requested indication %d on channel %s\n", condition, chan->name);
+ ast_debug(1, "Requested indication %d on channel %s\n", condition, chan->name);
if (index == SUB_REAL) {
switch (condition) {
case AST_CONTROL_BUSY:
@@ -5381,8 +5264,7 @@ static int zt_indicate(struct ast_channel *chan, int condition, const void *data
}
break;
case AST_CONTROL_PROCEEDING:
- if (option_debug)
- ast_log(LOG_DEBUG,"Received AST_CONTROL_PROCEEDING on %s\n",chan->name);
+ ast_debug(1,"Received AST_CONTROL_PROCEEDING on %s\n",chan->name);
#ifdef HAVE_PRI
if (!p->proceeding && p->sig==SIG_PRI && p->pri && !p->outgoing) {
if (p->pri->pri) {
@@ -5411,8 +5293,7 @@ static int zt_indicate(struct ast_channel *chan, int condition, const void *data
res = 0;
break;
case AST_CONTROL_PROGRESS:
- if (option_debug)
- ast_log(LOG_DEBUG,"Received AST_CONTROL_PROGRESS on %s\n",chan->name);
+ ast_debug(1,"Received AST_CONTROL_PROGRESS on %s\n",chan->name);
#ifdef HAVE_PRI
p->digital = 0; /* Digital-only calls isn't allows any inband progress messages */
if (!p->progress && p->sig==SIG_PRI && p->pri && !p->outgoing) {
@@ -5604,8 +5485,7 @@ static struct ast_channel *zt_new(struct zt_pvt *i, int state, int startpbx, int
}
if (features) {
if (i->dsp) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Already have a dsp on %s?\n", tmp->name);
+ ast_debug(1, "Already have a dsp on %s?\n", tmp->name);
} else {
if (i->channel != CHAN_PSEUDO)
i->dsp = ast_dsp_new();
@@ -5808,8 +5688,7 @@ static void *ss_thread(void *data)
timeout = gendigittimeout;
res = ast_waitfordigit(chan, timeout);
if (res < 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "waitfordigit returned < 0...\n");
+ ast_debug(1, "waitfordigit returned < 0...\n");
ast_hangup(chan);
return NULL;
} else if (res) {
@@ -5837,8 +5716,7 @@ static void *ss_thread(void *data)
ast_log(LOG_WARNING, "PBX exited non-zero!\n");
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "No such possible extension '%s' in context '%s'\n", exten, chan->context);
+ ast_debug(1, "No such possible extension '%s' in context '%s'\n", exten, chan->context);
chan->hangupcause = AST_CAUSE_UNALLOCATED;
ast_hangup(chan);
p->exten[0] = '\0';
@@ -5957,8 +5835,7 @@ static void *ss_thread(void *data)
}
res = ast_waitfordigit(chan, timeout);
if (res < 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "waitfordigit returned < 0...\n");
+ ast_debug(1, "waitfordigit returned < 0...\n");
ast_hangup(chan);
return NULL;
} else if (res) {
@@ -5976,8 +5853,7 @@ static void *ss_thread(void *data)
ast_hangup(chan);
return NULL;
} else if (res < 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Got hung up before digits finished\n");
+ ast_debug(1, "Got hung up before digits finished\n");
ast_hangup(chan);
return NULL;
}
@@ -6134,8 +6010,7 @@ static void *ss_thread(void *data)
res = ast_waitfordigit(chan, timeout);
timeout = 0;
if (res < 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "waitfordigit returned < 0...\n");
+ ast_debug(1, "waitfordigit returned < 0...\n");
res = tone_zone_play_tone(p->subs[index].zfd, -1);
ast_hangup(chan);
return NULL;
@@ -6192,8 +6067,7 @@ static void *ss_thread(void *data)
timeout = matchdigittimeout;
}
} else if (res == 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "not enough digits (and no ambiguous match)...\n");
+ ast_debug(1, "not enough digits (and no ambiguous match)...\n");
res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_CONGESTION);
zt_wait_event(p->subs[index].zfd);
ast_hangup(chan);
@@ -6229,8 +6103,7 @@ static void *ss_thread(void *data)
}
zt_enable_ec(p);
if (ast_pickup_call(chan)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "No call pickup possible...\n");
+ ast_debug(1, "No call pickup possible...\n");
res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_CONGESTION);
zt_wait_event(p->subs[index].zfd);
}
@@ -6382,8 +6255,7 @@ static void *ss_thread(void *data)
}
} else if (!ast_canmatch_extension(chan, chan->context, exten, 1, chan->cid.cid_num) &&
((exten[0] != '*') || (strlen(exten) > 2))) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Can't match %s from '%s' in context %s\n", exten, chan->cid.cid_num ? chan->cid.cid_num : "<Unknown Caller>", chan->context);
+ ast_debug(1, "Can't match %s from '%s' in context %s\n", exten, chan->cid.cid_num ? chan->cid.cid_num : "<Unknown Caller>", chan->context);
break;
}
if (!timeout)
@@ -6418,8 +6290,7 @@ static void *ss_thread(void *data)
res = 0;
ast_frfree(f);
if (res) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Got ring!\n");
+ ast_debug(1, "Got ring!\n");
res = 0;
break;
}
@@ -6439,8 +6310,7 @@ static void *ss_thread(void *data)
else if (smdi_msg->type == 'N')
pbx_builtin_setvar_helper(chan, "_SMDI_VM_TYPE", "u");
- if (option_debug)
- ast_log(LOG_DEBUG, "Recieved SMDI message on %s\n", chan->name);
+ ast_debug(1, "Recieved SMDI message on %s\n", chan->name);
} else {
ast_log(LOG_WARNING, "SMDI enabled but no SMDI message present\n");
}
@@ -6457,9 +6327,8 @@ static void *ss_thread(void *data)
if (p->cid_signalling == CID_SIG_DTMF) {
int i = 0;
cs = NULL;
- if (option_debug)
- ast_log(LOG_DEBUG, "Receiving DTMF cid on "
- "channel %s\n", chan->name);
+ ast_debug(1, "Receiving DTMF cid on "
+ "channel %s\n", chan->name);
zt_setlinear(p->subs[index].zfd, 0);
res = 2000;
for (;;) {
@@ -6474,8 +6343,7 @@ static void *ss_thread(void *data)
f = ast_read(chan);
if (f->frametype == AST_FRAME_DTMF) {
dtmfbuf[i++] = f->subclass;
- if (option_debug)
- ast_log(LOG_DEBUG, "CID got digit '%c'\n", f->subclass);
+ ast_debug(1, "CID got digit '%c'\n", f->subclass);
res = 2000;
}
ast_frfree(f);
@@ -6486,12 +6354,10 @@ static void *ss_thread(void *data)
dtmfbuf[i] = '\0';
zt_setlinear(p->subs[index].zfd, p->subs[index].linear);
/* Got cid and ring. */
- if (option_debug)
- ast_log(LOG_DEBUG, "CID got string '%s'\n", dtmfbuf);
+ ast_debug(1, "CID got string '%s'\n", dtmfbuf);
callerid_get_dtmf(dtmfbuf, dtmfcid, &flags);
- if (option_debug)
- ast_log(LOG_DEBUG, "CID is '%s', flags %d\n",
- dtmfcid, flags);
+ ast_debug(1, "CID is '%s', flags %d\n",
+ dtmfcid, flags);
/* If first byte is NULL, we have no cid */
if (!ast_strlen_zero(dtmfcid))
number = dtmfcid;
@@ -6777,8 +6643,7 @@ static void *ss_thread(void *data)
}
if (res == 1) {
callerid_get(cs, &name, &number, &flags);
- if (option_debug)
- ast_log(LOG_DEBUG, "CallerID number: %s, name: %s, flags=%d\n", number, name, flags);
+ ast_debug(1, "CallerID number: %s, name: %s, flags=%d\n", number, name, flags);
}
if (distinctiveringaftercid == 1) {
/* Clear the current ring data array so we dont have old data in it. */
@@ -7151,8 +7016,7 @@ static void *do_monitor(void *data)
ast_log(LOG_WARNING, "Unable to set cancel type to asynchronous\n");
return NULL;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Monitor starting...\n");
+ ast_debug(1, "Monitor starting...\n");
#endif
for (;;) {
/* Lock the interface list */
@@ -7218,8 +7082,7 @@ static void *do_monitor(void *data)
res = has_voicemail(last);
if (last->msgstate != res) {
int x;
- if (option_debug)
- ast_log(LOG_DEBUG, "Message status for %s changed from %d to %d on %d\n", last->mailbox, last->msgstate, res, last->channel);
+ ast_debug(1, "Message status for %s changed from %d to %d on %d\n", last->mailbox, last->msgstate, res, last->channel);
x = ZT_FLUSH_BOTH;
res2 = ioctl(last->subs[SUB_REAL].zfd, ZT_FLUSH, &x);
if (res2)
@@ -7246,8 +7109,7 @@ static void *do_monitor(void *data)
res = zt_get_event(i->subs[SUB_REAL].zfd);
if (res)
{
- if (option_debug)
- ast_log(LOG_DEBUG, "Monitor doohicky got event %s on radio channel %d\n", event2str(res), i->channel);
+ ast_debug(1, "Monitor doohicky got event %s on radio channel %d\n", event2str(res), i->channel);
/* Don't hold iflock while handling init events */
ast_mutex_unlock(&iflock);
handle_init_event(i, res);
@@ -7292,8 +7154,7 @@ static void *do_monitor(void *data)
} else {
ast_log(LOG_WARNING, "Read failed with %d: %s\n", res, strerror(errno));
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Monitor doohicky got event %s on channel %d\n", event2str(res), i->channel);
+ ast_debug(1, "Monitor doohicky got event %s on channel %d\n", event2str(res), i->channel);
/* Don't hold iflock while handling init events -- race with chlock */
ast_mutex_unlock(&iflock);
handle_init_event(i, res);
@@ -7309,8 +7170,7 @@ static void *do_monitor(void *data)
continue;
}
res = zt_get_event(i->subs[SUB_REAL].zfd);
- if (option_debug)
- ast_log(LOG_DEBUG, "Monitor doohicky got event %s on channel %d\n", event2str(res), i->channel);
+ ast_debug(1, "Monitor doohicky got event %s on channel %d\n", event2str(res), i->channel);
/* Don't hold iflock while handling init events */
ast_mutex_unlock(&iflock);
handle_init_event(i, res);
@@ -8073,8 +7933,7 @@ static inline int available(struct zt_pvt *p, int channelmatch, int groupmatch,
return 1;
#endif
} else if (par.rxisoffhook) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Channel %d off hook, can't use\n", p->channel);
+ ast_debug(1, "Channel %d off hook, can't use\n", p->channel);
/* Not available when the other end is off hook */
return 0;
}
@@ -8158,9 +8017,8 @@ static int pri_find_empty_chan(struct zt_pri *pri, int backwards)
if (!backwards && (x >= pri->numchans))
break;
if (pri->pvts[x] && !pri->pvts[x]->inalarm && !pri->pvts[x]->owner) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Found empty available channel %d/%d\n",
- pri->pvts[x]->logicalspan, pri->pvts[x]->prioffset);
+ ast_debug(1, "Found empty available channel %d/%d\n",
+ pri->pvts[x]->logicalspan, pri->pvts[x]->prioffset);
return x;
}
if (backwards)
@@ -8289,10 +8147,9 @@ static struct ast_channel *zt_request(const char *type, int format, void *data,
#endif
if (p && available(p, channelmatch, groupmatch, &busy, &channelmatched, &groupmatched)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Using channel %d\n", p->channel);
- if (p->inalarm)
- goto next;
+ ast_debug(1, "Using channel %d\n", p->channel);
+ if (p->inalarm)
+ goto next;
callwait = (p->owner != NULL);
#ifdef HAVE_PRI
@@ -8312,10 +8169,9 @@ static struct ast_channel *zt_request(const char *type, int format, void *data,
ast_log(LOG_NOTICE, "Failed to allocate place holder pseudo channel!\n");
p = NULL;
break;
- } else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Allocated placeholder pseudo channel\n");
- }
+ } else
+ ast_debug(1, "Allocated placeholder pseudo channel\n");
+
p->pri = pri;
}
}
@@ -8563,13 +8419,13 @@ static void *ss7_linkset(void *data)
}
switch (x) {
case ZT_EVENT_OVERRUN:
- ast_log(LOG_DEBUG, "Overrun detected!\n");
+ ast_debug(1, "Overrun detected!\n");
break;
case ZT_EVENT_BADFCS:
- ast_log(LOG_DEBUG, "Bad FCS\n");
+ ast_debug(1, "Bad FCS\n");
break;
case ZT_EVENT_ABORT:
- ast_log(LOG_DEBUG, "HDLC Abort\n");
+ ast_debug(1, "HDLC Abort\n");
break;
case ZT_EVENT_ALARM:
ast_log(LOG_ERROR, "Alarm on link!\n");
@@ -8623,7 +8479,7 @@ static void *ss7_linkset(void *data)
}
break;
case MTP2_LINK_UP:
- ast_log(LOG_DEBUG, "MTP2 link up\n");
+ ast_debug(1, "MTP2 link up\n");
break;
case ISUP_EVENT_CPG:
chanpos = ss7_find_cic(linkset, e->cpg.cic);
@@ -8642,13 +8498,13 @@ static void *ss7_linkset(void *data)
case CPG_EVENT_INBANDINFO:
{
struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_PROGRESS, };
- ast_log(LOG_DEBUG, "Queuing frame PROGRESS on CIC %d\n", p->cic);
+ ast_debug(1, "Queuing frame PROGRESS on CIC %d\n", p->cic);
zap_queue_frame(p, &f, ss7);
p->progress = 1;
}
break;
default:
- ast_log(LOG_DEBUG, "Do not handle CPG with event type 0x%x\n", e->cpg.event);
+ ast_debug(1, "Do not handle CPG with event type 0x%x\n", e->cpg.event);
}
ast_mutex_unlock(&p->lock);
@@ -8670,7 +8526,7 @@ static void *ss7_linkset(void *data)
isup_rlc(ss7, e->rsc.call);
break;
case ISUP_EVENT_GRS:
- ast_log(LOG_DEBUG, "Got Reset for CICs %d to %d: Acknowledging\n", e->grs.startcic, e->grs.endcic);
+ ast_debug(1, "Got Reset for CICs %d to %d: Acknowledging\n", e->grs.startcic, e->grs.endcic);
chanpos = ss7_find_cic(linkset, e->grs.startcic);
if (chanpos < 0) {
ast_log(LOG_WARNING, "GRS on unconfigured CIC %d\n", e->grs.startcic);
@@ -8686,7 +8542,7 @@ static void *ss7_linkset(void *data)
ss7_block_cics(linkset, e->gra.startcic, e->gra.endcic, e->gra.status, 1);
break;
case ISUP_EVENT_IAM:
- ast_log(LOG_DEBUG, "Got IAM for CIC %d and number %s\n", e->iam.cic, e->iam.called_party_num);
+ ast_debug(1, "Got IAM for CIC %d and number %s\n", e->iam.cic, e->iam.called_party_num);
chanpos = ss7_find_cic(linkset, e->iam.cic);
if (chanpos < 0) {
ast_log(LOG_WARNING, "IAM on unconfigured CIC %d\n", e->iam.cic);
@@ -8743,7 +8599,7 @@ static void *ss7_linkset(void *data)
} else
ss7_start_call(p, linkset);
} else {
- ast_log(LOG_DEBUG, "Call on CIC for unconfigured extension %s\n", p->exten);
+ ast_debug(1, "Call on CIC for unconfigured extension %s\n", p->exten);
isup_rel(ss7, e->iam.call, -1);
}
ast_mutex_unlock(&p->lock);
@@ -8791,7 +8647,7 @@ static void *ss7_linkset(void *data)
p = linkset->pvts[chanpos];
- ast_log(LOG_DEBUG, "Queueing frame from SS7_EVENT_ACM on CIC %d\n", p->cic);
+ ast_debug(1, "Queueing frame from SS7_EVENT_ACM on CIC %d\n", p->cic);
ast_mutex_lock(&p->lock);
zap_queue_frame(p, &f, linkset);
@@ -8827,7 +8683,7 @@ static void *ss7_linkset(void *data)
break;
}
p = linkset->pvts[chanpos];
- ast_log(LOG_DEBUG, "Blocking CIC %d\n", e->blo.cic);
+ ast_debug(1, "Blocking CIC %d\n", e->blo.cic);
ast_mutex_lock(&p->lock);
p->remotelyblocked = 1;
ast_mutex_unlock(&p->lock);
@@ -8840,7 +8696,7 @@ static void *ss7_linkset(void *data)
break;
}
p = linkset->pvts[chanpos];
- ast_log(LOG_DEBUG, "Unblocking CIC %d\n", e->ubl.cic);
+ ast_debug(1, "Unblocking CIC %d\n", e->ubl.cic);
ast_mutex_lock(&p->lock);
p->remotelyblocked = 0;
ast_mutex_unlock(&p->lock);
@@ -8879,7 +8735,7 @@ static void *ss7_linkset(void *data)
}
break;
default:
- ast_log(LOG_DEBUG, "Unknown event %s\n", ss7_event2str(e->e));
+ ast_debug(1, "Unknown event %s\n", ss7_event2str(e->e));
break;
}
}
@@ -9024,10 +8880,9 @@ static int pri_fixup_principle(struct zt_pri *pri, int principle, q931_call *c)
zt_close(crv->subs[SUB_REAL].zfd);
pri->pvts[principle]->call = crv->call;
pri_assign_bearer(crv, pri, pri->pvts[principle]);
- if (option_debug)
- ast_log(LOG_DEBUG, "Assigning bearer %d/%d to CRV %d:%d\n",
- pri->pvts[principle]->logicalspan, pri->pvts[principle]->prioffset,
- pri->trunkgroup, crv->channel);
+ ast_debug(1, "Assigning bearer %d/%d to CRV %d:%d\n",
+ pri->pvts[principle]->logicalspan, pri->pvts[principle]->prioffset,
+ pri->trunkgroup, crv->channel);
wakeup_sub(crv, SUB_REAL, pri);
}
return principle;
@@ -9456,8 +9311,7 @@ static void *pri_dchannel(void *vpri)
pri_restart(pri->dchans[which]);
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Got event %s (%d) on D-channel for span %d\n", event2str(x), x, pri->span);
+ ast_debug(1, "Got event %s (%d) on D-channel for span %d\n", event2str(x), x, pri->span);
} else if (fds[which].revents & POLLIN) {
e = pri_check_event(pri->dchans[which]);
}
@@ -9644,7 +9498,7 @@ static void *pri_dchannel(void *vpri)
break;
} else {
/* This is where we handle initial glare */
- ast_log(LOG_DEBUG, "Ring requested on channel %d/%d already in use or previously requested on span %d. Attempting to renegotiate channel.\n",
+ ast_debug(1, "Ring requested on channel %d/%d already in use or previously requested on span %d. Attempting to renegotiate channel.\n",
PRI_SPAN(e->ring.channel), PRI_CHANNEL(e->ring.channel), pri->span);
ast_mutex_unlock(&pri->pvts[chanpos]->lock);
chanpos = -1;
@@ -9767,8 +9621,7 @@ static void *pri_dchannel(void *vpri)
pri_assign_bearer(crv, pri, pri->pvts[chanpos]);
c = zt_new(crv, AST_STATE_RESERVED, 0, SUB_REAL, law, e->ring.ctype);
pri->pvts[chanpos]->owner = &inuse;
- if (option_debug)
- ast_log(LOG_DEBUG, "Started up crv %d:%d on bearer channel %d\n", pri->trunkgroup, crv->channel, crv->bearer->channel);
+ ast_debug(1, "Started up crv %d:%d on bearer channel %d\n", pri->trunkgroup, crv->channel, crv->bearer->channel);
} else {
c = zt_new(pri->pvts[chanpos], AST_STATE_RESERVED, 0, SUB_REAL, law, e->ring.ctype);
}
@@ -9877,10 +9730,9 @@ static void *pri_dchannel(void *vpri)
zt_enable_ec(pri->pvts[chanpos]);
pri->pvts[chanpos]->subs[SUB_REAL].needringing = 1;
pri->pvts[chanpos]->alerting = 1;
- } else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Deferring ringing notification because of extra digits to dial...\n");
- }
+ } else
+ ast_debug(1, "Deferring ringing notification because of extra digits to dial...\n");
+
#ifdef PRI_PROGRESS_MASK
if (e->ringing.progressmask & PRI_PROG_INBAND_AVAILABLE) {
#else
@@ -9932,9 +9784,8 @@ static void *pri_dchannel(void *vpri)
}
ast_mutex_lock(&pri->pvts[chanpos]->lock);
- if (option_debug)
- ast_log(LOG_DEBUG, "Queuing frame from PRI_EVENT_PROGRESS on channel %d/%d span %d\n",
- pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset,pri->span);
+ ast_debug(1, "Queuing frame from PRI_EVENT_PROGRESS on channel %d/%d span %d\n",
+ pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset,pri->span);
zap_queue_frame(pri->pvts[chanpos], &f, pri);
#ifdef PRI_PROGRESS_MASK
if (e->proceeding.progressmask & PRI_PROG_INBAND_AVAILABLE) {
@@ -9959,9 +9810,8 @@ static void *pri_dchannel(void *vpri)
struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_PROCEEDING, };
ast_mutex_lock(&pri->pvts[chanpos]->lock);
- if (option_debug)
- ast_log(LOG_DEBUG, "Queuing frame from PRI_EVENT_PROCEEDING on channel %d/%d span %d\n",
- pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset,pri->span);
+ ast_debug(1, "Queuing frame from PRI_EVENT_PROCEEDING on channel %d/%d span %d\n",
+ pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset,pri->span);
zap_queue_frame(pri->pvts[chanpos], &f, pri);
#ifdef PRI_PROGRESS_MASK
if (e->proceeding.progressmask & PRI_PROG_INBAND_AVAILABLE) {
@@ -10025,8 +9875,7 @@ static void *pri_dchannel(void *vpri)
pri->pvts[chanpos]->dsp_features = 0;
}
if (pri->pvts[chanpos]->realcall && (pri->pvts[chanpos]->realcall->sig == SIG_FXSKS)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Starting up GR-303 trunk now that we got CONNECT...\n");
+ ast_debug(1, "Starting up GR-303 trunk now that we got CONNECT...\n");
x = ZT_START;
res = ioctl(pri->pvts[chanpos]->subs[SUB_REAL].zfd, ZT_HOOK, &x);
if (res < 0) {
@@ -10041,14 +9890,12 @@ static void *pri_dchannel(void *vpri)
if (res < 0) {
ast_log(LOG_WARNING, "Unable to initiate dialing on trunk channel %d\n", pri->pvts[chanpos]->channel);
pri->pvts[chanpos]->dop.dialstr[0] = '\0';
- } else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Sent deferred digit string: %s\n", pri->pvts[chanpos]->dop.dialstr);
- }
+ } else
+ ast_debug(1, "Sent deferred digit string: %s\n", pri->pvts[chanpos]->dop.dialstr);
+
pri->pvts[chanpos]->dop.dialstr[0] = '\0';
} else if (pri->pvts[chanpos]->confirmanswer) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Waiting on answer confirmation on channel %d!\n", pri->pvts[chanpos]->channel);
+ ast_debug(1, "Waiting on answer confirmation on channel %d!\n", pri->pvts[chanpos]->channel);
} else {
pri->pvts[chanpos]->subs[SUB_REAL].needanswer =1;
/* Enable echo cancellation if it's not on already */
@@ -10230,9 +10077,8 @@ static void *pri_dchannel(void *vpri)
if (pri->pvts[x] && pri->pvts[x]->resetting) {
chanpos = x;
ast_mutex_lock(&pri->pvts[chanpos]->lock);
- if (option_debug)
- ast_log(LOG_DEBUG, "Assuming restart ack is really for channel %d/%d span %d\n", pri->pvts[chanpos]->logicalspan,
- pri->pvts[chanpos]->prioffset, pri->span);
+ ast_debug(1, "Assuming restart ack is really for channel %d/%d span %d\n", pri->pvts[chanpos]->logicalspan,
+ pri->pvts[chanpos]->prioffset, pri->span);
if (pri->pvts[chanpos]->realcall)
pri_hangup_all(pri->pvts[chanpos]->realcall, pri);
else if (pri->pvts[chanpos]->owner) {
@@ -10287,8 +10133,7 @@ static void *pri_dchannel(void *vpri)
pri->pvts[chanpos]->setup_ack = 1;
/* Send any queued digits */
for (x = 0;x < strlen(pri->pvts[chanpos]->dialdest); x++) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Sending pending digit '%c'\n", pri->pvts[chanpos]->dialdest[x]);
+ ast_debug(1, "Sending pending digit '%c'\n", pri->pvts[chanpos]->dialdest[x]);
pri_information(pri->pri, pri->pvts[chanpos]->call,
pri->pvts[chanpos]->dialdest[x]);
}
@@ -10319,8 +10164,7 @@ static void *pri_dchannel(void *vpri)
}
break;
default:
- if (option_debug)
- ast_log(LOG_DEBUG, "Event: %d\n", e->e);
+ ast_debug(1, "Event: %d\n", e->e);
}
}
ast_mutex_unlock(&pri->lock);
@@ -10744,13 +10588,11 @@ static int zap_restart(void)
if (option_verbose > 0)
ast_verbose(VERBOSE_PREFIX_1 "Destroying channels and reloading zaptel configuration.\n");
while (iflist) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Destroying zaptel channel no. %d\n", iflist->channel);
+ ast_debug(1, "Destroying zaptel channel no. %d\n", iflist->channel);
/* Also updates iflist: */
destroy_channel(NULL, iflist, 1);
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Channels destroyed. Now re-reading config.\n");
+ ast_debug(1, "Channels destroyed. Now re-reading config.\n");
if (setup_zap(1) != 0) {
ast_log(LOG_WARNING, "Reload channels from zap config failed!\n");
return 1;
@@ -12916,16 +12758,14 @@ static int zt_sendtext(struct ast_channel *c, const char *text)
fds[0].revents = 0;
res = poll(fds, 1, -1);
if (!res) {
- if (option_debug)
- ast_log(LOG_DEBUG, "poll (for write) ret. 0 on channel %d\n", p->channel);
+ ast_debug(1, "poll (for write) ret. 0 on channel %d\n", p->channel);
continue;
}
/* if got exception */
if (fds[0].revents & POLLPRI)
return -1;
if (!(fds[0].revents & POLLOUT)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "write fd not ready on channel %d\n", p->channel);
+ ast_debug(1, "write fd not ready on channel %d\n", p->channel);
continue;
}
res = write(fd, buf, size);
@@ -12934,8 +12774,7 @@ static int zt_sendtext(struct ast_channel *c, const char *text)
ast_free(mybuf);
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Write returned %d (%s) on channel %d\n", res, strerror(errno), p->channel);
+ ast_debug(1, "Write returned %d (%s) on channel %d\n", res, strerror(errno), p->channel);
break;
}
len -= size;
diff --git a/channels/iax2-provision.c b/channels/iax2-provision.c
index 31016b2ad..4c5727967 100644
--- a/channels/iax2-provision.c
+++ b/channels/iax2-provision.c
@@ -249,12 +249,12 @@ int iax_provision_version(unsigned int *version, const char *template, int force
if (sscanf(tmp, "v%x", version) != 1) {
if (strcmp(tmp, "u")) {
ret = iax_provision_build(&ied, version, template, force);
- if (ret && option_debug)
- ast_log(LOG_DEBUG, "Unable to create provisioning packet for '%s'\n", template);
+ if (ret)
+ ast_debug(1, "Unable to create provisioning packet for '%s'\n", template);
} else
ret = -1;
- } else if (option_debug)
- ast_log(LOG_DEBUG, "Retrieved cached version '%s' = '%08x'\n", tmp, *version);
+ } else
+ ast_debug(1, "Retrieved cached version '%s' = '%08x'\n", tmp, *version);
ast_mutex_unlock(&provlock);
return ret;
}
diff --git a/codecs/codec_zap.c b/codecs/codec_zap.c
index 60f7fe2c1..9073f9545 100644
--- a/codecs/codec_zap.c
+++ b/codecs/codec_zap.c
@@ -362,7 +362,7 @@ static int find_transcoders(void)
info.op = ZT_TCOP_GETINFO;
if ((fd = open("/dev/zap/transcode", O_RDWR)) < 0) {
- ast_log(LOG_DEBUG, "No Zaptel transcoder support!\n");
+ ast_debug(1, "No Zaptel transcoder support!\n");
return 0;
}
for (info.tcnum = 0; !(res = ioctl(fd, ZT_TRANSCODE_OP, &info)); info.tcnum++) {
diff --git a/formats/format_g726.c b/formats/format_g726.c
index 41cd87a08..09504bf6c 100644
--- a/formats/format_g726.c
+++ b/formats/format_g726.c
@@ -78,9 +78,7 @@ static int g726_open(struct ast_filestream *tmp, int rate)
{
struct g726_desc *s = (struct g726_desc *)tmp->private;
s->rate = rate;
- if (option_debug)
- ast_log(LOG_DEBUG, "Created filestream G.726-%dk.\n",
- 40 - s->rate * 8);
+ ast_debug(1, "Created filestream G.726-%dk.\n", 40 - s->rate * 8);
return 0;
}
diff --git a/formats/format_ogg_vorbis.c b/formats/format_ogg_vorbis.c
index 9d80b63d4..bc2cc79ac 100644
--- a/formats/format_ogg_vorbis.c
+++ b/formats/format_ogg_vorbis.c
@@ -175,9 +175,9 @@ error:
}
for (ptr = tmp->vc.user_comments; *ptr; ptr++)
- ast_log(LOG_DEBUG, "OGG/Vorbis comment: %s\n", *ptr);
- ast_log(LOG_DEBUG, "OGG/Vorbis bitstream is %d channel, %ldHz\n", tmp->vi.channels, tmp->vi.rate);
- ast_log(LOG_DEBUG, "OGG/Vorbis file encoded by: %s\n", tmp->vc.vendor);
+ ast_debug(1, "OGG/Vorbis comment: %s\n", *ptr);
+ ast_debug(1, "OGG/Vorbis bitstream is %d channel, %ldHz\n", tmp->vi.channels, tmp->vi.rate);
+ ast_debug(1, "OGG/Vorbis file encoded by: %s\n", tmp->vc.vendor);
if (tmp->vi.channels != 1) {
ast_log(LOG_ERROR, "Only monophonic OGG/Vorbis files are currently supported!\n");
diff --git a/formats/format_wav.c b/formats/format_wav.c
index 194f82458..d37b55cd4 100644
--- a/formats/format_wav.c
+++ b/formats/format_wav.c
@@ -364,7 +364,7 @@ static struct ast_frame *wav_read(struct ast_filestream *s, int *whennext)
bytes = fs->maxlen - here;
if (bytes < 0)
bytes = 0;
-/* ast_log(LOG_DEBUG, "here: %d, maxlen: %d, bytes: %d\n", here, s->maxlen, bytes); */
+/* ast_debug(1, "here: %d, maxlen: %d, bytes: %d\n", here, s->maxlen, bytes); */
s->fr.frametype = AST_FRAME_VOICE;
s->fr.subclass = AST_FORMAT_SLINEAR;
s->fr.mallocd = 0;
diff --git a/funcs/func_db.c b/funcs/func_db.c
index 9f9b9ca5c..49e52bfd0 100644
--- a/funcs/func_db.c
+++ b/funcs/func_db.c
@@ -69,9 +69,7 @@ static int function_db_read(struct ast_channel *chan, const char *cmd,
}
if (ast_db_get(args.family, args.key, buf, len - 1)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "DB: %s/%s not found in database.\n", args.family,
- args.key);
+ ast_debug(1, "DB: %s/%s not found in database.\n", args.family, args.key);
} else
pbx_builtin_setvar_helper(chan, "DB_RESULT", buf);
@@ -185,13 +183,10 @@ static int function_db_delete(struct ast_channel *chan, const char *cmd,
}
if (ast_db_get(args.family, args.key, buf, len - 1)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "DB_DELETE: %s/%s not found in database.\n", args.family, args.key);
+ ast_debug(1, "DB_DELETE: %s/%s not found in database.\n", args.family, args.key);
} else {
if (ast_db_del(args.family, args.key)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "DB_DELETE: %s/%s could not be deleted from the database\n",
- args.family, args.key);
+ ast_debug(1, "DB_DELETE: %s/%s could not be deleted from the database\n", args.family, args.key);
}
}
pbx_builtin_setvar_helper(chan, "DB_RESULT", buf);
diff --git a/funcs/func_iconv.c b/funcs/func_iconv.c
index f757c8bfa..cc7294c6c 100644
--- a/funcs/func_iconv.c
+++ b/funcs/func_iconv.c
@@ -73,8 +73,7 @@ static int iconv_read(struct ast_channel *chan, const char *cmd, char *arguments
incount = strlen(args.text);
- if (option_debug)
- ast_log(LOG_DEBUG, "Iconv: \"%s\" %s -> %s\n", args.text, args.in_charset, args.out_charset);
+ ast_debug(1, "Iconv: \"%s\" %s -> %s\n", args.text, args.in_charset, args.out_charset);
cd = iconv_open(args.out_charset, args.in_charset);
diff --git a/funcs/func_rand.c b/funcs/func_rand.c
index 4ec712e39..e92f16e95 100644
--- a/funcs/func_rand.c
+++ b/funcs/func_rand.c
@@ -66,14 +66,11 @@ static int acf_rand_exec(struct ast_channel *chan, const char *cmd,
max_int = min_int;
min_int = tmp;
- if (option_debug)
- ast_log(LOG_DEBUG, "max<min\n");
+ ast_debug(1, "max<min\n");
}
response_int = min_int + (ast_random() % (max_int - min_int + 1));
- if (option_debug)
- ast_log(LOG_DEBUG, "%d was the lucky number in range [%d,%d]\n",
- response_int, min_int, max_int);
+ ast_debug(1, "%d was the lucky number in range [%d,%d]\n", response_int, min_int, max_int);
snprintf(buffer, buflen, "%d", response_int);
ast_module_user_remove(u);
diff --git a/funcs/func_strings.c b/funcs/func_strings.c
index faf9ef024..4619206ee 100644
--- a/funcs/func_strings.c
+++ b/funcs/func_strings.c
@@ -146,8 +146,7 @@ static int regex(struct ast_channel *chan, const char *cmd, char *parse, char *b
if ((*args.str == ' ') || (*args.str == '\t'))
args.str++;
- if (option_debug)
- ast_log(LOG_DEBUG, "FUNCTION REGEX (%s)(%s)\n", args.reg, args.str);
+ ast_debug(1, "FUNCTION REGEX (%s)(%s)\n", args.reg, args.str);
if ((errcode = regcomp(&regexbuf, args.reg, REG_EXTENDED | REG_NOSUB))) {
regerror(errcode, &regexbuf, buf, len);
@@ -237,8 +236,7 @@ static int array(struct ast_channel *chan, const char *cmd, char *var,
* want them to be surprised by the result. Hence, we prefer commas as the
* delimiter, but we'll fall back to vertical bars if commas aren't found.
*/
- if (option_debug)
- ast_log(LOG_DEBUG, "array (%s=%s)\n", var, value2);
+ ast_debug(1, "array (%s=%s)\n", var, value2);
if (strchr(var, ','))
AST_NONSTANDARD_APP_ARGS(arg1, var, ',');
else
@@ -250,8 +248,7 @@ static int array(struct ast_channel *chan, const char *cmd, char *var,
AST_STANDARD_APP_ARGS(arg2, value2);
for (i = 0; i < arg1.argc; i++) {
- if (option_debug)
- ast_log(LOG_DEBUG, "array set value (%s=%s)\n", arg1.var[i],
+ ast_debug(1, "array set value (%s=%s)\n", arg1.var[i],
arg2.val[i]);
if (i < arg2.argc) {
if (ishash) {
diff --git a/funcs/func_version.c b/funcs/func_version.c
index b72d0e78f..88ad138e7 100644
--- a/funcs/func_version.c
+++ b/funcs/func_version.c
@@ -76,9 +76,7 @@ static int acf_version_exec(struct ast_channel *chan, const char *cmd,
}
- if (option_debug)
- ast_log(LOG_DEBUG, "VERSION returns %s result, given %s argument\n",
- response_char, args.info);
+ ast_debug(1, "VERSION returns %s result, given %s argument\n", response_char, args.info);
snprintf(buffer, buflen, "%s", response_char);
ast_module_user_remove(u);
diff --git a/main/acl.c b/main/acl.c
index 3a88c3c1a..74d0c096d 100644
--- a/main/acl.c
+++ b/main/acl.c
@@ -197,8 +197,7 @@ struct ast_ha *ast_append_ha(char *sense, char *stuff, struct ast_ha *path, int
ret = ha;
}
}
- if (option_debug)
- ast_log(LOG_DEBUG, "%s/%s appended to acl for peer\n", stuff, nm);
+ ast_debug(1, "%s/%s appended to acl for peer\n", stuff, nm);
return ret;
}
@@ -212,8 +211,7 @@ int ast_apply_ha(struct ast_ha *ha, struct sockaddr_in *sin)
/* DEBUG */
ast_copy_string(iabuf, ast_inet_ntoa(sin->sin_addr), sizeof(iabuf));
ast_copy_string(iabuf2, ast_inet_ntoa(ha->netaddr), sizeof(iabuf2));
- if (option_debug)
- ast_log(LOG_DEBUG, "##### Testing %s with %s\n", iabuf, iabuf2);
+ ast_debug(1, "##### Testing %s with %s\n", iabuf, iabuf2);
/* For each rule, if this address and the netmask = the net address
apply the current rule */
if ((sin->sin_addr.s_addr & ha->netmask.s_addr) == ha->netaddr.s_addr)
diff --git a/main/adsistub.c b/main/adsistub.c
index d92e54288..38eaa0efc 100644
--- a/main/adsistub.c
+++ b/main/adsistub.c
@@ -43,8 +43,7 @@ int (*func_name)(__VA_ARGS__) = \
#define build_stub(func_name,...) \
static int stub_##func_name(__VA_ARGS__) \
{ \
- if (option_debug > 4) \
- ast_log(LOG_DEBUG, "ADSI support not loaded!\n"); \
+ ast_debug(5, "ADSI support not loaded!\n"); \
return -1; \
} \
\
diff --git a/main/app.c b/main/app.c
index a81831385..53c0d1f0f 100644
--- a/main/app.c
+++ b/main/app.c
@@ -472,8 +472,7 @@ int ast_control_streamfile(struct ast_channel *chan, const char *file,
/* We go at next loop if we got the restart char */
if (restart && strchr(restart, res)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "we'll restart the stream here at next loop\n");
+ ast_debug(1, "we'll restart the stream here at next loop\n");
pause_restart_point = 0;
continue;
}
@@ -581,8 +580,7 @@ static int __ast_play_and_record(struct ast_channel *chan, const char *playfile,
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG,"play_and_record: %s, %s, '%s'\n", playfile ? playfile : "<None>", recordfile, fmt);
+ ast_debug(1, "play_and_record: %s, %s, '%s'\n", playfile ? playfile : "<None>", recordfile, fmt);
snprintf(comment, sizeof(comment), "Playing %s, Recording to: %s on %s\n", playfile ? playfile : "<None>", recordfile, chan->name);
if (playfile || beep) {
@@ -603,8 +601,7 @@ static int __ast_play_and_record(struct ast_channel *chan, const char *playfile,
stringp = fmts;
strsep(&stringp, "|");
- if (option_debug)
- ast_log(LOG_DEBUG, "Recording Formats: sfmts=%s\n", fmts);
+ ast_debug(1, "Recording Formats: sfmts=%s\n", fmts);
sfmt[0] = ast_strdupa(fmts);
while ((fmt = strsep(&stringp, "|"))) {
@@ -659,8 +656,7 @@ static int __ast_play_and_record(struct ast_channel *chan, const char *playfile,
for (;;) {
res = ast_waitfor(chan, 2000);
if (!res) {
- if (option_debug)
- ast_log(LOG_DEBUG, "One waitfor failed, trying another\n");
+ ast_debug(1, "One waitfor failed, trying another\n");
/* Try one more time in case of masq */
res = ast_waitfor(chan, 2000);
if (!res) {
@@ -1071,8 +1067,7 @@ enum AST_LOCK_RESULT ast_lock_path(const char *path)
ast_log(LOG_WARNING, "Failed to lock path '%s': %s\n", path, strerror(errno));
return AST_LOCK_TIMEOUT;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Locked path '%s'\n", path);
+ ast_debug(1, "Locked path '%s'\n", path);
return AST_LOCK_SUCCESS;
}
}
@@ -1092,8 +1087,7 @@ int ast_unlock_path(const char *path)
if ((res = unlink(s)))
ast_log(LOG_ERROR, "Could not unlock path '%s': %s\n", path, strerror(errno));
else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Unlocked path '%s'\n", path);
+ ast_debug(1, "Unlocked path '%s'\n", path);
}
return res;
@@ -1324,8 +1318,7 @@ static int ast_ivr_menu_run_internal(struct ast_channel *chan, struct ast_ivr_me
while (menu->options[pos].option) {
if (!strcasecmp(menu->options[pos].option, exten)) {
res = ivr_dispatch(chan, menu->options + pos, exten, cbdata);
- if (option_debug)
- ast_log(LOG_DEBUG, "IVR Dispatch of '%s' (pos %d) yields %d\n", exten, pos, res);
+ ast_debug(1, "IVR Dispatch of '%s' (pos %d) yields %d\n", exten, pos, res);
if (res < 0)
break;
else if (res & RES_UPONE)
@@ -1341,8 +1334,7 @@ static int ast_ivr_menu_run_internal(struct ast_channel *chan, struct ast_ivr_me
if (!maxretries)
maxretries = 3;
if ((maxretries > 0) && (retries >= maxretries)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Max retries %d exceeded\n", maxretries);
+ ast_debug(1, "Max retries %d exceeded\n", maxretries);
return -2;
} else {
if (option_exists(menu, "g") > -1)
@@ -1353,28 +1345,24 @@ static int ast_ivr_menu_run_internal(struct ast_channel *chan, struct ast_ivr_me
pos = 0;
continue;
} else if (res && strchr(AST_DIGIT_ANY, res)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Got start of extension, %c\n", res);
+ ast_debug(1, "Got start of extension, %c\n", res);
exten[1] = '\0';
exten[0] = res;
if ((res = read_newoption(chan, menu, exten, sizeof(exten))))
break;
if (option_exists(menu, exten) < 0) {
if (option_exists(menu, "i")) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Invalid extension entered, going to 'i'!\n");
+ ast_debug(1, "Invalid extension entered, going to 'i'!\n");
strcpy(exten, "i");
pos = 0;
continue;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Aborting on invalid entry, with no 'i' option!\n");
+ ast_debug(1, "Aborting on invalid entry, with no 'i' option!\n");
res = -2;
break;
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "New existing extension: %s\n", exten);
+ ast_debug(1, "New existing extension: %s\n", exten);
pos = 0;
continue;
}
@@ -1382,8 +1370,7 @@ static int ast_ivr_menu_run_internal(struct ast_channel *chan, struct ast_ivr_me
}
pos++;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Stopping option '%s', res is %d\n", exten, res);
+ ast_debug(1, "Stopping option '%s', res is %d\n", exten, res);
pos = 0;
if (!strcasecmp(exten, "s"))
strcpy(exten, "g");
diff --git a/main/asterisk.c b/main/asterisk.c
index 7a65e47bc..4f5ada9b0 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -1266,8 +1266,7 @@ static void quit_handler(int num, int nice, int safeshutdown, int restart)
/* Called on exit */
if (option_verbose && ast_opt_console)
ast_verbose("Asterisk %s ending (%d).\n", ast_active_channels() ? "uncleanly" : "cleanly", num);
- if (option_debug)
- ast_log(LOG_DEBUG, "Asterisk ending (%d).\n", num);
+ ast_debug(1, "Asterisk ending (%d).\n", num);
manager_event(EVENT_FLAG_SYSTEM, "Shutdown", "Shutdown: %s\r\nRestart: %s\r\n", ast_active_channels() ? "Uncleanly" : "Cleanly", restart ? "True" : "False");
if (ast_socket > -1) {
pthread_cancel(lthread);
diff --git a/main/callerid.c b/main/callerid.c
index c870a462f..55e20d3da 100644
--- a/main/callerid.c
+++ b/main/callerid.c
@@ -180,7 +180,7 @@ void callerid_get_dtmf(char *cidstring, char *number, int *flags)
number[0] = 0;
if (strlen(cidstring) < 2) {
- ast_log(LOG_DEBUG, "No cid detected\n");
+ ast_debug(1, "No cid detected\n");
*flags = CID_UNKNOWN_NUMBER;
return;
}
@@ -194,7 +194,7 @@ void callerid_get_dtmf(char *cidstring, char *number, int *flags)
else if (code == 10)
*flags = CID_PRIVATE_NUMBER;
else
- ast_log(LOG_DEBUG, "Unknown DTMF code %d\n", code);
+ ast_debug(1, "Unknown DTMF code %d\n", code);
} else if (cidstring[0] == 'D' && cidstring[2] == '#') {
/* .DK special code */
if (cidstring[1] == '1')
@@ -209,7 +209,7 @@ void callerid_get_dtmf(char *cidstring, char *number, int *flags)
if (isdigit(cidstring[i]))
number[i-1] = cidstring[i];
else
- ast_log(LOG_DEBUG, "Unknown CID digit '%c'\n",
+ ast_debug(1, "Unknown CID digit '%c'\n",
cidstring[i]);
}
number[i-1] = 0;
@@ -226,8 +226,7 @@ void callerid_get_dtmf(char *cidstring, char *number, int *flags)
}
number[i] = 0;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Unknown CID protocol, start digit '%c'\n", cidstring[0]);
+ ast_debug(1, "Unknown CID protocol, start digit '%c'\n", cidstring[0]);
*flags = CID_UNKNOWN_NUMBER;
}
}
@@ -420,8 +419,7 @@ int callerid_feed_jp(struct callerid_state *cid, unsigned char *ubuf, int len, i
case 0x06: /* short dial number */
case 0x07: /* reserved */
default: /* reserved */
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "cid info:#1=%X\n", cid->rawdata[x]);
+ ast_debug(2, "cid info:#1=%X\n", cid->rawdata[x]);
break ;
}
x++;
@@ -437,8 +435,7 @@ int callerid_feed_jp(struct callerid_state *cid, unsigned char *ubuf, int len, i
case 0x09: /* private dial plan */
case 0x05: /* reserved */
default: /* reserved */
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "cid info:#2=%X\n", cid->rawdata[x]);
+ ast_debug(2, "cid info:#2=%X\n", cid->rawdata[x]);
break ;
}
x++;
@@ -453,8 +450,7 @@ int callerid_feed_jp(struct callerid_state *cid, unsigned char *ubuf, int len, i
case 'C': /* pay phone */
case 'S': /* service congested */
cid->flags |= CID_UNKNOWN_NUMBER;
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "no cid reason:%c\n",cid->rawdata[x]);
+ ast_debug(2, "no cid reason:%c\n",cid->rawdata[x]);
break ;
}
x++;
@@ -495,8 +491,7 @@ int callerid_feed_jp(struct callerid_state *cid, unsigned char *ubuf, int len, i
case 0x09: /* private dial plan */
case 0x05: /* reserved */
default: /* reserved */
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "did info:#2=%X\n", cid->rawdata[x]);
+ ast_debug(2, "did info:#2=%X\n", cid->rawdata[x]);
break ;
}
x++;
diff --git a/main/cdr.c b/main/cdr.c
index 76b5cfc1c..6614604eb 100644
--- a/main/cdr.c
+++ b/main/cdr.c
@@ -1049,16 +1049,14 @@ void ast_cdr_submit_batch(int shutdown)
/* if configured, spawn a new thread to post these CDRs,
also try to save as much as possible if we are shutting down safely */
if (batchscheduleronly || shutdown) {
- if (option_debug)
- ast_log(LOG_DEBUG, "CDR single-threaded batch processing begins now\n");
+ ast_debug(1, "CDR single-threaded batch processing begins now\n");
do_batch_backend_process(oldbatchitems);
} else {
if (ast_pthread_create_detached_background(&batch_post_thread, NULL, do_batch_backend_process, oldbatchitems)) {
ast_log(LOG_WARNING, "CDR processing thread could not detach, now trying in this thread\n");
do_batch_backend_process(oldbatchitems);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "CDR multi-threaded batch processing begins now\n");
+ ast_debug(1, "CDR multi-threaded batch processing begins now\n");
}
}
}
@@ -1095,8 +1093,7 @@ void ast_cdr_detach(struct ast_cdr *cdr)
/* maybe they disabled CDR stuff completely, so just drop it */
if (!enabled) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Dropping CDR !\n");
+ ast_debug(1, "Dropping CDR !\n");
ast_set_flag(cdr, AST_CDR_FLAG_POST_DISABLED);
ast_cdr_free(cdr);
return;
@@ -1110,8 +1107,7 @@ void ast_cdr_detach(struct ast_cdr *cdr)
}
/* otherwise, each CDR gets put into a batch list (at the end) */
- if (option_debug)
- ast_log(LOG_DEBUG, "CDR detaching from this thread\n");
+ ast_debug(1, "CDR detaching from this thread\n");
/* we'll need a new tail for every CDR */
if (!(newtail = ast_calloc(1, sizeof(*newtail)))) {
@@ -1161,8 +1157,7 @@ static void *do_cdr(void *data)
ast_cond_timedwait(&cdr_pending_cond, &cdr_pending_lock, &timeout);
numevents = ast_sched_runq(sched);
ast_mutex_unlock(&cdr_pending_lock);
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Processed %d scheduled CDR batches from the run queue\n", numevents);
+ ast_debug(2, "Processed %d scheduled CDR batches from the run queue\n", numevents);
}
return NULL;
diff --git a/main/channel.c b/main/channel.c
index dc99dfda9..86e4a92b9 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -433,8 +433,7 @@ int ast_channel_register(const struct ast_channel_tech *tech)
chan->tech = tech;
AST_LIST_INSERT_HEAD(&backends, chan, list);
- if (option_debug)
- ast_log(LOG_DEBUG, "Registered handler for '%s' (%s)\n", chan->tech->type, chan->tech->description);
+ ast_debug(1, "Registered handler for '%s' (%s)\n", chan->tech->type, chan->tech->description);
if (option_verbose > 1)
ast_verbose(VERBOSE_PREFIX_2 "Registered channel type '%s' (%s)\n", chan->tech->type,
@@ -449,8 +448,7 @@ void ast_channel_unregister(const struct ast_channel_tech *tech)
{
struct chanlist *chan;
- if (option_debug)
- ast_log(LOG_DEBUG, "Unregistering channel type '%s'\n", tech->type);
+ ast_debug(1, "Unregistering channel type '%s'\n", tech->type);
AST_RWLIST_WRLOCK(&channels);
@@ -827,8 +825,7 @@ int ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin)
ast_log(LOG_WARNING, "Exceptionally long queue length queuing to %s\n", chan->name);
CRASH;
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Dropping voice to exceptionally long queue on %s\n", chan->name);
+ ast_debug(1, "Dropping voice to exceptionally long queue on %s\n", chan->name);
ast_frfree(f);
ast_channel_unlock(chan);
return 0;
@@ -974,14 +971,12 @@ static struct ast_channel *channel_find_locked(const struct ast_channel *prev,
/* this is slightly unsafe, as we _should_ hold the lock to access c->name */
done = c == NULL || ast_channel_trylock(c) == 0;
if (!done) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Avoiding %s for channel '%p'\n", msg, c);
+ ast_debug(1, "Avoiding %s for channel '%p'\n", msg, c);
if (retries == 9) {
/* We are about to fail due to a deadlock, so report this
* while we still have the list lock.
*/
- if (option_debug)
- ast_log(LOG_DEBUG, "Failure, could not lock '%p' after %d retries!\n", c, retries);
+ ast_debug(1, "Failure, could not lock '%p' after %d retries!\n", c, retries);
/* As we have deadlocked, we will skip this channel and
* see if there is another match.
* NOTE: No point doing this for a full-name match,
@@ -1329,9 +1324,8 @@ int ast_channel_spy_add(struct ast_channel *chan, struct ast_channel_spy *spy)
ast_clear_flag(spy, CHANSPY_TRIGGER_WRITE);
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Spy %s added to channel %s\n",
- spy->type, chan->name);
+ ast_debug(1, "Spy %s added to channel %s\n",
+ spy->type, chan->name);
return 0;
}
@@ -1366,8 +1360,7 @@ static void spy_detach(struct ast_channel_spy *spy, struct ast_channel *chan)
}
/* Print it out while we still have a lock so the structure can't go away (if signalled above) */
- if (option_debug)
- ast_log(LOG_DEBUG, "Spy %s removed from channel %s\n", spy->type, chan->name);
+ ast_debug(1, "Spy %s removed from channel %s\n", spy->type, chan->name);
ast_mutex_unlock(&spy->lock);
@@ -1461,8 +1454,7 @@ static void detach_spies(struct ast_channel *chan)
/*! \brief Softly hangup a channel, don't lock */
int ast_softhangup_nolock(struct ast_channel *chan, int cause)
{
- if (option_debug)
- ast_log(LOG_DEBUG, "Soft-Hanging up channel '%s'\n", chan->name);
+ ast_debug(1, "Soft-Hanging up channel '%s'\n", chan->name);
/* Inform channel driver that we need to be hung up, if it cares */
chan->_softhangup |= cause;
ast_queue_frame(chan, &ast_null_frame);
@@ -1512,8 +1504,7 @@ static void queue_frame_to_spies(struct ast_channel *chan, struct ast_frame *f,
trans->path = NULL;
}
if (!trans->path) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Building translator from %s to SLINEAR for spies on channel %s\n",
+ ast_debug(1, "Building translator from %s to SLINEAR for spies on channel %s\n",
ast_getformatname(f->subclass), chan->name);
if ((trans->path = ast_translator_build_path(AST_FORMAT_SLINEAR, f->subclass)) == NULL) {
ast_log(LOG_WARNING, "Cannot build a path from %s to %s\n",
@@ -1552,30 +1543,26 @@ static void queue_frame_to_spies(struct ast_channel *chan, struct ast_frame *f,
if (dir == SPY_WRITE) {
ast_set_flag(spy, CHANSPY_TRIGGER_WRITE);
ast_clear_flag(spy, CHANSPY_TRIGGER_READ);
- if (option_debug)
- ast_log(LOG_DEBUG, "Switching spy '%s' on '%s' to write-trigger mode\n",
- spy->type, chan->name);
+ ast_debug(1, "Switching spy '%s' on '%s' to write-trigger mode\n",
+ spy->type, chan->name);
}
break;
case CHANSPY_TRIGGER_WRITE:
if (dir == SPY_READ) {
ast_set_flag(spy, CHANSPY_TRIGGER_READ);
ast_clear_flag(spy, CHANSPY_TRIGGER_WRITE);
- if (option_debug)
- ast_log(LOG_DEBUG, "Switching spy '%s' on '%s' to read-trigger mode\n",
- spy->type, chan->name);
+ ast_debug(1, "Switching spy '%s' on '%s' to read-trigger mode\n",
+ spy->type, chan->name);
}
break;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Triggering queue flush for spy '%s' on '%s'\n",
- spy->type, chan->name);
+ ast_debug(1, "Triggering queue flush for spy '%s' on '%s'\n",
+ spy->type, chan->name);
ast_set_flag(spy, CHANSPY_TRIGGER_FLUSH);
ast_cond_signal(&spy->trigger);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Spy '%s' on channel '%s' %s queue too long, dropping frames\n",
- spy->type, chan->name, (dir == SPY_READ) ? "read" : "write");
+ ast_debug(1, "Spy '%s' on channel '%s' %s queue too long, dropping frames\n",
+ spy->type, chan->name, (dir == SPY_READ) ? "read" : "write");
while (queue->samples > SPY_QUEUE_SAMPLE_LIMIT) {
struct ast_frame *drop = AST_LIST_REMOVE_HEAD(&queue->list, frame_list);
queue->samples -= drop->samples;
@@ -1675,13 +1662,11 @@ int ast_hangup(struct ast_channel *chan)
CRASH;
}
if (!ast_test_flag(chan, AST_FLAG_ZOMBIE)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Hanging up channel '%s'\n", chan->name);
+ ast_debug(1, "Hanging up channel '%s'\n", chan->name);
if (chan->tech->hangup)
res = chan->tech->hangup(chan);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Hanging up zombie '%s'\n", chan->name);
+ ast_debug(1, "Hanging up zombie '%s'\n", chan->name);
}
ast_channel_unlock(chan);
@@ -1774,8 +1759,7 @@ static int generator_force(void *data)
res = generate(chan, tmp, 0, 160);
chan->generatordata = tmp;
if (res) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Auto-deactivating generator\n");
+ ast_debug(1, "Auto-deactivating generator\n");
ast_deactivate_generator(chan);
}
return 0;
@@ -1994,8 +1978,7 @@ int ast_settimeout(struct ast_channel *c, int samples, int (*func)(void *data),
samples = 0;
data = 0;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Scheduling timer at %d sample intervals\n", samples);
+ ast_debug(1, "Scheduling timer at %d sample intervals\n", samples);
res = ioctl(c->timingfd, ZT_TIMERCONFIG, &samples);
c->timingfunc = func;
c->timingdata = data;
@@ -2219,13 +2202,11 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
case AST_FRAME_CONTROL:
if (f->subclass == AST_CONTROL_ANSWER) {
if (!ast_test_flag(chan, AST_FLAG_OUTGOING)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Ignoring answer on an inbound call!\n");
+ ast_debug(1, "Ignoring answer on an inbound call!\n");
ast_frfree(f);
f = &ast_null_frame;
} else if (prestate == AST_STATE_UP) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Dropping duplicate answer!\n");
+ ast_debug(1, "Dropping duplicate answer!\n");
ast_frfree(f);
f = &ast_null_frame;
} else {
@@ -2398,8 +2379,7 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
int res;
if (chan->timingfunc) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Generator got voice, switching to phase locked mode\n");
+ ast_debug(2, "Generator got voice, switching to phase locked mode\n");
ast_settimeout(chan, 0, NULL, NULL);
}
@@ -2407,15 +2387,13 @@ static struct ast_frame *__ast_read(struct ast_channel *chan, int dropaudio)
res = chan->generator->generate(chan, tmp, f->datalen, f->samples);
chan->generatordata = tmp;
if (res) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Auto-deactivating generator\n");
+ ast_debug(2, "Auto-deactivating generator\n");
ast_deactivate_generator(chan);
}
} else if (f->frametype == AST_FRAME_CNG) {
if (chan->generator && !chan->timingfunc && (chan->timingfd > -1)) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Generator got CNG, switching to timed mode\n");
+ ast_debug(2, "Generator got CNG, switching to timed mode\n");
ast_settimeout(chan, 160, generator_force, chan);
}
}
@@ -2450,8 +2428,7 @@ done:
int ast_internal_timing_enabled(struct ast_channel *chan)
{
int ret = ast_opt_internal_timing && chan->timingfd > -1;
- if (option_debug > 4)
- ast_log(LOG_DEBUG, "Internal timing is %s (option_internal_timing=%d chan->timingfd=%d)\n", ret? "enabled": "disabled", ast_opt_internal_timing, chan->timingfd);
+ ast_debug(5, "Internal timing is %s (option_internal_timing=%d chan->timingfd=%d)\n", ret? "enabled": "disabled", ast_opt_internal_timing, chan->timingfd);
return ret;
}
@@ -2504,8 +2481,7 @@ int ast_indicate_data(struct ast_channel *chan, int condition, const void *data,
break;
}
if (ts && ts->data[0]) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Driver for channel '%s' does not support indication %d, emulating it\n", chan->name, condition);
+ ast_debug(1, "Driver for channel '%s' does not support indication %d, emulating it\n", chan->name, condition);
ast_playtones_start(chan,0,ts->data, 1);
res = 0;
} else if (condition == AST_CONTROL_PROGRESS) {
@@ -2618,8 +2594,7 @@ int ast_senddigit_begin(struct ast_channel *chan, char digit)
ast_playtones_start(chan, 0, dtmf_tones[15], 0);
else {
/* not handled */
- if (option_debug)
- ast_log(LOG_DEBUG, "Unable to generate DTMF tone '%c' for '%s'\n", digit, chan->name);
+ ast_debug(1, "Unable to generate DTMF tone '%c' for '%s'\n", digit, chan->name);
}
return 0;
@@ -2655,8 +2630,7 @@ int ast_prod(struct ast_channel *chan)
/* Send an empty audio frame to get things moving */
if (chan->_state != AST_STATE_UP) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Prodding channel '%s'\n", chan->name);
+ ast_debug(1, "Prodding channel '%s'\n", chan->name);
a.subclass = chan->rawwriteformat;
a.data = nothing + AST_FRIENDLY_OFFSET;
a.src = "ast_prod";
@@ -2931,9 +2905,8 @@ static int set_format(struct ast_channel *chan, int fmt, int *rawformat, int *fo
/* writing */
*trans = ast_translator_build_path(*rawformat, *format);
ast_channel_unlock(chan);
- if (option_debug)
- ast_log(LOG_DEBUG, "Set channel %s to %s format %s\n", chan->name,
- direction ? "write" : "read", ast_getformatname(fmt));
+ ast_debug(1, "Set channel %s to %s format %s\n", chan->name,
+ direction ? "write" : "read", ast_getformatname(fmt));
return 0;
}
@@ -3332,9 +3305,8 @@ int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clo
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Planning to masquerade channel %s into the structure of %s\n",
- clone->name, original->name);
+ ast_debug(1, "Planning to masquerade channel %s into the structure of %s\n",
+ clone->name, original->name);
if (original->masq) {
ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
original->masq->name, original->name);
@@ -3346,8 +3318,7 @@ int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clo
clone->masqr = original;
ast_queue_frame(original, &ast_null_frame);
ast_queue_frame(clone, &ast_null_frame);
- if (option_debug)
- ast_log(LOG_DEBUG, "Done planning to masquerade channel %s into the structure of %s\n", clone->name, original->name);
+ ast_debug(1, "Done planning to masquerade channel %s into the structure of %s\n", clone->name, original->name);
res = 0;
}
@@ -3386,21 +3357,18 @@ void ast_channel_inherit_variables(const struct ast_channel *parent, struct ast_
newvar = ast_var_assign(&varname[1], ast_var_value(current));
if (newvar) {
AST_LIST_INSERT_TAIL(&child->varshead, newvar, entries);
- if (option_debug)
- ast_log(LOG_DEBUG, "Copying soft-transferable variable %s.\n", ast_var_name(newvar));
+ ast_debug(1, "Copying soft-transferable variable %s.\n", ast_var_name(newvar));
}
break;
case 2:
newvar = ast_var_assign(ast_var_full_name(current), ast_var_value(current));
if (newvar) {
AST_LIST_INSERT_TAIL(&child->varshead, newvar, entries);
- if (option_debug)
- ast_log(LOG_DEBUG, "Copying hard-transferable variable %s.\n", ast_var_name(newvar));
+ ast_debug(1, "Copying hard-transferable variable %s.\n", ast_var_name(newvar));
}
break;
default:
- if (option_debug)
- ast_log(LOG_DEBUG, "Not copying variable %s.\n", ast_var_name(current));
+ ast_debug(1, "Not copying variable %s.\n", ast_var_name(current));
break;
}
}
@@ -3448,9 +3416,8 @@ int ast_do_masquerade(struct ast_channel *original)
char masqn[100];
char zombn[100];
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "Actually Masquerading %s(%d) into the structure of %s(%d)\n",
- clone->name, clone->_state, original->name, original->_state);
+ ast_debug(4, "Actually Masquerading %s(%d) into the structure of %s(%d)\n",
+ clone->name, clone->_state, original->name, original->_state);
manager_event(EVENT_FLAG_CALL, "Masquerade", "Clone: %s\r\nCloneState: %s\r\nOriginal: %s\r\nOriginalState: %s\r\n",
clone->name, ast_state2str(clone->_state), original->name, ast_state2str(original->_state));
@@ -3463,8 +3430,7 @@ int ast_do_masquerade(struct ast_channel *original)
/* We need the clone's lock, too */
ast_channel_lock(clone);
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Got clone lock for masquerade on '%s' at %p\n", clone->name, &clone->lock);
+ ast_debug(2, "Got clone lock for masquerade on '%s' at %p\n", clone->name, &clone->lock);
/* Having remembered the original read/write formats, we turn off any translation on either
one */
@@ -3665,8 +3631,7 @@ int ast_do_masquerade(struct ast_channel *original)
/* Copy the music class */
ast_string_field_set(original, musicclass, clone->musicclass);
- if (option_debug)
- ast_log(LOG_DEBUG, "Putting channel %s in %d/%d formats\n", original->name, wformat, rformat);
+ ast_debug(1, "Putting channel %s in %d/%d formats\n", original->name, wformat, rformat);
/* Okay. Last thing is to let the channel driver know about all this mess, so he
can fix up everything as best as possible */
@@ -3686,8 +3651,7 @@ int ast_do_masquerade(struct ast_channel *original)
a zombie so nothing tries to touch it. If it's already been marked as a
zombie, then free it now (since it already is considered invalid). */
if (ast_test_flag(clone, AST_FLAG_ZOMBIE)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Destroying channel clone '%s'\n", clone->name);
+ ast_debug(1, "Destroying channel clone '%s'\n", clone->name);
ast_channel_unlock(clone);
manager_event(EVENT_FLAG_CALL, "Hangup",
"Channel: %s\r\n"
@@ -3701,8 +3665,7 @@ int ast_do_masquerade(struct ast_channel *original)
);
ast_channel_free(clone);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Released clone lock on '%s'\n", clone->name);
+ ast_debug(1, "Released clone lock on '%s'\n", clone->name);
ast_set_flag(clone, AST_FLAG_ZOMBIE);
ast_queue_frame(clone, &ast_null_frame);
ast_channel_unlock(clone);
@@ -3711,8 +3674,7 @@ int ast_do_masquerade(struct ast_channel *original)
/* Signal any blocker */
if (ast_test_flag(original, AST_FLAG_BLOCKING))
pthread_kill(original->blocker, SIGURG);
- if (option_debug)
- ast_log(LOG_DEBUG, "Done Masquerading %s (%d)\n", original->name, original->_state);
+ ast_debug(1, "Done Masquerading %s (%d)\n", original->name, original->_state);
return 0;
}
@@ -3893,8 +3855,7 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct
if (!f) {
*fo = NULL;
*rc = who;
- if (option_debug)
- ast_log(LOG_DEBUG, "Didn't get a frame from channel: %s\n",who->name);
+ ast_debug(1, "Didn't get a frame from channel: %s\n",who->name);
break;
}
@@ -3916,8 +3877,7 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct
*fo = f;
*rc = who;
bridge_exit = 1;
- if (option_debug)
- ast_log(LOG_DEBUG, "Got a FRAME_CONTROL (%d) frame on channel %s\n", f->subclass, who->name);
+ ast_debug(1, "Got a FRAME_CONTROL (%d) frame on channel %s\n", f->subclass, who->name);
break;
}
if (bridge_exit)
@@ -3939,10 +3899,9 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct
f->frametype == AST_FRAME_DTMF_BEGIN)) {
*fo = f;
*rc = who;
- if (option_debug)
- ast_log(LOG_DEBUG, "Got DTMF %s on channel (%s)\n",
- f->frametype == AST_FRAME_DTMF_END ? "end" : "begin",
- who->name);
+ ast_debug(1, "Got DTMF %s on channel (%s)\n",
+ f->frametype == AST_FRAME_DTMF_END ? "end" : "begin",
+ who->name);
break;
}
/* Write immediately frames, not passed through jb */
@@ -4110,8 +4069,7 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
c1->_softhangup = 0;
c0->_bridge = c1;
c1->_bridge = c0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Unbridge signal received. Ending native bridge.\n");
+ ast_debug(1, "Unbridge signal received. Ending native bridge.\n");
continue;
}
@@ -4122,13 +4080,12 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
if (who)
*rc = who;
res = 0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Bridge stops because we're zombie or need a soft hangup: c0=%s, c1=%s, flags: %s,%s,%s,%s\n",
- c0->name, c1->name,
- ast_test_flag(c0, AST_FLAG_ZOMBIE) ? "Yes" : "No",
- ast_check_hangup(c0) ? "Yes" : "No",
- ast_test_flag(c1, AST_FLAG_ZOMBIE) ? "Yes" : "No",
- ast_check_hangup(c1) ? "Yes" : "No");
+ ast_debug(1, "Bridge stops because we're zombie or need a soft hangup: c0=%s, c1=%s, flags: %s,%s,%s,%s\n",
+ c0->name, c1->name,
+ ast_test_flag(c0, AST_FLAG_ZOMBIE) ? "Yes" : "No",
+ ast_check_hangup(c0) ? "Yes" : "No",
+ ast_test_flag(c1, AST_FLAG_ZOMBIE) ? "Yes" : "No",
+ ast_check_hangup(c1) ? "Yes" : "No");
break;
}
@@ -4151,8 +4108,7 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
"CallerID1: %s\r\n"
"CallerID2: %s\r\n",
c0->name, c1->name, c0->uniqueid, c1->uniqueid, c0->cid.cid_num, c1->cid.cid_num);
- if (option_debug)
- ast_log(LOG_DEBUG, "Returning from native bridge, channels: %s, %s\n", c0->name, c1->name);
+ ast_debug(1, "Returning from native bridge, channels: %s, %s\n", c0->name, c1->name);
ast_clear_flag(c0, AST_FLAG_NBRIDGE);
ast_clear_flag(c1, AST_FLAG_NBRIDGE);
@@ -4221,8 +4177,7 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
"CallerID1: %s\r\n"
"CallerID2: %s\r\n",
c0->name, c1->name, c0->uniqueid, c1->uniqueid, c0->cid.cid_num, c1->cid.cid_num);
- if (option_debug)
- ast_log(LOG_DEBUG, "Bridge stops bridging channels %s and %s\n", c0->name, c1->name);
+ ast_debug(1, "Bridge stops bridging channels %s and %s\n", c0->name, c1->name);
return res;
}
@@ -4694,8 +4649,7 @@ struct ast_silence_generator *ast_channel_start_silence_generator(struct ast_cha
ast_activate_generator(chan, &silence_generator, state);
- if (option_debug)
- ast_log(LOG_DEBUG, "Started silence generator on '%s'\n", chan->name);
+ ast_debug(1, "Started silence generator on '%s'\n", chan->name);
return state;
}
@@ -4707,8 +4661,7 @@ void ast_channel_stop_silence_generator(struct ast_channel *chan, struct ast_sil
ast_deactivate_generator(chan);
- if (option_debug)
- ast_log(LOG_DEBUG, "Stopped silence generator on '%s'\n", chan->name);
+ ast_debug(1, "Stopped silence generator on '%s'\n", chan->name);
if (ast_set_write_format(chan, state->old_write_format) < 0)
ast_log(LOG_ERROR, "Could not return write format to its original state\n");
@@ -4743,12 +4696,10 @@ const char *channelreloadreason2txt(enum channelreloadreason reason)
int ast_channel_unlock(struct ast_channel *chan)
{
int res = 0;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "::::==== Unlocking AST channel %s\n", chan->name);
+ ast_debug(3, "::::==== Unlocking AST channel %s\n", chan->name);
if (!chan) {
- if (option_debug)
- ast_log(LOG_DEBUG, "::::==== Unlocking non-existing channel \n");
+ ast_debug(1, "::::==== Unlocking non-existing channel \n");
return 0;
}
@@ -4758,21 +4709,17 @@ int ast_channel_unlock(struct ast_channel *chan)
#ifdef DEBUG_THREADS
int count = 0;
if ((count = chan->lock.reentrancy))
- if (option_debug)
- ast_log(LOG_DEBUG, ":::=== Still have %d locks (recursive)\n", count);
+ ast_debug(3, ":::=== Still have %d locks (recursive)\n", count);
#endif
if (!res)
- if (option_debug)
- ast_log(LOG_DEBUG, "::::==== Channel %s was unlocked\n", chan->name);
+ ast_debug(3, "::::==== Channel %s was unlocked\n", chan->name);
if (res == EINVAL) {
- if (option_debug)
- ast_log(LOG_DEBUG, "::::==== Channel %s had no lock by this thread. Failed unlocking\n", chan->name);
+ ast_debug(3, "::::==== Channel %s had no lock by this thread. Failed unlocking\n", chan->name);
}
}
if (res == EPERM) {
/* We had no lock, so okay any way*/
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "::::==== Channel %s was not locked at all \n", chan->name);
+ ast_debug(4, "::::==== Channel %s was not locked at all \n", chan->name);
res = 0;
}
return res;
@@ -4784,8 +4731,7 @@ int ast_channel_lock(struct ast_channel *chan)
{
int res;
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "====:::: Locking AST channel %s\n", chan->name);
+ ast_debug(4, "====:::: Locking AST channel %s\n", chan->name);
res = ast_mutex_lock(&chan->lock);
@@ -4793,20 +4739,16 @@ int ast_channel_lock(struct ast_channel *chan)
#ifdef DEBUG_THREADS
int count = 0;
if ((count = chan->lock.reentrancy))
- if (option_debug)
- ast_log(LOG_DEBUG, ":::=== Now have %d locks (recursive)\n", count);
+ ast_debug(4, ":::=== Now have %d locks (recursive)\n", count);
#endif
if (!res)
- if (option_debug)
- ast_log(LOG_DEBUG, "::::==== Channel %s was locked\n", chan->name);
+ ast_debug(4, "::::==== Channel %s was locked\n", chan->name);
if (res == EDEADLK) {
/* We had no lock, so okey any way */
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "::::==== Channel %s was not locked by us. Lock would cause deadlock.\n", chan->name);
+ ast_debug(4, "::::==== Channel %s was not locked by us. Lock would cause deadlock.\n", chan->name);
}
if (res == EINVAL) {
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "::::==== Channel %s lock failed. No mutex.\n", chan->name);
+ ast_debug(4, "::::==== Channel %s lock failed. No mutex.\n", chan->name);
}
}
return res;
@@ -4818,8 +4760,7 @@ int ast_channel_trylock(struct ast_channel *chan)
{
int res;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "====:::: Trying to lock AST channel %s\n", chan->name);
+ ast_debug(3, "====:::: Trying to lock AST channel %s\n", chan->name);
res = ast_mutex_trylock(&chan->lock);
@@ -4827,24 +4768,20 @@ int ast_channel_trylock(struct ast_channel *chan)
#ifdef DEBUG_THREADS
int count = 0;
if ((count = chan->lock.reentrancy))
- if (option_debug)
- ast_log(LOG_DEBUG, ":::=== Now have %d locks (recursive)\n", count);
+ ast_debug(3, ":::=== Now have %d locks (recursive)\n", count);
#endif
if (!res)
- if (option_debug)
- ast_log(LOG_DEBUG, "::::==== Channel %s was locked\n", chan->name);
+ ast_debug(3, "::::==== Channel %s was locked\n", chan->name);
if (res == EBUSY) {
/* We failed to lock */
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "::::==== Channel %s failed to lock. Not waiting around...\n", chan->name);
+ ast_debug(3, "::::==== Channel %s failed to lock. Not waiting around...\n", chan->name);
}
if (res == EDEADLK) {
/* We had no lock, so okey any way*/
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "::::==== Channel %s was not locked. Lock would cause deadlock.\n", chan->name);
+ ast_debug(3, "::::==== Channel %s was not locked. Lock would cause deadlock.\n", chan->name);
}
- if (res == EINVAL && option_debug > 2)
- ast_log(LOG_DEBUG, "::::==== Channel %s lock failed. No mutex.\n", chan->name);
+ if (res == EINVAL)
+ ast_debug(3, "::::==== Channel %s lock failed. No mutex.\n", chan->name);
}
return res;
}
diff --git a/main/config.c b/main/config.c
index 54e899761..ad7138443 100644
--- a/main/config.c
+++ b/main/config.c
@@ -829,15 +829,13 @@ static struct ast_config *config_text_file_load(const char *database, const char
fflush(stdout);
}
if (!(f = fopen(fn, "r"))) {
- if (option_debug)
- ast_log(LOG_DEBUG, "No file to parse: %s\n", fn);
+ ast_debug(1, "No file to parse: %s\n", fn);
if (option_verbose > 1)
ast_verbose( "Not found (%s)\n", strerror(errno));
continue;
}
count++;
- if (option_debug)
- ast_log(LOG_DEBUG, "Parsing %s\n", fn);
+ ast_debug(1, "Parsing %s\n", fn);
if (option_verbose > 1)
ast_verbose("Found\n");
while (!feof(f)) {
@@ -1028,8 +1026,7 @@ int config_text_file_save(const char *configfile, const struct ast_config *cfg,
if ((option_verbose > 1) && !option_debug)
ast_verbose("Saved\n");
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Unable to open for writing: %s\n", fn);
+ ast_debug(1, "Unable to open for writing: %s\n", fn);
if (option_verbose > 1)
ast_verbose(VERBOSE_PREFIX_2 "Unable to write (%s)", strerror(errno));
return -1;
diff --git a/main/db.c b/main/db.c
index b7182e60c..c733ef9dc 100644
--- a/main/db.c
+++ b/main/db.c
@@ -194,8 +194,7 @@ int ast_db_get(const char *family, const char *keys, char *value, int valuelen)
/* Be sure to NULL terminate our data either way */
if (res) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Unable to find key '%s' in family '%s'\n", keys, family);
+ ast_debug(1, "Unable to find key '%s' in family '%s'\n", keys, family);
} else {
#if 0
printf("Got value of size %d\n", data.size);
@@ -234,8 +233,7 @@ int ast_db_del(const char *family, const char *keys)
ast_mutex_unlock(&dblock);
if (res) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Unable to find key '%s' in family '%s'\n", keys, family);
+ ast_debug(1, "Unable to find key '%s' in family '%s'\n", keys, family);
}
return res;
}
diff --git a/main/devicestate.c b/main/devicestate.c
index 2c30011b0..a233e5686 100644
--- a/main/devicestate.c
+++ b/main/devicestate.c
@@ -284,13 +284,11 @@ enum ast_device_state ast_device_state(const char *device)
}
if (provider) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Checking if I can find provider for \"%s\" - number: %s\n", provider, number);
+ ast_debug(3, "Checking if I can find provider for \"%s\" - number: %s\n", provider, number);
return getproviderstate(provider, number);
}
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "No provider found, checking channel drivers for %s - %s\n", tech, number);
+ ast_debug(4, "No provider found, checking channel drivers for %s - %s\n", tech, number);
if (!(chan_tech = ast_get_channel_tech(tech)))
return AST_DEVICE_INVALID;
@@ -359,8 +357,7 @@ static int getproviderstate(const char *provider, const char *address)
AST_RWLIST_RDLOCK(&devstate_provs);
AST_RWLIST_TRAVERSE(&devstate_provs, devprov, list) {
- if (option_debug > 4)
- ast_log(LOG_DEBUG, "Checking provider %s with %s\n", devprov->label, provider);
+ ast_debug(5, "Checking provider %s with %s\n", devprov->label, provider);
if (!strcasecmp(devprov->label, provider)) {
res = devprov->callback(address);
@@ -380,8 +377,7 @@ static void do_state_change(const char *device)
struct ast_event *event;
state = ast_device_state(device);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Changing state for %s - state %d (%s)\n", device, state, devstate2str(state));
+ ast_debug(3, "Changing state for %s - state %d (%s)\n", device, state, devstate2str(state));
if (!(event = ast_event_new(AST_EVENT_DEVICE_STATE,
AST_EVENT_IE_DEVICE, AST_EVENT_IE_PLTYPE_STR, device,
@@ -401,8 +397,7 @@ static int __ast_device_state_changed_literal(char *buf)
struct state_change *change;
char *tmp = NULL;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Notification of state change to be queued on device/channel %s\n", buf);
+ ast_debug(3, "Notification of state change to be queued on device/channel %s\n", buf);
device = buf;
diff --git a/main/dial.c b/main/dial.c
index 8b804fdbb..de30419ba 100644
--- a/main/dial.c
+++ b/main/dial.c
@@ -576,13 +576,13 @@ enum ast_dial_result ast_dial_run(struct ast_dial *dial, struct ast_channel *cha
/* Ensure required arguments are passed */
if (!dial || (!chan && !async)) {
- ast_log(LOG_DEBUG, "invalid #1\n");
+ ast_debug(1, "invalid #1\n");
return AST_DIAL_RESULT_INVALID;
}
/* If there are no channels to dial we can't very well try to dial them */
if (AST_LIST_EMPTY(&dial->channels)) {
- ast_log(LOG_DEBUG, "invalid #2\n");
+ ast_debug(1, "invalid #2\n");
return AST_DIAL_RESULT_INVALID;
}
diff --git a/main/dns.c b/main/dns.c
index 52a4b8ddb..bb7827226 100644
--- a/main/dns.c
+++ b/main/dns.c
@@ -222,8 +222,7 @@ int ast_search_dns(void *context,
ret = -1;
}
else if (ret == 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "No matches found in DNS for %s\n", dname);
+ ast_debug(1, "No matches found in DNS for %s\n", dname);
ret = 0;
}
else
diff --git a/main/dsp.c b/main/dsp.c
index 9519c56cc..428873ebf 100644
--- a/main/dsp.c
+++ b/main/dsp.c
@@ -1323,8 +1323,7 @@ int ast_dsp_busydetect(struct ast_dsp *dsp)
#ifndef BUSYDETECT_TONEONLY
#if 1
if (res) {
- if (option_debug)
- ast_log(LOG_DEBUG, "ast_dsp_busydetect detected busy, avgtone: %d, avgsilence %d\n", avgtone, avgsilence);
+ ast_debug(1, "ast_dsp_busydetect detected busy, avgtone: %d, avgsilence %d\n", avgtone, avgsilence);
}
#endif
#endif
@@ -1460,8 +1459,7 @@ struct ast_frame *ast_dsp_process(struct ast_channel *chan, struct ast_dsp *dsp,
memset(&dsp->f, 0, sizeof(dsp->f));
dsp->f.frametype = AST_FRAME_CONTROL;
dsp->f.subclass = AST_CONTROL_BUSY;
- if (option_debug)
- ast_log(LOG_DEBUG, "Requesting Hangup because the busy tone was detected on channel %s\n", chan->name);
+ ast_debug(1, "Requesting Hangup because the busy tone was detected on channel %s\n", chan->name);
return &dsp->f;
}
if ((dsp->features & DSP_FEATURE_DTMF_DETECT)) {
@@ -1646,8 +1644,7 @@ void ast_dsp_set_busy_pattern(struct ast_dsp *dsp, int tonelength, int quietleng
{
dsp->busy_tonelength = tonelength;
dsp->busy_quietlength = quietlength;
- if (option_debug)
- ast_log(LOG_DEBUG, "dsp busy pattern set to %d,%d\n", tonelength, quietlength);
+ ast_debug(1, "dsp busy pattern set to %d,%d\n", tonelength, quietlength);
}
void ast_dsp_digitreset(struct ast_dsp *dsp)
diff --git a/main/enum.c b/main/enum.c
index a860dcb4c..a54506045 100644
--- a/main/enum.c
+++ b/main/enum.c
@@ -169,9 +169,8 @@ static int parse_naptr(char *dst, int dstsize, char *tech, int techsize, unsigne
return -1;
}
- if (option_debug > 2) /* Advanced NAPTR debugging */
- ast_log(LOG_DEBUG, "NAPTR input='%s', flags='%s', services='%s', regexp='%s', repl='%s'\n",
- naptrinput, flags, services, regexp, repl);
+ ast_debug(3, "NAPTR input='%s', flags='%s', services='%s', regexp='%s', repl='%s'\n",
+ naptrinput, flags, services, regexp, repl);
if (tolower(flags[0]) != 'u') {
ast_log(LOG_WARNING, "NAPTR Flag must be 'U' or 'u'.\n");
@@ -403,7 +402,7 @@ int ast_get_enum(struct ast_channel *chan, const char *number, char *dst, int ds
}
}
- ast_log(LOG_DEBUG, "ast_get_enum(): n='%s', tech='%s', suffix='%s', options='%d', record='%d'\n",
+ ast_debug(1, "ast_get_enum(): n='%s', tech='%s', suffix='%s', options='%d', record='%d'\n",
number, tech, suffix, context->options, context->position);
if (pos > 128)
@@ -450,7 +449,7 @@ int ast_get_enum(struct ast_channel *chan, const char *number, char *dst, int ds
if (suffix) {
ast_copy_string(tmp + newpos, suffix, sizeof(tmp) - newpos);
ret = ast_search_dns(context, tmp, C_IN, T_NAPTR, enum_callback);
- ast_log(LOG_DEBUG, "ast_get_enum: ast_search_dns(%s) returned %d\n", tmp, ret);
+ ast_debug(1, "ast_get_enum: ast_search_dns(%s) returned %d\n", tmp, ret);
} else {
ret = -1; /* this is actually dead code since the demise of app_enum.c */
for (;;) {
@@ -469,15 +468,14 @@ int ast_get_enum(struct ast_channel *chan, const char *number, char *dst, int ds
ast_copy_string(tmp + newpos, s->toplev, sizeof(tmp) - newpos);
ret = ast_search_dns(&context, tmp, C_IN, T_NAPTR, enum_callback);
- ast_log(LOG_DEBUG, "ast_get_enum: ast_search_dns(%s) returned %d\n", tmp, ret);
+ ast_debug(1, "ast_get_enum: ast_search_dns(%s) returned %d\n", tmp, ret);
if (ret > 0)
break;
}
}
if (ret < 0) {
- if (option_debug)
- ast_log(LOG_DEBUG, "No such number found: %s (%s)\n", tmp, strerror(errno));
+ ast_debug(1, "No such number found: %s (%s)\n", tmp, strerror(errno));
strcpy(dst, "0");
ret = 0;
}
@@ -589,8 +587,7 @@ int ast_get_txt(struct ast_channel *chan, const char *number, char *dst, int dst
break;
}
if (ret < 0) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "No such number found in ENUM: %s (%s)\n", tmp, strerror(errno));
+ ast_debug(2, "No such number found in ENUM: %s (%s)\n", tmp, strerror(errno));
ret = 0;
}
if (chan)
diff --git a/main/file.c b/main/file.c
index f315bfcd2..cd5e2e435 100644
--- a/main/file.c
+++ b/main/file.c
@@ -155,8 +155,7 @@ int ast_writestream(struct ast_filestream *fs, struct ast_frame *f)
if (!fs->vfs && fs->filename) {
const char *type = ast_getformatname(f->subclass & ~0x1);
fs->vfs = ast_writefile(fs->filename, type, NULL, fs->flags, 0, fs->mode);
- if (option_debug)
- ast_log(LOG_DEBUG, "Opened video output file\n");
+ ast_debug(1, "Opened video output file\n");
}
if (fs->vfs)
return ast_writestream(fs->vfs, f);
@@ -788,8 +787,7 @@ int ast_streamfile(struct ast_channel *chan, const char *filename, const char *p
if (fs)
vfs = ast_openvstream(chan, filename, preflang);
if (vfs) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Ooh, found a video stream, too, format %s\n", ast_getformatname(vfs->fmt->format));
+ ast_debug(1, "Ooh, found a video stream, too, format %s\n", ast_getformatname(vfs->fmt->format));
}
if (fs){
if (ast_applystream(chan, fs))
diff --git a/main/frame.c b/main/frame.c
index 57a8b0b33..c5a9e82eb 100644
--- a/main/frame.c
+++ b/main/frame.c
@@ -1153,8 +1153,7 @@ int ast_codec_choose(struct ast_codec_pref *pref, int formats, int find_best)
if (ret & AST_FORMAT_AUDIO_MASK)
return ret;
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "Could not find preferred codec - %s\n", find_best ? "Going for the best codec" : "Returning zero codec");
+ ast_debug(4, "Could not find preferred codec - %s\n", find_best ? "Going for the best codec" : "Returning zero codec");
return find_best ? ast_best_codec(formats) : 0;
}
@@ -1170,8 +1169,7 @@ int ast_parse_allow_disallow(struct ast_codec_pref *pref, int *mask, const char
framems = 0;
if ((psize = strrchr(this, ':'))) {
*psize++ = '\0';
- if (option_debug)
- ast_log(LOG_DEBUG,"Packetization for codec: %s is %s\n", this, psize);
+ ast_debug(1, "Packetization for codec: %s is %s\n", this, psize);
framems = atoi(psize);
if (framems < 0) {
framems = 0;
diff --git a/res/res_adsi.c b/res/res_adsi.c
index 6b3fccf14..28ff200e4 100644
--- a/res/res_adsi.c
+++ b/res/res_adsi.c
@@ -232,8 +232,7 @@ static int __adsi_transmit_messages(struct ast_channel *chan, unsigned char **ms
for(;;) {
if (((res = ast_waitfor(chan, waittime)) < 1)) {
/* Didn't get back DTMF A in time */
- if (option_debug)
- ast_log(LOG_DEBUG, "No ADSI CPE detected (%d)\n", res);
+ ast_debug(1, "No ADSI CPE detected (%d)\n", res);
if (!chan->adsicpe)
chan->adsicpe = AST_ADSI_UNAVAILABLE;
errno = ENOSYS;
@@ -242,8 +241,7 @@ static int __adsi_transmit_messages(struct ast_channel *chan, unsigned char **ms
waittime = res;
f = ast_read(chan);
if (!f) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Hangup in ADSI\n");
+ ast_debug(1, "Hangup in ADSI\n");
return -1;
}
if (f->frametype == AST_FRAME_DTMF) {
@@ -254,8 +252,7 @@ static int __adsi_transmit_messages(struct ast_channel *chan, unsigned char **ms
break;
} else {
if (f->subclass == 'D') {
- if (option_debug)
- ast_log(LOG_DEBUG, "Off-hook capable CPE only, not ADSI\n");
+ ast_debug(1, "Off-hook capable CPE only, not ADSI\n");
} else
ast_log(LOG_WARNING, "Unknown ADSI response '%c'\n", f->subclass);
if (!chan->adsicpe)
@@ -267,11 +264,9 @@ static int __adsi_transmit_messages(struct ast_channel *chan, unsigned char **ms
ast_frfree(f);
}
- if (option_debug)
- ast_log(LOG_DEBUG, "ADSI Compatible CPE Detected\n");
+ ast_debug(1, "ADSI Compatible CPE Detected\n");
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Already in data mode\n");
+ ast_debug(1, "Already in data mode\n");
}
x = 0;
@@ -285,9 +280,7 @@ static int __adsi_transmit_messages(struct ast_channel *chan, unsigned char **ms
ast_log(LOG_WARNING, "Failed to generate ADSI message %d on channel %s\n", x + 1, chan->name);
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "Message %d, of %d input bytes, %d output bytes\n",
- x + 1, msglen[x], res);
+ ast_debug(1, "Message %d, of %d input bytes, %d output bytes\n", x + 1, msglen[x], res);
pos += res;
x++;
}
@@ -300,8 +293,7 @@ static int __adsi_transmit_messages(struct ast_channel *chan, unsigned char **ms
if (res)
return -1;
- if (option_debug)
- ast_log(LOG_DEBUG, "Sent total spill of %d bytes\n", pos);
+ ast_debug(1, "Sent total spill of %d bytes\n", pos);
memset(ack, 0, sizeof(ack));
/* Get real result */
@@ -310,15 +302,12 @@ static int __adsi_transmit_messages(struct ast_channel *chan, unsigned char **ms
if (res < 0)
return -1;
if (ack[0] == 'D') {
- if (option_debug)
- ast_log(LOG_DEBUG, "Acked up to message %d\n", atoi(ack + 1));
- start += atoi(ack + 1);
+ ast_debug(1, "Acked up to message %d\n", atoi(ack + 1)); start += atoi(ack + 1);
if (start >= x)
break;
else {
retries++;
- if (option_debug)
- ast_log(LOG_DEBUG, "Retransmitting (%d), from %d\n", retries, start + 1);
+ ast_debug(1, "Retransmitting (%d), from %d\n", retries, start + 1);
}
} else {
retries++;
@@ -349,8 +338,7 @@ static int _ast_adsi_begin_download(struct ast_channel *chan, char *service, uns
return -1;
if (ack[0] == 'B')
return 0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Download was denied by CPE\n");
+ ast_debug(1, "Download was denied by CPE\n");
return -1;
}
@@ -385,15 +373,13 @@ static int _ast_adsi_transmit_message_full(struct ast_channel *chan, unsigned ch
for (x=0;x<msglen;x+=(msg[x+1]+2)) {
if (msg[x] == ADSI_SWITCH_TO_DATA) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Switch to data is sent!\n");
+ ast_debug(1, "Switch to data is sent!\n");
waitforswitch++;
newdatamode = ADSI_FLAG_DATAMODE;
}
if (msg[x] == ADSI_SWITCH_TO_VOICE) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Switch to voice is sent!\n");
+ ast_debug(1, "Switch to voice is sent!\n");
waitforswitch++;
newdatamode = 0;
}
@@ -426,12 +412,10 @@ static int _ast_adsi_transmit_message_full(struct ast_channel *chan, unsigned ch
res = __adsi_transmit_messages(chan, msgs, msglens, msgtypes);
if (dowait) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Wait for switch is '%d'\n", waitforswitch);
+ ast_debug(1, "Wait for switch is '%d'\n", waitforswitch);
while (waitforswitch-- && ((res = ast_waitfordigit(chan, 1000)) > 0)) {
res = 0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Waiting for 'B'...\n");
+ ast_debug(1, "Waiting for 'B'...\n");
}
}
@@ -1014,17 +998,14 @@ static int _ast_adsi_load_session(struct ast_channel *chan, unsigned char *app,
if (res < 0)
return -1;
if (res) {
- if (option_debug)
- ast_log(LOG_DEBUG, "No response from CPE about version. Assuming not there.\n");
+ ast_debug(1, "No response from CPE about version. Assuming not there.\n");
return 0;
}
if (!strcmp(resp, "B")) {
- if (option_debug)
- ast_log(LOG_DEBUG, "CPE has script '%s' version %d already loaded\n", app, ver);
+ ast_debug(1, "CPE has script '%s' version %d already loaded\n", app, ver);
return 1;
} else if (!strcmp(resp, "A")) {
- if (option_debug)
- ast_log(LOG_DEBUG, "CPE hasn't script '%s' version %d already loaded\n", app, ver);
+ ast_debug(1, "CPE hasn't script '%s' version %d already loaded\n", app, ver);
} else {
ast_log(LOG_WARNING, "Unexpected CPE response to script query: %s\n", resp);
}
diff --git a/res/res_agi.c b/res/res_agi.c
index 5d58de4b0..1fef67a59 100644
--- a/res/res_agi.c
+++ b/res/res_agi.c
@@ -224,8 +224,7 @@ static enum agi_result launch_netscript(char *agiurl, char *argv[], int *fds, in
if (!ast_strlen_zero(script))
fdprintf(s, "agi_network_script: %s\n", script);
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "Wow, connected!\n");
+ ast_debug(4, "Wow, connected!\n");
fds[0] = s;
fds[1] = s;
*opid = -1;
@@ -584,8 +583,7 @@ static int handle_streamfile(struct ast_channel *chan, AGI *agi, int argc, char
return RESULT_SUCCESS;
}
vfs = ast_openvstream(chan, argv[2], chan->language);
- if (vfs && option_debug)
- ast_log(LOG_DEBUG, "Ooh, found a video stream, too\n");
+ ast_debug(vfs && 1, "Ooh, found a video stream, too\n");
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Playing '%s' (escape_digits=%s) (sample_offset %ld)\n", argv[2], edigits, sample_offset);
@@ -649,8 +647,7 @@ static int handle_getoption(struct ast_channel *chan, AGI *agi, int argc, char *
return RESULT_SUCCESS;
}
vfs = ast_openvstream(chan, argv[2], chan->language);
- if (vfs && option_debug)
- ast_log(LOG_DEBUG, "Ooh, found a video stream, too\n");
+ ast_debug(vfs && 1, "Ooh, found a video stream, too\n");
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Playing '%s' (escape_digits=%s) (timeout %d)\n", argv[2], edigits, timeout);
@@ -1860,8 +1857,7 @@ static enum agi_result run_agi(struct ast_channel *chan, char *request, AGI *agi
/* Idle the channel until we get a command */
f = ast_read(c);
if (!f) {
- if (option_debug)
- ast_log(LOG_DEBUG, "%s hungup\n", chan->name);
+ ast_debug(1, "%s hungup\n", chan->name);
returnstatus = AGI_RESULT_HANGUP;
break;
} else {
diff --git a/res/res_config_pgsql.c b/res/res_config_pgsql.c
index 20b2312c0..821f32cc0 100644
--- a/res/res_config_pgsql.c
+++ b/res/res_config_pgsql.c
@@ -132,11 +132,8 @@ static struct ast_variable *realtime_pgsql(const char *database, const char *tab
if (!(result = PQexec(pgsqlConn, sql))) {
ast_log(LOG_WARNING,
"Postgresql RealTime: Failed to query database. Check debug for more info.\n");
- if (option_debug) {
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql);
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s\n",
- PQerrorMessage(pgsqlConn));
- }
+ ast_debug(1, "Postgresql RealTime: Query: %s\n", sql);
+ ast_debug(1, "Postgresql RealTime: Query Failed because: %s\n", PQerrorMessage(pgsqlConn));
ast_mutex_unlock(&pgsql_lock);
return NULL;
} else {
@@ -146,18 +143,15 @@ static struct ast_variable *realtime_pgsql(const char *database, const char *tab
&& result_status != PGRES_NONFATAL_ERROR) {
ast_log(LOG_WARNING,
"Postgresql RealTime: Failed to query database. Check debug for more info.\n");
- if (option_debug) {
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql);
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s (%s)\n",
+ ast_debug(1, "Postgresql RealTime: Query: %s\n", sql);
+ ast_debug(1, "Postgresql RealTime: Query Failed because: %s (%s)\n",
PQresultErrorMessage(result), PQresStatus(result_status));
- }
ast_mutex_unlock(&pgsql_lock);
return NULL;
}
}
- if (option_debug)
- ast_log(LOG_DEBUG, "1Postgresql RealTime: Result=%p Query: %s\n", result, sql);
+ ast_debug(1, "1Postgresql RealTime: Result=%p Query: %s\n", result, sql);
if ((num_rows = PQntuples(result)) > 0) {
int i = 0;
@@ -165,8 +159,7 @@ static struct ast_variable *realtime_pgsql(const char *database, const char *tab
int numFields = PQnfields(result);
char **fieldnames = NULL;
- if (option_debug)
- ast_log(LOG_DEBUG, "Postgresql RealTime: Found %d rows.\n", num_rows);
+ ast_debug(1, "Postgresql RealTime: Found %d rows.\n", num_rows);
if (!(fieldnames = ast_calloc(1, numFields * sizeof(char *)))) {
ast_mutex_unlock(&pgsql_lock);
@@ -284,11 +277,8 @@ static struct ast_config *realtime_multi_pgsql(const char *database, const char
if (!(result = PQexec(pgsqlConn, sql))) {
ast_log(LOG_WARNING,
"Postgresql RealTime: Failed to query database. Check debug for more info.\n");
- if (option_debug) {
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql);
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s\n",
- PQerrorMessage(pgsqlConn));
- }
+ ast_debug(1, "Postgresql RealTime: Query: %s\n", sql);
+ ast_debug(1, "Postgresql RealTime: Query Failed because: %s\n", PQerrorMessage(pgsqlConn));
ast_mutex_unlock(&pgsql_lock);
return NULL;
} else {
@@ -298,18 +288,15 @@ static struct ast_config *realtime_multi_pgsql(const char *database, const char
&& result_status != PGRES_NONFATAL_ERROR) {
ast_log(LOG_WARNING,
"Postgresql RealTime: Failed to query database. Check debug for more info.\n");
- if (option_debug) {
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql);
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s (%s)\n",
+ ast_debug(1, "Postgresql RealTime: Query: %s\n", sql);
+ ast_debug(1, "Postgresql RealTime: Query Failed because: %s (%s)\n",
PQresultErrorMessage(result), PQresStatus(result_status));
- }
ast_mutex_unlock(&pgsql_lock);
return NULL;
}
}
- if (option_debug)
- ast_log(LOG_DEBUG, "2Postgresql RealTime: Result=%p Query: %s\n", result, sql);
+ ast_debug(1, "2Postgresql RealTime: Result=%p Query: %s\n", result, sql);
if ((num_rows = PQntuples(result)) > 0) {
int numFields = PQnfields(result);
@@ -317,8 +304,7 @@ static struct ast_config *realtime_multi_pgsql(const char *database, const char
int rowIndex = 0;
char **fieldnames = NULL;
- if (option_debug)
- ast_log(LOG_DEBUG, "Postgresql RealTime: Found %d rows.\n", num_rows);
+ ast_debug(1, "Postgresql RealTime: Found %d rows.\n", num_rows);
if (!(fieldnames = ast_calloc(1, numFields * sizeof(char *)))) {
ast_mutex_unlock(&pgsql_lock);
@@ -398,8 +384,7 @@ static int update_pgsql(const char *database, const char *table, const char *key
snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), " WHERE %s = '%s'", keyfield,
lookup);
- if (option_debug)
- ast_log(LOG_DEBUG, "Postgresql RealTime: Update SQL: %s\n", sql);
+ ast_debug(1, "Postgresql RealTime: Update SQL: %s\n", sql);
/* We now have our complete statement; Lets connect to the server and execute it. */
ast_mutex_lock(&pgsql_lock);
@@ -411,11 +396,8 @@ static int update_pgsql(const char *database, const char *table, const char *key
if (!(result = PQexec(pgsqlConn, sql))) {
ast_log(LOG_WARNING,
"Postgresql RealTime: Failed to query database. Check debug for more info.\n");
- if (option_debug) {
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql);
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s\n",
- PQerrorMessage(pgsqlConn));
- }
+ ast_debug(1, "Postgresql RealTime: Query: %s\n", sql);
+ ast_debug(1, "Postgresql RealTime: Query Failed because: %s\n", PQerrorMessage(pgsqlConn));
ast_mutex_unlock(&pgsql_lock);
return -1;
} else {
@@ -425,11 +407,9 @@ static int update_pgsql(const char *database, const char *table, const char *key
&& result_status != PGRES_NONFATAL_ERROR) {
ast_log(LOG_WARNING,
"Postgresql RealTime: Failed to query database. Check debug for more info.\n");
- if (option_debug) {
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql);
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s (%s)\n",
+ ast_debug(1, "Postgresql RealTime: Query: %s\n", sql);
+ ast_debug(1, "Postgresql RealTime: Query Failed because: %s (%s)\n",
PQresultErrorMessage(result), PQresStatus(result_status));
- }
ast_mutex_unlock(&pgsql_lock);
return -1;
}
@@ -438,9 +418,7 @@ static int update_pgsql(const char *database, const char *table, const char *key
numrows = atoi(PQcmdTuples(result));
ast_mutex_unlock(&pgsql_lock);
- if (option_debug)
- ast_log(LOG_DEBUG, "Postgresql RealTime: Updated %d rows on table: %s\n", numrows,
- table);
+ ast_debug(1, "Postgresql RealTime: Updated %d rows on table: %s\n", numrows, table);
/* From http://dev.pgsql.com/doc/pgsql/en/pgsql-affected-rows.html
* An integer greater than zero indicates the number of rows affected
@@ -479,8 +457,7 @@ static struct ast_config *config_pgsql(const char *database, const char *table,
ast_build_string(&sql, &sqlleft, "WHERE filename='%s' and commented=0", file);
ast_build_string(&sql, &sqlleft, "ORDER BY cat_metric DESC, var_metric ASC, category, var_name ");
- if (option_debug)
- ast_log(LOG_DEBUG, "Postgresql RealTime: Static SQL: %s\n", sqlbuf);
+ ast_debug(1, "Postgresql RealTime: Static SQL: %s\n", sqlbuf);
/* We now have our complete statement; Lets connect to the server and execute it. */
ast_mutex_lock(&pgsql_lock);
@@ -492,11 +469,8 @@ static struct ast_config *config_pgsql(const char *database, const char *table,
if (!(result = PQexec(pgsqlConn, sqlbuf))) {
ast_log(LOG_WARNING,
"Postgresql RealTime: Failed to query database. Check debug for more info.\n");
- if (option_debug) {
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql);
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s\n",
- PQerrorMessage(pgsqlConn));
- }
+ ast_debug(1, "Postgresql RealTime: Query: %s\n", sql);
+ ast_debug(1, "Postgresql RealTime: Query Failed because: %s\n", PQerrorMessage(pgsqlConn));
ast_mutex_unlock(&pgsql_lock);
return NULL;
} else {
@@ -506,11 +480,9 @@ static struct ast_config *config_pgsql(const char *database, const char *table,
&& result_status != PGRES_NONFATAL_ERROR) {
ast_log(LOG_WARNING,
"Postgresql RealTime: Failed to query database. Check debug for more info.\n");
- if (option_debug) {
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql);
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s (%s)\n",
+ ast_debug(1, "Postgresql RealTime: Query: %s\n", sql);
+ ast_debug(1, "Postgresql RealTime: Query Failed because: %s (%s)\n",
PQresultErrorMessage(result), PQresStatus(result_status));
- }
ast_mutex_unlock(&pgsql_lock);
return NULL;
}
@@ -519,8 +491,7 @@ static struct ast_config *config_pgsql(const char *database, const char *table,
if ((num_rows = PQntuples(result)) > 0) {
int rowIndex = 0;
- if (option_debug)
- ast_log(LOG_DEBUG, "Postgresql RealTime: Found %ld rows.\n", num_rows);
+ ast_debug(1, "Postgresql RealTime: Found %ld rows.\n", num_rows);
for (rowIndex = 0; rowIndex < num_rows; rowIndex++) {
char *field_category = PQgetvalue(result, rowIndex, 0);
@@ -576,9 +547,7 @@ static int load_module(void)
if (!pgsql_reconnect(NULL)) {
ast_log(LOG_WARNING,
"Postgresql RealTime: Couldn't establish connection. Check debug.\n");
- if (option_debug)
- ast_log(LOG_DEBUG, "Postgresql RealTime: Cannot Connect: %s\n",
- PQerrorMessage(pgsqlConn));
+ ast_debug(1, "Postgresql RealTime: Cannot Connect: %s\n", PQerrorMessage(pgsqlConn));
}
ast_config_engine_register(&pgsql_engine);
@@ -629,9 +598,7 @@ static int reload(void)
if (!pgsql_reconnect(NULL)) {
ast_log(LOG_WARNING,
"Postgresql RealTime: Couldn't establish connection. Check debug.\n");
- if (option_debug)
- ast_log(LOG_DEBUG, "Postgresql RealTime: Cannot Connect: %s\n",
- PQerrorMessage(pgsqlConn));
+ ast_debug(1, "Postgresql RealTime: Cannot Connect: %s\n", PQerrorMessage(pgsqlConn));
}
ast_verbose(VERBOSE_PREFIX_2 "Postgresql RealTime reloaded.\n");
@@ -704,14 +671,14 @@ static int parse_config(void)
if (option_debug) {
if (dbhost) {
- ast_log(LOG_DEBUG, "Postgresql RealTime Host: %s\n", dbhost);
- ast_log(LOG_DEBUG, "Postgresql RealTime Port: %i\n", dbport);
+ ast_debug(1, "Postgresql RealTime Host: %s\n", dbhost);
+ ast_debug(1, "Postgresql RealTime Port: %i\n", dbport);
} else {
- ast_log(LOG_DEBUG, "Postgresql RealTime Socket: %s\n", dbsock);
+ ast_debug(1, "Postgresql RealTime Socket: %s\n", dbsock);
}
- ast_log(LOG_DEBUG, "Postgresql RealTime User: %s\n", dbuser);
- ast_log(LOG_DEBUG, "Postgresql RealTime Password: %s\n", dbpass);
- ast_log(LOG_DEBUG, "Postgresql RealTime DBName: %s\n", dbname);
+ ast_debug(1, "Postgresql RealTime User: %s\n", dbuser);
+ ast_debug(1, "Postgresql RealTime Password: %s\n", dbpass);
+ ast_debug(1, "Postgresql RealTime DBName: %s\n", dbname);
}
return 1;
@@ -742,32 +709,25 @@ static int pgsql_reconnect(const char *database)
sprintf(connInfo, "host=%s port=%d dbname=%s user=%s password=%s",
dbhost, dbport, my_database, dbuser, dbpass);
- if (option_debug)
- ast_log(LOG_DEBUG, "%u connInfo=%s\n", size, connInfo);
+ ast_debug(1, "%u connInfo=%s\n", size, connInfo);
pgsqlConn = PQconnectdb(connInfo);
- if (option_debug)
- ast_log(LOG_DEBUG, "%u connInfo=%s\n", size, connInfo);
+ ast_debug(1, "%u connInfo=%s\n", size, connInfo);
ast_free(connInfo);
connInfo = NULL;
- if (option_debug)
- ast_log(LOG_DEBUG, "pgsqlConn=%p\n", pgsqlConn);
+ ast_debug(1, "pgsqlConn=%p\n", pgsqlConn);
if (pgsqlConn && PQstatus(pgsqlConn) == CONNECTION_OK) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Postgresql RealTime: Successfully connected to database.\n");
+ ast_debug(1, "Postgresql RealTime: Successfully connected to database.\n");
connect_time = time(NULL);
return 1;
} else {
ast_log(LOG_ERROR,
"Postgresql RealTime: Failed to connect database server %s on %s. Check debug for more info.\n",
dbname, dbhost);
- if (option_debug)
- ast_log(LOG_DEBUG, "Postgresql RealTime: Cannot Connect: %s\n",
- PQresultErrorMessage(NULL));
+ ast_debug(1, "Postgresql RealTime: Cannot Connect: %s\n", PQresultErrorMessage(NULL));
return 0;
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Postgresql RealTime: Everything is fine.\n");
+ ast_debug(1, "Postgresql RealTime: Everything is fine.\n");
return 1;
}
}
diff --git a/res/res_config_sqlite.c b/res/res_config_sqlite.c
index f8f9d81d1..9aa37d5f0 100644
--- a/res/res_config_sqlite.c
+++ b/res/res_config_sqlite.c
@@ -909,7 +909,7 @@ realtime_handler(const char *database, const char *table, va_list ap)
}
query = tmp_str;
- ast_log(LOG_DEBUG, "SQL query: %s\n", query);
+ ast_debug(1, "SQL query: %s\n", query);
args.var = NULL;
args.last = NULL;
@@ -1074,7 +1074,7 @@ static struct ast_config *realtime_multi_handler(const char *database,
sqlite_freemem(query);
query = tmp_str;
- ast_log(LOG_DEBUG, "SQL query: %s\n", query);
+ ast_debug(1, "SQL query: %s\n", query);
args.cfg = cfg;
args.initfield = initfield;
@@ -1157,7 +1157,7 @@ static int realtime_update_handler(const char *database, const char *table,
sqlite_freemem(query);
query = tmp_str;
- ast_log(LOG_DEBUG, "SQL query: %s\n", query);
+ ast_debug(1, "SQL query: %s\n", query);
ast_mutex_lock(&mutex);
diff --git a/res/res_crypto.c b/res/res_crypto.c
index 341723d70..73a54ba6d 100644
--- a/res/res_crypto.c
+++ b/res/res_crypto.c
@@ -258,8 +258,7 @@ static struct ast_key *try_load_key (char *dir, char *fname, int ifd, int ofd, i
key->ktype &= ~KEY_NEEDS_PASSCODE;
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Loaded %s key '%s'\n", key->ktype == AST_KEY_PUBLIC ? "PUBLIC" : "PRIVATE", key->name);
- if (option_debug)
- ast_log(LOG_DEBUG, "Key '%s' loaded OK\n", key->name);
+ ast_debug(1, "Key '%s' loaded OK\n", key->name);
key->delme = 0;
} else
ast_log(LOG_NOTICE, "Key '%s' is not expected size.\n", key->name);
@@ -436,8 +435,7 @@ static int __ast_check_signature_bin(struct ast_key *key, const char *msg, int m
res = RSA_verify(NID_sha1, digest, sizeof(digest), (unsigned char *)dsig, 128, key->rsa);
if (!res) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Key failed verification: %s\n", key->name);
+ ast_debug(1, "Key failed verification: %s\n", key->name);
return -1;
}
/* Pass */
@@ -491,8 +489,7 @@ static void crypto_load(int ifd, int ofd)
while(key) {
nkey = key->next;
if (key->delme) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Deleting key %s type %d\n", key->name, key->ktype);
+ ast_debug(1, "Deleting key %s type %d\n", key->name, key->ktype);
/* Do the delete */
if (last)
last->next = nkey;
diff --git a/res/res_features.c b/res/res_features.c
index b4feda26c..bd8504f05 100644
--- a/res/res_features.c
+++ b/res/res_features.c
@@ -324,8 +324,7 @@ static int adsi_announce_park(struct ast_channel *chan, char *parkingexten)
/*! \brief Notify metermaids that we've changed an extension */
static void notify_metermaids(const char *exten, char *context)
{
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "Notification of state change to metermaids %s@%s\n", exten, context);
+ ast_debug(4, "Notification of state change to metermaids %s@%s\n", exten, context);
/* Send notification to devicestate subsystem */
ast_device_state_changed("park:%s@%s", exten, context);
@@ -343,8 +342,7 @@ static enum ast_device_state metermaidstate(const char *data)
if (!context)
return res;
- if (option_debug > 3)
- ast_log(LOG_DEBUG, "Checking state of exten %s in context %s\n", exten, context);
+ ast_debug(4, "Checking state of exten %s in context %s\n", exten, context);
res = ast_exists_extension(NULL, context, exten, 1, NULL);
@@ -807,8 +805,7 @@ static int builtin_atxfer(struct ast_channel *chan, struct ast_channel *peer, st
struct ast_frame *f;
int l;
- if (option_debug)
- ast_log(LOG_DEBUG, "Executing Attended Transfer %s, %s (sense=%d) \n", chan->name, peer->name, sense);
+ ast_debug(1, "Executing Attended Transfer %s, %s (sense=%d) \n", chan->name, peer->name, sense);
set_peers(&transferer, &transferee, peer, chan, sense);
transferer_real_context = real_ctx(transferer, transferee);
/* Start autoservice on chan while we talk to the originator */
@@ -957,11 +954,9 @@ static int builtin_atxfer(struct ast_channel *chan, struct ast_channel *peer, st
}
if (!newchan) {
/* Transfer failed, sleeping */
- if (option_debug)
- ast_log(LOG_DEBUG, "Sleeping for %d ms before callback.\n", atxferloopdelay);
+ ast_debug(1, "Sleeping for %d ms before callback.\n", atxferloopdelay);
ast_safe_sleep(transferee, atxferloopdelay);
- if (option_debug)
- ast_log(LOG_DEBUG, "Trying to callback...\n");
+ ast_debug(1, "Trying to callback...\n");
newchan = ast_feature_request_and_dial(transferee, NULL, "Local", ast_best_codec(transferee->nativeformats),
callbackto, atxfernoanswertimeout, &outstate, transferee->cid.cid_num, transferee->cid.cid_name, 0);
}
@@ -1329,8 +1324,7 @@ static int ast_feature_interpret(struct ast_channel *chan, struct ast_channel *p
ast_copy_flags(&features, &(config->features_caller), AST_FLAGS_ALL);
else
ast_copy_flags(&features, &(config->features_callee), AST_FLAGS_ALL);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Feature interpret: chan=%s, peer=%s, sense=%d, features=%d\n", chan->name, peer->name, sense, features.flags);
+ ast_debug(3, "Feature interpret: chan=%s, peer=%s, sense=%d, features=%d\n", chan->name, peer->name, sense, features.flags);
ast_rwlock_rdlock(&features_lock);
for (x = 0; x < FEATURES_COUNT; x++) {
@@ -1693,8 +1687,7 @@ int ast_bridge_call(struct ast_channel *chan,struct ast_channel *peer,struct ast
activated, but that's no excuse to keep things going
indefinitely! */
if (backup_config.feature_timer && ((backup_config.feature_timer -= diff) <= 0)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Timed out, realtime this time!\n");
+ ast_debug(1, "Timed out, realtime this time!\n");
config->feature_timer = 0;
who = chan;
if (f)
@@ -1704,8 +1697,7 @@ int ast_bridge_call(struct ast_channel *chan,struct ast_channel *peer,struct ast
} else if (config->feature_timer <= 0) {
/* Not *really* out of time, just out of time for
digits to come in for features. */
- if (option_debug)
- ast_log(LOG_DEBUG, "Timed out for feature!\n");
+ ast_debug(1, "Timed out for feature!\n");
if (!ast_strlen_zero(peer_featurecode)) {
ast_dtmf_stream(chan, peer, peer_featurecode, 0);
memset(peer_featurecode, 0, sizeof(peer_featurecode));
@@ -1827,8 +1819,7 @@ int ast_bridge_call(struct ast_channel *chan,struct ast_channel *peer,struct ast
}
config->start_time = ast_tvnow();
config->feature_timer = featuredigittimeout;
- if (option_debug)
- ast_log(LOG_DEBUG, "Set time limit to %ld\n", config->feature_timer);
+ ast_debug(1, "Set time limit to %ld\n", config->feature_timer);
}
}
if (f)
@@ -2032,8 +2023,7 @@ static void *do_parking_thread(void *ignore)
/*! \todo XXX Maybe we could do something with packets, like dial "0" for operator or something XXX */
ast_frfree(f);
if (pu->moh_trys < 3 && !chan->generatordata) {
- if (option_debug)
- ast_log(LOG_DEBUG, "MOH on parked call stopped by outside source. Restarting.\n");
+ ast_debug(1, "MOH on parked call stopped by outside source. Restarting.\n");
ast_indicate_data(chan, AST_CONTROL_HOLD,
S_OR(parkmohclass, NULL),
!ast_strlen_zero(parkmohclass) ? strlen(parkmohclass) + 1 : 0);
@@ -2573,8 +2563,7 @@ int ast_pickup_call(struct ast_channel *chan)
ast_channel_unlock(cur);
}
if (cur) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Call pickup on chan '%s' by '%s'\n",cur->name, chan->name);
+ ast_debug(1, "Call pickup on chan '%s' by '%s'\n",cur->name, chan->name);
res = ast_answer(chan);
if (res)
ast_log(LOG_WARNING, "Unable to answer '%s'\n", chan->name);
@@ -2586,8 +2575,7 @@ int ast_pickup_call(struct ast_channel *chan)
ast_log(LOG_WARNING, "Unable to masquerade '%s' into '%s'\n", chan->name, cur->name); /* Done */
ast_channel_unlock(cur);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "No call pickup possible...\n");
+ ast_debug(1, "No call pickup possible...\n");
}
return res;
}
@@ -2880,8 +2868,7 @@ static int load_config(void)
if (!ast_strlen_zero(old_parking_con) && (con = ast_context_find(old_parking_con))) {
if(ast_context_remove_extension2(con, old_parking_ext, 1, registrar))
notify_metermaids(old_parking_ext, old_parking_con);
- if (option_debug)
- ast_log(LOG_DEBUG, "Removed old parking extension %s@%s\n", old_parking_ext, old_parking_con);
+ ast_debug(1, "Removed old parking extension %s@%s\n", old_parking_ext, old_parking_con);
}
if (!(con = ast_context_find(parking_con)) && !(con = ast_context_create(NULL, parking_con, registrar))) {
@@ -3023,20 +3010,17 @@ static int bridge_exec(struct ast_channel *chan, void *data)
/* the bridge has ended, set BRIDGERESULT to SUCCESS. If the other channel has not been hung up, return it to the PBX */
pbx_builtin_setvar_helper(chan, "BRIDGERESULT", "SUCCESS");
if (!ast_check_hangup(final_dest_chan)) {
- if (option_debug) {
- ast_log(LOG_DEBUG, "starting new PBX in %s,%s,%d for chan %s\n",
+ ast_debug(1, "starting new PBX in %s,%s,%d for chan %s\n",
final_dest_chan->context, final_dest_chan->exten,
final_dest_chan->priority, final_dest_chan->name);
- }
if (ast_pbx_start(final_dest_chan) != AST_PBX_SUCCESS) {
ast_log(LOG_WARNING, "FAILED continuing PBX on dest chan %s\n", final_dest_chan->name);
ast_hangup(final_dest_chan);
- } else if (option_debug)
- ast_log(LOG_DEBUG, "SUCCESS continuing PBX on chan %s\n", final_dest_chan->name);
+ } else
+ ast_debug(1, "SUCCESS continuing PBX on chan %s\n", final_dest_chan->name);
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "hangup chan %s since the other endpoint has hung up\n", final_dest_chan->name);
+ ast_debug(1, "hangup chan %s since the other endpoint has hung up\n", final_dest_chan->name);
ast_hangup(final_dest_chan);
}
diff --git a/res/res_jabber.c b/res/res_jabber.c
index d7af93d53..2562f43ef 100644
--- a/res/res_jabber.c
+++ b/res/res_jabber.c
@@ -683,32 +683,26 @@ static int aji_act_hook(void *data, int type, iks *node)
switch (pak->type) {
case IKS_PAK_NONE:
- if (option_debug)
- ast_log(LOG_DEBUG, "JABBER: I Don't know what to do with you NONE\n");
+ ast_debug(1, "JABBER: I Don't know what to do with you NONE\n");
break;
case IKS_PAK_MESSAGE:
aji_handle_message(client, pak);
- if (option_debug)
- ast_log(LOG_DEBUG, "JABBER: I Don't know what to do with you MESSAGE\n");
+ ast_debug(1, "JABBER: I Don't know what to do with you MESSAGE\n");
break;
case IKS_PAK_PRESENCE:
aji_handle_presence(client, pak);
- if (option_debug)
- ast_log(LOG_DEBUG, "JABBER: I Do know how to handle presence!!\n");
+ ast_debug(1, "JABBER: I Do know how to handle presence!!\n");
break;
case IKS_PAK_S10N:
aji_handle_subscribe(client, pak);
- if (option_debug)
- ast_log(LOG_DEBUG, "JABBER: I Dont know S10N subscribe!!\n");
+ ast_debug(1, "JABBER: I Dont know S10N subscribe!!\n");
break;
case IKS_PAK_IQ:
- if (option_debug)
- ast_log(LOG_DEBUG, "JABBER: I Dont have an IQ!!!\n");
+ ast_debug(1, "JABBER: I Dont have an IQ!!!\n");
aji_handle_iq(client, node);
break;
default:
- if (option_debug)
- ast_log(LOG_DEBUG, "JABBER: I Dont know %i\n", pak->type);
+ ast_debug(1, "JABBER: I Dont know %i\n", pak->type);
break;
}
@@ -1346,8 +1340,7 @@ static void aji_handle_presence(struct aji_client *client, ikspak *pak)
if(gtalk_yuck(pak->x)) /* gtalk should do discover */
found->cap->jingle = 1;
if(found->cap->jingle && option_debug > 4) {
- if (option_debug)
- ast_log(LOG_DEBUG,"Special case for google till they support discover.\n");
+ ast_debug(1,"Special case for google till they support discover.\n");
}
else {
iks *iq, *query;
@@ -1597,8 +1590,7 @@ static void *aji_recv_loop(void *data)
res = iks_recv(client->p, 1);
if (client->state == AJI_DISCONNECTING) {
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "Ending our Jabber client's thread due to a disconnect\n");
+ ast_debug(2, "Ending our Jabber client's thread due to a disconnect\n");
pthread_exit(NULL);
}
client->timeout--;
@@ -2512,8 +2504,7 @@ static int unload_module(void)
ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, {
ASTOBJ_RDLOCK(iterator);
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "JABBER: Releasing and disconneing client: %s\n", iterator->name);
+ ast_debug(3, "JABBER: Releasing and disconneing client: %s\n", iterator->name);
iterator->state = AJI_DISCONNECTING;
ast_aji_disconnect(iterator);
pthread_join(iterator->thread, NULL);
diff --git a/res/res_monitor.c b/res/res_monitor.c
index 5bff1b1ff..d23c6f727 100644
--- a/res/res_monitor.c
+++ b/res/res_monitor.c
@@ -222,9 +222,7 @@ int ast_monitor_start( struct ast_channel *chan, const char *format_spec,
/* so we know this call has been monitored in case we need to bill for it or something */
pbx_builtin_setvar_helper(chan, "__MONITORED","true");
} else {
- if (option_debug)
- ast_log(LOG_DEBUG,"Cannot start monitoring %s, already monitored\n",
- chan->name);
+ ast_debug(1,"Cannot start monitoring %s, already monitored\n", chan->name);
res = -1;
}
@@ -315,8 +313,7 @@ int ast_monitor_stop(struct ast_channel *chan, int need_lock)
snprintf(tmp2,sizeof(tmp2), "( %s& rm -f \"%s/%s-\"* ) &",tmp, dir ,name); /* remove legs when done mixing */
ast_copy_string(tmp, tmp2, sizeof(tmp));
}
- if (option_debug)
- ast_log(LOG_DEBUG,"monitor executing %s\n",tmp);
+ ast_debug(1,"monitor executing %s\n",tmp);
if (ast_safe_system(tmp) == -1)
ast_log(LOG_WARNING, "Execute of %s failed.\n",tmp);
}
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index 22e44302f..765786369 100644
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -250,8 +250,7 @@ static int ast_moh_files_next(struct ast_channel *chan)
return -1;
}
- if (option_debug)
- ast_log(LOG_DEBUG, "%s Opened file %d '%s'\n", chan->name, state->pos, state->class->filearray[state->pos]);
+ ast_debug(1, "%s Opened file %d '%s'\n", chan->name, state->pos, state->class->filearray[state->pos]);
if (state->samples)
ast_seekstream(chan->stream, state->samples, SEEK_SET);
@@ -583,8 +582,7 @@ static void *monmp3thread(void *data)
class->pid = 0;
}
} else {
- if (option_debug)
- ast_log(LOG_DEBUG, "Read %d bytes of audio while expecting %d\n", res2, len);
+ ast_debug(1, "Read %d bytes of audio while expecting %d\n", res2, len);
}
continue;
}
@@ -593,8 +591,7 @@ static void *monmp3thread(void *data)
AST_RWLIST_TRAVERSE(&class->members, moh, list) {
/* Write data */
if ((res = write(moh->pipe[1], sbuf, res2)) != res2) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Only wrote %d of %d bytes to pipe\n", res, res2);
+ ast_debug(1, "Only wrote %d of %d bytes to pipe\n", res, res2);
}
}
AST_RWLIST_UNLOCK(&mohclasses);
@@ -875,8 +872,7 @@ static int moh_register(struct mohclass *moh, int reload)
AST_RWLIST_WRLOCK(&mohclasses);
if (get_mohbyname(moh->name)) {
if (reload) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Music on Hold class '%s' left alone from initial load.\n", moh->name);
+ ast_debug(1, "Music on Hold class '%s' left alone from initial load.\n", moh->name);
} else {
ast_log(LOG_WARNING, "Music on Hold class '%s' already exists\n", moh->name);
}
@@ -1100,8 +1096,7 @@ static void ast_moh_destroy(void)
AST_RWLIST_WRLOCK(&mohclasses);
while ((moh = AST_RWLIST_REMOVE_HEAD(&mohclasses, list))) {
if (moh->pid > 1) {
- if (option_debug)
- ast_log(LOG_DEBUG, "killing %d!\n", moh->pid);
+ ast_debug(1, "killing %d!\n", moh->pid);
stime = time(NULL) + 2;
pid = moh->pid;
moh->pid = 0;
@@ -1115,8 +1110,7 @@ static void ast_moh_destroy(void)
kill(pid, SIGKILL);
while ((ast_wait_for_input(moh->srcfd, 100) > 0) && (bytes = read(moh->srcfd, buff, 8192)) && time(NULL) < stime)
tbytes = tbytes + bytes;
- if (option_debug)
- ast_log(LOG_DEBUG, "mpg123 pid %d and child died after %d bytes read\n", pid, tbytes);
+ ast_debug(1, "mpg123 pid %d and child died after %d bytes read\n", pid, tbytes);
close(moh->srcfd);
}
ast_moh_free_class(&moh);
diff --git a/res/res_smdi.c b/res/res_smdi.c
index f3d695408..fc9d6d1e4 100644
--- a/res/res_smdi.c
+++ b/res/res_smdi.c
@@ -111,8 +111,7 @@ int ast_smdi_mwi_set(struct ast_smdi_interface *iface, const char *mailbox)
fclose(file);
ASTOBJ_UNLOCK(iface);
- if (option_debug)
- ast_log(LOG_DEBUG, "Sent MWI set message for %s on %s\n", mailbox, iface->name);
+ ast_debug(1, "Sent MWI set message for %s on %s\n", mailbox, iface->name);
return 0;
}
@@ -143,8 +142,7 @@ int ast_smdi_mwi_unset(struct ast_smdi_interface *iface, const char *mailbox)
fclose(file);
ASTOBJ_UNLOCK(iface);
- if (option_debug)
- ast_log(LOG_DEBUG, "Sent MWI unset message for %s on %s\n", mailbox, iface->name);
+ ast_debug(1, "Sent MWI unset message for %s on %s\n", mailbox, iface->name);
return 0;
}
@@ -413,8 +411,7 @@ static void *smdi_read(void *iface_p)
/* add the message to the message queue */
md_msg->timestamp = ast_tvnow();
ast_smdi_md_message_push(iface, md_msg);
- if (option_debug)
- ast_log(LOG_DEBUG, "Recieved SMDI MD message on %s\n", iface->name);
+ ast_debug(1, "Recieved SMDI MD message on %s\n", iface->name);
ASTOBJ_UNREF(md_msg, ast_smdi_md_message_destroy);
@@ -457,8 +454,7 @@ static void *smdi_read(void *iface_p)
/* add the message to the message queue */
mwi_msg->timestamp = ast_tvnow();
ast_smdi_mwi_message_push(iface, mwi_msg);
- if (option_debug)
- ast_log(LOG_DEBUG, "Recieved SMDI MWI message on %s\n", iface->name);
+ ast_debug(1, "Recieved SMDI MWI message on %s\n", iface->name);
ASTOBJ_UNREF(mwi_msg, ast_smdi_mwi_message_destroy);
} else {