aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormogorman <mogorman@f38db490-d61c-443f-a65b-d21fe96a405b>2006-10-03 15:53:07 +0000
committermogorman <mogorman@f38db490-d61c-443f-a65b-d21fe96a405b>2006-10-03 15:53:07 +0000
commit4a1aaf52ae4189e660ad57ba69253f54603a2beb (patch)
tree27a80e26cf8f6ea1728ab5b2b8cc7573fd9f7cdc
parent1bd1494da59a95dce73628aafc4ba892036b82b2 (diff)
bug #8076 check option_debug before printing to debug channel.
patch provided in bugnote, with minor changes. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@44253 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--apps/app_alarmreceiver.c32
-rw-r--r--apps/app_db.c9
-rw-r--r--apps/app_dial.c3
-rw-r--r--apps/app_directed_pickup.c7
-rw-r--r--apps/app_disa.c34
-rw-r--r--apps/app_externalivr.c6
-rw-r--r--apps/app_festival.c74
-rw-r--r--apps/app_ices.c6
-rw-r--r--apps/app_macro.c14
-rw-r--r--apps/app_meetme.c29
-rw-r--r--apps/app_mp3.c12
-rw-r--r--apps/app_nbscat.c12
-rw-r--r--apps/app_osplookup.c304
-rw-r--r--apps/app_queue.c30
-rw-r--r--apps/app_record.c3
-rw-r--r--apps/app_talkdetect.c16
-rw-r--r--apps/app_test.c6
-rw-r--r--apps/app_voicemail.c138
-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.c10
-rw-r--r--cdr/cdr_odbc.c18
-rw-r--r--cdr/cdr_tds.c3
-rw-r--r--channels/chan_agent.c47
-rw-r--r--channels/chan_alsa.c30
-rw-r--r--channels/chan_features.c3
-rw-r--r--channels/chan_gtalk.c9
-rw-r--r--channels/chan_iax2.c103
-rw-r--r--channels/chan_jingle.c6
-rw-r--r--channels/chan_mgcp.c49
-rw-r--r--channels/chan_misdn.c28
-rw-r--r--channels/chan_nbs.c3
-rw-r--r--channels/chan_phone.c39
-rw-r--r--channels/chan_sip.c108
-rw-r--r--channels/chan_skinny.c15
-rw-r--r--channels/chan_zap.c518
-rw-r--r--channels/iax2-provision.c2
-rw-r--r--funcs/func_db.c13
-rw-r--r--funcs/func_rand.c9
-rw-r--r--funcs/func_strings.c12
-rw-r--r--main/app.c42
-rw-r--r--main/channel.c118
-rw-r--r--main/db.c9
-rw-r--r--main/dns.c4
-rw-r--r--main/dsp.c13
-rw-r--r--main/enum.c3
-rw-r--r--main/file.c9
-rw-r--r--main/http.c3
-rw-r--r--main/loader.c3
-rw-r--r--main/logger.c9
-rw-r--r--main/manager.c18
-rw-r--r--main/pbx.c33
-rw-r--r--main/rtp.c36
-rw-r--r--main/say.c92
-rw-r--r--main/sched.c32
-rw-r--r--main/udptl.c37
-rw-r--r--pbx/pbx_dundi.c141
-rw-r--r--res/res_adsi.c60
-rw-r--r--res/res_agi.c7
-rw-r--r--res/res_config_pgsql.c138
-rw-r--r--res/res_crypto.c6
-rw-r--r--res/res_jabber.c6
-rw-r--r--res/res_monitor.c9
-rw-r--r--res/res_musiconhold.c15
-rw-r--r--res/res_smdi.c12
67 files changed, 1719 insertions, 923 deletions
diff --git a/apps/app_alarmreceiver.c b/apps/app_alarmreceiver.c
index 8afce25d5..6ae985353 100644
--- a/apps/app_alarmreceiver.c
+++ b/apps/app_alarmreceiver.c
@@ -251,14 +251,16 @@ 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);
- ast_log(LOG_DEBUG,"AlarmReceiver: DTMF timeout on chan %s\n",chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG,"AlarmReceiver: DTMF timeout on chan %s\n",chan->name);
res = 1;
break;
}
if ((r = ast_waitfor(chan, -1) < 0)) {
- ast_log(LOG_DEBUG, "Waitfor returned %d\n", r);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Waitfor returned %d\n", r);
continue;
}
@@ -350,9 +352,11 @@ static int write_metadata( FILE *logfile, char *signalling_type, struct ast_chan
res = fprintf(logfile, "[events]\n\n");
if(res < 0){
+ if (option_verbose >= 3 )
ast_verbose(VERBOSE_PREFIX_4 "AlarmReceiver: can't write metadata\n");
- ast_log(LOG_DEBUG,"AlarmReceiver: can't write metadata\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"AlarmReceiver: can't write metadata\n");
}
else
res = 0;
@@ -400,9 +404,11 @@ static int log_events(struct ast_channel *chan, char *signalling_type, event_no
fd = mkstemp(workstring);
- if(fd == -1){
- ast_verbose(VERBOSE_PREFIX_4 "AlarmReceiver: can't make temporary file\n");
- ast_log(LOG_DEBUG,"AlarmReceiver: can't make temporary file\n");
+ 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");
res = -1;
}
@@ -521,9 +527,10 @@ static int receive_ademco_contact_id( struct ast_channel *chan, void *data, int
got_some_digits = 1;
- if(option_verbose >= 2)
+ if (option_verbose >= 2)
ast_verbose(VERBOSE_PREFIX_2 "AlarmReceiver: Received Event %s\n", event);
- ast_log(LOG_DEBUG, "AlarmReceiver: Received event: %s\n", event);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "AlarmReceiver: Received event: %s\n", event);
/* Calculate checksum */
@@ -553,7 +560,8 @@ 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");
- ast_log(LOG_DEBUG, "AlarmReceiver: Nonzero checksum\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "AlarmReceiver: Nonzero checksum\n");
continue;
}
@@ -564,7 +572,8 @@ 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");
- ast_log(LOG_DEBUG, "AlarmReceiver: Wrong message type\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "AlarmReceiver: Wrong message type\n");
continue;
}
}
@@ -706,7 +715,8 @@ static int alarmreceiver_exec(struct ast_channel *chan, void *data)
*/
if((!res) && (!ast_strlen_zero(event_app)) && (event_head)){
- ast_log(LOG_DEBUG,"Alarmreceiver: executing: %s\n", event_app);
+ if (option_debug)
+ ast_log(LOG_DEBUG,"Alarmreceiver: executing: %s\n", event_app);
ast_safe_system(event_app);
}
diff --git a/apps/app_db.c b/apps/app_db.c
index 73d092ab6..52309b9cf 100644
--- a/apps/app_db.c
+++ b/apps/app_db.c
@@ -78,7 +78,8 @@ static int deltree_exec(struct ast_channel *chan, void *data)
family = strsep(&argv, "/");
keytree = strsep(&argv, "\0");
if (!family || !keytree) {
- ast_log(LOG_DEBUG, "Ignoring; Syntax error in argument\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Ignoring; Syntax error in argument\n");
ast_module_user_remove(u);
return 0;
}
@@ -125,7 +126,8 @@ static int del_exec(struct ast_channel *chan, void *data)
family = strsep(&argv, "/");
key = strsep(&argv, "\0");
if (!family || !key) {
- ast_log(LOG_DEBUG, "Ignoring; Syntax error in argument\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Ignoring; Syntax error in argument\n");
ast_module_user_remove(u);
return 0;
}
@@ -136,7 +138,8 @@ static int del_exec(struct ast_channel *chan, void *data)
ast_verbose(VERBOSE_PREFIX_3 "DBdel: Error deleting key from database.\n");
}
} else {
- ast_log(LOG_DEBUG, "Ignoring, no parameters\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Ignoring, no parameters\n");
}
ast_module_user_remove(u);
diff --git a/apps/app_dial.c b/apps/app_dial.c
index da68e83fe..27eb2b0aa 100644
--- a/apps/app_dial.c
+++ b/apps/app_dial.c
@@ -1466,7 +1466,8 @@ 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]);
- ast_log(LOG_DEBUG, "Macro exited with status %d\n", res);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Macro exited with status %d\n", res);
res = 0;
} else {
ast_log(LOG_ERROR, "Could not find application Macro\n");
diff --git a/apps/app_directed_pickup.c b/apps/app_directed_pickup.c
index e45c87603..8076bfafa 100644
--- a/apps/app_directed_pickup.c
+++ b/apps/app_directed_pickup.c
@@ -41,6 +41,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/module.h"
#include "asterisk/lock.h"
#include "asterisk/app.h"
+#include "asterisk/options.h"
#define PICKUPMARK "PICKUPMARK"
@@ -109,14 +110,16 @@ static int pickup_exec(struct ast_channel *chan, void *data)
ast_mutex_unlock(&origin->lock);
} else {
- ast_log(LOG_DEBUG, "No originating channel found.\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "No originating channel found.\n");
}
if (res)
continue;
if (target && (!target->pbx) && ((target->_state == AST_STATE_RINGING) || (target->_state == AST_STATE_RING) ) ) {
- ast_log(LOG_DEBUG, "Call pickup on chan '%s' by '%s'\n", target->name,
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Call pickup on chan '%s' by '%s'\n", target->name,
chan->name);
res = ast_answer(chan);
if (res) {
diff --git a/apps/app_disa.c b/apps/app_disa.c
index 1ec0531bf..586640e67 100644
--- a/apps/app_disa.c
+++ b/apps/app_disa.c
@@ -48,6 +48,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/ulaw.h"
#include "asterisk/callerid.h"
#include "asterisk/stringfields.h"
+#include "asterisk/options.h"
static char *app = "DISA";
@@ -154,8 +155,10 @@ static int disa_exec(struct ast_channel *chan, void *data)
return -1;
}
- ast_log(LOG_DEBUG, "Digittimeout: %d\n", digittimeout);
- ast_log(LOG_DEBUG, "Responsetimeout: %d\n", firstdigittimeout);
+ if (option_debug) {
+ ast_log(LOG_DEBUG, "Digittimeout: %d\n", digittimeout);
+ ast_log(LOG_DEBUG, "Responsetimeout: %d\n", firstdigittimeout);
+ }
tmp = ast_strdupa(data);
@@ -166,8 +169,8 @@ static int disa_exec(struct ast_channel *chan, void *data)
if (ast_strlen_zero(args.mailbox))
args.mailbox = "";
- ast_log(LOG_DEBUG, "Mailbox: %s\n",args.mailbox);
-
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Mailbox: %s\n",args.mailbox);
special_noanswer = 0;
if ((!args.noanswer) || strcmp(args.noanswer,"NOANSWER"))
@@ -183,11 +186,13 @@ static int disa_exec(struct ast_channel *chan, void *data)
acctcode[0] = 0;
/* can we access DISA without password? */
- ast_log(LOG_DEBUG, "Context: %s\n",args.context);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Context: %s\n",args.context);
if (!strcasecmp(args.passcode, "no-password")) {
k |= 1; /* We have the password */
- ast_log(LOG_DEBUG, "DISA no-password login success\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "DISA no-password login success\n");
}
lastdigittime = ast_tvnow();
@@ -197,12 +202,14 @@ 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)) {
- ast_log(LOG_DEBUG,"DISA %s entry timeout on chan %s\n",
- ((k&1) ? "extension" : "password"),chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG,"DISA %s entry timeout on chan %s\n",
+ ((k&1) ? "extension" : "password"),chan->name);
break;
}
if ((res = ast_waitfor(chan, -1) < 0)) {
- ast_log(LOG_DEBUG, "Waitfor returned %d\n", res);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Waitfor returned %d\n", res);
continue;
}
@@ -263,7 +270,8 @@ static int disa_exec(struct ast_channel *chan, void *data)
AST_STANDARD_APP_ARGS(args, pwline);
- ast_log(LOG_DEBUG, "Mailbox: %s\n",args.mailbox);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Mailbox: %s\n",args.mailbox);
/* password must be in valid format (numeric) */
if (sscanf(args.passcode,"%d", &j) < 1)
@@ -286,7 +294,8 @@ static int disa_exec(struct ast_channel *chan, void *data)
}
/* password good, set to dial state */
- ast_log(LOG_DEBUG,"DISA on chan %s password is good\n",chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG,"DISA on chan %s password is good\n",chan->name);
play_dialtone(chan, args.mailbox);
k|=1; /* In number mode */
@@ -294,7 +303,8 @@ static int disa_exec(struct ast_channel *chan, void *data)
exten[sizeof(acctcode)] = 0;
ast_copy_string(acctcode, exten, sizeof(acctcode));
exten[0] = 0;
- ast_log(LOG_DEBUG,"Successful DISA log-in on chan %s\n", chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG,"Successful DISA log-in on chan %s\n", chan->name);
continue;
}
}
diff --git a/apps/app_externalivr.c b/apps/app_externalivr.c
index e81f4f34f..3ce156348 100644
--- a/apps/app_externalivr.c
+++ b/apps/app_externalivr.c
@@ -103,7 +103,8 @@ static void send_child_event(FILE *handle, const char event, const char *data,
}
fprintf(handle, "%s\n", tmp);
- ast_chan_log(LOG_DEBUG, chan, "sent '%s'\n", tmp);
+ if (option_debug)
+ ast_chan_log(LOG_DEBUG, chan, "sent '%s'\n", tmp);
}
static void *gen_alloc(struct ast_channel *chan, void *params)
@@ -439,7 +440,8 @@ static int app_exec(struct ast_channel *chan, void *data)
command = ast_strip(input);
- ast_chan_log(LOG_DEBUG, chan, "got command '%s'\n", input);
+ if (option_debug)
+ ast_chan_log(LOG_DEBUG, chan, "got command '%s'\n", input);
if (strlen(input) < 4)
continue;
diff --git a/apps/app_festival.c b/apps/app_festival.c
index 6e7a4ffd4..dafd89423 100644
--- a/apps/app_festival.c
+++ b/apps/app_festival.c
@@ -210,7 +210,8 @@ static int send_waveform_to_channel(struct ast_channel *chan, char *waveform, in
break;
}
if (f->frametype == AST_FRAME_DTMF) {
- ast_log(LOG_DEBUG, "User pressed a key\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "User pressed a key\n");
if (intkeys && strchr(intkeys, f->subclass)) {
res = f->subclass;
ast_frfree(f);
@@ -241,13 +242,15 @@ static int send_waveform_to_channel(struct ast_channel *chan, char *waveform, in
break;
}
if (res < needed) { /* last frame */
- ast_log(LOG_DEBUG, "Last frame\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Last frame\n");
res=0;
ast_frfree(f);
break;
}
} else {
- ast_log(LOG_DEBUG, "No more waveform\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "No more waveform\n");
res = 0;
}
}
@@ -367,29 +370,34 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
intstr = AST_DIGIT_ANY;
}
- ast_log(LOG_DEBUG, "Text passed to festival server : %s\n",(char *)data);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Text passed to festival server : %s\n",(char *)data);
/* Connect to local festival server */
- fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
- if (fd < 0) {
+ if (fd < 0) {
ast_log(LOG_WARNING,"festival_client: can't get socket\n");
ast_config_destroy(cfg);
ast_module_user_remove(u);
- return -1;
+ return -1;
}
- memset(&serv_addr, 0, sizeof(serv_addr));
- if ((serv_addr.sin_addr.s_addr = inet_addr(host)) == -1) {
- /* its a name rather than an ipnum */
- serverhost = ast_gethostbyname(host, &ahp);
- if (serverhost == (struct hostent *)0) {
- ast_log(LOG_WARNING,"festival_client: gethostbyname failed\n");
+
+ memset(&serv_addr, 0, sizeof(serv_addr));
+
+ if ((serv_addr.sin_addr.s_addr = inet_addr(host)) == -1) {
+ /* its a name rather than an ipnum */
+ serverhost = ast_gethostbyname(host, &ahp);
+
+ if (serverhost == (struct hostent *)0) {
+ ast_log(LOG_WARNING,"festival_client: gethostbyname failed\n");
ast_config_destroy(cfg);
ast_module_user_remove(u);
- return -1;
- }
- memmove(&serv_addr.sin_addr,serverhost->h_addr, serverhost->h_length);
- }
+ return -1;
+ }
+ memmove(&serv_addr.sin_addr,serverhost->h_addr, serverhost->h_length);
+ }
+
serv_addr.sin_family = AF_INET;
serv_addr.sin_port = htons(port);
@@ -422,17 +430,21 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
if (fdesc!=-1) {
writecache=1;
strln=strlen((char *)data);
- ast_log(LOG_DEBUG,"line length : %d\n",strln);
+ if (option_debug)
+ ast_log(LOG_DEBUG,"line length : %d\n",strln);
write(fdesc,&strln,sizeof(int));
write(fdesc,data,strln);
seekpos=lseek(fdesc,0,SEEK_CUR);
- ast_log(LOG_DEBUG,"Seek position : %d\n",seekpos);
+ if (option_debug)
+ ast_log(LOG_DEBUG,"Seek position : %d\n",seekpos);
}
} else {
read(fdesc,&strln,sizeof(int));
- ast_log(LOG_DEBUG,"Cache file exists, strln=%d, strlen=%d\n",strln,(int)strlen((char *)data));
+ if (option_debug)
+ ast_log(LOG_DEBUG,"Cache file exists, strln=%d, strlen=%d\n",strln,(int)strlen((char *)data));
if (strlen((char *)data)==strln) {
- ast_log(LOG_DEBUG,"Size OK\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"Size OK\n");
read(fdesc,&bigstring,strln);
bigstring[strln] = 0;
if (strcmp(bigstring,data)==0) {
@@ -449,10 +461,12 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
if (readcache==1) {
close(fd);
fd=fdesc;
- ast_log(LOG_DEBUG,"Reading from cache...\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"Reading from cache...\n");
} else {
- ast_log(LOG_DEBUG,"Passing text to festival...\n");
- fs=fdopen(dup(fd),"wb");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"Passing text to festival...\n");
+ fs=fdopen(dup(fd),"wb");
fprintf(fs,festivalcommand,(char *)data);
fflush(fs);
fclose(fs);
@@ -460,7 +474,8 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
/* Write to cache and then pass it down */
if (writecache==1) {
- ast_log(LOG_DEBUG,"Writing result to cache...\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"Writing result to cache...\n");
while ((strln=read(fd,buffer,16384))!=0) {
write(fdesc,buffer,strln);
}
@@ -470,7 +485,8 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
lseek(fd,seekpos,SEEK_SET);
}
- ast_log(LOG_DEBUG,"Passing data to channel...\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"Passing data to channel...\n");
/* Read back info from server */
/* This assumes only one waveform will come back, also LP is unlikely */
@@ -495,14 +511,16 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
}
ack[3] = '\0';
if (strcmp(ack,"WV\n") == 0) { /* receive a waveform */
- ast_log(LOG_DEBUG,"Festival WV command\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"Festival WV command\n");
waveform = socket_receive_file_to_buff(fd,&filesize);
res = send_waveform_to_channel(chan,waveform,filesize, intstr);
free(waveform);
break;
}
else if (strcmp(ack,"LP\n") == 0) { /* receive an s-expr */
- ast_log(LOG_DEBUG,"Festival LP command\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"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_ices.c b/apps/app_ices.c
index 9d93dabdf..4a223bd5d 100644
--- a/apps/app_ices.c
+++ b/apps/app_ices.c
@@ -156,13 +156,15 @@ static int ices_exec(struct ast_channel *chan, void *data)
/* Wait for audio, and stream */
ms = ast_waitfor(chan, -1);
if (ms < 0) {
- ast_log(LOG_DEBUG, "Hangup detected\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Hangup detected\n");
res = -1;
break;
}
f = ast_read(chan);
if (!f) {
- ast_log(LOG_DEBUG, "Null frame == hangup() detected\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Null frame == hangup() detected\n");
res = -1;
break;
}
diff --git a/apps/app_macro.c b/apps/app_macro.c
index 21c2b7c62..861248c1e 100644
--- a/apps/app_macro.c
+++ b/apps/app_macro.c
@@ -164,7 +164,8 @@ 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) {
- ast_log(LOG_DEBUG, "Locking macrolock for '%s'\n", fullmacro);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
@@ -228,7 +229,8 @@ 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 */
- ast_log(LOG_DEBUG, "Oooh, got something to jump out with ('%c')!\n", res);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Oooh, got something to jump out with ('%c')!\n", res);
break;
}
switch(res) {
@@ -258,8 +260,9 @@ 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 && strcasecmp(oldexten,"h") && strcasecmp(chan->macroexten,"h")) {
- 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);
+ 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);
goto out;
}
chan->priority++;
@@ -330,7 +333,8 @@ static int _macro_exec(struct ast_channel *chan, void *data, int exclusive)
/* Unlock the macro */
if (exclusive) {
- ast_log(LOG_DEBUG, "Unlocking macrolock for '%s'\n", fullmacro);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 aa52c3b40..80514f8d1 100644
--- a/apps/app_meetme.c
+++ b/apps/app_meetme.c
@@ -825,7 +825,10 @@ static int meetme_cmd(int fd, int argc, char **argv)
return RESULT_SUCCESS;
} else
return RESULT_SHOWUSAGE;
- ast_log(LOG_DEBUG, "Cmdline: %s\n", cmdline);
+
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Cmdline: %s\n", cmdline);
+
admin_exec(NULL, cmdline);
return 0;
@@ -1258,7 +1261,8 @@ 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) {
- ast_log(LOG_DEBUG, "Zap channel is in a conference already, retrying with pseudo\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Zap channel is in a conference already, retrying with pseudo\n");
retryzap = 1;
goto zapretry;
}
@@ -1292,7 +1296,8 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
ast_mutex_unlock(&conf->playlock);
goto outrun;
}
- ast_log(LOG_DEBUG, "Placed channel %s in ZAP conf %d\n", chan->name, conf->zapconf);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Placed channel %s in ZAP conf %d\n", chan->name, conf->zapconf);
if (!sent_event) {
manager_event(EVENT_FLAG_CALL, "MeetmeJoin",
@@ -1524,7 +1529,8 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
close(fd);
using_pseudo = 0;
}
- ast_log(LOG_DEBUG, "Ooh, something swapped out under us, starting over\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Ooh, something swapped out under us, starting over\n");
retryzap = strcasecmp(c->tech->type, "Zap");
user->zapchannel = !retryzap;
goto zapretry;
@@ -1602,7 +1608,8 @@ 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)) {
- ast_log(LOG_DEBUG, "Got DTMF %c, goto context %s\n", tmp[0], exitcontext);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Got DTMF %c, goto context %s\n", tmp[0], exitcontext);
ret = 0;
ast_frfree(f);
break;
@@ -2038,7 +2045,8 @@ static struct ast_conference *find_conf(struct ast_channel *chan, char *confno,
if (!cnf) {
if (dynamic) {
/* No need to parse meetme.conf */
- ast_log(LOG_DEBUG, "Building dynamic conference '%s'\n", confno);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Building dynamic conference '%s'\n", confno);
if (dynamic_pin) {
if (dynamic_pin[0] == 'q') {
/* Query the user to enter a PIN */
@@ -2074,7 +2082,8 @@ 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);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "%s isn't a valid conference\n", confno);
}
ast_config_destroy(cfg);
}
@@ -2920,7 +2929,8 @@ static int slastate(const char *data)
struct ast_conference *conf;
struct ast_sla *sla, *sla2;
- ast_log(LOG_DEBUG, "asked for sla state for '%s'\n", data);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "asked for sla state for '%s'\n", data);
/* Find conference */
AST_LIST_LOCK(&confs);
@@ -2934,7 +2944,8 @@ static int slastate(const char *data)
sla = sla2 = ASTOBJ_CONTAINER_FIND(&slas, data);
ASTOBJ_UNREF(sla2, sla_destroy);
- ast_log(LOG_DEBUG, "for '%s' conf = %p, sla = %p\n", data, conf, sla);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "for '%s' conf = %p, sla = %p\n", data, conf, sla);
if (!conf && !sla)
return AST_DEVICE_INVALID;
diff --git a/apps/app_mp3.c b/apps/app_mp3.c
index 667de67ad..704666d8f 100644
--- a/apps/app_mp3.c
+++ b/apps/app_mp3.c
@@ -183,7 +183,8 @@ static int mp3_exec(struct ast_channel *chan, void *data)
break;
}
} else {
- ast_log(LOG_DEBUG, "No more mp3\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "No more mp3\n");
res = 0;
break;
}
@@ -191,19 +192,22 @@ static int mp3_exec(struct ast_channel *chan, void *data)
} else {
ms = ast_waitfor(chan, ms);
if (ms < 0) {
- ast_log(LOG_DEBUG, "Hangup detected\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Hangup detected\n");
res = -1;
break;
}
if (ms) {
f = ast_read(chan);
if (!f) {
- ast_log(LOG_DEBUG, "Null frame == hangup() detected\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Null frame == hangup() detected\n");
res = -1;
break;
}
if (f->frametype == AST_FRAME_DTMF) {
- ast_log(LOG_DEBUG, "User pressed a key\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "User pressed a key\n");
ast_frfree(f);
res = 0;
break;
diff --git a/apps/app_nbscat.c b/apps/app_nbscat.c
index 346584346..60623cc93 100644
--- a/apps/app_nbscat.c
+++ b/apps/app_nbscat.c
@@ -165,7 +165,8 @@ static int NBScat_exec(struct ast_channel *chan, void *data)
break;
}
} else {
- ast_log(LOG_DEBUG, "No more mp3\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "No more mp3\n");
res = 0;
break;
}
@@ -173,19 +174,22 @@ static int NBScat_exec(struct ast_channel *chan, void *data)
} else {
ms = ast_waitfor(chan, ms);
if (ms < 0) {
- ast_log(LOG_DEBUG, "Hangup detected\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Hangup detected\n");
res = -1;
break;
}
if (ms) {
f = ast_read(chan);
if (!f) {
- ast_log(LOG_DEBUG, "Null frame == hangup() detected\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Null frame == hangup() detected\n");
res = -1;
break;
}
if (f->frametype == AST_FRAME_DTMF) {
- ast_log(LOG_DEBUG, "User pressed a key\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "User pressed a key\n");
ast_frfree(f);
res = 0;
break;
diff --git a/apps/app_osplookup.c b/apps/app_osplookup.c
index ec7eecf39..23ad0da84 100644
--- a/apps/app_osplookup.c
+++ b/apps/app_osplookup.c
@@ -179,14 +179,16 @@ static int osp_create_provider(struct ast_config* cfg, const char* provider)
} else {
snprintf(p->privatekey, sizeof(p->privatekey), "%s/%s", ast_config_AST_KEY_DIR, v->value);
}
- ast_log(LOG_DEBUG, "OSP: privatekey '%s'\n", p->privatekey);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
}
- ast_log(LOG_DEBUG, "OSP: localcert '%s'\n", p->localcert);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: localcert '%s'\n", p->localcert);
} else if (!strcasecmp(v->name, "cacert")) {
if (p->cacount < OSP_MAX_CERTS) {
if (v->value[0] == '/') {
@@ -194,7 +196,8 @@ static int osp_create_provider(struct ast_config* cfg, const char* provider)
} else {
snprintf(p->cacerts[p->cacount], sizeof(p->cacerts[0]), "%s/%s", ast_config_AST_KEY_DIR, v->value);
}
- ast_log(LOG_DEBUG, "OSP: cacert[%d]: '%s'\n", p->cacount, p->cacerts[p->cacount]);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
@@ -202,7 +205,8 @@ static int osp_create_provider(struct ast_config* cfg, const char* 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]));
- ast_log(LOG_DEBUG, "OSP: servicepoint[%d]: '%s'\n", p->spcount, p->srvpoints[p->spcount]);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
@@ -210,7 +214,8 @@ static int osp_create_provider(struct ast_config* cfg, const char* 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;
- ast_log(LOG_DEBUG, "OSP: maxconnections '%d'\n", t);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
@@ -218,7 +223,8 @@ static int osp_create_provider(struct ast_config* cfg, const char* 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;
- ast_log(LOG_DEBUG, "OSP: retrydelay '%d'\n", t);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
@@ -226,7 +232,8 @@ static int osp_create_provider(struct ast_config* cfg, const char* 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;
- ast_log(LOG_DEBUG, "OSP: retrylimit '%d'\n", t);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
@@ -234,18 +241,21 @@ static int osp_create_provider(struct ast_config* cfg, const char* 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;
- ast_log(LOG_DEBUG, "OSP: timeout '%d'\n", t);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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));
- ast_log(LOG_DEBUG, "OSP: source '%s'\n", p->source);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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;
- ast_log(LOG_DEBUG, "OSP: authpolicy '%d'\n", t);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
@@ -273,7 +283,8 @@ static int osp_create_provider(struct ast_config* cfg, const char* provider)
if (p->cacount < 1) {
snprintf(p->cacerts[p->cacount], sizeof(p->cacerts[0]), "%s/%s-cacert.pem", ast_config_AST_KEY_DIR, provider);
- ast_log(LOG_DEBUG, "OSP: cacert[%d]: '%s'\n", p->cacount, p->cacerts[p->cacount]);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: cacert[%d]: '%s'\n", p->cacount, p->cacerts[p->cacount]);
p->cacount++;
}
for (i = 0; i < p->cacount; i++) {
@@ -309,7 +320,8 @@ static int osp_create_provider(struct ast_config* cfg, const char* provider)
free(p);
res = -1;
} else {
- ast_log(LOG_DEBUG, "OSP: provider '%s'\n", provider);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: provider '%s'\n", provider);
ast_mutex_lock(&osplock);
p->next = ospproviders;
ospproviders = p;
@@ -348,7 +360,8 @@ static int osp_get_policy(const char* provider, int* policy)
while(p) {
if (!strcasecmp(p->name, provider)) {
*policy = p->authpolicy;
- ast_log(LOG_DEBUG, "OSP: authpolicy '%d'\n", *policy);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: authpolicy '%d'\n", *policy);
res = 1;
break;
}
@@ -379,13 +392,16 @@ static int osp_create_transaction(const char* provider, int* transaction, unsign
if (!strcasecmp(p->name, provider)) {
error = OSPPTransactionNew(p->handle, transaction);
if (error == OSPC_ERR_NO_ERROR) {
- ast_log(LOG_DEBUG, "OSP: transaction '%d'\n", *transaction);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: transaction '%d'\n", *transaction);
ast_copy_string(source, p->source, sourcesize);
- ast_log(LOG_DEBUG, "OSP: source '%s'\n", source);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: source '%s'\n", source);
res = 1;
} else {
*transaction = OSP_INVALID_HANDLE;
- ast_log(LOG_DEBUG, "OSP: Unable to create transaction handle, error '%d'\n", error);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: Unable to create transaction handle, error '%d'\n", error);
res = -1;
}
break;
@@ -430,13 +446,16 @@ static int osp_validate_token(int transaction, const char* source, const char* d
&dummy, NULL,
osp_tokenformat);
if (error != OSPC_ERR_NO_ERROR) {
- ast_log(LOG_DEBUG, "OSP: Unable to validate inbound token\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: Unable to validate inbound token\n");
res = -1;
} else if (authorised) {
- ast_log(LOG_DEBUG, "OSP: Authorised\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: Authorised\n");
res = 1;
} else {
- ast_log(LOG_DEBUG, "OSP: Unauthorised\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: Unauthorised\n");
res = 0;
}
@@ -479,13 +498,15 @@ static int osp_check_destination(const char* called, const char* calling, char*
int error;
if (strlen(destination) <= 2) {
- ast_log(LOG_DEBUG, "OSP: Wrong destination format '%s'\n", destination);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: Wrong destination format '%s'\n", destination);
*reason = OSPC_FAIL_NORMAL_UNSPECIFIED;
return -1;
}
if ((error = OSPPTransactionIsDestOSPEnabled(result->outhandle, &enabled)) != OSPC_ERR_NO_ERROR) {
- ast_log(LOG_DEBUG, "OSP: Unable to get destination OSP version, error '%d'\n", error);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: Unable to get destination OSP version, error '%d'\n", error);
*reason = OSPC_FAIL_NORMAL_UNSPECIFIED;
return -1;
}
@@ -497,7 +518,8 @@ static int osp_check_destination(const char* called, const char* calling, char*
}
if ((error = OSPPTransactionGetDestProtocol(result->outhandle, &protocol)) != OSPC_ERR_NO_ERROR) {
- ast_log(LOG_DEBUG, "OSP: Unable to get destination protocol, error '%d'\n", error);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: Unable to get destination protocol, error '%d'\n", error);
*reason = OSPC_FAIL_NORMAL_UNSPECIFIED;
result->token[0] = '\0';
return -1;
@@ -508,25 +530,29 @@ static int osp_check_destination(const char* called, const char* calling, char*
destination[strlen(destination) - 1] = '\0';
switch(protocol) {
case OSPE_DEST_PROT_H323_SETUP:
- ast_log(LOG_DEBUG, "OSP: protocol '%d'\n", protocol);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: protocol '%d'\n", protocol);
ast_copy_string(result->tech, "H323", sizeof(result->tech));
snprintf(result->dest, sizeof(result->dest), "%s@%s", called, destination + 1);
ast_copy_string(result->calling, calling, sizeof(result->calling));
break;
case OSPE_DEST_PROT_SIP:
- ast_log(LOG_DEBUG, "OSP: protocol '%d'\n", protocol);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: protocol '%d'\n", protocol);
ast_copy_string(result->tech, "SIP", sizeof(result->tech));
snprintf(result->dest, sizeof(result->dest), "%s@%s", called, destination + 1);
ast_copy_string(result->calling, calling, sizeof(result->calling));
break;
case OSPE_DEST_PROT_IAX:
- ast_log(LOG_DEBUG, "OSP: protocol '%d'\n", protocol);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: protocol '%d'\n", protocol);
ast_copy_string(result->tech, "IAX", sizeof(result->tech));
snprintf(result->dest, sizeof(result->dest), "%s@%s", called, destination + 1);
ast_copy_string(result->calling, calling, sizeof(result->calling));
break;
default:
- ast_log(LOG_DEBUG, "OSP: Unknown protocol '%d'\n", protocol);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: Unknown protocol '%d'\n", protocol);
*reason = OSPC_FAIL_PROTOCOL_ERROR;
result->token[0] = '\0';
res = 0;
@@ -566,7 +592,8 @@ static int osp_auth(const char* provider, int* transaction, const char* source,
*timelimit = OSP_DEF_TIMELIMIT;
res = osp_get_policy(provider, &policy);
if (!res) {
- ast_log(LOG_DEBUG, "OSP: Unabe to find OSP authentication policy\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: Unabe to find OSP authentication policy\n");
return res;
}
@@ -578,7 +605,8 @@ static int osp_auth(const char* provider, int* transaction, const char* source,
if (ast_strlen_zero(token)) {
res = 0;
} else if ((res = osp_create_transaction(provider, transaction, sizeof(dest), dest)) <= 0) {
- ast_log(LOG_DEBUG, "OSP: Unable to generate transaction handle\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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) {
@@ -590,7 +618,8 @@ static int osp_auth(const char* provider, int* transaction, const char* source,
if (ast_strlen_zero(token)) {
res = 1;
} else if ((res = osp_create_transaction(provider, transaction, sizeof(dest), dest)) <= 0) {
- ast_log(LOG_DEBUG, "OSP: Unable to generate transaction handle\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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) {
@@ -635,7 +664,8 @@ static int osp_lookup(const char* provider, const char* srcdev, const char* call
result->outtimelimit = OSP_DEF_TIMELIMIT;
if ((res = osp_create_transaction(provider, &result->outhandle, sizeof(source), source)) <= 0) {
- ast_log(LOG_DEBUG, "OSP: Unable to generate transaction handle\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
@@ -647,7 +677,8 @@ static int osp_lookup(const char* provider, const char* srcdev, const char* call
error = OSPPTransactionRequestAuthorisation(result->outhandle, source, srcdev, calling ? calling : "",
OSPC_E164, called, OSPC_E164, NULL, 0, NULL, NULL, &result->numresults, &dummy, NULL);
if (error != OSPC_ERR_NO_ERROR) {
- ast_log(LOG_DEBUG, "OSP: Unable to request authorization\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: Unable to request authorization\n");
result->numresults = 0;
if (result->inhandle != OSP_INVALID_HANDLE) {
OSPPTransactionRecordFailure(result->inhandle, OSPC_FAIL_NORMAL_UNSPECIFIED);
@@ -656,7 +687,8 @@ static int osp_lookup(const char* provider, const char* srcdev, const char* call
}
if (!result->numresults) {
- ast_log(LOG_DEBUG, "OSP: No more destination\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: No more destination\n");
if (result->inhandle != OSP_INVALID_HANDLE) {
OSPPTransactionRecordFailure(result->inhandle, OSPC_FAIL_NO_ROUTE_TO_DEST);
}
@@ -668,7 +700,8 @@ static int osp_lookup(const char* provider, const char* srcdev, const char* call
error = OSPPTransactionGetFirstDestination(result->outhandle, 0, NULL, NULL, &result->outtimelimit, &callidlen, callid,
sizeof(callednum), callednum, sizeof(callingnum), callingnum, sizeof(destination), destination, 0, NULL, &tokenlen, token);
if (error != OSPC_ERR_NO_ERROR) {
- ast_log(LOG_DEBUG, "OSP: Unable to get first route\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: Unable to get first route\n");
result->numresults = 0;
result->outtimelimit = OSP_DEF_TIMELIMIT;
if (result->inhandle != OSP_INVALID_HANDLE) {
@@ -679,18 +712,21 @@ static int osp_lookup(const char* provider, const char* srcdev, const char* call
result->numresults--;
result->outtimelimit = osp_choose_timelimit(result->intimelimit, result->outtimelimit);
- 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);
+ 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);
+ }
if ((res = osp_check_destination(callednum, callingnum, destination, tokenlen, token, &reason, result)) > 0) {
return 1;
}
if (!result->numresults) {
- ast_log(LOG_DEBUG, "OSP: No more destination\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: No more destination\n");
result->outtimelimit = OSP_DEF_TIMELIMIT;
OSPPTransactionRecordFailure(result->outhandle, reason);
if (result->inhandle != OSP_INVALID_HANDLE) {
@@ -707,15 +743,18 @@ static int osp_lookup(const char* provider, const char* srcdev, const char* call
if (error == OSPC_ERR_NO_ERROR) {
result->numresults--;
result->outtimelimit = osp_choose_timelimit(result->intimelimit, result->outtimelimit);
- 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);
+ 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);
+ }
if ((res = osp_check_destination(callednum, callingnum, destination, tokenlen, token, &reason, result)) > 0) {
break;
} else if (!result->numresults) {
- ast_log(LOG_DEBUG, "OSP: No more destination\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: No more destination\n");
OSPPTransactionRecordFailure(result->outhandle, reason);
if (result->inhandle != OSP_INVALID_HANDLE) {
OSPPTransactionRecordFailure(result->inhandle, OSPC_FAIL_NO_ROUTE_TO_DEST);
@@ -724,7 +763,8 @@ static int osp_lookup(const char* provider, const char* srcdev, const char* call
break;
}
} else {
- ast_log(LOG_DEBUG, "OSP: Unable to get route, error '%d'\n", error);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: Unable to get route, error '%d'\n", error);
result->numresults = 0;
result->outtimelimit = OSP_DEF_TIMELIMIT;
if (result->inhandle != OSP_INVALID_HANDLE) {
@@ -763,7 +803,8 @@ static int osp_next(int cause, struct osp_result* result)
result->outtimelimit = OSP_DEF_TIMELIMIT;
if (result->outhandle == OSP_INVALID_HANDLE) {
- ast_log(LOG_DEBUG, "OSP: Transaction handle undefined\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: Transaction handle undefined\n");
result->numresults = 0;
if (result->inhandle != OSP_INVALID_HANDLE) {
OSPPTransactionRecordFailure(result->inhandle, OSPC_FAIL_NORMAL_UNSPECIFIED);
@@ -774,7 +815,8 @@ static int osp_next(int cause, struct osp_result* result)
reason = asterisk2osp(cause);
if (!result->numresults) {
- ast_log(LOG_DEBUG, "OSP: No more destination\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: No more destination\n");
OSPPTransactionRecordFailure(result->outhandle, reason);
if (result->inhandle != OSP_INVALID_HANDLE) {
OSPPTransactionRecordFailure(result->inhandle, OSPC_FAIL_NO_ROUTE_TO_DEST);
@@ -790,16 +832,19 @@ static int osp_next(int cause, struct osp_result* result)
if (error == OSPC_ERR_NO_ERROR) {
result->numresults--;
result->outtimelimit = osp_choose_timelimit(result->intimelimit, result->outtimelimit);
- 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);
+ 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);
+ }
if ((res = osp_check_destination(callednum, callingnum, destination, tokenlen, token, &reason, result)) > 0) {
res = 1;
break;
} else if (!result->numresults) {
- ast_log(LOG_DEBUG, "OSP: No more destination\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: No more destination\n");
OSPPTransactionRecordFailure(result->outhandle, reason);
if (result->inhandle != OSP_INVALID_HANDLE) {
OSPPTransactionRecordFailure(result->inhandle, OSPC_FAIL_NO_ROUTE_TO_DEST);
@@ -808,7 +853,8 @@ static int osp_next(int cause, struct osp_result* result)
break;
}
} else {
- ast_log(LOG_DEBUG, "OSP: Unable to get route, error '%d'\n", error);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: Unable to get route, error '%d'\n", error);
result->token[0] = '\0';
result->numresults = 0;
result->outtimelimit = OSP_DEF_TIMELIMIT;
@@ -856,10 +902,12 @@ static int osp_finish(int handle, int recorded, int cause, time_t start, time_t
error = OSPPTransactionReportUsage(handle, difftime(end, connect), start, end, alert, connect, isPddInfoPresent, pdd,
release, (unsigned char *) "", 0, 0, 0, 0, &dummy, NULL);
if (error == OSPC_ERR_NO_ERROR) {
- ast_log(LOG_DEBUG, "OSP: Usage reported\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: Usage reported\n");
res = 1;
} else {
- ast_log(LOG_DEBUG, "OSP: Unable to report usage, error '%d'\n", error);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: Unable to report usage, error '%d'\n", error);
res = -1;
}
OSPPTransactionDelete(handle);
@@ -909,12 +957,14 @@ static int ospauth_exec(struct ast_channel* chan, void* data)
if (!ast_strlen_zero(args.provider)) {
provider = args.provider;
}
- ast_log(LOG_DEBUG, "OSPAuth: provider '%s'\n", provider);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPAuth: provider '%s'\n", provider);
if ((args.options) && (strchr(args.options, 'j'))) {
priority_jump = 1;
}
- ast_log(LOG_DEBUG, "OSPAuth: priority jump '%d'\n", priority_jump);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPAuth: priority jump '%d'\n", priority_jump);
headp = &chan->varshead;
AST_LIST_TRAVERSE(headp, current, entries) {
@@ -924,9 +974,11 @@ static int ospauth_exec(struct ast_channel* chan, void* data)
token = ast_var_value(current);
}
}
- ast_log(LOG_DEBUG, "OSPAuth: source '%s'\n", source);
- ast_log(LOG_DEBUG, "OSPAuth: token size '%zd'\n", strlen(token));
+ if (option_debug) {
+ ast_log(LOG_DEBUG, "OSPAuth: source '%s'\n", source);
+ ast_log(LOG_DEBUG, "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;
@@ -941,12 +993,15 @@ static int ospauth_exec(struct ast_channel* chan, void* data)
snprintf(buffer, sizeof(buffer), "%d", handle);
pbx_builtin_setvar_helper(chan, "OSPINHANDLE", buffer);
- ast_log(LOG_DEBUG, "OSPAuth: OSPINHANDLE '%s'\n", buffer);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPAuth: OSPINHANDLE '%s'\n", buffer);
snprintf(buffer, sizeof(buffer), "%d", timelimit);
pbx_builtin_setvar_helper(chan, "OSPINTIMELIMIT", buffer);
- ast_log(LOG_DEBUG, "OSPAuth: OSPINTIMELIMIT '%s'\n", buffer);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPAuth: OSPINTIMELIMIT '%s'\n", buffer);
pbx_builtin_setvar_helper(chan, "OSPAUTHSTATUS", status);
- ast_log(LOG_DEBUG, "OSPAuth: %s\n", status);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPAuth: %s\n", status);
if(res <= 0) {
if (priority_jump || ast_opt_priority_jumping) {
@@ -1005,17 +1060,20 @@ static int osplookup_exec(struct ast_channel* chan, void* data)
AST_STANDARD_APP_ARGS(args, tmp);
- ast_log(LOG_DEBUG, "OSPLookup: exten '%s'\n", args.exten);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPLookup: exten '%s'\n", args.exten);
if (!ast_strlen_zero(args.provider)) {
provider = args.provider;
}
- ast_log(LOG_DEBUG, "OSPlookup: provider '%s'\n", provider);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPlookup: provider '%s'\n", provider);
if ((args.options) && (strchr(args.options, 'j'))) {
priority_jump = 1;
}
- ast_log(LOG_DEBUG, "OSPLookup: priority jump '%d'\n", priority_jump);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPLookup: priority jump '%d'\n", priority_jump);
result.inhandle = OSP_INVALID_HANDLE;
result.intimelimit = OSP_DEF_TIMELIMIT;
@@ -1034,9 +1092,11 @@ static int osplookup_exec(struct ast_channel* chan, void* data)
srcdev = ast_var_value(current);
}
}
- 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: source device '%s'\n", srcdev);
+ 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: source device '%s'\n", srcdev);
+ }
if ((cres = ast_autoservice_start(chan)) < 0) {
ast_module_user_remove(u);
@@ -1061,29 +1121,38 @@ static int osplookup_exec(struct ast_channel* chan, void* data)
snprintf(buffer, sizeof(buffer), "%d", result.outhandle);
pbx_builtin_setvar_helper(chan, "OSPOUTHANDLE", buffer);
- ast_log(LOG_DEBUG, "OSPLookup: OSPOUTHANDLE '%s'\n", buffer);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPLookup: OSPOUTHANDLE '%s'\n", buffer);
pbx_builtin_setvar_helper(chan, "OSPTECH", result.tech);
- ast_log(LOG_DEBUG, "OSPLookup: OSPTECH '%s'\n", result.tech);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPLookup: OSPTECH '%s'\n", result.tech);
pbx_builtin_setvar_helper(chan, "OSPDEST", result.dest);
- ast_log(LOG_DEBUG, "OSPLookup: OSPDEST '%s'\n", result.dest);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPLookup: OSPDEST '%s'\n", result.dest);
pbx_builtin_setvar_helper(chan, "OSPCALLING", result.calling);
- ast_log(LOG_DEBUG, "OSPLookup: OSPCALLING '%s'\n", result.calling);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPLookup: OSPCALLING '%s'\n", result.calling);
pbx_builtin_setvar_helper(chan, "OSPOUTTOKEN", result.token);
- ast_log(LOG_DEBUG, "OSPLookup: OSPOUTTOKEN size '%zd'\n", strlen(result.token));
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPLookup: OSPOUTTOKEN size '%zd'\n", strlen(result.token));
snprintf(buffer, sizeof(buffer), "%d", result.numresults);
pbx_builtin_setvar_helper(chan, "OSPRESULTS", buffer);
- ast_log(LOG_DEBUG, "OSPLookup: OSPRESULTS '%s'\n", buffer);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPLookup: OSPRESULTS '%s'\n", buffer);
snprintf(buffer, sizeof(buffer), "%d", result.outtimelimit);
pbx_builtin_setvar_helper(chan, "OSPOUTTIMELIMIT", buffer);
- ast_log(LOG_DEBUG, "OSPLookup: OSPOUTTIMELIMIT '%s'\n", buffer);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPLookup: OSPOUTTIMELIMIT '%s'\n", buffer);
pbx_builtin_setvar_helper(chan, "OSPLOOKUPSTATUS", status);
- ast_log(LOG_DEBUG, "OSPLookup: %s\n", status);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPLookup: %s\n", status);
if (!strcasecmp(result.tech, "SIP")) {
if (!ast_strlen_zero(result.token)) {
snprintf(buffer, sizeof(buffer), "P-OSP-Auth-Token: %s", result.token);
pbx_builtin_setvar_helper(chan, "_SIPADDHEADER", buffer);
- ast_log(LOG_DEBUG, "OSPLookup: SIPADDHEADER size '%zd'\n", strlen(buffer));
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPLookup: SIPADDHEADER size '%zd'\n", strlen(buffer));
}
} else if (!strcasecmp(result.tech, "H323")) {
} else if (!strcasecmp(result.tech, "IAX")) {
@@ -1152,12 +1221,14 @@ static int ospnext_exec(struct ast_channel* chan, void* data)
if (!ast_strlen_zero(args.cause) && sscanf(args.cause, "%d", &cause) != 1) {
cause = 0;
}
- ast_log(LOG_DEBUG, "OSPNext: cause '%d'\n", cause);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPNext: cause '%d'\n", cause);
if ((args.options) && (strchr(args.options, 'j'))) {
priority_jump = 1;
}
- ast_log(LOG_DEBUG, "OSPNext: priority jump '%d'\n", priority_jump);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPNext: priority jump '%d'\n", priority_jump);
result.inhandle = OSP_INVALID_HANDLE;
result.outhandle = OSP_INVALID_HANDLE;
@@ -1184,10 +1255,12 @@ static int ospnext_exec(struct ast_channel* chan, void* data)
}
}
}
- 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: OSPRESULTS '%d'\n", result.numresults);
+ 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: OSPRESULTS '%d'\n", result.numresults);
+ }
if ((res = osp_next(cause, &result)) > 0) {
status = AST_OSP_SUCCESS;
@@ -1206,27 +1279,35 @@ static int ospnext_exec(struct ast_channel* chan, void* data)
}
pbx_builtin_setvar_helper(chan, "OSPTECH", result.tech);
- ast_log(LOG_DEBUG, "OSPNext: OSPTECH '%s'\n", result.tech);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPNext: OSPTECH '%s'\n", result.tech);
pbx_builtin_setvar_helper(chan, "OSPDEST", result.dest);
- ast_log(LOG_DEBUG, "OSPNext: OSPDEST '%s'\n", result.dest);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPNext: OSPDEST '%s'\n", result.dest);
pbx_builtin_setvar_helper(chan, "OSPCALLING", result.calling);
- ast_log(LOG_DEBUG, "OSPNext: OSPCALLING '%s'\n", result.calling);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPNext: OSPCALLING '%s'\n", result.calling);
pbx_builtin_setvar_helper(chan, "OSPOUTTOKEN", result.token);
- ast_log(LOG_DEBUG, "OSPNext: OSPOUTTOKEN size '%zd'\n", strlen(result.token));
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPNext: OSPOUTTOKEN size '%zd'\n", strlen(result.token));
snprintf(buffer, sizeof(buffer), "%d", result.numresults);
pbx_builtin_setvar_helper(chan, "OSPRESULTS", buffer);
- ast_log(LOG_DEBUG, "OSPNext: OSPRESULTS '%s'\n", buffer);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPNext: OSPRESULTS '%s'\n", buffer);
snprintf(buffer, sizeof(buffer), "%d", result.outtimelimit);
pbx_builtin_setvar_helper(chan, "OSPOUTTIMELIMIT", buffer);
- ast_log(LOG_DEBUG, "OSPNext: OSPOUTTIMELIMIT '%s'\n", buffer);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPNext: OSPOUTTIMELIMIT '%s'\n", buffer);
pbx_builtin_setvar_helper(chan, "OSPNEXTSTATUS", status);
- ast_log(LOG_DEBUG, "OSPNext: %s\n", status);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPNext: %s\n", status);
if (!strcasecmp(result.tech, "SIP")) {
if (!ast_strlen_zero(result.token)) {
snprintf(buffer, sizeof(buffer), "P-OSP-Auth-Token: %s", result.token);
pbx_builtin_setvar_helper(chan, "_SIPADDHEADER", buffer);
- ast_log(LOG_DEBUG, "OSPLookup: SIPADDHEADER size '%zd'\n", strlen(buffer));
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPLookup: SIPADDHEADER size '%zd'\n", strlen(buffer));
}
} else if (!strcasecmp(result.tech, "H323")) {
} else if (!strcasecmp(result.tech, "IAX")) {
@@ -1289,7 +1370,8 @@ static int ospfinished_exec(struct ast_channel* chan, void* data)
if ((args.options) && (strchr(args.options, 'j'))) {
priority_jump = 1;
}
- ast_log(LOG_DEBUG, "OSPFinish: priority jump '%d'\n", priority_jump);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPFinish: priority jump '%d'\n", priority_jump);
headp = &chan->varshead;
AST_LIST_TRAVERSE(headp, current, entries) {
@@ -1311,14 +1393,17 @@ static int ospfinished_exec(struct ast_channel* chan, void* data)
}
}
}
- 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);
+ 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);
+ }
if (!ast_strlen_zero(args.cause) && sscanf(args.cause, "%d", &cause) != 1) {
cause = 0;
}
- ast_log(LOG_DEBUG, "OSPFinish: cause '%d'\n", cause);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPFinish: cause '%d'\n", cause);
if (chan->cdr) {
start = chan->cdr->start.tv_sec;
@@ -1333,14 +1418,17 @@ static int ospfinished_exec(struct ast_channel* chan, void* data)
connect = 0;
end = 0;
}
- 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);
+ 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);
+ }
release = chan->_softhangup ? 0 : 1;
if (osp_finish(outhandle, recorded, cause, start, connect, end, release) <= 0) {
- ast_log(LOG_DEBUG, "OSPFinish: Unable to report usage for outbound call\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPFinish: Unable to report usage for outbound call\n");
}
switch (cause) {
case AST_CAUSE_NORMAL_CLEARING:
@@ -1350,7 +1438,8 @@ static int ospfinished_exec(struct ast_channel* chan, void* data)
break;
}
if (osp_finish(inhandle, recorded, cause, start, connect, end, release) <= 0) {
- ast_log(LOG_DEBUG, "OSPFinish: Unable to report usage for inbound call\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSPFinish: Unable to report usage for inbound call\n");
}
snprintf(buffer, sizeof(buffer), "%d", OSP_INVALID_HANDLE);
pbx_builtin_setvar_helper(chan, "OSPOUTHANDLE", buffer);
@@ -1403,7 +1492,8 @@ static int osp_load(void)
} else {
OSPPInit(0);
}
- ast_log(LOG_DEBUG, "OSP: osp_hardware '%d'\n", osp_hardware);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: osp_hardware '%d'\n", osp_hardware);
t = ast_variable_retrieve(cfg, OSP_GENERAL_CAT, "tokenformat");
if (t) {
@@ -1416,7 +1506,8 @@ static int osp_load(void)
TOKEN_ALGO_SIGNED, TOKEN_ALGO_UNSIGNED, TOKEN_ALGO_BOTH, t);
}
}
- ast_log(LOG_DEBUG, "OSP: osp_tokenformat '%d'\n", osp_tokenformat);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: osp_tokenformat '%d'\n", osp_tokenformat);
t = ast_category_browse(cfg, NULL);
while(t) {
@@ -1433,7 +1524,8 @@ static int osp_load(void)
ast_log(LOG_WARNING, "OSP: Unable to find configuration. OSP support disabled\n");
return 0;
}
- ast_log(LOG_DEBUG, "OSP: osp_initialized '%d'\n", osp_initialized);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "OSP: osp_initialized '%d'\n", osp_initialized);
return 1;
}
diff --git a/apps/app_queue.c b/apps/app_queue.c
index 79a8f2ebd..f0ce9059c 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -1020,7 +1020,8 @@ 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. */
- ast_log(LOG_DEBUG, "Queue %s not found in realtime.\n", queuename);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Queue %s not found in realtime.\n", queuename);
q->dead = 1;
/* Delete if unused (else will be deleted when last caller leaves). */
@@ -1499,9 +1500,11 @@ static int compare_weight(struct call_queue *rq, struct member *member)
if (strcmp(mem->interface, member->interface))
continue;
- ast_log(LOG_DEBUG, "Found matching member %s in queue '%s'\n", mem->interface, q->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Found matching member %s in queue '%s'\n", mem->interface, q->name);
if (q->weight > rq->weight) {
- 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);
+ 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);
found = 1;
break;
}
@@ -1593,7 +1596,8 @@ static int ring_entry(struct queue_ent *qe, struct callattempt *tmp, int *busies
return 0;
}
if (use_weight && compare_weight(qe->parent,tmp->member)) {
- ast_log(LOG_DEBUG, "Priority queue delaying call to %s:%s\n", qe->parent->name, tmp->interface);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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;
@@ -1891,7 +1895,8 @@ static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callatte
}
if (pos == 1 /* not found */) {
if (numlines == (numbusies + numnochan)) {
- ast_log(LOG_DEBUG, "Everyone is busy at this time\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
}
@@ -2029,7 +2034,8 @@ static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callatte
/* Ignore going off hook */
break;
default:
- ast_log(LOG_DEBUG, "Dunno what to do with control type %d\n", f->subclass);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Dunno what to do with control type %d\n", f->subclass);
}
}
ast_frfree(f);
@@ -2849,8 +2855,10 @@ static int set_member_paused(char *queuename, char *interface, int paused)
if (ast_strlen_zero(queuename) || !strcasecmp(q->name, queuename)) {
if ((mem = interface_exists(q, interface))) {
found++;
- if (mem->paused == paused)
- ast_log(LOG_DEBUG, "%spausing already-%spaused queue member %s:%s\n", (paused ? "" : "un"), (paused ? "" : "un"), q->name, interface);
+ 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);
+ }
mem->paused = paused;
if (queue_persistent_members)
@@ -3109,12 +3117,14 @@ static int rqm_exec(struct ast_channel *chan, void *data)
switch (remove_from_queue(args.queuename, args.interface)) {
case RES_OKAY:
- ast_log(LOG_DEBUG, "Removed interface '%s' from queue '%s'\n", args.interface, args.queuename);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Removed interface '%s' from queue '%s'\n", args.interface, args.queuename);
pbx_builtin_setvar_helper(chan, "RQMSTATUS", "REMOVED");
res = 0;
break;
case RES_EXISTS:
- ast_log(LOG_DEBUG, "Unable to remove interface '%s' from queue '%s': Not there\n", args.interface, args.queuename);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Unable to remove interface '%s' from queue '%s': Not there\n", args.interface, args.queuename);
if (priority_jump || ast_opt_priority_jumping)
ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
pbx_builtin_setvar_helper(chan, "RQMSTATUS", "NOTINQUEUE");
diff --git a/apps/app_record.c b/apps/app_record.c
index a51a8a508..924e6ba2d 100644
--- a/apps/app_record.c
+++ b/apps/app_record.c
@@ -335,7 +335,8 @@ static int record_exec(struct ast_channel *chan, void *data)
ast_frfree(f);
}
if (!f) {
- ast_log(LOG_DEBUG, "Got hangup\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Got hangup\n");
res = -1;
}
diff --git a/apps/app_talkdetect.c b/apps/app_talkdetect.c
index 79cbbd5d0..7d9376a13 100644
--- a/apps/app_talkdetect.c
+++ b/apps/app_talkdetect.c
@@ -42,6 +42,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/translate.h"
#include "asterisk/utils.h"
#include "asterisk/dsp.h"
+#include "asterisk/options.h"
static char *app = "BackgroundDetect";
@@ -102,7 +103,8 @@ static int background_detect_exec(struct ast_channel *chan, void *data)
}
}
}
- ast_log(LOG_DEBUG, "Preparing detect of '%s', sil=%d,min=%d,max=%d\n",
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 */
@@ -162,7 +164,8 @@ static int background_detect_exec(struct ast_channel *chan, void *data)
ms = 0;
if ((ms > min) && ((max < 0) || (ms < max))) {
char ms_str[10];
- ast_log(LOG_DEBUG, "Found qualified token of %d ms\n", ms);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Found qualified token of %d ms\n", ms);
/* Save detected talk time (in milliseconds) */
sprintf(ms_str, "%d", ms );
@@ -172,15 +175,18 @@ static int background_detect_exec(struct ast_channel *chan, void *data)
res = 0;
ast_frfree(fr);
break;
- } else
- ast_log(LOG_DEBUG, "Found unqualified token of %d ms\n", ms);
+ } else {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Found unqualified token of %d ms\n", ms);
+ }
notsilent = 0;
}
} else {
if (!notsilent) {
/* Heard some audio, mark the begining of the token */
start = ast_tvnow();
- ast_log(LOG_DEBUG, "Start of voice token!\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Start of voice token!\n");
notsilent = 1;
}
}
diff --git a/apps/app_test.c b/apps/app_test.c
index b38fe4ca7..02c354f98 100644
--- a/apps/app_test.c
+++ b/apps/app_test.c
@@ -112,7 +112,8 @@ 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;
}
- ast_log(LOG_DEBUG, "%s: Noise: %d, samples: %d, avg: %d\n", who, noise, samples, noise / samples);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "%s: Noise: %d, samples: %d, avg: %d\n", who, noise, samples, noise / samples);
return (noise / samples);
}
@@ -363,7 +364,8 @@ 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");
- ast_log(LOG_DEBUG, "Processing Test ID '%s'\n", testid);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Processing Test ID '%s'\n", testid);
res = ast_safe_sleep(chan, 1000);
if (!res) {
/* Step 1: Send "1" */
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 157b2e7ca..ac3fd52a2 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -1862,7 +1862,8 @@ static int sendmail(char *srcemail, struct ast_vm_user *vmu, int msgnum, char *c
}
if (!strcmp(format, "wav49"))
format = "WAV";
- ast_log(LOG_DEBUG, "Attaching file '%s', format '%s', uservm is '%d', global is %d\n", attach, format, attach_user_voicemail, ast_test_flag((&globalflags), VM_ATTACH));
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Attaching file '%s', format '%s', uservm is '%d', global is %d\n", attach, format, attach_user_voicemail, ast_test_flag((&globalflags), VM_ATTACH));
/* Make a temporary file instead of piping directly to sendmail, in case the mail
command hangs */
if ((p = vm_mkftemp(tmp)) == NULL) {
@@ -1987,12 +1988,14 @@ static int sendmail(char *srcemail, struct ast_vm_user *vmu, int msgnum, char *c
create_dirpath(tmpdir, sizeof(tmpdir), vmu->context, vmu->mailbox, "tmp");
snprintf(newtmp, sizeof(newtmp), "%s/XXXXXX", tmpdir);
tmpfd = mkstemp(newtmp);
- ast_log(LOG_DEBUG, "newtmp: %s\n", newtmp);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "newtmp: %s\n", newtmp);
if (vmu->volgain < -.001 || vmu->volgain > .001) {
snprintf(tmpcmd, sizeof(tmpcmd), "sox -v %.4f %s.%s %s.%s", vmu->volgain, attach, format, newtmp, format);
ast_safe_system(tmpcmd);
attach = newtmp;
- ast_log(LOG_DEBUG, "VOLGAIN: Stored at: %s.%s - Level: %.4f - Mailbox: %s\n", attach, format, vmu->volgain, mailbox);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "VOLGAIN: Stored at: %s.%s - Level: %.4f - Mailbox: %s\n", attach, format, vmu->volgain, mailbox);
}
fprintf(p, "--%s\n", bound);
fprintf(p, "Content-Type: %s%s; name=\"msg%04d.%s\"\n", ctype, format, msgnum, format);
@@ -2022,7 +2025,8 @@ 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);
- ast_log(LOG_DEBUG, "Sent mail to %s with command '%s'\n", vmu->email, mailcmd);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Sent mail to %s with command '%s'\n", vmu->email, mailcmd);
}
return 0;
}
@@ -2105,7 +2109,8 @@ 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);
- ast_log(LOG_DEBUG, "Sent page to %s with command '%s'\n", pager, mailcmd);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Sent page to %s with command '%s'\n", pager, mailcmd);
}
return 0;
}
@@ -2677,14 +2682,16 @@ 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 {
- ast_log(LOG_DEBUG, "Successfully executed SMDI MWI change for %s on %s\n", extension, smdi_iface->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Successfully executed SMDI MWI change for %s on %s\n", extension, smdi_iface->name);
}
} else if (!ast_strlen_zero(externnotify)) {
if (inboxcount(ext_context, &newvoicemails, &oldvoicemails)) {
ast_log(LOG_ERROR, "Problem in calculating number of voicemail messages available for extension %s\n", extension);
} else {
snprintf(arguments, sizeof(arguments), "%s %s %s %d&", externnotify, context, extension, newvoicemails);
- ast_log(LOG_DEBUG, "Executing %s\n", arguments);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Executing %s\n", arguments);
ast_safe_system(arguments);
}
}
@@ -2803,12 +2810,14 @@ 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 {
- ast_log(LOG_DEBUG, "%s doesn't exist, doing what we can\n", prefile);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "%s doesn't exist, doing what we can\n", prefile);
res = invent_message(chan, vmu->context, ext, ast_test_flag(options, OPT_BUSY_GREETING), ecodes);
}
DISPOSE(prefile, -1);
if (res < 0) {
- ast_log(LOG_DEBUG, "Hang up during prefile playback\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Hang up during prefile playback\n");
free_user(vmu);
pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED");
return -1;
@@ -2897,7 +2906,8 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_
/* Check if mailbox is full */
if (vms->quota_usage >= vms->quota_limit) {
- ast_log(LOG_DEBUG, "*** QUOTA EXCEEDED!!\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "*** QUOTA EXCEEDED!!\n");
ast_play_and_wait(chan, "vm-mailboxfull");
return -1;
}
@@ -2907,7 +2917,8 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_
if (!res)
res = ast_waitstream(chan, "");
/* play_record_review does recording and verify */
- ast_log(LOG_DEBUG, "About to record message in file %s\n",fn);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "About to record message in file %s\n",fn);
res = play_record_review(chan, NULL, fn, vmmaxmessage, fmt, 1, vmu, &duration, dir, options->record_gain);
if (res == '0') {
goto transfer;
@@ -3103,7 +3114,7 @@ static int save_to_folder(struct ast_vm_user *vmu, struct vm_state *vms, int msg
if (box == 1) return 10;
/* get the real IMAP message number for this message */
sprintf(sequence,"%ld",vms->msgArray[msg]);
- if(option_debug > 2)
+ if (option_debug > 2)
ast_log(LOG_DEBUG, "Copying sequence %s to mailbox %s\n",sequence,dbox);
res = mail_copy(vms->mailstream,sequence,dbox);
if (res == 1) return 0;
@@ -3253,7 +3264,8 @@ 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);
- ast_log(LOG_DEBUG, "Done downloading scripts...\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Done downloading scripts...\n");
#ifdef DISPLAY
/* Add last dot */
@@ -3261,7 +3273,8 @@ 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
- ast_log(LOG_DEBUG, "Restarting session...\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Restarting session...\n");
bytes = 0;
/* Load the session now */
@@ -3961,13 +3974,13 @@ static int forward_message(struct ast_channel *chan, char *context, struct vm_st
}
if (!strcasecmp(fmt, "wav49"))
fmt = "WAV";
- if(option_debug > 2)
+ if (option_debug > 2)
ast_log (LOG_DEBUG,"**** 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/imap", VM_SPOOL_DIR);
make_gsm_file(vms->fn, vms->imapuser, todir, vms->curmsg);
- if(option_debug > 2)
+ 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);
/*mail_fetchstructure (mailstream, vmArray[0], &body); */
mail_fetchstructure (vms->mailstream, vms->msgArray[vms->curmsg], &body);
@@ -4119,13 +4132,15 @@ static int play_message_callerid(struct ast_channel *chan, struct vm_state *vms,
return res;
/* Strip off caller ID number from name */
- ast_log(LOG_DEBUG, "VM-CID: composite caller ID received: %s, context: %s\n", cid, context);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "VM-CID: composite caller ID received: %s, context: %s\n", cid, context);
ast_callerid_parse(cid, &name, &callerid);
if ((!ast_strlen_zero(callerid)) && strcmp(callerid, "Unknown")) {
/* Check for internal contexts and only */
/* say extension when the call didn't come from an internal context in the list */
for (i = 0 ; i < MAX_NUM_CID_CONTEXTS ; i++){
- ast_log(LOG_DEBUG, "VM-CID: comparing internalcontext: %s\n", cidinternalcontexts[i]);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "VM-CID: comparing internalcontext: %s\n", cidinternalcontexts[i]);
if ((strcmp(cidinternalcontexts[i], context) == 0))
break;
}
@@ -4153,7 +4168,8 @@ static int play_message_callerid(struct ast_channel *chan, struct vm_state *vms,
}
else if (!res){
- ast_log(LOG_DEBUG, "VM-CID: Numeric caller id: (%s)\n",callerid);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "VM-CID: Numeric caller id: (%s)\n",callerid);
/* BB: Since this is all nicely figured out, why not say "from phone number" in this case" */
if (!callback)
res = wait_file2(chan, vms, "vm-from-phonenumber");
@@ -4161,7 +4177,8 @@ static int play_message_callerid(struct ast_channel *chan, struct vm_state *vms,
}
} else {
/* Number unknown */
- ast_log(LOG_DEBUG, "VM-CID: From an unknown number\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "VM-CID: From an unknown number\n");
/* Say "from an unknown caller" as one phrase - it is already recorded by "the voice" anyhow */
res = wait_file2(chan, vms, "vm-unknown-caller");
}
@@ -4181,7 +4198,8 @@ static int play_message_duration(struct ast_channel *chan, struct vm_state *vms,
durations=atoi(duration);
durationm=(durations / 60);
- ast_log(LOG_DEBUG, "VM-Duration: duration is: %d seconds converted to: %d minutes\n", durations, durationm);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "VM-Duration: duration is: %d seconds converted to: %d minutes\n", durations, durationm);
if ((!res) && (durationm >= minduration)) {
res = wait_file2(chan, vms, "vm-duration");
@@ -5481,7 +5499,8 @@ static int vm_newuser(struct ast_channel *chan, struct ast_vm_user *vmu, struct
vm_change_password(vmu,newpassword);
else
vm_change_password_shell(vmu,newpassword);
- ast_log(LOG_DEBUG,"User %s set password to %s of length %d\n",vms->username,newpassword,(int)strlen(newpassword));
+ if (option_debug)
+ ast_log(LOG_DEBUG,"User %s set password to %s of length %d\n",vms->username,newpassword,(int)strlen(newpassword));
cmd = ast_play_and_wait(chan,"vm-passchanged");
/* If forcename is set, have the user record their name */
@@ -5583,7 +5602,8 @@ static int vm_options(struct ast_channel *chan, struct ast_vm_user *vmu, struct
vm_change_password(vmu,newpassword);
else
vm_change_password_shell(vmu,newpassword);
- ast_log(LOG_DEBUG,"User %s set password to %s of length %d\n",vms->username,newpassword,(int)strlen(newpassword));
+ if (option_debug)
+ ast_log(LOG_DEBUG,"User %s set password to %s of length %d\n",vms->username,newpassword,(int)strlen(newpassword));
cmd = ast_play_and_wait(chan,"vm-passchanged");
break;
case '*':
@@ -5827,7 +5847,8 @@ static int vm_authenticate(struct ast_channel *chan, char *mailbox, int mailbox_
ast_copy_string(mailbox, fullusername, mailbox_size);
}
- ast_log(LOG_DEBUG, "Before find user for mailbox %s\n",mailbox);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Before find user for mailbox %s\n",mailbox);
vmu = find_user(&vmus, context, mailbox);
if (vmu && (vmu->password[0] == '\0' || (vmu->password[0] == '-' && vmu->password[1] == '\0'))) {
/* saved password is blank, so don't bother asking */
@@ -5919,7 +5940,8 @@ static int vm_execmain(struct ast_channel *chan, void *data)
memset(&vmus, 0, sizeof(vmus));
if (chan->_state != AST_STATE_UP) {
- ast_log(LOG_DEBUG, "Before ast_answer\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Before ast_answer\n");
ast_answer(chan);
}
@@ -6001,7 +6023,8 @@ 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);
- ast_log(LOG_DEBUG, "After vm_authenticate\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "After vm_authenticate\n");
if (!res) {
valid = 1;
if (!skipuser)
@@ -6036,18 +6059,21 @@ 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 */
- ast_log(LOG_DEBUG, "Before open_mailbox\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Before open_mailbox\n");
res = open_mailbox(&vms, vmu, 1);
if (res == ERROR_LOCK_PATH)
goto out;
vms.oldmessages = vms.lastmsg + 1;
- ast_log(LOG_DEBUG, "Number of old messages: %d\n",vms.oldmessages);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Number of old messages: %d\n",vms.oldmessages);
/* Start in INBOX */
res = open_mailbox(&vms, vmu, 0);
if (res == ERROR_LOCK_PATH)
goto out;
vms.newmessages = vms.lastmsg + 1;
- ast_log(LOG_DEBUG, "Number of new messages: %d\n",vms.newmessages);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Number of new messages: %d\n",vms.newmessages);
/* Select proper mailbox FIRST!! */
if (play_auto) {
@@ -6938,13 +6964,16 @@ static int load_config(void)
if ((notifystr = ast_variable_retrieve(cfg, "general", "externnotify"))) {
ast_copy_string(externnotify, notifystr, sizeof(externnotify));
- ast_log(LOG_DEBUG, "found externnotify: %s\n", externnotify);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "found externnotify: %s\n", externnotify);
if (!strcasecmp(externnotify, "smdi")) {
- ast_log(LOG_DEBUG, "Using SMDI for external voicemail notification\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Using SMDI for external voicemail notification\n");
if ((smdistr = ast_variable_retrieve(cfg, "general", "smdiport"))) {
smdi_iface = ast_smdi_interface_find(smdistr);
} else {
- ast_log(LOG_DEBUG, "No SMDI interface set, trying default (/dev/ttyS0)\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "No SMDI interface set, trying default (/dev/ttyS0)\n");
smdi_iface = ast_smdi_interface_find("/dev/ttyS0");
}
@@ -6952,7 +6981,8 @@ static int load_config(void)
ast_log(LOG_ERROR, "No valid SMDI interface specfied, disabling external voicemail notification\n");
externnotify[0] = '\0';
} else {
- ast_log(LOG_DEBUG, "Using SMDI port %s\n", smdi_iface->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Using SMDI port %s\n", smdi_iface->name);
}
}
} else {
@@ -7029,7 +7059,8 @@ static int load_config(void)
ast_set2_flag((&globalflags), ast_true(astforcegreet), VM_FORCEGREET);
if ((s = ast_variable_retrieve(cfg, "general", "cidinternalcontexts"))){
- ast_log(LOG_DEBUG,"VM_CID Internal context string: %s\n",s);
+ if (option_debug)
+ ast_log(LOG_DEBUG,"VM_CID Internal context string: %s\n",s);
stringp = ast_strdupa(s);
for (x = 0 ; x < MAX_NUM_CID_CONTEXTS ; x++){
if (!ast_strlen_zero(stringp)) {
@@ -7037,53 +7068,62 @@ static int load_config(void)
while ((*q == ' ')||(*q == '\t')) /* Eat white space between contexts */
q++;
ast_copy_string(cidinternalcontexts[x], q, sizeof(cidinternalcontexts[x]));
- ast_log(LOG_DEBUG,"VM_CID Internal context %d: %s\n", x, cidinternalcontexts[x]);
+ if (option_debug)
+ ast_log(LOG_DEBUG,"VM_CID Internal context %d: %s\n", x, cidinternalcontexts[x]);
} else {
cidinternalcontexts[x][0] = '\0';
}
}
}
if (!(astreview = ast_variable_retrieve(cfg, "general", "review"))){
- ast_log(LOG_DEBUG,"VM Review Option disabled globally\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"VM Review Option disabled globally\n");
astreview = "no";
}
ast_set2_flag((&globalflags), ast_true(astreview), VM_REVIEW);
/*Temperary greeting reminder */
if (!(asttempgreetwarn = ast_variable_retrieve(cfg, "general", "tempgreetwarn"))) {
- ast_log(LOG_DEBUG, "VM Temperary Greeting Reminder Option disabled globally\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "VM Temperary Greeting Reminder Option disabled globally\n");
asttempgreetwarn = "no";
} else {
- ast_log(LOG_DEBUG, "VM Temperary Greeting Reminder Option enabled globally\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "VM Temperary Greeting Reminder Option enabled globally\n");
}
ast_set2_flag((&globalflags), ast_true(asttempgreetwarn), VM_TEMPGREETWARN);
if (!(astcallop = ast_variable_retrieve(cfg, "general", "operator"))){
- ast_log(LOG_DEBUG,"VM Operator break disabled globally\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"VM Operator break disabled globally\n");
astcallop = "no";
}
ast_set2_flag((&globalflags), ast_true(astcallop), VM_OPERATOR);
if (!(astsaycid = ast_variable_retrieve(cfg, "general", "saycid"))) {
- ast_log(LOG_DEBUG,"VM CID Info before msg disabled globally\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"VM CID Info before msg disabled globally\n");
astsaycid = "no";
}
ast_set2_flag((&globalflags), ast_true(astsaycid), VM_SAYCID);
if (!(send_voicemail = ast_variable_retrieve(cfg,"general", "sendvoicemail"))){
- ast_log(LOG_DEBUG,"Send Voicemail msg disabled globally\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"Send Voicemail msg disabled globally\n");
send_voicemail = "no";
}
ast_set2_flag((&globalflags), ast_true(send_voicemail), VM_SVMAIL);
if (!(asthearenv = ast_variable_retrieve(cfg, "general", "envelope"))) {
- ast_log(LOG_DEBUG,"ENVELOPE before msg enabled globally\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"ENVELOPE before msg enabled globally\n");
asthearenv = "yes";
}
ast_set2_flag((&globalflags), ast_true(asthearenv), VM_ENVELOPE);
if (!(astsaydurationinfo = ast_variable_retrieve(cfg, "general", "sayduration"))) {
- ast_log(LOG_DEBUG,"Duration info before msg enabled globally\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"Duration info before msg enabled globally\n");
astsaydurationinfo = "yes";
}
ast_set2_flag((&globalflags), ast_true(astsaydurationinfo), VM_SAYDURATION);
@@ -7098,28 +7138,32 @@ static int load_config(void)
}
if (!(astskipcmd = ast_variable_retrieve(cfg, "general", "nextaftercmd"))) {
- ast_log(LOG_DEBUG,"We are not going to skip to the next msg after save/delete\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"We are not going to skip to the next msg after save/delete\n");
astskipcmd = "no";
}
ast_set2_flag((&globalflags), ast_true(astskipcmd), VM_SKIPAFTERCMD);
if ((dialoutcxt = ast_variable_retrieve(cfg, "general", "dialout"))) {
ast_copy_string(dialcontext, dialoutcxt, sizeof(dialcontext));
- ast_log(LOG_DEBUG, "found dialout context: %s\n", dialcontext);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "found dialout context: %s\n", dialcontext);
} else {
dialcontext[0] = '\0';
}
if ((callbackcxt = ast_variable_retrieve(cfg, "general", "callback"))) {
ast_copy_string(callcontext, callbackcxt, sizeof(callcontext));
- ast_log(LOG_DEBUG, "found callback context: %s\n", callcontext);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "found callback context: %s\n", callcontext);
} else {
callcontext[0] = '\0';
}
if ((exitcxt = ast_variable_retrieve(cfg, "general", "exitcontext"))) {
ast_copy_string(exitcontext, exitcxt, sizeof(exitcontext));
- ast_log(LOG_DEBUG, "found operator context: %s\n", exitcontext);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "found operator context: %s\n", exitcontext);
} else {
exitcontext[0] = '\0';
}
diff --git a/apps/app_waitforsilence.c b/apps/app_waitforsilence.c
index ef0734cdc..55fc714f9 100644
--- a/apps/app_waitforsilence.c
+++ b/apps/app_waitforsilence.c
@@ -135,13 +135,15 @@ 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");
- ast_log(LOG_DEBUG, "WAITSTATUS was set to SILENCE\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "WAITSTATUS was set to SILENCE\n");
break;
}
if ( timeout && (difftime(time(&now),waitstart) >= timeout) ) {
pbx_builtin_setvar_helper(chan, "WAITSTATUS", "TIMEOUT");
- ast_log(LOG_DEBUG, "WAITSTATUS was set to TIMEOUT\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "WAITSTATUS was set to TIMEOUT\n");
res = 0;
break;
}
diff --git a/apps/app_zapbarge.c b/apps/app_zapbarge.c
index 735020f60..bd0637edf 100644
--- a/apps/app_zapbarge.c
+++ b/apps/app_zapbarge.c
@@ -172,7 +172,8 @@ zapretry:
if (ztc.confmode) {
/* Whoa, already in a conference... Retry... */
if (!retryzap) {
- ast_log(LOG_DEBUG, "Zap channel is in a conference already, retrying with pseudo\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Zap channel is in a conference already, retrying with pseudo\n");
retryzap = 1;
goto zapretry;
}
@@ -188,7 +189,8 @@ zapretry:
close(fd);
goto outrun;
}
- ast_log(LOG_DEBUG, "Placed channel %s in ZAP channel %d monitor\n", chan->name, confno);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Placed channel %s in ZAP channel %d monitor\n", chan->name, confno);
for(;;) {
outfd = -1;
@@ -200,7 +202,8 @@ zapretry:
/* Kill old pseudo */
close(fd);
}
- ast_log(LOG_DEBUG, "Ooh, something swapped out under us, starting over\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 de682f72c..9e841603c 100644
--- a/apps/app_zapras.c
+++ b/apps/app_zapras.c
@@ -153,7 +153,8 @@ static void run_ras(struct ast_channel *chan, char *args)
if (!res) {
/* Check for hangup */
if (chan->_softhangup && !signalled) {
- ast_log(LOG_DEBUG, "Channel '%s' hungup. Signalling RAS at %d to die...\n", chan->name, pid);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 690d9a5cc..86442b890 100644
--- a/apps/app_zapscan.c
+++ b/apps/app_zapscan.c
@@ -179,7 +179,8 @@ static int conf_run(struct ast_channel *chan, int confno, int confflags)
if (ztc.confmode) {
/* Whoa, already in a conference... Retry... */
if (!retryzap) {
- ast_log(LOG_DEBUG, "Zap channel is in a conference already, retrying with pseudo\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Zap channel is in a conference already, retrying with pseudo\n");
retryzap = 1;
goto zapretry;
}
@@ -195,7 +196,8 @@ static int conf_run(struct ast_channel *chan, int confno, int confflags)
close(fd);
goto outrun;
}
- ast_log(LOG_DEBUG, "Placed channel %s in ZAP channel %d monitor\n", chan->name, confno);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Placed channel %s in ZAP channel %d monitor\n", chan->name, confno);
for(;;) {
outfd = -1;
@@ -207,7 +209,8 @@ static int conf_run(struct ast_channel *chan, int confno, int confflags)
/* Kill old pseudo */
close(fd);
}
- ast_log(LOG_DEBUG, "Ooh, something swapped out under us, starting over\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 350620315..ffbfee27b 100644
--- a/cdr/cdr_csv.c
+++ b/cdr/cdr_csv.c
@@ -45,6 +45,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/channel.h"
#include "asterisk/cdr.h"
#include "asterisk/module.h"
+#include "asterisk/options.h"
#include "asterisk/logger.h"
#include "asterisk/utils.h"
@@ -121,7 +122,8 @@ static int load_config(void)
if (tmp) {
usegmtime = ast_true(tmp);
if (usegmtime) {
- ast_log(LOG_DEBUG, "logging time in GMT\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "logging time in GMT\n");
}
}
@@ -129,7 +131,8 @@ static int load_config(void)
if (tmp) {
loguniqueid = ast_true(tmp);
if (loguniqueid) {
- ast_log(LOG_DEBUG, "logging CDR field UNIQUEID\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "logging CDR field UNIQUEID\n");
}
}
@@ -137,7 +140,8 @@ static int load_config(void)
if (tmp) {
loguserfield = ast_true(tmp);
if (loguserfield) {
- ast_log(LOG_DEBUG, "logging CDR user-defined field\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "logging CDR user-defined field\n");
}
}
diff --git a/cdr/cdr_odbc.c b/cdr/cdr_odbc.c
index 6ff12120c..f916a8d85 100644
--- a/cdr/cdr_odbc.c
+++ b/cdr/cdr_odbc.c
@@ -306,12 +306,15 @@ static int odbc_load_module(void)
if (tmp) {
loguniqueid = ast_true(tmp);
if (loguniqueid) {
- ast_log(LOG_DEBUG,"cdr_odbc: Logging uniqueid\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"cdr_odbc: Logging uniqueid\n");
} else {
- ast_log(LOG_DEBUG,"cdr_odbc: Not logging uniqueid\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"cdr_odbc: Not logging uniqueid\n");
}
} else {
- ast_log(LOG_DEBUG,"cdr_odbc: Not logging uniqueid\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"cdr_odbc: Not logging uniqueid\n");
loguniqueid = 0;
}
@@ -319,12 +322,15 @@ static int odbc_load_module(void)
if (tmp) {
usegmtime = ast_true(tmp);
if (usegmtime) {
- ast_log(LOG_DEBUG,"cdr_odbc: Logging in GMT\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"cdr_odbc: Logging in GMT\n");
} else {
- ast_log(LOG_DEBUG,"cdr_odbc: Not logging in GMT\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"cdr_odbc: Not logging in GMT\n");
}
} else {
- ast_log(LOG_DEBUG,"cdr_odbc: Not logging in GMT\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"cdr_odbc: Not logging in GMT\n");
usegmtime = 0;
}
diff --git a/cdr/cdr_tds.c b/cdr/cdr_tds.c
index 2ac8481a8..b4d51729a 100644
--- a/cdr/cdr_tds.c
+++ b/cdr/cdr_tds.c
@@ -482,7 +482,8 @@ static int tds_load_module(void)
ptr = ast_variable_retrieve(cfg,"global","table");
if (ptr == NULL) {
- ast_log(LOG_DEBUG,"cdr_tds: table not specified. Assuming cdr\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"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 42d795a06..db545c4b5 100644
--- a/channels/chan_agent.c
+++ b/channels/chan_agent.c
@@ -194,10 +194,12 @@ 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) { \
- ast_log(LOG_DEBUG, "Native formats changing from %d to %d\n", 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); \
/* Native formats changed, reset things */ \
ast->nativeformats = p->chan->nativeformats; \
- ast_log(LOG_DEBUG, "Resetting read to %d and write to %d\n", ast->readformat, ast->writeformat);\
+ if (option_debug) \
+ ast_log(LOG_DEBUG, "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); \
} \
@@ -442,7 +444,7 @@ 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)
+ if (p->chan && option_debug)
ast_log(LOG_DEBUG, "Bridge on '%s' being cleared (2)\n", p->chan->name);
status = pbx_builtin_getvar_helper(p->chan, "CHANLOCALSTATUS");
@@ -513,7 +515,7 @@ 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)
+ 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);
}
}
@@ -559,9 +561,10 @@ static int agent_write(struct ast_channel *ast, struct ast_frame *f)
(f->subclass == p->chan->writeformat)) {
res = ast_write(p->chan, f);
} else {
- 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);
+ 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);
res = 0;
}
}
@@ -626,7 +629,8 @@ static int agent_call(struct ast_channel *ast, char *dest, int timeout)
p->acknowledged = 0;
if (!p->chan) {
if (p->pending) {
- ast_log(LOG_DEBUG, "Pretending to dial on pending agent\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Pretending to dial on pending agent\n");
newstate = AST_STATE_DIALING;
res = 0;
} else {
@@ -759,7 +763,8 @@ static int agent_hangup(struct ast_channel *ast)
ast_hangup(p->chan);
p->chan = NULL;
}
- ast_log(LOG_DEBUG, "Hungup, howlong is %d, autologoff is %d\n", howlong, p->autologoff);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Hungup, howlong is %d, autologoff is %d\n", howlong, p->autologoff);
if (howlong && p->autologoff && (howlong > p->autologoff)) {
long logintime = time(NULL) - p->loginstart;
p->loginstart = 0;
@@ -826,7 +831,7 @@ static int agent_cont_sleep( void *data )
}
ast_mutex_unlock(&p->lock);
- if(option_debug > 4 && !res )
+ if (option_debug > 4 && !res)
ast_log(LOG_DEBUG, "agent_cont_sleep() returning %d\n", res );
return res;
@@ -1177,13 +1182,14 @@ static int check_availability(struct agent_pvt *newlyavailable, int needlock)
res = 0;
} else {
if (option_debug > 2)
- ast_log( LOG_DEBUG, "Playing beep, lang '%s'\n", newlyavailable->chan->language);
+ ast_log(LOG_DEBUG, "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_log(LOG_DEBUG, "Played beep, result '%d'\n", res);
if (!res) {
res = ast_waitstream(newlyavailable->chan, "");
- ast_log( LOG_DEBUG, "Waited for stream, result '%d'\n", res);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Waited for stream, result '%d'\n", res);
}
}
if (!res) {
@@ -1220,7 +1226,8 @@ static int check_beep(struct agent_pvt *newlyavailable, int needlock)
struct agent_pvt *p;
int res=0;
- ast_log(LOG_DEBUG, "Checking beep availability of '%s'\n", newlyavailable->agent);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Checking beep availability of '%s'\n", newlyavailable->agent);
if (needlock)
AST_LIST_LOCK(&agents);
AST_LIST_TRAVERSE(&agents, p, list) {
@@ -1241,14 +1248,14 @@ static int check_beep(struct agent_pvt *newlyavailable, int needlock)
if (p) {
ast_mutex_unlock(&newlyavailable->lock);
if (option_debug > 2)
- ast_log( LOG_DEBUG, "Playing beep, lang '%s'\n", newlyavailable->chan->language);
+ ast_log(LOG_DEBUG, "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_log(LOG_DEBUG, "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_log(LOG_DEBUG, "Waited for stream, result '%d'\n", res);
}
ast_mutex_lock(&newlyavailable->lock);
}
@@ -1361,8 +1368,10 @@ static struct ast_channel *agent_request(const char *type, int format, void *dat
chan = agent_new(p, AST_STATE_DOWN);
if (!chan)
ast_log(LOG_WARNING, "Weird... Fix this to drop the unused pending agent\n");
- } else
- ast_log(LOG_DEBUG, "Not creating place holder for '%s' since nobody logged in\n", s);
+ } else {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Not creating place holder for '%s' since nobody logged in\n", s);
+ }
}
*cause = hasagent ? AST_CAUSE_BUSY : AST_CAUSE_UNREGISTERED;
AST_LIST_UNLOCK(&agents);
diff --git a/channels/chan_alsa.c b/channels/chan_alsa.c
index 15e0222b7..44dc22fc3 100644
--- a/channels/chan_alsa.c
+++ b/channels/chan_alsa.c
@@ -366,8 +366,10 @@ static snd_pcm_t *alsa_card_init(char *dev, snd_pcm_stream_t stream)
if (err < 0) {
ast_log(LOG_ERROR, "snd_pcm_open failed: %s\n", snd_strerror(err));
return NULL;
- } else
- ast_log(LOG_DEBUG, "Opening device %s in %s mode\n", dev, (stream == SND_PCM_STREAM_CAPTURE) ? "read" : "write");
+ } else {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Opening device %s in %s mode\n", dev, (stream == SND_PCM_STREAM_CAPTURE) ? "read" : "write");
+ }
snd_pcm_hw_params_alloca(&hwparams);
snd_pcm_hw_params_any(handle, hwparams);
@@ -393,15 +395,19 @@ static snd_pcm_t *alsa_card_init(char *dev, snd_pcm_stream_t stream)
err = snd_pcm_hw_params_set_period_size_near(handle, hwparams, &period_size, &direction);
if (err < 0)
ast_log(LOG_ERROR, "period_size(%ld frames) is bad: %s\n", period_size, snd_strerror(err));
- else
- ast_log(LOG_DEBUG, "Period size is %d\n", err);
+ else {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Period size is %d\n", err);
+ }
buffer_size = 4096 * 2; /* period_size * 16; */
err = snd_pcm_hw_params_set_buffer_size_near(handle, hwparams, &buffer_size);
if (err < 0)
ast_log(LOG_WARNING, "Problem setting buffer size of %ld: %s\n", buffer_size, snd_strerror(err));
- else
- ast_log(LOG_DEBUG, "Buffer size is set to %d frames\n", err);
+ else {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Buffer size is set to %d frames\n", err);
+ }
#if 0
direction = 0;
@@ -460,11 +466,14 @@ static snd_pcm_t *alsa_card_init(char *dev, snd_pcm_stream_t stream)
err = snd_pcm_poll_descriptors_count(handle);
if (err <= 0)
ast_log(LOG_ERROR, "Unable to get a poll descriptors count, error is %s\n", snd_strerror(err));
- if (err != 1)
- ast_log(LOG_DEBUG, "Can't handle more than one device\n");
+ if (err != 1) {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Can't handle more than one device\n");
+ }
snd_pcm_poll_descriptors(handle, &pfd, err);
- ast_log(LOG_DEBUG, "Acquired fd %d from the poll descriptor\n", pfd.fd);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Acquired fd %d from the poll descriptor\n", pfd.fd);
if (stream == SND_PCM_STREAM_CAPTURE)
readdev = pfd.fd;
@@ -628,7 +637,8 @@ 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
- ast_log(LOG_DEBUG, "XRUN write\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 273f349d6..3ed41ba76 100644
--- a/channels/chan_features.c
+++ b/channels/chan_features.c
@@ -209,7 +209,8 @@ static void swap_subs(struct feature_pvt *p, int a, int b)
int tinthreeway;
struct ast_channel *towner;
- ast_log(LOG_DEBUG, "Swapping %d and %d\n", a, b);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 9346d5ce8..c5a8483e4 100644
--- a/channels/chan_gtalk.c
+++ b/channels/chan_gtalk.c
@@ -597,7 +597,8 @@ static int gtalk_is_answered(struct gtalk *client, ikspak *pak)
{
struct gtalk_pvt *tmp;
char *from;
- ast_log(LOG_DEBUG, "The client is %s\n", client->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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))
@@ -675,7 +676,8 @@ static int gtalk_hangup_farend(struct gtalk *client, ikspak *pak)
struct gtalk_pvt *tmp;
char *from;
- ast_log(LOG_DEBUG, "The client is %s\n", client->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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))
@@ -1239,7 +1241,8 @@ 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))
- ast_log(LOG_DEBUG, "* Detected inband DTMF '%c'\n", f->subclass);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "* Detected inband DTMF '%c'\n", f->subclass);
} */
}
}
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 4ea3bd831..99949ed9a 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -1177,7 +1177,8 @@ static int make_trunk(unsigned short callno, int locked)
ast_log(LOG_WARNING, "Unable to trunk call: Insufficient space\n");
return -1;
}
- ast_log(LOG_DEBUG, "Made call %d into trunk call %d\n", callno, x);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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();
@@ -2274,7 +2275,8 @@ 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
- ast_log(LOG_DEBUG, "schedule_delivery: set delivery to 0 as we don't have an rxcore yet, or frame is from trunk.\n");
+ 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");
#endif
fr->af.delivery = ast_tv(0,0);
}
@@ -2903,7 +2905,8 @@ static int iax2_hangup(struct ast_channel *c)
memset(&ied, 0, sizeof(ied));
ast_mutex_lock(&iaxsl[callno]);
if (callno && iaxs[callno]) {
- ast_log(LOG_DEBUG, "We're hanging up %s now...\n", c->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
@@ -2913,7 +2916,8 @@ static int iax2_hangup(struct ast_channel *c)
iax2_predestroy(callno);
/* If we were already gone to begin with, destroy us now */
if (alreadygone) {
- ast_log(LOG_DEBUG, "Really destroying %s now...\n", c->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Really destroying %s now...\n", c->name);
iax2_destroy(callno);
}
}
@@ -3509,7 +3513,8 @@ 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
- ast_log(LOG_DEBUG, "Created trunk peer for '%s:%d'\n", ast_inet_ntoa(tpeer->addr.sin_addr), ntohs(tpeer->addr.sin_port));
+ 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_LIST_INSERT_TAIL(&tpeers, tpeer, list);
}
}
@@ -3540,7 +3545,8 @@ static int iax2_trunk_queue(struct chan_iax2_pvt *pvt, struct iax_frame *fr)
tpeer->trunkdataalloc += DEFAULT_TRUNKDATA;
tpeer->trunkdata = tmp;
- 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);
+ 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);
} 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);
@@ -4471,7 +4477,8 @@ 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 {
- ast_log(LOG_DEBUG, "Write error: %s\n", strerror(errno));
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Write error: %s\n", strerror(errno));
}
}
/* If it's already gone, just return */
@@ -5455,7 +5462,8 @@ static void __expire_registry(void *data)
if (!p)
return;
- ast_log(LOG_DEBUG, "Expiring registration for peer '%s'\n", p->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
@@ -5869,7 +5877,8 @@ 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
- 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));
+ 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));
#endif
/* Reset transmit trunk side data */
tpeer->trunkdatalen = 0;
@@ -5944,7 +5953,8 @@ 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 */
- ast_log(LOG_DEBUG, "Dropping unused iax2 trunk peer '%s:%d'\n", ast_inet_ntoa(drop->addr.sin_addr), ntohs(drop->addr.sin_port));
+ 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));
free(drop->trunkdata);
ast_mutex_unlock(&drop->lock);
ast_mutex_destroy(&drop->lock);
@@ -6561,8 +6571,10 @@ static int socket_process(struct iax2_thread *thread)
ast_mutex_unlock(&iaxsl[fr->callno]);
return 1;
}
- } else
- ast_log(LOG_DEBUG, "Received iseqno %d not within window %d->%d\n", fr->iseqno, iaxs[fr->callno]->rseqno, iaxs[fr->callno]->oseqno);
+ } 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);
+ }
}
if (inaddrcmp(&sin, &iaxs[fr->callno]->addr) &&
((f.frametype != AST_FRAME_IAX) ||
@@ -6593,7 +6605,8 @@ 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;
- ast_log(LOG_DEBUG, "Ooh, voice format changed to %d\n", f.subclass);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Ooh, voice format changed to %d\n", f.subclass);
if (iaxs[fr->callno]->owner) {
int orignative;
retryowner:
@@ -6613,7 +6626,8 @@ retryowner:
ast_mutex_unlock(&iaxs[fr->callno]->owner->lock);
}
} else {
- ast_log(LOG_DEBUG, "Neat, somebody took away the channel at a magical time but i found it!\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Neat, somebody took away the channel at a magical time but i found it!\n");
ast_mutex_unlock(&iaxsl[fr->callno]);
return 1;
}
@@ -6622,7 +6636,8 @@ retryowner:
}
if (f.frametype == AST_FRAME_VIDEO) {
if (f.subclass != iaxs[fr->callno]->videoformat) {
- ast_log(LOG_DEBUG, "Ooh, video format changed to %d\n", f.subclass & ~0x1);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Ooh, video format changed to %d\n", f.subclass & ~0x1);
iaxs[fr->callno]->videoformat = f.subclass & ~0x1;
}
}
@@ -6888,7 +6903,8 @@ retryowner:
break;
case IAX_COMMAND_HANGUP:
ast_set_flag(iaxs[fr->callno], IAX_ALREADYGONE);
- ast_log(LOG_DEBUG, "Immediately destroying %d, having received hangup\n", fr->callno);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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;
@@ -6906,8 +6922,9 @@ 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>");
- ast_log(LOG_DEBUG, "Immediately destroying %d, having received reject\n",
- fr->callno);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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,
@@ -6924,18 +6941,24 @@ retryowner:
if (!strcmp(ies.called_number, ast_parking_ext())) {
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
- ast_log(LOG_DEBUG, "Parked call on '%s'\n", ast_bridged_channel(iaxs[fr->callno]->owner)->name);
+ } else {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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
- 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);
+ 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);
+ }
}
- } else
+ } else {
+ if (option_debug)
ast_log(LOG_DEBUG, "Async goto not applicable on call %d\n", fr->callno);
+ }
break;
case IAX_COMMAND_ACCEPT:
/* Ignore if call is already up or needs authentication or is a TBD */
@@ -7146,7 +7169,8 @@ retryowner2:
}
if (!format) {
if(!ast_test_flag(iaxs[fr->callno], IAX_CODEC_NOCAP)) {
- 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);
+ 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);
format = iaxs[fr->callno]->peercapability & iaxs[fr->callno]->capability;
}
if (!format) {
@@ -7265,13 +7289,15 @@ retryowner2:
break;
case IAX_COMMAND_INVAL:
iaxs[fr->callno]->error = ENOTCONN;
- ast_log(LOG_DEBUG, "Immediately destroying %d, having received INVAL\n", fr->callno);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
break;
case IAX_COMMAND_VNAK:
- ast_log(LOG_DEBUG, "Received VNAK: resending outstanding frames\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Received VNAK: resending outstanding frames\n");
/* Force retransmission */
vnak_retransmit(fr->callno, fr->iseqno);
break;
@@ -7427,7 +7453,8 @@ retryowner2:
send_command(iaxs[fr->callno], AST_FRAME_IAX, IAX_COMMAND_FWDATA, 0, ied0.buf, ied0.pos, -1);
break;
default:
- ast_log(LOG_DEBUG, "Unknown IAX command %d on %d/%d\n", f.subclass, fr->callno, iaxs[fr->callno]->peercallno);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
@@ -7693,7 +7720,8 @@ static int iax2_provision(struct sockaddr_in *end, int sockfd, char *dest, const
ast_log(LOG_DEBUG, "Provisioning '%s' from template '%s'\n", dest, template);
if (iax_provision_build(&provdata, &sig, template, force)) {
- ast_log(LOG_DEBUG, "No provisioning found for template '%s'\n", template);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "No provisioning found for template '%s'\n", template);
return 0;
}
@@ -7973,7 +8001,7 @@ static void *sched_thread(void *ignore)
pthread_testcancel();
count = ast_sched_runq(sched);
- if (count >= 20)
+ if (count >= 20 && option_debug)
ast_log(LOG_DEBUG, "chan_iax2: ast_sched_runq ran %d scheduled tasks all at once\n", count);
}
@@ -8021,13 +8049,13 @@ static void *network_thread(void *ignore)
AST_LIST_TRAVERSE_SAFE_END
AST_LIST_UNLOCK(&iaxq.queue);
- if (count >= 20)
+ if (count >= 20 && option_debug)
ast_log(LOG_DEBUG, "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, -1);
if (res >= 0) {
- if (res >= 20)
+ if (res >= 20 && option_debug)
ast_log(LOG_DEBUG, "chan_iax2: ast_io_wait ran %d I/Os all at once\n", res);
}
}
@@ -8101,7 +8129,8 @@ static int check_srcaddr(struct sockaddr *sa, socklen_t salen)
res = bind(sd, sa, salen);
if (res < 0) {
- ast_log(LOG_DEBUG, "Can't bind: %s\n", strerror(errno));
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Can't bind: %s\n", strerror(errno));
close(sd);
return 1;
}
@@ -8160,7 +8189,8 @@ static int peer_set_srcaddr(struct iax2_peer *peer, const char *srcaddr)
srcaddr, peer->name);
return -1;
} else {
- ast_log(LOG_DEBUG, "Using sourceaddress %s for '%s'\n", srcaddr, peer->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Using sourceaddress %s for '%s'\n", srcaddr, peer->name);
return 0;
}
}
@@ -9125,8 +9155,9 @@ static int cache_get_callno_locked(const char *data)
if (create_addr(pds.peer, &sin, &cai))
return -1;
- ast_log(LOG_DEBUG, "peer: %s, username: %s, password: %s, context: %s\n",
- pds.peer, pds.username, pds.password, pds.context);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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) {
diff --git a/channels/chan_jingle.c b/channels/chan_jingle.c
index 6b09815fb..20fa6d083 100644
--- a/channels/chan_jingle.c
+++ b/channels/chan_jingle.c
@@ -487,7 +487,8 @@ static int jingle_is_answered(struct jingle *client, ikspak *pak)
{
struct jingle_pvt *tmp;
- ast_log(LOG_DEBUG, "The client is %s\n", client->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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))
@@ -555,7 +556,8 @@ static int jingle_hangup_farend(struct jingle *client, ikspak *pak)
{
struct jingle_pvt *tmp;
- ast_log(LOG_DEBUG, "The client is %s\n", client->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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))
diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c
index fbdf74982..cd2cad804 100644
--- a/channels/chan_mgcp.c
+++ b/channels/chan_mgcp.c
@@ -462,7 +462,8 @@ 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;
}
- ast_log(LOG_DEBUG, "Released sub %d of channel %s@%s\n", sub->id, p->name, p->parent->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Released sub %d of channel %s@%s\n", sub->id, p->name, p->parent->name);
sub->owner = NULL;
if (!ast_strlen_zero(sub->cxident)) {
@@ -725,7 +726,8 @@ static int mgcp_postrequest(struct mgcp_endpoint *p, struct mgcp_subchannel *sub
/* XXX Should schedule retransmission XXX */
/* SC
} else
- ast_log(LOG_DEBUG, "Deferring transmission of transaction %d\n", seqno);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Deferring transmission of transaction %d\n", seqno);
*/
return 0;
}
@@ -738,7 +740,8 @@ static int send_request(struct mgcp_endpoint *p, struct mgcp_subchannel *sub,
struct mgcp_request **queue, *q, *r, *t;
ast_mutex_t *l;
- ast_log(LOG_DEBUG, "Slow sequence is %d\n", p->slowsequence);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Slow sequence is %d\n", p->slowsequence);
if (p->slowsequence) {
queue = &p->cmd_queue;
l = &p->cmd_queue_lock;
@@ -918,11 +921,13 @@ static int mgcp_hangup(struct ast_channel *ast)
ast_log(LOG_DEBUG, "mgcp_hangup(%s)\n", ast->name);
}
if (!ast->tech_pvt) {
- ast_log(LOG_DEBUG, "Asked to hangup channel not connected\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Asked to hangup channel not connected\n");
return 0;
}
if (strcmp(sub->magic, MGCP_SUBCHANNEL_MAGIC)) {
- ast_log(LOG_DEBUG, "Invalid magic. MGCP subchannel freed up already.\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Invalid magic. MGCP subchannel freed up already.\n");
return 0;
}
ast_mutex_lock(&sub->lock);
@@ -1195,7 +1200,8 @@ 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) {
- ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
@@ -1670,8 +1676,9 @@ static struct mgcp_subchannel *find_subchannel_and_lock(char *name, int msgid, s
/* SC */
break;
} else if (name && !strcasecmp(p->name, tmp)) {
- ast_log(LOG_DEBUG, "Coundn't determine subchannel, assuming current master %s@%s-%d\n",
- p->name, g->name, p->sub->id);
+ 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);
sub = p->sub;
found = 1;
break;
@@ -2616,7 +2623,8 @@ static void *mgcp_ss(void *data)
res = ast_waitfordigit(chan, timeout);
timeout = 0;
if (res < 0) {
- ast_log(LOG_DEBUG, "waitfordigit returned < 0...\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "waitfordigit returned < 0...\n");
/*res = tone_zone_play_tone(p->subs[index].zfd, -1);*/
ast_indicate(chan, -1);
ast_hangup(chan);
@@ -2684,7 +2692,8 @@ static void *mgcp_ss(void *data)
timeout = matchdigittimeout;
}
} else if (res == 0) {
- ast_log(LOG_DEBUG, "not enough digits (and no ambiguous match)...\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);*/
@@ -2820,11 +2829,13 @@ static void *mgcp_ss(void *data)
for (;;) {
res = ast_waitfordigit(chan, to);
if (!res) {
- ast_log(LOG_DEBUG, "Timeout...\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Timeout...\n");
break;
}
if (res < 0) {
- ast_log(LOG_DEBUG, "Got hangup...\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Got hangup...\n");
ast_hangup(chan);
break;
}
@@ -2901,8 +2912,9 @@ static int attempt_transfer(struct mgcp_endpoint *p)
/* Tell the caller not to hangup */
return 1;
} else {
- 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);
+ 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);
p->sub->next->owner->_softhangup |= AST_SOFTHANGUP_DEV;
if (p->sub->next->owner) {
p->sub->next->alreadygone = 1;
@@ -3068,7 +3080,8 @@ 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;
- ast_log(LOG_DEBUG, "Endpoint '%s@%s-%d' observed '%s'\n", p->name, p->parent->name, sub->id, ev);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
@@ -3166,7 +3179,8 @@ 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;
- ast_log(LOG_DEBUG, "MGCP %s@%s Went on hook\n", p->name, p->parent->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
@@ -3333,7 +3347,8 @@ 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) {
- ast_log(LOG_DEBUG, "Got response back on transaction %d\n", ident);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 c1a0f0dfc..2288b1d8c 100644
--- a/channels/chan_misdn.c
+++ b/channels/chan_misdn.c
@@ -647,9 +647,8 @@ static void send_digit_to_chan(struct chan_list *cl, char digit )
ast_playtones_start(chan,0,dtmf_tones[15], 0);
else {
/* not handled */
- ast_log(LOG_DEBUG, "Unable to handle DTMF tone '%c' for '%s'\n", digit, chan->name);
-
-
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Unable to handle DTMF tone '%c' for '%s'\n", digit, chan->name);
}
}
/*** CLI HANDLING ***/
@@ -2223,8 +2222,9 @@ static int misdn_hangup(struct ast_channel *ast)
{
struct chan_list *p;
struct misdn_bchannel *bc=NULL;
-
- ast_log(LOG_DEBUG, "misdn_hangup(%s)\n", ast->name);
+
+ if (option_debug)
+ ast_log(LOG_DEBUG, "misdn_hangup(%s)\n", ast->name);
if (!ast || ! (p=MISDN_ASTERISK_TECH_PVT(ast) ) ) return -1;
@@ -2248,7 +2248,8 @@ static int misdn_hangup(struct ast_channel *ast)
if (ast->_state == AST_STATE_RESERVED || p->state == MISDN_NOTHING) {
/* between request and call */
- ast_log(LOG_DEBUG, "State Reserved (or nothing) => chanIsAvail\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "State Reserved (or nothing) => chanIsAvail\n");
MISDN_ASTERISK_TECH_PVT(ast)=NULL;
cl_dequeue_chan(&cl_te, p);
@@ -2392,7 +2393,8 @@ static struct ast_frame *process_ast_dsp(struct chan_list *tmp, struct ast_frame
if (!f || (f->frametype != AST_FRAME_DTMF))
return frame;
- ast_log(LOG_DEBUG, "Detected inband DTMF digit: %c\n", f->subclass);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Detected inband DTMF digit: %c\n", f->subclass);
if (tmp->faxdetect && (f->subclass == 'f')) {
/* Fax tone -- Handle and return NULL */
@@ -2423,15 +2425,19 @@ static struct ast_frame *process_ast_dsp(struct chan_list *tmp, struct ast_frame
ast_log(LOG_WARNING, "Failed to async goto '%s' into fax of '%s'\n", ast->name, context);
} else
ast_log(LOG_NOTICE, "Fax detected, but no fax extension ctx:%s exten:%s\n", context, ast->exten);
- } else
- ast_log(LOG_DEBUG, "Already in a fax extension, not redirecting\n");
+ } else {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Already in a fax extension, not redirecting\n");
+ }
break;
case 2:
ast_verbose(VERBOSE_PREFIX_3 "Not redirecting %s to fax extension, nojump is set.\n", ast->name);
break;
}
- } else
- ast_log(LOG_DEBUG, "Fax already handled\n");
+ } else {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Fax already handled\n");
+ }
}
if (tmp->ast_dsp && (f->subclass != 'f')) {
diff --git a/channels/chan_nbs.c b/channels/chan_nbs.c
index 30ee32346..340ed2475 100644
--- a/channels/chan_nbs.c
+++ b/channels/chan_nbs.c
@@ -201,7 +201,8 @@ static struct ast_frame *nbs_xread(struct ast_channel *ast)
p->fr.delivery.tv_sec = 0;
p->fr.delivery.tv_usec = 0;
- ast_log(LOG_DEBUG, "Returning null frame on %s\n", ast->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Returning null frame on %s\n", ast->name);
return &p->fr;
}
diff --git a/channels/chan_phone.c b/channels/chan_phone.c
index 6e658ad3a..a6e3d7b45 100644
--- a/channels/chan_phone.c
+++ b/channels/chan_phone.c
@@ -214,7 +214,8 @@ static int phone_indicate(struct ast_channel *chan, int condition, const void *d
{
struct phone_pvt *p = chan->tech_pvt;
int res=-1;
- ast_log(LOG_DEBUG, "Requested indication %d on channel %s\n", condition, chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
@@ -370,8 +371,10 @@ 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))
- 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)) {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "ioctl(PHONE_PSTN_SET_STATE) failed on %s (%s)\n",ast->name, strerror(errno));
+ }
}
/* If they're off hook, give a busy signal */
@@ -466,10 +469,14 @@ 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))
- ast_log(LOG_DEBUG, "ioctl(PHONE_PSTN_SET_STATE) failed on %s (%s)\n", ast->name, strerror(errno));
- else
- ast_log(LOG_DEBUG, "Took linejack off hook\n");
+ 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");
+ }
}
phone_setup(ast);
if (option_debug)
@@ -919,7 +926,8 @@ static void phone_check_exception(struct phone_pvt *i)
union telephony_exception phonee;
/* XXX Do something XXX */
#if 0
- ast_log(LOG_DEBUG, "Exception!\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Exception!\n");
#endif
phonee.bytes = ioctl(i->fd, PHONE_EXCEPTION);
if (phonee.bits.dtmf_ready) {
@@ -1085,7 +1093,8 @@ static void *do_monitor(void *data)
}
/* Okay, select has finished. Let's see what happened. */
if (res < 0) {
- ast_log(LOG_DEBUG, "select return %d: %s\n", res, strerror(errno));
+ if (option_debug)
+ ast_log(LOG_DEBUG, "select return %d: %s\n", res, strerror(errno));
continue;
}
/* If there are no fd's changed, just continue, it's probably time
@@ -1172,8 +1181,10 @@ static struct phone_pvt *mkif(char *iface, int mode, int txgain, int rxgain)
return NULL;
}
if (mode == MODE_FXO) {
- if (ioctl(tmp->fd, IXJCTL_PORT, PORT_PSTN))
- ast_log(LOG_DEBUG, "Unable to set port to PSTN\n");
+ if (ioctl(tmp->fd, IXJCTL_PORT, PORT_PSTN)) {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Unable to set port to PSTN\n");
+ }
} else {
if (ioctl(tmp->fd, IXJCTL_PORT, PORT_POTS))
if (mode != MODE_FXS)
@@ -1183,8 +1194,10 @@ static struct phone_pvt *mkif(char *iface, int mode, int txgain, int rxgain)
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))
- 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)) {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 21ce89647..78ebc97c7 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -1569,7 +1569,7 @@ static char *referstatus2str(enum referstatus rstatus)
a dialog */
static void initialize_initreq(struct sip_pvt *p, struct sip_request *req)
{
- if (p->initreq.headers) {
+ if (p->initreq.headers && option_debug) {
ast_log(LOG_DEBUG, "Initializing already initialized SIP dialog %s (presumably reinvite)\n", p->callid);
}
/* Use this as the basis */
@@ -2002,7 +2002,8 @@ static void __sip_ack(struct sip_pvt *p, int seqno, int resp, int sipmethod, int
((ast_test_flag(cur, FLAG_RESPONSE)) ||
(!strncasecmp(msg, cur->data, strlen(msg)) && (cur->data[strlen(msg)] < 33)))) {
if (!resp && (seqno == p->pendinginvite)) {
- ast_log(LOG_DEBUG, "Acked pending invite %d\n", p->pendinginvite);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Acked pending invite %d\n", p->pendinginvite);
p->pendinginvite = 0;
}
/* this is our baby */
@@ -3148,7 +3149,8 @@ static const char *hangup_cause2sip(int cause)
case AST_CAUSE_NOTDEFINED:
default:
- ast_log(LOG_DEBUG, "AST hangup cause %d (no match found in SIP)\n", cause);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "AST hangup cause %d (no match found in SIP)\n", cause);
return NULL;
}
@@ -3167,7 +3169,8 @@ static int sip_hangup(struct ast_channel *ast)
struct ast_channel *oldowner = ast;
if (!p) {
- ast_log(LOG_DEBUG, "Asked to hangup channel that was not connected\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Asked to hangup channel that was not connected\n");
return 0;
}
@@ -3186,8 +3189,10 @@ static int sip_hangup(struct ast_channel *ast)
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
- ast_log(LOG_DEBUG, "Hangup call %s, SIP callid %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");
@@ -3433,9 +3438,9 @@ 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))
+ 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))
+ if (oldchan && ast_test_flag(oldchan, AST_FLAG_ZOMBIE) && option_debug)
ast_log(LOG_DEBUG, "Old channel is zombie\n");
if (!newchan || !newchan->tech_pvt) {
@@ -4764,7 +4769,8 @@ 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;
- ast_log(LOG_DEBUG, "Can't read framing from SDP: %s\n", a);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Can't read framing from SDP: %s\n", a);
}
}
if (framing && last_rtpmap_codec) {
@@ -7002,7 +7008,8 @@ 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);
- ast_log(LOG_DEBUG, "Scheduled a registration timeout for %s id #%d \n", r->hostname, r->timeout);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Scheduled a registration timeout for %s id #%d \n", r->hostname, r->timeout);
}
if (strchr(r->username, '@')) {
@@ -7611,7 +7618,8 @@ 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) {
- ast_log(LOG_DEBUG, "build_route: Retaining previous route: <%s>\n", p->route->hop);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "build_route: Retaining previous route: <%s>\n", p->route->hop);
return;
}
@@ -8208,7 +8216,8 @@ 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)) {
- ast_log(LOG_DEBUG, "Got SIP %s to non-local domain '%s'; refusing request.\n", sip_methods[req->method].text, p->domain);
+ 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);
return -2;
}
}
@@ -8861,15 +8870,18 @@ static enum check_auth_result check_user_full(struct sip_pvt *p, struct sip_requ
}
usenatroute = ast_test_flag(&p->flags[0], SIP_NAT_ROUTE);
if (p->rtp) {
- ast_log(LOG_DEBUG, "Setting NAT on RTP to %s\n", usenatroute ? "On" : "Off");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Setting NAT on RTP to %s\n", usenatroute ? "On" : "Off");
ast_rtp_setnat(p->rtp, usenatroute);
}
if (p->vrtp) {
- ast_log(LOG_DEBUG, "Setting NAT on VRTP to %s\n", usenatroute ? "On" : "Off");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Setting NAT on VRTP to %s\n", usenatroute ? "On" : "Off");
ast_rtp_setnat(p->vrtp, usenatroute);
}
if (p->udptl) {
- ast_log(LOG_DEBUG, "Setting NAT on UDPTL to %s\n", usenatroute ? "On" : "Off");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Setting NAT on UDPTL to %s\n", usenatroute ? "On" : "Off");
ast_udptl_setnat(p->udptl, usenatroute);
}
ast_string_field_set(p, peersecret, peer->secret);
@@ -10409,6 +10421,11 @@ static void sip_dump_history(struct sip_pvt *dialog)
if (!dialog)
return;
+ if (!option_debug && !sipdebug) {
+ ast_log(LOG_NOTICE, "You must have debugging enabled (SIP or Asterisk) in order to dump SIP history.\n");
+ return;
+ }
+
ast_log(LOG_DEBUG, "\n---------- SIP HISTORY for '%s' \n", dialog->callid);
if (dialog->subscribed)
ast_log(LOG_DEBUG, " * Subscription\n");
@@ -11220,7 +11237,8 @@ static void parse_moved_contact(struct sip_pvt *p, struct sip_request *req)
e = strchr(s, '/');
if (e)
*e = '\0';
- ast_log(LOG_DEBUG, "Found promiscuous redirection to 'SIP/%s'\n", s);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Found promiscuous redirection to 'SIP/%s'\n", s);
if (p->owner)
ast_string_field_build(p->owner, call_forward, "SIP/%s", s);
} else {
@@ -11284,7 +11302,8 @@ static void handle_response_invite(struct sip_pvt *p, int resp, char *rest, stru
}
if (ast_test_flag(&p->flags[0], SIP_ALREADYGONE)) { /* This call is already gone */
- ast_log(LOG_DEBUG, "Got response on call that is already terminated: %s (ignoring)\n", p->callid);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Got response on call that is already terminated: %s (ignoring)\n", p->callid);
return;
}
@@ -11602,9 +11621,11 @@ 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", "ChannelDriver: SIP\r\nDomain: %s\r\nStatus: %s\r\n", r->hostname, regstate2str(r->regstate));
r->regattempts = 0;
- ast_log(LOG_DEBUG, "Registration successful\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Registration successful\n");
if (r->timeout > -1) {
- ast_log(LOG_DEBUG, "Cancelling timeout %d\n", r->timeout);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Cancelling timeout %d\n", r->timeout);
ast_sched_del(sched, r->timeout);
}
r->timeout=-1;
@@ -11883,7 +11904,8 @@ 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 {
- ast_log(LOG_DEBUG, "Got 491 on %s, unspported. Call ID %s\n", sip_methods[sipmethod].text, p->callid);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Got 491 on %s, unspported. Call ID %s\n", sip_methods[sipmethod].text, p->callid);
ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
}
break;
@@ -11944,7 +11966,8 @@ 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... */
- ast_log(LOG_DEBUG, "Hairpin detected, setting up call forward for what it's worth\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
@@ -12010,7 +12033,8 @@ 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) {
- ast_log(LOG_DEBUG, "Got 200 OK on CANCEL\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Got 200 OK on CANCEL\n");
/* Wait for 487, then destroy */
} else if (sipmethod == SIP_NOTIFY) {
@@ -12235,10 +12259,14 @@ static int sip_park(struct ast_channel *chan1, struct ast_channel *chan2, struct
}
ast_channel_unlock(transferer);
if (!transferer || !transferee) {
- if (!transferer)
- ast_log(LOG_DEBUG, "No transferer channel, giving up parking\n");
- if (!transferee)
- ast_log(LOG_DEBUG, "No transferee channel, giving up parking\n");
+ if (!transferer) {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "No transferer channel, giving up parking\n");
+ }
+ if (!transferee) {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "No transferee channel, giving up parking\n");
+ }
return -1;
}
if ((d = ast_calloc(1, sizeof(*d)))) {
@@ -12874,7 +12902,8 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
}
} else {
p->jointcapability = p->capability;
- ast_log(LOG_DEBUG, "Hm.... No sdp for the moment\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Hm.... No sdp for the moment\n");
}
if (recordhistory) /* This is a response, note what it was for */
append_history(p, "ReInv", "Re-invite received");
@@ -13269,7 +13298,8 @@ 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) {
- ast_log(LOG_DEBUG, "SIP attended transfer: Unlocking channel %s\n", targetcall_pvt->owner->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "SIP attended transfer: Unlocking channel %s\n", targetcall_pvt->owner->name);
ast_channel_unlock(targetcall_pvt->owner);
}
}
@@ -13397,13 +13427,13 @@ 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))
+ 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");
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))
+ if (ast_test_flag(req, SIP_PKT_DEBUG) && option_debug)
ast_log(LOG_DEBUG, "SIP transfer to non-SIP uri denied\n");
break;
default:
@@ -13412,7 +13442,7 @@ 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))
+ 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);
break;
}
@@ -13770,13 +13800,16 @@ 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 */
- 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);
+ 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);
return 0;
} else if (ast_test_flag(req, SIP_PKT_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 (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);
+ }
}
}
@@ -15041,7 +15074,8 @@ static struct sip_auth *add_realm_authentication(struct sip_auth *authlist, char
if (ast_strlen_zero(configuration))
return authlist;
- ast_log(LOG_DEBUG, "Auth config :: %s\n", configuration);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Auth config :: %s\n", configuration);
ast_copy_string(authcopy, configuration, sizeof(authcopy));
stringp = authcopy;
diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c
index 232bfd1ca..57fb071e8 100644
--- a/channels/chan_skinny.c
+++ b/channels/chan_skinny.c
@@ -2297,7 +2297,8 @@ static void *skinny_ss(void *data)
timeout = matchdigittimeout;
}
} else if (res == 0) {
- ast_log(LOG_DEBUG, "Not enough digits (and no ambiguous match)...\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Not enough digits (and no ambiguous match)...\n");
transmit_tone(s, SKINNY_REORDER);
ast_hangup(c);
return NULL;
@@ -2384,7 +2385,8 @@ static int skinny_hangup(struct ast_channel *ast)
struct skinnysession *s;
if (!sub) {
- ast_log(LOG_DEBUG, "Asked to hangup channel not connected\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Asked to hangup channel not connected\n");
return 0;
}
l = sub->parent;
@@ -2487,7 +2489,8 @@ 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) {
- ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
@@ -3161,7 +3164,8 @@ static int handle_stimulus_message(struct skinny_req *req, struct skinnysession
ast_setstate(sub->owner, AST_STATE_UP);
} else {
if (sub && sub->owner) {
- ast_log(LOG_DEBUG, "Current subchannel [%s] already has owner\n", sub->owner->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Current subchannel [%s] already has owner\n", sub->owner->name);
} else {
c = skinny_new(l, AST_STATE_DOWN);
if(c) {
@@ -3237,7 +3241,8 @@ static int handle_offhook_message(struct skinny_req *req, struct skinnysession *
ast_setstate(sub->owner, AST_STATE_UP);
} else {
if (sub && sub->owner) {
- ast_log(LOG_DEBUG, "Current sub [%s] already has owner\n", sub->owner->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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_zap.c b/channels/chan_zap.c
index e0d2308ef..da1d48233 100644
--- a/channels/chan_zap.c
+++ b/channels/chan_zap.c
@@ -975,7 +975,8 @@ static void swap_subs(struct zt_pvt *p, int a, int b)
int tinthreeway;
struct ast_channel *towner;
- ast_log(LOG_DEBUG, "Swapping %d and %d\n", a, b);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Swapping %d and %d\n", a, b);
tchan = p->subs[a].chan;
towner = p->subs[a].owner;
@@ -1095,7 +1096,8 @@ 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;
}
- ast_log(LOG_DEBUG, "Released sub %d of channel %d\n", x, p->channel);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Released sub %d of channel %d\n", x, p->channel);
if (p->subs[x].zfd > -1) {
zt_close(p->subs[x].zfd);
}
@@ -1150,7 +1152,8 @@ 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;
- ast_log(LOG_DEBUG, "Queueing digit '%c' since setup_ack not yet received\n", digit);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Queueing digit '%c' since setup_ack not yet received\n", digit);
res = strlen(pvt->dialdest);
pvt->dialdest[res++] = digit;
pvt->dialdest[res] = '\0';
@@ -1174,7 +1177,8 @@ static int zt_digit_begin(struct ast_channel *chan, char digit)
else
pvt->dialing = 1;
} else {
- ast_log(LOG_DEBUG, "Started VLDTMF digit '%c'\n", digit);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Started VLDTMF digit '%c'\n", digit);
pvt->dialing = 1;
pvt->begindigit = digit;
}
@@ -1209,7 +1213,8 @@ static int zt_digit_end(struct ast_channel *chan, char digit)
if (pvt->begindigit) {
x = -1;
- ast_log(LOG_DEBUG, "Ending VLDTMF digit '%c'\n", digit);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Ending VLDTMF digit '%c'\n", digit);
res = ioctl(pvt->subs[SUB_REAL].zfd, ZT_SENDTONE, &x);
pvt->dialing = 0;
pvt->begindigit = 0;
@@ -1383,7 +1388,8 @@ 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));
- ast_log(LOG_DEBUG, "Added %d to conference %d/%d\n", c->zfd, c->curconf.confmode, c->curconf.confno);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Added %d to conference %d/%d\n", c->zfd, c->curconf.confmode, c->curconf.confno);
return 0;
}
@@ -1415,7 +1421,8 @@ 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;
}
- ast_log(LOG_DEBUG, "Removed %d from conference %d/%d\n", c->zfd, c->curconf.confmode, c->curconf.confno);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Removed %d from conference %d/%d\n", c->zfd, c->curconf.confmode, c->curconf.confno);
memcpy(&c->curconf, &zi, sizeof(c->curconf));
return 0;
}
@@ -1529,7 +1536,8 @@ static int update_conf(struct zt_pvt *p)
Kill it. */
p->confno = -1;
}
- ast_log(LOG_DEBUG, "Updated conferencing on %d, with %d conference users\n", p->channel, needconf);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Updated conferencing on %d, with %d conference users\n", p->channel, needconf);
return 0;
}
@@ -1540,11 +1548,13 @@ static void zt_enable_ec(struct zt_pvt *p)
if (!p)
return;
if (p->echocanon) {
- ast_log(LOG_DEBUG, "Echo cancellation already on\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Echo cancellation already on\n");
return;
}
if (p->digital) {
- ast_log(LOG_DEBUG, "Echo cancellation isn't required on digital connection\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Echo cancellation isn't required on digital connection\n");
return;
}
if (p->echocancel) {
@@ -1560,10 +1570,13 @@ 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;
- ast_log(LOG_DEBUG, "Enabled echo cancellation on channel %d\n", p->channel);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Enabled echo cancellation on channel %d\n", p->channel);
}
- } else
- ast_log(LOG_DEBUG, "No echo cancellation requested\n");
+ } else {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "No echo cancellation requested\n");
+ }
}
static void zt_train_ec(struct zt_pvt *p)
@@ -1576,10 +1589,13 @@ static void zt_train_ec(struct zt_pvt *p)
if (res)
ast_log(LOG_WARNING, "Unable to request echo training on channel %d\n", p->channel);
else {
- ast_log(LOG_DEBUG, "Engaged echo training on channel %d\n", p->channel);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Engaged echo training on channel %d\n", p->channel);
}
- } else
- ast_log(LOG_DEBUG, "No echo training requested\n");
+ } else {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "No echo training requested\n");
+ }
}
static void zt_disable_ec(struct zt_pvt *p)
@@ -1591,8 +1607,10 @@ 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
- ast_log(LOG_DEBUG, "disabled 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);
+ }
}
p->echocanon = 0;
}
@@ -1674,7 +1692,8 @@ static int set_actual_txgain(int fd, int chan, float gain, int law)
g.chan = chan;
res = ioctl(fd, ZT_GETGAINS, &g);
if (res) {
- ast_log(LOG_DEBUG, "Failed to read gains: %s\n", strerror(errno));
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Failed to read gains: %s\n", strerror(errno));
return res;
}
@@ -1692,7 +1711,8 @@ static int set_actual_rxgain(int fd, int chan, float gain, int law)
g.chan = chan;
res = ioctl(fd, ZT_GETGAINS, &g);
if (res) {
- ast_log(LOG_DEBUG, "Failed to read gains: %s\n", strerror(errno));
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Failed to read gains: %s\n", strerror(errno));
return res;
}
@@ -1977,7 +1997,8 @@ 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);
- ast_log(LOG_DEBUG, "FXO: setup deferred dialstring: %s\n", c);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "FXO: setup deferred dialstring: %s\n", c);
} else {
p->dop.dialstr[0] = '\0';
}
@@ -2069,7 +2090,8 @@ static int zt_call(struct ast_channel *ast, char *rdest, int timeout)
#ifdef HAVE_PRI
}
#endif
- ast_log(LOG_DEBUG, "Dialing '%s'\n", c);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Dialing '%s'\n", c);
p->dop.op = ZT_DIAL_OP_REPLACE;
c += p->stripmsd;
@@ -2144,8 +2166,10 @@ static int zt_call(struct ast_channel *ast, char *rdest, int timeout)
ast_mutex_unlock(&p->lock);
return -1;
}
- } else
- ast_log(LOG_DEBUG, "Deferring dialing...\n");
+ } else {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Deferring dialing...\n");
+ }
p->dialing = 1;
if (ast_strlen_zero(c))
p->dialednone = 1;
@@ -2161,7 +2185,8 @@ static int zt_call(struct ast_channel *ast, char *rdest, int timeout)
p->dialdest[0] = '\0';
break;
default:
- ast_log(LOG_DEBUG, "not yet implemented\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "not yet implemented\n");
ast_mutex_unlock(&p->lock);
return -1;
}
@@ -2258,10 +2283,13 @@ static int zt_call(struct ast_channel *ast, char *rdest, int timeout)
}
if (p->bearer || (mysig == SIG_FXSKS)) {
if (p->bearer) {
- 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);
+ 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);
p->bearer->call = p->call;
- } else
- ast_log(LOG_DEBUG, "I'm being setup with no bearer right now...\n");
+ } else {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
@@ -2442,21 +2470,24 @@ static int zap_send_keypad_facility_exec(struct ast_channel *chan, void *data)
char *digits = (char *) data;
if (ast_strlen_zero(digits)) {
- ast_log(LOG_DEBUG, "No digit string sent to application!\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "No digit string sent to application!\n");
return -1;
}
p = (struct zt_pvt *)chan->tech_pvt;
if (!p) {
- ast_log(LOG_DEBUG, "Unable to find technology private\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Unable to find technology private\n");
return -1;
}
ast_mutex_lock(&p->lock);
if (!p->pri || !p->call) {
- ast_log(LOG_DEBUG, "Unable to find pri or call on channel!\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Unable to find pri or call on channel!\n");
ast_mutex_unlock(&p->lock);
return -1;
}
@@ -2465,7 +2496,8 @@ 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 {
- ast_log(LOG_DEBUG, "Unable to grab pri to send keypad facility!\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Unable to grab pri to send keypad facility!\n");
ast_mutex_unlock(&p->lock);
return -1;
}
@@ -2598,8 +2630,9 @@ static int zt_hangup(struct ast_channel *ast)
if (p->exten)
p->exten[0] = '\0';
- 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);
+ 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);
p->ignoredtmf = 0;
if (index > -1) {
@@ -2616,27 +2649,32 @@ 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)) {
- ast_log(LOG_DEBUG, "Normal call hung up with both three way call and a call waiting call in place?\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 */
- ast_log(LOG_DEBUG, "We were flipped over to the callwait, moving back and unowning.\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 */
- ast_log(LOG_DEBUG, "We were in the threeway and have a callwait still. Ditching the threeway.\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 */
- ast_log(LOG_DEBUG, "Call was complete, setting owner to former third call\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 */
- ast_log(LOG_DEBUG, "Call was incomplete, setting owner to NULL\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Call was incomplete, setting owner to NULL\n");
p->owner = NULL;
}
p->subs[SUB_REAL].inthreeway = 0;
@@ -2656,11 +2694,13 @@ 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 */
- ast_log(LOG_DEBUG, "Call was complete, setting owner to former third call\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 */
- ast_log(LOG_DEBUG, "Call was incomplete, setting owner to NULL\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Call was incomplete, setting owner to NULL\n");
p->owner = NULL;
}
p->subs[SUB_REAL].inthreeway = 0;
@@ -2756,7 +2796,8 @@ 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) {
- ast_log(LOG_DEBUG, "Already hungup... Calling hangup once, and clearing call\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Already hungup... Calling hangup once, and clearing call\n");
#ifdef SUPPORT_USERUSER
pri_call_set_useruser(p->call, useruser);
@@ -2769,7 +2810,8 @@ 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;
- ast_log(LOG_DEBUG, "Not yet hungup... Calling hangup once with icause, and clearing call\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Not yet hungup... Calling hangup once with icause, and clearing call\n");
#ifdef SUPPORT_USERUSER
pri_call_set_useruser(p->call, useruser);
@@ -2793,7 +2835,8 @@ static int zt_hangup(struct ast_channel *ast)
}
} else {
if (p->bearer)
- ast_log(LOG_DEBUG, "Bearer call is %p, while ours is still %p\n", p->bearer->call, p->call);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Bearer call is %p, while ours is still %p\n", p->bearer->call, p->call);
p->call = NULL;
res = 0;
}
@@ -2811,7 +2854,8 @@ static int zt_hangup(struct ast_channel *ast)
res = ioctl(p->subs[SUB_REAL].zfd, ZT_GET_PARAMS, &par);
if (!res) {
#if 0
- ast_log(LOG_DEBUG, "Hanging up channel %d, offhook = %d\n", p->channel, par.rxisoffhook);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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))))
@@ -2856,7 +2900,8 @@ static int zt_hangup(struct ast_channel *ast)
}
#ifdef HAVE_PRI
if (p->bearer) {
- ast_log(LOG_DEBUG, "Freeing up bearer channel %d\n", p->bearer->channel);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
@@ -2940,7 +2985,8 @@ static int zt_answer(struct ast_channel *ast)
case SIG_FXOGS:
case SIG_FXOKS:
/* Pick up the line */
- ast_log(LOG_DEBUG, "Took %s off hook\n", ast->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Took %s off hook\n", ast->name);
if (p->hanguponpolarityswitch) {
gettimeofday(&p->polaritydelaytv, NULL);
}
@@ -2949,7 +2995,8 @@ 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) {
- ast_log(LOG_DEBUG, "Finally swapping real and threeway\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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;
@@ -3020,7 +3067,8 @@ 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;
}
- ast_log(LOG_DEBUG, "Setting actual tx gain on %s to %f\n", chan->name, p->txgain + (float) *scp);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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;
@@ -3029,7 +3077,8 @@ 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;
}
- ast_log(LOG_DEBUG, "Setting actual rx gain on %s to %f\n", chan->name, p->rxgain + (float) *scp);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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)
@@ -3037,15 +3086,18 @@ static int zt_setoption(struct ast_channel *chan, int option, void *data, int da
cp = (char *) data;
switch (*cp) {
case 1:
- ast_log(LOG_DEBUG, "Set option TONE VERIFY, mode: MUTECONF(1) on %s\n",chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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:
- ast_log(LOG_DEBUG, "Set option TONE VERIFY, mode: MUTECONF/MAX(2) on %s\n",chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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:
- ast_log(LOG_DEBUG, "Set option TONE VERIFY, mode: OFF(0) on %s\n",chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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;
}
@@ -3055,14 +3107,16 @@ 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 */
- ast_log(LOG_DEBUG, "Set option TDD MODE, value: OFF(0) on %s\n",chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Set option TDD MODE, value: OFF(0) on %s\n",chan->name);
if (p->tdd)
tdd_free(p->tdd);
p->tdd = 0;
break;
}
- ast_log(LOG_DEBUG, "Set option TDD MODE, value: %s(%d) on %s\n",
- (*cp == 2) ? "MATE" : "ON", (int) *cp, chan->name);
+ 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);
zt_disable_ec(p);
/* otherwise, turn it on */
if (!p->didtdd) { /* if havent done it yet */
@@ -3091,20 +3145,23 @@ 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) {
- ast_log(LOG_DEBUG, "poll (for write) ret. 0 on channel %d\n", p->channel);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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)) {
- ast_log(LOG_DEBUG, "write fd not ready on channel %d\n", p->channel);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "write fd not ready on channel %d\n", p->channel);
continue;
}
res = write(fd, buf, size);
if (res != size) {
if (res == -1) return -1;
- ast_log(LOG_DEBUG, "Write returned %d (%s) on channel %d\n", res, strerror(errno), p->channel);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Write returned %d (%s) on channel %d\n", res, strerror(errno), p->channel);
break;
}
len -= size;
@@ -3127,18 +3184,21 @@ static int zt_setoption(struct ast_channel *chan, int option, void *data, int da
if (!p->dsp)
break;
cp = (char *) data;
- ast_log(LOG_DEBUG, "Set option RELAX DTMF, value: %s(%d) on %s\n",
- *cp ? "ON" : "OFF", (int) *cp, chan->name);
+ 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_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) {
- ast_log(LOG_DEBUG, "Set option AUDIO MODE, value: OFF(0) on %s\n", chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Set option AUDIO MODE, value: OFF(0) on %s\n", chan->name);
x = 0;
zt_disable_ec(p);
} else {
- ast_log(LOG_DEBUG, "Set option AUDIO MODE, value: ON(1) on %s\n", chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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)
@@ -3157,16 +3217,19 @@ static int zt_setoption(struct ast_channel *chan, int option, void *data, int da
pp->oprmode = oprmode->mode;
p->oprmode = -oprmode->mode;
}
- ast_log(LOG_DEBUG, "Set Operator Services mode, value: %d on %s/%s\n",
- oprmode->mode, chan->name,oprmode->peer->name);;
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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) {
- ast_log(LOG_DEBUG, "Enabling echo cancelation on %s\n", chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Enabling echo cancelation on %s\n", chan->name);
zt_enable_ec(p);
} else {
- ast_log(LOG_DEBUG, "Disabling echo cancelation on %s\n", chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Disabling echo cancelation on %s\n", chan->name);
zt_disable_ec(p);
}
break;
@@ -3217,7 +3280,8 @@ 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 */
- ast_log(LOG_DEBUG, "Unlinking slave %d from %d\n", master->slaves[x]->channel, master->channel);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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;
@@ -3273,7 +3337,8 @@ 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;
- ast_log(LOG_DEBUG, "Making %d slave to master %d at %d\n", slave->channel, master->channel, x);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Making %d slave to master %d at %d\n", slave->channel, master->channel, x);
}
static void disable_dtmf_detect(struct zt_pvt *p)
@@ -3436,8 +3501,9 @@ static enum ast_bridge_result zt_bridge(struct ast_channel *c0, struct ast_chann
nothingok = 0;
}
}
- ast_log(LOG_DEBUG, "master: %d, slave: %d, nothingok: %d\n",
- master ? master->channel : 0, slave ? slave->channel : 0, nothingok);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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
@@ -3447,11 +3513,13 @@ 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)) {
- ast_log(LOG_DEBUG, "Playing ringback on %s since %s is in a ringing three-way\n", c0->name, c1->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 {
- ast_log(LOG_DEBUG, "Stopping tones on %d/%d talking to %d/%d\n", p0->channel, oi0, p1->channel, oi1);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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) &&
@@ -3459,11 +3527,13 @@ 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)) {
- ast_log(LOG_DEBUG, "Playing ringback on %s since %s is in a ringing three-way\n", c1->name, c0->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 {
- ast_log(LOG_DEBUG, "Stopping tones on %d/%d talking to %d/%d\n", p1->channel, oi1, p0->channel, oi0);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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)) {
@@ -3536,8 +3606,9 @@ static enum ast_bridge_result zt_bridge(struct ast_channel *c0, struct ast_chann
(t1 != p1->subs[SUB_REAL].inthreeway) ||
(oi0 != i0) ||
(oi1 != i1)) {
- ast_log(LOG_DEBUG, "Something changed out on %d/%d to %d/%d, returning -3 to restart\n",
- op0->channel, oi0, op1->channel, oi1);
+ 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);
res = AST_BRIDGE_RETRY;
goto return_from_bridge;
}
@@ -3555,7 +3626,8 @@ 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) {
- ast_log(LOG_DEBUG, "Ooh, empty read...\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Ooh, empty read...\n");
continue;
}
f = ast_read(who);
@@ -3606,7 +3678,8 @@ 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);
- ast_log(LOG_DEBUG, "New owner for channel %d is %s\n", p->channel, newchan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "New owner for channel %d is %s\n", p->channel, newchan->name);
if (p->owner == oldchan) {
p->owner = newchan;
}
@@ -3718,8 +3791,9 @@ static int attempt_transfer(struct zt_pvt *p)
/* Tell the caller not to hangup */
return 1;
} else {
- 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);
+ 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);
p->subs[SUB_THREEWAY].owner->_softhangup |= AST_SOFTHANGUP_DEV;
return -1;
}
@@ -3795,11 +3869,13 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
} else
res = zt_get_event(p->subs[index].zfd);
- ast_log(LOG_DEBUG, "Got event %s(%d) on channel %d (index %d)\n", event2str(res), res, p->channel, index);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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;
- ast_log(LOG_DEBUG, "Detected %sdigit '%c'\n", p->pulsedial ? "pulse ": "", res & 0xff);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Detected %sdigit '%c'\n", p->pulsedial ? "pulse ": "", res & 0xff);
#ifdef HAVE_PRI
if (!p->proceeding && p->sig == SIG_PRI && p->pri && p->pri->overlapdial) {
/* absorb event */
@@ -3816,7 +3892,8 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
}
if (res & ZT_EVENT_DTMFDOWN) {
- ast_log(LOG_DEBUG, "DTMF Down '%c'\n", res & 0xff);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "DTMF Down '%c'\n", res & 0xff);
/* Mute conference */
zt_confmute(p, 1);
p->subs[index].f.frametype = AST_FRAME_DTMF_BEGIN;
@@ -3843,7 +3920,8 @@ 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) {
- ast_log(LOG_DEBUG, "ZT_DIALING ioctl failed on %s\n",ast->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "ZT_DIALING ioctl failed on %s\n",ast->name);
return NULL;
}
if (!x) { /* if not still dialing in driver */
@@ -3870,7 +3948,8 @@ 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) {
- ast_log(LOG_DEBUG, "Done dialing, but waiting for progress detection before doing more...\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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) {
@@ -3988,14 +4067,16 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
return NULL;
}
mssinceflash = ast_tvdiff_ms(ast_tvnow(), p->flashtime);
- ast_log(LOG_DEBUG, "Last flash was %d ms ago\n", mssinceflash);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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;
- ast_log(LOG_DEBUG, "Looks like a bounced flash, hanging up both calls on %d\n", p->channel);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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) {
@@ -4103,7 +4184,8 @@ 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);
- ast_log(LOG_DEBUG, "channel %d answered\n", p->channel);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "channel %d answered\n", p->channel);
if (p->cidspill) {
/* Cancel any running CallerID spill */
free(p->cidspill);
@@ -4123,7 +4205,8 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
p->dop.dialstr[0] = '\0';
return NULL;
} else {
- ast_log(LOG_DEBUG, "Sent FXO deferred digit string: %s\n", p->dop.dialstr);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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;
@@ -4138,7 +4221,8 @@ 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;
- ast_log(LOG_DEBUG, "channel %d picked up\n", p->channel);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "channel %d picked up\n", p->channel);
return &p->subs[index].f;
case AST_STATE_UP:
/* Make sure it stops ringing */
@@ -4168,9 +4252,10 @@ 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 */
- ast_log(LOG_DEBUG, "Setting IDLE polarity due "
- "to ring. Old polarity was %d\n",
- p->polarity);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Setting IDLE polarity due "
+ "to ring. Old polarity was %d\n",
+ p->polarity);
p->polarity = POLARITY_IDLE;
/* Fall through */
@@ -4280,8 +4365,9 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
case SIG_FXOLS:
case SIG_FXOGS:
case SIG_FXOKS:
- 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);
+ 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);
p->callwaitcas = 0;
if (index != SUB_REAL) {
@@ -4294,7 +4380,8 @@ 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;
- ast_log(LOG_DEBUG, "Making %s the new owner\n", p->owner->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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;
@@ -4334,8 +4421,9 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
if (!((ast->pbx) ||
(ast->_state == AST_STATE_UP) ||
(ast->_state == AST_STATE_RING))) {
- ast_log(LOG_DEBUG, "Flash when call not up or ringing\n");
- goto winkflashdone;
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Flash when call not up or ringing\n");
+ goto winkflashdone;
}
if (alloc_sub(p, SUB_THREEWAY)) {
ast_log(LOG_WARNING, "Unable to allocate three-way subchannel\n");
@@ -4416,7 +4504,8 @@ 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) {
- ast_log(LOG_DEBUG, "Enabling ringtone on real and threeway\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
}
@@ -4446,15 +4535,18 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
case SIG_SF_FEATD:
case SIG_FXSLS:
case SIG_FXSGS:
- if (p->dialing)
- ast_log(LOG_DEBUG, "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);
+ if (option_debug) {
+ if (p->dialing)
+ ast_log(LOG_DEBUG, "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);
+ }
break;
case SIG_FEATDMF_TA:
switch (p->whichwink) {
case 0:
- ast_log(LOG_DEBUG, "ANI2 set to '%d' and ANI is '%s'\n", p->owner->cid.cid_ani2, p->owner->cid.cid_ani);
+ 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);
snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*%d%s#", p->owner->cid.cid_ani2, p->owner->cid.cid_ani);
break;
case 1:
@@ -4480,8 +4572,10 @@ 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
- ast_log(LOG_DEBUG, "Sent deferred digit string: %s\n", p->dop.dialstr);
+ } else {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Sent deferred digit string: %s\n", p->dop.dialstr);
+ }
p->dop.dialstr[0] = '\0';
break;
default:
@@ -4508,8 +4602,10 @@ 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
- ast_log(LOG_DEBUG, "Sent deferred digit string: %s\n", p->dop.dialstr);
+ } else {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Sent deferred digit string: %s\n", p->dop.dialstr);
+ }
p->dop.dialstr[0] = '\0';
p->dop.op = ZT_DIAL_OP_REPLACE;
break;
@@ -4521,7 +4617,8 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
case SIG_FEATB:
case SIG_SF_FEATDMF:
case SIG_SF_FEATB:
- ast_log(LOG_DEBUG, "Got hook complete in MF FGD, waiting for wink now on channel %d\n",p->channel);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Got hook complete in MF FGD, waiting for wink now on channel %d\n",p->channel);
break;
default:
break;
@@ -4539,13 +4636,16 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
if (p->answeronpolarityswitch &&
((ast->_state == AST_STATE_DIALING) ||
(ast->_state == AST_STATE_RINGING))) {
- ast_log(LOG_DEBUG, "Answering on polarity switch!\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Answering on polarity switch!\n");
ast_setstate(p->owner, AST_STATE_UP);
if (p->hanguponpolarityswitch) {
gettimeofday(&p->polaritydelaytv, NULL);
}
- } else
- ast_log(LOG_DEBUG, "Ignore switch to REVERSED Polarity on channel %d, state %d\n", p->channel, ast->_state);
+ } else {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 */
@@ -4554,24 +4654,30 @@ 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 */
- 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) );
+ 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) );
if (ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) > p->polarityonanswerdelay) {
- ast_log(LOG_DEBUG, "Polarity Reversal detected and now Hanging up on channel %d\n", p->channel);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 {
- 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);
+ 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 {
p->polarity = POLARITY_IDLE;
- ast_log(LOG_DEBUG, "Ignoring Polarity switch to IDLE on channel %d, state %d\n", p->channel, ast->_state);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 */
- 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) );
+ 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) );
break;
default:
- ast_log(LOG_DEBUG, "Dunno what to do with event %d on channel %d\n", res, p->channel);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Dunno what to do with event %d on channel %d\n", res, p->channel);
}
return &p->subs[index].f;
}
@@ -4612,7 +4718,8 @@ 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)) {
- ast_log(LOG_DEBUG, "Restoring owner of channel %d on event %d\n", p->channel, res);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
@@ -4671,7 +4778,10 @@ static struct ast_frame *__zt_exception(struct ast_channel *ast)
f = &p->subs[index].f;
return f;
}
- if (!(p->radio || (p->oprmode < 0))) ast_log(LOG_DEBUG, "Exception on %d, channel %d\n", ast->fds[0],p->channel);
+ if (!(p->radio || (p->oprmode < 0))) {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
@@ -4814,7 +4924,8 @@ 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);
- ast_log(LOG_DEBUG, "Sending hold on '%s'\n", ast->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Sending hold on '%s'\n", ast->name);
return &p->subs[index].f;
}
@@ -4824,7 +4935,8 @@ 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);
- ast_log(LOG_DEBUG, "Sending unhold on '%s'\n", ast->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Sending unhold on '%s'\n", ast->name);
return &p->subs[index].f;
}
@@ -4869,7 +4981,8 @@ static struct ast_frame *zt_read(struct ast_channel *ast)
return f;
}
if (res != (p->subs[index].linear ? READ_SIZE * 2 : READ_SIZE)) {
- ast_log(LOG_DEBUG, "Short read (%d/%d), must be an event...\n", 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);
f = __zt_exception(ast);
ast_mutex_unlock(&p->lock);
return f;
@@ -4879,7 +4992,8 @@ static struct ast_frame *zt_read(struct ast_channel *ast)
c = tdd_feed(p->tdd,readbuf,READ_SIZE);
if (c < 0) {
- ast_log(LOG_DEBUG,"tdd_feed failed\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG,"tdd_feed failed\n");
ast_mutex_unlock(&p->lock);
return NULL;
}
@@ -4927,7 +5041,8 @@ 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/2;
#if 0
- ast_log(LOG_DEBUG, "Read %d of voice on %s\n", p->subs[index].f.datalen, ast->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 */
@@ -4968,9 +5083,11 @@ static struct ast_frame *zt_read(struct ast_channel *ast)
} else
f = &p->subs[index].f;
if (f && (f->frametype == AST_FRAME_DTMF)) {
- ast_log(LOG_DEBUG, "DTMF digit: %c on %s\n", f->subclass, ast->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "DTMF digit: %c on %s\n", f->subclass, ast->name);
if (p->confirmanswer) {
- ast_log(LOG_DEBUG, "Confirm answer on %s!\n", ast->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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;
@@ -4980,7 +5097,8 @@ static struct ast_frame *zt_read(struct ast_channel *ast)
p->confirmanswer = 0;
} else if (p->callwaitcas) {
if ((f->subclass == 'A') || (f->subclass == 'D')) {
- ast_log(LOG_DEBUG, "Got some DTMF, but it's for the CAS\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Got some DTMF, but it's for the CAS\n");
if (p->cidspill)
free(p->cidspill);
send_cwcidspill(p);
@@ -5006,10 +5124,14 @@ static struct ast_frame *zt_read(struct ast_channel *ast)
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
- ast_log(LOG_DEBUG, "Already in a fax extension, not redirecting\n");
- } else
- ast_log(LOG_DEBUG, "Fax already handled\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");
+ }
zt_confmute(p, 0);
p->subs[index].f.frametype = AST_FRAME_NULL;
p->subs[index].f.subclass = 0;
@@ -5157,7 +5279,8 @@ 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);
- ast_log(LOG_DEBUG, "Requested indication %d on channel %s\n", condition, chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Requested indication %d on channel %s\n", condition, chan->name);
if (index == SUB_REAL) {
switch (condition) {
case AST_CONTROL_BUSY:
@@ -5217,7 +5340,8 @@ static int zt_indicate(struct ast_channel *chan, int condition, const void *data
}
break;
case AST_CONTROL_PROCEEDING:
- ast_log(LOG_DEBUG,"Received AST_CONTROL_PROCEEDING on %s\n",chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG,"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) {
@@ -5246,7 +5370,8 @@ static int zt_indicate(struct ast_channel *chan, int condition, const void *data
res = 0;
break;
case AST_CONTROL_PROGRESS:
- ast_log(LOG_DEBUG,"Received AST_CONTROL_PROGRESS on %s\n",chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG,"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) {
@@ -5422,7 +5547,8 @@ static struct ast_channel *zt_new(struct zt_pvt *i, int state, int startpbx, int
#endif
if (features) {
if (i->dsp) {
- ast_log(LOG_DEBUG, "Already have a dsp on %s?\n", tmp->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Already have a dsp on %s?\n", tmp->name);
} else {
if (i->channel != CHAN_PSEUDO)
i->dsp = ast_dsp_new();
@@ -5619,7 +5745,8 @@ static void *ss_thread(void *data)
timeout = gendigittimeout;
res = ast_waitfordigit(chan, timeout);
if (res < 0) {
- ast_log(LOG_DEBUG, "waitfordigit returned < 0...\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "waitfordigit returned < 0...\n");
ast_hangup(chan);
return NULL;
} else if (res) {
@@ -5647,7 +5774,8 @@ static void *ss_thread(void *data)
ast_log(LOG_WARNING, "PBX exited non-zero!\n");
}
} else {
- ast_log(LOG_DEBUG, "No such possible extension '%s' in context '%s'\n", exten, chan->context);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "No such possible extension '%s' in context '%s'\n", exten, chan->context);
chan->hangupcause = AST_CAUSE_UNALLOCATED;
ast_hangup(chan);
p->exten[0] = '\0';
@@ -5766,7 +5894,8 @@ static void *ss_thread(void *data)
}
res = ast_waitfordigit(chan, timeout);
if (res < 0) {
- ast_log(LOG_DEBUG, "waitfordigit returned < 0...\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "waitfordigit returned < 0...\n");
ast_hangup(chan);
return NULL;
} else if (res) {
@@ -5784,7 +5913,8 @@ static void *ss_thread(void *data)
ast_hangup(chan);
return NULL;
} else if (res < 0) {
- ast_log(LOG_DEBUG, "Got hung up before digits finished\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Got hung up before digits finished\n");
ast_hangup(chan);
return NULL;
}
@@ -5941,7 +6071,8 @@ static void *ss_thread(void *data)
res = ast_waitfordigit(chan, timeout);
timeout = 0;
if (res < 0) {
- ast_log(LOG_DEBUG, "waitfordigit returned < 0...\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "waitfordigit returned < 0...\n");
res = tone_zone_play_tone(p->subs[index].zfd, -1);
ast_hangup(chan);
return NULL;
@@ -5998,7 +6129,8 @@ static void *ss_thread(void *data)
timeout = matchdigittimeout;
}
} else if (res == 0) {
- ast_log(LOG_DEBUG, "not enough digits (and no ambiguous match)...\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
@@ -6034,7 +6166,8 @@ static void *ss_thread(void *data)
}
zt_enable_ec(p);
if (ast_pickup_call(chan)) {
- ast_log(LOG_DEBUG, "No call pickup possible...\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "No call pickup possible...\n");
res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_CONGESTION);
zt_wait_event(p->subs[index].zfd);
}
@@ -6222,7 +6355,8 @@ static void *ss_thread(void *data)
res = 0;
ast_frfree(f);
if (res) {
- ast_log(LOG_DEBUG, "Got ring!\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Got ring!\n");
res = 0;
break;
}
@@ -6242,7 +6376,8 @@ static void *ss_thread(void *data)
else if (smdi_msg->type == 'N')
pbx_builtin_setvar_helper(chan, "_SMDI_VM_TYPE", "u");
- ast_log(LOG_DEBUG, "Recieved SMDI message on %s\n", chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Recieved SMDI message on %s\n", chan->name);
} else {
ast_log(LOG_WARNING, "SMDI enabled but no SMDI message present\n");
}
@@ -6259,8 +6394,9 @@ static void *ss_thread(void *data)
if (p->cid_signalling == CID_SIG_DTMF) {
int i = 0;
cs = NULL;
- ast_log(LOG_DEBUG, "Receiving DTMF cid on "
- "channel %s\n", chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Receiving DTMF cid on "
+ "channel %s\n", chan->name);
zt_setlinear(p->subs[index].zfd, 0);
res = 2000;
for (;;) {
@@ -6275,7 +6411,8 @@ static void *ss_thread(void *data)
f = ast_read(chan);
if (f->frametype == AST_FRAME_DTMF) {
dtmfbuf[i++] = f->subclass;
- ast_log(LOG_DEBUG, "CID got digit '%c'\n", f->subclass);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "CID got digit '%c'\n", f->subclass);
res = 2000;
}
ast_frfree(f);
@@ -6286,10 +6423,12 @@ static void *ss_thread(void *data)
dtmfbuf[i] = '\0';
zt_setlinear(p->subs[index].zfd, p->subs[index].linear);
/* Got cid and ring. */
- ast_log(LOG_DEBUG, "CID got string '%s'\n", dtmfbuf);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "CID got string '%s'\n", dtmfbuf);
callerid_get_dtmf(dtmfbuf, dtmfcid, &flags);
- ast_log(LOG_DEBUG, "CID is '%s', flags %d\n",
- dtmfcid, flags);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "CID is '%s', flags %d\n",
+ dtmfcid, flags);
/* If first byte is NULL, we have no cid */
if (!ast_strlen_zero(dtmfcid))
number = dtmfcid;
@@ -6906,7 +7045,8 @@ static void *do_monitor(void *data)
ast_log(LOG_WARNING, "Unable to set cancel type to asynchronous\n");
return NULL;
}
- ast_log(LOG_DEBUG, "Monitor starting...\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Monitor starting...\n");
#endif
for (;;) {
/* Lock the interface list */
@@ -6972,7 +7112,8 @@ static void *do_monitor(void *data)
res = ast_app_has_voicemail(last->mailbox, NULL);
if (last->msgstate != res) {
int x;
- ast_log(LOG_DEBUG, "Message status for %s changed from %d to %d on %d\n", last->mailbox, last->msgstate, res, last->channel);
+ 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);
x = ZT_FLUSH_BOTH;
res2 = ioctl(last->subs[SUB_REAL].zfd, ZT_FLUSH, &x);
if (res2)
@@ -7800,7 +7941,8 @@ static inline int available(struct zt_pvt *p, int channelmatch, int groupmatch,
return 1;
#endif
} else if (par.rxisoffhook) {
- ast_log(LOG_DEBUG, "Channel %d off hook, can't use\n", p->channel);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Channel %d off hook, can't use\n", p->channel);
/* Not available when the other end is off hook */
return 0;
}
@@ -7884,8 +8026,9 @@ 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) {
- ast_log(LOG_DEBUG, "Found empty available channel %d/%d\n",
- pri->pvts[x]->logicalspan, pri->pvts[x]->prioffset);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Found empty available channel %d/%d\n",
+ pri->pvts[x]->logicalspan, pri->pvts[x]->prioffset);
return x;
}
if (backwards)
@@ -8037,8 +8180,10 @@ 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
- ast_log(LOG_DEBUG, "Allocated placeholder pseudo channel\n");
+ } else {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Allocated placeholder pseudo channel\n");
+ }
p->pri = pri;
}
}
@@ -8672,9 +8817,10 @@ 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]);
- 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);
+ 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);
wakeup_sub(crv, SUB_REAL, pri);
}
return principle;
@@ -9412,7 +9558,8 @@ 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;
- ast_log(LOG_DEBUG, "Started up crv %d:%d on bearer channel %d\n", pri->trunkgroup, crv->channel, crv->bearer->channel);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
}
@@ -9517,8 +9664,10 @@ 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
- ast_log(LOG_DEBUG, "Deferring ringing notification because of extra digits to dial...\n");
+ } else {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Deferring ringing notification because of extra digits to dial...\n");
+ }
#ifdef PRI_PROGRESS_MASK
if (e->ringing.progressmask & PRI_PROG_INBAND_AVAILABLE) {
#else
@@ -9570,8 +9719,9 @@ static void *pri_dchannel(void *vpri)
}
ast_mutex_lock(&pri->pvts[chanpos]->lock);
- 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);
+ 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);
zap_queue_frame(pri->pvts[chanpos], &f, pri);
#ifdef PRI_PROGRESS_MASK
if (e->proceeding.progressmask & PRI_PROG_INBAND_AVAILABLE) {
@@ -9596,8 +9746,9 @@ static void *pri_dchannel(void *vpri)
struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_PROCEEDING, };
ast_mutex_lock(&pri->pvts[chanpos]->lock);
- 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);
+ 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);
zap_queue_frame(pri->pvts[chanpos], &f, pri);
#ifdef PRI_PROGRESS_MASK
if (e->proceeding.progressmask & PRI_PROG_INBAND_AVAILABLE) {
@@ -9661,7 +9812,8 @@ static void *pri_dchannel(void *vpri)
pri->pvts[chanpos]->dsp_features = 0;
}
if (pri->pvts[chanpos]->realcall && (pri->pvts[chanpos]->realcall->sig == SIG_FXSKS)) {
- ast_log(LOG_DEBUG, "Starting up GR-303 trunk now that we got CONNECT...\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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) {
@@ -9676,11 +9828,14 @@ 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
- ast_log(LOG_DEBUG, "Sent deferred digit string: %s\n", pri->pvts[chanpos]->dop.dialstr);
+ } else {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Sent deferred digit string: %s\n", pri->pvts[chanpos]->dop.dialstr);
+ }
pri->pvts[chanpos]->dop.dialstr[0] = '\0';
} else if (pri->pvts[chanpos]->confirmanswer) {
- ast_log(LOG_DEBUG, "Waiting on answer confirmation on channel %d!\n", pri->pvts[chanpos]->channel);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 */
@@ -9862,8 +10017,9 @@ static void *pri_dchannel(void *vpri)
if (pri->pvts[x] && pri->pvts[x]->resetting) {
chanpos = x;
ast_mutex_lock(&pri->pvts[chanpos]->lock);
- 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);
+ 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);
if (pri->pvts[chanpos]->realcall)
pri_hangup_all(pri->pvts[chanpos]->realcall, pri);
else if (pri->pvts[chanpos]->owner) {
@@ -9917,7 +10073,8 @@ 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++) {
- ast_log(LOG_DEBUG, "Sending pending digit '%c'\n", pri->pvts[chanpos]->dialdest[x]);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Sending pending digit '%c'\n", pri->pvts[chanpos]->dialdest[x]);
pri_information(pri->pri, pri->pvts[chanpos]->call,
pri->pvts[chanpos]->dialdest[x]);
}
@@ -9948,7 +10105,8 @@ static void *pri_dchannel(void *vpri)
}
break;
default:
- ast_log(LOG_DEBUG, "Event: %d\n", e->e);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Event: %d\n", e->e);
}
}
ast_mutex_unlock(&pri->lock);
@@ -12376,14 +12534,16 @@ static int zt_sendtext(struct ast_channel *c, const char *text)
fds[0].revents = 0;
res = poll(fds, 1, -1);
if (!res) {
- ast_log(LOG_DEBUG, "poll (for write) ret. 0 on channel %d\n", p->channel);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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)) {
- ast_log(LOG_DEBUG, "write fd not ready on channel %d\n", p->channel);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "write fd not ready on channel %d\n", p->channel);
continue;
}
res = write(fd, buf, size);
diff --git a/channels/iax2-provision.c b/channels/iax2-provision.c
index b6137a88b..acd7beda8 100644
--- a/channels/iax2-provision.c
+++ b/channels/iax2-provision.c
@@ -249,7 +249,7 @@ 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)
+ if (ret && option_debug)
ast_log(LOG_DEBUG, "Unable to create provisioning packet for '%s'\n", template);
} else
ret = -1;
diff --git a/funcs/func_db.c b/funcs/func_db.c
index 13932d27d..2ad135fa0 100644
--- a/funcs/func_db.c
+++ b/funcs/func_db.c
@@ -67,8 +67,9 @@ static int function_db_read(struct ast_channel *chan, char *cmd,
}
if (ast_db_get(args.family, args.key, buf, len - 1)) {
- ast_log(LOG_DEBUG, "DB: %s/%s not found in database.\n", args.family,
- args.key);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "DB: %s/%s not found in database.\n", args.family,
+ args.key);
} else
pbx_builtin_setvar_helper(chan, "DB_RESULT", buf);
@@ -182,11 +183,13 @@ static int function_db_delete(struct ast_channel *chan, char* cmd,
}
if (ast_db_get(args.family, args.key, buf, len - 1)) {
- ast_log(LOG_DEBUG, "DB_DELETE: %s/%s not found in database.\n", args.family, args.key);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "DB_DELETE: %s/%s not found in database.\n", args.family, args.key);
} else {
if (ast_db_del(args.family, args.key)) {
- ast_log(LOG_DEBUG, "DB_DELETE: %s/%s could not be deleted from the database\n",
- 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);
}
}
pbx_builtin_setvar_helper(chan, "DB_RESULT", buf);
diff --git a/funcs/func_rand.c b/funcs/func_rand.c
index a216754ac..67bc8e931 100644
--- a/funcs/func_rand.c
+++ b/funcs/func_rand.c
@@ -38,6 +38,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/logger.h"
#include "asterisk/utils.h"
#include "asterisk/app.h"
+#include "asterisk/options.h"
static int acf_rand_exec(struct ast_channel *chan, char *cmd,
char *parse, char *buffer, size_t buflen)
@@ -64,12 +65,14 @@ static int acf_rand_exec(struct ast_channel *chan, char *cmd,
max_int = min_int;
min_int = tmp;
- ast_log(LOG_DEBUG, "max<min\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "max<min\n");
}
response_int = min_int + (ast_random() % (max_int - min_int + 1));
- ast_log(LOG_DEBUG, "%d was the lucky number in range [%d,%d]\n",
- response_int, min_int, max_int);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "%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 e9abe50c2..6f7b54902 100644
--- a/funcs/func_strings.c
+++ b/funcs/func_strings.c
@@ -41,6 +41,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/utils.h"
#include "asterisk/app.h"
#include "asterisk/localtime.h"
+#include "asterisk/options.h"
static int function_fieldqty(struct ast_channel *chan, char *cmd,
char *parse, char *buf, size_t len)
@@ -126,7 +127,8 @@ static int regex(struct ast_channel *chan, char *cmd, char *parse, char *buf,
if ((*args.str == ' ') || (*args.str == '\t'))
args.str++;
- ast_log(LOG_DEBUG, "FUNCTION REGEX (%s)(%s)\n", args.reg, args.str);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "FUNCTION REGEX (%s)(%s)\n", args.reg, args.str);
if ((errcode = regcomp(&regexbuf, args.reg, REG_EXTENDED | REG_NOSUB))) {
regerror(errcode, &regexbuf, buf, len);
@@ -175,7 +177,8 @@ static int array(struct ast_channel *chan, char *cmd, char *var,
* want them to be surprised by the result. Hence, we prefer commas as the
* delimiter, but we'll fall back to vertical bars if commas aren't found.
*/
- ast_log(LOG_DEBUG, "array (%s=%s)\n", var, value2);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "array (%s=%s)\n", var, value2);
if (strchr(var, ','))
AST_NONSTANDARD_APP_ARGS(arg1, var, ',');
else
@@ -187,8 +190,9 @@ static int array(struct ast_channel *chan, char *cmd, char *var,
AST_STANDARD_APP_ARGS(arg2, value2);
for (i = 0; i < arg1.argc; i++) {
- ast_log(LOG_DEBUG, "array set value (%s=%s)\n", arg1.var[i],
- arg2.val[i]);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "array set value (%s=%s)\n", arg1.var[i],
+ arg2.val[i]);
if (i < arg2.argc) {
pbx_builtin_setvar_helper(chan, arg1.var[i], arg2.val[i]);
} else {
diff --git a/main/app.c b/main/app.c
index b6a7f73a9..20620a62f 100644
--- a/main/app.c
+++ b/main/app.c
@@ -416,7 +416,8 @@ 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)) {
- ast_log(LOG_DEBUG, "we'll restart the stream here at next loop\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "we'll restart the stream here at next loop\n");
pause_restart_point = 0;
continue;
}
@@ -508,7 +509,8 @@ static int __ast_play_and_record(struct ast_channel *chan, const char *playfile,
return -1;
}
- ast_log(LOG_DEBUG,"play_and_record: %s, %s, '%s'\n", playfile ? playfile : "<None>", recordfile, fmt);
+ if (option_debug)
+ ast_log(LOG_DEBUG,"play_and_record: %s, %s, '%s'\n", playfile ? playfile : "<None>", recordfile, fmt);
snprintf(comment, sizeof(comment), "Playing %s, Recording to: %s on %s\n", playfile ? playfile : "<None>", recordfile, chan->name);
if (playfile || beep) {
@@ -529,7 +531,8 @@ static int __ast_play_and_record(struct ast_channel *chan, const char *playfile,
stringp = fmts;
strsep(&stringp, "|");
- ast_log(LOG_DEBUG, "Recording Formats: sfmts=%s\n", fmts);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Recording Formats: sfmts=%s\n", fmts);
sfmt[0] = ast_strdupa(fmts);
while ((fmt = strsep(&stringp, "|"))) {
@@ -584,7 +587,8 @@ static int __ast_play_and_record(struct ast_channel *chan, const char *playfile,
for (;;) {
res = ast_waitfor(chan, 2000);
if (!res) {
- ast_log(LOG_DEBUG, "One waitfor failed, trying another\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "One waitfor failed, trying another\n");
/* Try one more time in case of masq */
res = ast_waitfor(chan, 2000);
if (!res) {
@@ -931,7 +935,8 @@ 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 {
- ast_log(LOG_DEBUG, "Locked path '%s'\n", path);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Locked path '%s'\n", path);
return AST_LOCK_SUCCESS;
}
}
@@ -950,8 +955,10 @@ int ast_unlock_path(const char *path)
if ((res = unlink(s)))
ast_log(LOG_ERROR, "Could not unlock path '%s': %s\n", path, strerror(errno));
- else
- ast_log(LOG_DEBUG, "Unlocked path '%s'\n", path);
+ else {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Unlocked path '%s'\n", path);
+ }
return res;
}
@@ -1181,7 +1188,8 @@ 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);
- ast_log(LOG_DEBUG, "IVR Dispatch of '%s' (pos %d) yields %d\n", exten, pos, res);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "IVR Dispatch of '%s' (pos %d) yields %d\n", exten, pos, res);
if (res < 0)
break;
else if (res & RES_UPONE)
@@ -1197,7 +1205,8 @@ static int ast_ivr_menu_run_internal(struct ast_channel *chan, struct ast_ivr_me
if (!maxretries)
maxretries = 3;
if ((maxretries > 0) && (retries >= maxretries)) {
- ast_log(LOG_DEBUG, "Max retries %d exceeded\n", maxretries);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Max retries %d exceeded\n", maxretries);
return -2;
} else {
if (option_exists(menu, "g") > -1)
@@ -1208,24 +1217,28 @@ 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)) {
- ast_log(LOG_DEBUG, "Got start of extension, %c\n", res);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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")) {
- ast_log(LOG_DEBUG, "Invalid extension entered, going to 'i'!\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Invalid extension entered, going to 'i'!\n");
strcpy(exten, "i");
pos = 0;
continue;
} else {
- ast_log(LOG_DEBUG, "Aborting on invalid entry, with no 'i' option!\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Aborting on invalid entry, with no 'i' option!\n");
res = -2;
break;
}
} else {
- ast_log(LOG_DEBUG, "New existing extension: %s\n", exten);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "New existing extension: %s\n", exten);
pos = 0;
continue;
}
@@ -1233,7 +1246,8 @@ static int ast_ivr_menu_run_internal(struct ast_channel *chan, struct ast_ivr_me
}
pos++;
}
- ast_log(LOG_DEBUG, "Stopping option '%s', res is %d\n", exten, res);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Stopping option '%s', res is %d\n", exten, res);
pos = 0;
if (!strcasecmp(exten, "s"))
strcpy(exten, "g");
diff --git a/main/channel.c b/main/channel.c
index 6a5ecaef1..c1e3c0a58 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -745,7 +745,8 @@ 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 {
- ast_log(LOG_DEBUG, "Dropping voice to exceptionally long queue on %s\n", chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Dropping voice to exceptionally long queue on %s\n", chan->name);
ast_frfree(f);
ast_channel_unlock(chan);
return 0;
@@ -881,8 +882,10 @@ static struct ast_channel *channel_find_locked(const struct ast_channel *prev,
/* exit if chan not found or mutex acquired successfully */
/* this is slightly unsafe, as we _should_ hold the lock to access c->name */
done = c == NULL || ast_channel_trylock(c) == 0;
- if (!done)
- ast_log(LOG_DEBUG, "Avoiding %s for channel '%p'\n", msg, c);
+ if (!done) {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Avoiding %s for channel '%p'\n", msg, c);
+ }
AST_LIST_UNLOCK(&channels);
if (done)
return c;
@@ -892,8 +895,9 @@ static struct ast_channel *channel_find_locked(const struct ast_channel *prev,
* c is surely not null, but we don't have the lock so cannot
* access c->name
*/
- ast_log(LOG_DEBUG, "Failure, could not lock '%p' after %d retries!\n",
- c, retries);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Failure, could not lock '%p' after %d retries!\n",
+ c, retries);
return NULL;
}
@@ -1202,8 +1206,9 @@ int ast_channel_spy_add(struct ast_channel *chan, struct ast_channel_spy *spy)
ast_clear_flag(spy, CHANSPY_TRIGGER_WRITE);
}
- ast_log(LOG_DEBUG, "Spy %s added to channel %s\n",
- spy->type, chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Spy %s added to channel %s\n",
+ spy->type, chan->name);
return 0;
}
@@ -1238,7 +1243,8 @@ 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) */
- ast_log(LOG_DEBUG, "Spy %s removed from channel %s\n", spy->type, chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Spy %s removed from channel %s\n", spy->type, chan->name);
ast_mutex_unlock(&spy->lock);
@@ -1383,8 +1389,9 @@ static void queue_frame_to_spies(struct ast_channel *chan, struct ast_frame *f,
trans->path = NULL;
}
if (!trans->path) {
- ast_log(LOG_DEBUG, "Building translator from %s to SLINEAR for spies on channel %s\n",
- ast_getformatname(f->subclass), chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Building translator from %s to SLINEAR for spies on channel %s\n",
+ ast_getformatname(f->subclass), chan->name);
if ((trans->path = ast_translator_build_path(AST_FORMAT_SLINEAR, f->subclass)) == NULL) {
ast_log(LOG_WARNING, "Cannot build a path from %s to %s\n",
ast_getformatname(f->subclass), ast_getformatname(AST_FORMAT_SLINEAR));
@@ -1628,7 +1635,8 @@ static int generator_force(void *data)
res = generate(chan, tmp, 0, 160);
chan->generatordata = tmp;
if (res) {
- ast_log(LOG_DEBUG, "Auto-deactivating generator\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Auto-deactivating generator\n");
ast_deactivate_generator(chan);
}
return 0;
@@ -1847,7 +1855,8 @@ int ast_settimeout(struct ast_channel *c, int samples, int (*func)(void *data),
samples = 0;
data = 0;
}
- ast_log(LOG_DEBUG, "Scheduling timer at %d sample intervals\n", samples);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Scheduling timer at %d sample intervals\n", samples);
res = ioctl(c->timingfd, ZT_TIMERCONFIG, &samples);
c->timingfunc = func;
c->timingdata = data;
@@ -2052,11 +2061,13 @@ 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)) {
- ast_log(LOG_DEBUG, "Ignoring answer on an inbound call!\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Ignoring answer on an inbound call!\n");
ast_frfree(f);
f = &ast_null_frame;
} else if (prestate == AST_STATE_UP) {
- ast_log(LOG_DEBUG, "Dropping duplicate answer!\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Dropping duplicate answer!\n");
ast_frfree(f);
f = &ast_null_frame;
} else {
@@ -2266,7 +2277,8 @@ int ast_indicate_data(struct ast_channel *chan, int condition, const void *data,
break;
}
if (ts && ts->data[0]) {
- ast_log(LOG_DEBUG, "Driver for channel '%s' does not support indication %d, emulating it\n", chan->name, condition);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Driver for channel '%s' does not support indication %d, emulating it\n", chan->name, condition);
ast_playtones_start(chan,0,ts->data, 1);
res = 0;
} else if (condition == AST_CONTROL_PROGRESS) {
@@ -2379,7 +2391,8 @@ int ast_senddigit_begin(struct ast_channel *chan, char digit)
ast_playtones_start(chan, 0, dtmf_tones[15], 0);
else {
/* not handled */
- ast_log(LOG_DEBUG, "Unable to generate DTMF tone '%c' for '%s'\n", digit, chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Unable to generate DTMF tone '%c' for '%s'\n", digit, chan->name);
}
}
@@ -2415,7 +2428,8 @@ int ast_prod(struct ast_channel *chan)
/* Send an empty audio frame to get things moving */
if (chan->_state != AST_STATE_UP) {
- ast_log(LOG_DEBUG, "Prodding channel '%s'\n", chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Prodding channel '%s'\n", chan->name);
a.subclass = chan->rawwriteformat;
a.data = nothing + AST_FRIENDLY_OFFSET;
a.src = "ast_prod";
@@ -3066,8 +3080,9 @@ int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clo
return -1;
}
- ast_log(LOG_DEBUG, "Planning to masquerade channel %s into the structure of %s\n",
- clone->name, original->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Planning to masquerade channel %s into the structure of %s\n",
+ clone->name, original->name);
if (original->masq) {
ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n",
original->masq->name, original->name);
@@ -3079,7 +3094,8 @@ 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);
- ast_log(LOG_DEBUG, "Done planning to masquerade channel %s into the structure of %s\n", clone->name, original->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Done planning to masquerade channel %s into the structure of %s\n", clone->name, original->name);
res = 0;
}
@@ -3438,7 +3454,8 @@ int ast_do_masquerade(struct ast_channel *original)
);
ast_channel_free(clone);
} else {
- ast_log(LOG_DEBUG, "Released clone lock on '%s'\n", clone->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Released clone lock on '%s'\n", clone->name);
ast_set_flag(clone, AST_FLAG_ZOMBIE);
ast_queue_frame(clone, &ast_null_frame);
ast_channel_unlock(clone);
@@ -3625,7 +3642,8 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct
if (!f) {
*fo = NULL;
*rc = who;
- ast_log(LOG_DEBUG, "Didn't get a frame from channel: %s\n",who->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Didn't get a frame from channel: %s\n",who->name);
break;
}
@@ -3647,7 +3665,8 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct
*fo = f;
*rc = who;
bridge_exit = 1;
- ast_log(LOG_DEBUG, "Got a FRAME_CONTROL (%d) frame on channel %s\n", f->subclass, who->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Got a FRAME_CONTROL (%d) frame on channel %s\n", f->subclass, who->name);
break;
}
if (bridge_exit)
@@ -3669,9 +3688,10 @@ static enum ast_bridge_result ast_generic_bridge(struct ast_channel *c0, struct
f->frametype == AST_FRAME_DTMF_BEGIN)) {
*fo = f;
*rc = who;
- ast_log(LOG_DEBUG, "Got DTMF %s on channel (%s)\n",
- f->frametype == AST_FRAME_DTMF_END ? "end" : "begin",
- who->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 */
@@ -3831,7 +3851,8 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
c1->_softhangup = 0;
c0->_bridge = c1;
c1->_bridge = c0;
- ast_log(LOG_DEBUG, "Unbridge signal received. Ending native bridge.\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Unbridge signal received. Ending native bridge.\n");
continue;
}
@@ -3842,12 +3863,13 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
if (who)
*rc = who;
res = 0;
- 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");
+ 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");
break;
}
@@ -3870,7 +3892,8 @@ 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);
- ast_log(LOG_DEBUG, "Returning from native bridge, channels: %s, %s\n", c0->name, c1->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Returning from native bridge, channels: %s, %s\n", c0->name, c1->name);
ast_clear_flag(c0, AST_FLAG_NBRIDGE);
ast_clear_flag(c1, AST_FLAG_NBRIDGE);
@@ -3936,7 +3959,8 @@ 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);
- ast_log(LOG_DEBUG, "Bridge stops bridging channels %s and %s\n", c0->name, c1->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Bridge stops bridging channels %s and %s\n", c0->name, c1->name);
return res;
}
@@ -4461,7 +4485,8 @@ int ast_channel_unlock(struct ast_channel *chan)
ast_log(LOG_DEBUG, "::::==== Unlocking AST channel %s\n", chan->name);
if (!chan) {
- ast_log(LOG_DEBUG, "::::==== Unlocking non-existing channel \n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "::::==== Unlocking non-existing channel \n");
return 0;
}
@@ -4479,12 +4504,15 @@ int ast_channel_unlock(struct ast_channel *chan)
#else
if ((count = chan->lock.__data.__count))
#endif
- ast_log(LOG_DEBUG, ":::=== Still have %d locks (recursive)\n", count);
+ if (option_debug)
+ ast_log(LOG_DEBUG, ":::=== Still have %d locks (recursive)\n", count);
#endif
if (!res)
- ast_log(LOG_DEBUG, "::::==== Channel %s was unlocked\n", chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "::::==== Channel %s was unlocked\n", chan->name);
if (res == EINVAL) {
- ast_log(LOG_DEBUG, "::::==== Channel %s had no lock by this thread. Failed unlocking\n", chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "::::==== Channel %s had no lock by this thread. Failed unlocking\n", chan->name);
}
}
if (res == EPERM) {
@@ -4515,10 +4543,12 @@ int ast_channel_lock(struct ast_channel *chan)
#else
if ((count = chan->lock.__data.__count))
#endif
- ast_log(LOG_DEBUG, ":::=== Now have %d locks (recursive)\n", count);
+ if (option_debug)
+ ast_log(LOG_DEBUG, ":::=== Now have %d locks (recursive)\n", count);
#endif
if (!res)
- ast_log(LOG_DEBUG, "::::==== Channel %s was locked\n", chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "::::==== Channel %s was locked\n", chan->name);
if (res == EDEADLK) {
/* We had no lock, so okey any way */
if (option_debug > 3)
@@ -4551,10 +4581,12 @@ int ast_channel_trylock(struct ast_channel *chan)
#else
if ((count = chan->lock.__data.__count))
#endif
- ast_log(LOG_DEBUG, ":::=== Now have %d locks (recursive)\n", count);
+ if (option_debug)
+ ast_log(LOG_DEBUG, ":::=== Now have %d locks (recursive)\n", count);
#endif
if (!res)
- ast_log(LOG_DEBUG, "::::==== Channel %s was locked\n", chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "::::==== Channel %s was locked\n", chan->name);
if (res == EBUSY) {
/* We failed to lock */
if (option_debug > 2)
diff --git a/main/db.c b/main/db.c
index b9c9115c2..6ce594499 100644
--- a/main/db.c
+++ b/main/db.c
@@ -194,7 +194,8 @@ 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) {
- ast_log(LOG_DEBUG, "Unable to find key '%s' in family '%s'\n", keys, family);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Unable to find key '%s' in family '%s'\n", keys, family);
} else {
#if 0
printf("Got value of size %d\n", data.size);
@@ -233,8 +234,10 @@ int ast_db_del(const char *family, const char *keys)
ast_mutex_unlock(&dblock);
- if (res)
- ast_log(LOG_DEBUG, "Unable to find key '%s' in family '%s'\n", keys, family);
+ if (res) {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Unable to find key '%s' in family '%s'\n", keys, family);
+ }
return res;
}
diff --git a/main/dns.c b/main/dns.c
index 3599de2c5..ff7dde745 100644
--- a/main/dns.c
+++ b/main/dns.c
@@ -44,6 +44,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/channel.h"
#include "asterisk/dns.h"
#include "asterisk/endian.h"
+#include "asterisk/options.h"
#define MAX_SIZE 4096
@@ -209,7 +210,8 @@ int ast_search_dns(void *context,
ret = -1;
}
else if (ret == 0) {
- ast_log(LOG_DEBUG, "No matches found in DNS for %s\n", dname);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "No matches found in DNS for %s\n", dname);
ret = 0;
}
else
diff --git a/main/dsp.c b/main/dsp.c
index 2992031b4..12ffaaf42 100644
--- a/main/dsp.c
+++ b/main/dsp.c
@@ -59,6 +59,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/ulaw.h"
#include "asterisk/alaw.h"
#include "asterisk/utils.h"
+#include "asterisk/options.h"
/*! Number of goertzels for progress detect */
enum gsamp_size {
@@ -1335,8 +1336,10 @@ int ast_dsp_busydetect(struct ast_dsp *dsp)
}
#endif
#if 1
- if (res)
- ast_log(LOG_DEBUG, "ast_dsp_busydetect detected busy, avgtone: %d, avgsilence %d\n", avgtone, avgsilence);
+ if (res) {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "ast_dsp_busydetect detected busy, avgtone: %d, avgsilence %d\n", avgtone, avgsilence);
+ }
#endif
return res;
}
@@ -1470,7 +1473,8 @@ 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;
- ast_log(LOG_DEBUG, "Requesting Hangup because the busy tone was detected on channel %s\n", chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Requesting Hangup because the busy tone was detected on channel %s\n", chan->name);
return &dsp->f;
}
if ((dsp->features & DSP_FEATURE_DTMF_DETECT)) {
@@ -1655,7 +1659,8 @@ void ast_dsp_set_busy_pattern(struct ast_dsp *dsp, int tonelength, int quietleng
{
dsp->busy_tonelength = tonelength;
dsp->busy_quietlength = quietlength;
- ast_log(LOG_DEBUG, "dsp busy pattern set to %d,%d\n", tonelength, quietlength);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 fff932f2f..a9392019d 100644
--- a/main/enum.c
+++ b/main/enum.c
@@ -486,7 +486,8 @@ int ast_get_enum(struct ast_channel *chan, const char *number, char *dst, int ds
break;
}
if (ret < 0) {
- ast_log(LOG_DEBUG, "No such number found: %s (%s)\n", tmp, strerror(errno));
+ if (option_debug)
+ ast_log(LOG_DEBUG, "No such number found: %s (%s)\n", tmp, strerror(errno));
strcpy(dst, "0");
ret = 0;
}
diff --git a/main/file.c b/main/file.c
index f8ca9afeb..412bb0f3f 100644
--- a/main/file.c
+++ b/main/file.c
@@ -156,7 +156,8 @@ 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);
- ast_log(LOG_DEBUG, "Opened video output file\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Opened video output file\n");
}
if (fs->vfs)
return ast_writestream(fs->vfs, f);
@@ -785,8 +786,10 @@ int ast_streamfile(struct ast_channel *chan, const char *filename, const char *p
fs = ast_openstream(chan, filename, preflang);
if (fs)
vfs = ast_openvstream(chan, filename, preflang);
- if (vfs)
- ast_log(LOG_DEBUG, "Ooh, found a video stream, too, format %s\n", ast_getformatname(vfs->fmt->format));
+ if (vfs) {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Ooh, found a video stream, too, format %s\n", ast_getformatname(vfs->fmt->format));
+ }
if (fs){
if (ast_applystream(chan, fs))
return -1;
diff --git a/main/http.c b/main/http.c
index a59d7a58b..a1cd73a91 100644
--- a/main/http.c
+++ b/main/http.c
@@ -544,7 +544,8 @@ static void http_server_start(struct sockaddr_in *sin)
/* Do nothing if nothing has changed */
if (!memcmp(&oldsin, sin, sizeof(oldsin))) {
- ast_log(LOG_DEBUG, "Nothing changed in http\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Nothing changed in http\n");
return;
}
diff --git a/main/loader.c b/main/loader.c
index 23aec019a..8b149f2d7 100644
--- a/main/loader.c
+++ b/main/loader.c
@@ -250,7 +250,8 @@ static int printdigest(const unsigned char *d)
for (pos = 0, x = 0; x < 16; x++)
pos += sprintf(buf + pos, " %02x", *d++);
- ast_log(LOG_DEBUG, "Unexpected signature:%s\n", buf);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Unexpected signature:%s\n", buf);
return 0;
}
diff --git a/main/logger.c b/main/logger.c
index 29c4cf48b..a8e5c3700 100644
--- a/main/logger.c
+++ b/main/logger.c
@@ -840,13 +840,16 @@ void ast_backtrace(void)
if ((addresses = ast_calloc(MAX_BACKTRACE_FRAMES, sizeof(*addresses)))) {
count = backtrace(addresses, MAX_BACKTRACE_FRAMES);
if ((strings = backtrace_symbols(addresses, count))) {
- ast_log(LOG_DEBUG, "Got %d backtrace record%c\n", count, count != 1 ? 's' : ' ');
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Got %d backtrace record%c\n", count, count != 1 ? 's' : ' ');
for (i=0; i < count ; i++) {
- ast_log(LOG_DEBUG, "#%d: [%08X] %s\n", i, (unsigned int)addresses[i], strings[i]);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "#%d: [%08X] %s\n", i, (unsigned int)addresses[i], strings[i]);
}
free(strings);
} else {
- ast_log(LOG_DEBUG, "Could not allocate memory for backtrace\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Could not allocate memory for backtrace\n");
}
free(addresses);
}
diff --git a/main/manager.c b/main/manager.c
index 674ae30ec..8e368bf0b 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -1193,7 +1193,8 @@ static int action_waitevent(struct mansession *s, struct message *m)
"\r\n", idText);
s->waiting_thread = AST_PTHREADT_NULL;
} else {
- ast_log(LOG_DEBUG, "Abandoning event request!\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Abandoning event request!\n");
}
ast_mutex_unlock(&s->__lock);
return 0;
@@ -1906,7 +1907,8 @@ static int process_message(struct mansession *s, struct message *m)
int ret = 0;
ast_copy_string(action, astman_get_header(m, "Action"), sizeof(action));
- ast_log( LOG_DEBUG, "Manager received command '%s'\n", action );
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Manager received command '%s'\n", action);
if (ast_strlen_zero(action)) {
astman_send_error(s, m, "Missing action in request");
@@ -2498,10 +2500,12 @@ static char *generic_http_callback(int format, struct sockaddr_in *requestor, co
ast_mutex_lock(&s->__lock);
if (s->needdestroy) {
if (s->inuse == 1) {
- ast_log(LOG_DEBUG, "Need destroy, doing it now!\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Need destroy, doing it now!\n");
blastaway = 1;
} else {
- ast_log(LOG_DEBUG, "Need destroy, but can't do it yet!\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Need destroy, but can't do it yet!\n");
if (s->waiting_thread != AST_PTHREADT_NULL)
pthread_kill(s->waiting_thread, SIGURG);
s->inuse--;
@@ -2700,8 +2704,10 @@ int init_manager(void)
user->write = ast_strdup(var->value);
} else if (!strcasecmp(var->name, "displayconnects") )
user->displayconnects = ast_true(var->value);
- else
- ast_log(LOG_DEBUG, "%s is an unknown option.\n", var->name);
+ else {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "%s is an unknown option.\n", var->name);
+ }
var = var->next;
}
}
diff --git a/main/pbx.c b/main/pbx.c
index 6f6127d4a..d3fb389da 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -1529,8 +1529,8 @@ static void pbx_substitute_variables_helper_full(struct ast_channel *c, struct v
if (isfunction) {
/* Evaluate function */
cp4 = ast_func_read(c, vars, workspace, VAR_BUF_SIZE) ? NULL : workspace;
-
- ast_log(LOG_DEBUG, "Function result is '%s'\n", cp4 ? cp4 : "(null)");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Function result is '%s'\n", cp4 ? cp4 : "(null)");
} else {
/* Retrieve variable value */
pbx_retrieve_variable(c, vars, &cp4, workspace, VAR_BUF_SIZE, headp);
@@ -1597,7 +1597,8 @@ static void pbx_substitute_variables_helper_full(struct ast_channel *c, struct v
length = ast_expr(vars, cp2, count);
if (length) {
- ast_log(LOG_DEBUG, "Expression result is '%s'\n", cp2);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Expression result is '%s'\n", cp2);
count -= length;
cp2 += length;
}
@@ -1678,7 +1679,8 @@ static int pbx_extension_helper(struct ast_channel *c, struct ast_context *con,
if (option_debug) {
char atmp[80];
char atmp2[EXT_DATA_SIZE+100];
- ast_log(LOG_DEBUG, "Launching '%s'\n", app->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Launching '%s'\n", app->name);
snprintf(atmp, sizeof(atmp), "STACK-%s-%s-%d", context, exten, priority);
snprintf(atmp2, sizeof(atmp2), "%s(\"%s\", \"%s\") %s",
app->name, c->name, passdata, "in new stack");
@@ -1735,7 +1737,8 @@ static int pbx_extension_helper(struct ast_channel *c, struct ast_context *con,
ast_log(LOG_NOTICE, "No such label '%s' in extension '%s' in context '%s'\n", label, exten, context);
break;
default:
- ast_log(LOG_DEBUG, "Shouldn't happen!\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Shouldn't happen!\n");
}
return (matching_action) ? 0 : -1;
@@ -2259,7 +2262,8 @@ static int __ast_pbx_run(struct ast_channel *c)
if ((res = ast_spawn_extension(c, c->context, c->exten, c->priority, c->cid.cid_num))) {
/* Something bad happened, or a hangup has been requested. */
if (strchr("0123456789ABCDEF*#", res)) {
- ast_log(LOG_DEBUG, "Oooh, got something to jump out with ('%c')!\n", res);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Oooh, got something to jump out with ('%c')!\n", res);
pos = 0;
dst_exten[pos++] = digit = res;
dst_exten[pos] = '\0';
@@ -2294,8 +2298,9 @@ static int __ast_pbx_run(struct ast_channel *c)
c->whentohangup = 0;
c->_softhangup &= ~AST_SOFTHANGUP_TIMEOUT;
} else if (c->_softhangup) {
- ast_log(LOG_DEBUG, "Extension %s, priority %d returned normally even though call was hung up\n",
- c->exten, c->priority);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Extension %s, priority %d returned normally even though call was hung up\n",
+ c->exten, c->priority);
error = 1;
break;
}
@@ -3623,7 +3628,8 @@ void ast_merge_contexts_and_delete(struct ast_context **extcontexts, const char
tmp = *extcontexts;
if (registrar) {
/* XXX remove previous contexts from same registrar */
- ast_log(LOG_DEBUG, "must remove any reg %s\n", registrar);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "must remove any reg %s\n", registrar);
__ast_context_destroy(NULL,registrar);
while (tmp) {
lasttmp = tmp;
@@ -4959,7 +4965,8 @@ void __ast_context_destroy(struct ast_context *con, const char *registrar)
for (tmp = contexts; tmp; ) {
struct ast_context *next; /* next starting point */
for (; tmp; tmpl = tmp, tmp = tmp->next) {
- ast_log(LOG_DEBUG, "check ctx %s %s\n", tmp->name, tmp->registrar);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "check ctx %s %s\n", tmp->name, tmp->registrar);
if ( (!registrar || !strcasecmp(registrar, tmp->registrar)) &&
(!con || !strcasecmp(tmp->name, con->name)) )
break; /* found it */
@@ -4967,7 +4974,8 @@ void __ast_context_destroy(struct ast_context *con, const char *registrar)
if (!tmp) /* not found, we are done */
break;
ast_mutex_lock(&tmp->lock);
- ast_log(LOG_DEBUG, "delete ctx %s %s\n", tmp->name, tmp->registrar);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "delete ctx %s %s\n", tmp->name, tmp->registrar);
next = tmp->next;
if (tmpl)
tmpl->next = next;
@@ -5639,7 +5647,8 @@ static int pbx_builtin_gotoif(struct ast_channel *chan, void *data)
branch = pbx_checkcondition(condition) ? branch1 : branch2;
if (ast_strlen_zero(branch)) {
- ast_log(LOG_DEBUG, "Not taking any branch\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Not taking any branch\n");
return 0;
}
diff --git a/main/rtp.c b/main/rtp.c
index c93887581..e45f5bc27 100644
--- a/main/rtp.c
+++ b/main/rtp.c
@@ -1019,12 +1019,18 @@ static int bridge_p2p_rtcp_write(struct ast_rtp *rtp, unsigned int *rtcpheader,
/* Send the data out */
res = sendto(bridged->rtcp->s, (void *)rtcpheader, len, 0, (struct sockaddr *)&bridged->rtcp->them, sizeof(bridged->rtcp->them));
if (res < 0) {
- if (!bridged->nat || (bridged->nat && (ast_test_flag(bridged, FLAG_NAT_ACTIVE) == FLAG_NAT_ACTIVE)))
- ast_log(LOG_DEBUG, "RTCP Transmission error of packet to %s:%d: %s\n", ast_inet_ntoa(bridged->rtcp->them.sin_addr), ntohs(bridged->rtcp->them.sin_port), strerror(errno));
- else if ((((ast_test_flag(bridged, FLAG_NAT_ACTIVE) == FLAG_NAT_INACTIVE) || rtpdebug)) && (option_debug || rtpdebug))
- ast_log(LOG_DEBUG, "RTCP NAT: Can't write RTCP to private address %s:%d, waiting for other end to send first...\n", ast_inet_ntoa(bridged->rtcp->them.sin_addr), ntohs(bridged->rtcp->them.sin_port));
- } else if (rtp_debug_test_addr(&bridged->rtcp->them))
- ast_verbose("Sent RTCP P2P packet to %s:%d (len %-6.6u)\n", ast_inet_ntoa(bridged->rtcp->them.sin_addr), ntohs(bridged->rtcp->them.sin_port), len);
+ if (!bridged->nat || (bridged->nat && (ast_test_flag(bridged, FLAG_NAT_ACTIVE) == FLAG_NAT_ACTIVE))) {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "RTCP Transmission error of packet to %s:%d: %s\n", ast_inet_ntoa(bridged->rtcp->them.sin_addr), ntohs(bridged->rtcp->them.sin_port), strerror(errno));
+ }
+ else if ((((ast_test_flag(bridged, FLAG_NAT_ACTIVE) == FLAG_NAT_INACTIVE) || rtpdebug)) && (option_debug || rtpdebug)) {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "RTCP NAT: Can't write RTCP to private address %s:%d, waiting for other end to send first...\n", ast_inet_ntoa(bridged->rtcp->them.sin_addr), ntohs(bridged->rtcp->them.sin_port));
+ }
+ } else if (rtp_debug_test_addr(&bridged->rtcp->them)) {
+ if (option_verbose)
+ ast_verbose("Sent RTCP P2P packet to %s:%d (len %-6.6u)\n", ast_inet_ntoa(bridged->rtcp->them.sin_addr), ntohs(bridged->rtcp->them.sin_port), len);
+ }
return 0;
}
@@ -1069,7 +1075,8 @@ static int bridge_p2p_rtp_write(struct ast_rtp *rtp, unsigned int *rtpheader, in
res = sendto(bridged->s, (void *)rtpheader, len, 0, (struct sockaddr *)&bridged->them, sizeof(bridged->them));
if (res < 0) {
if (!bridged->nat || (bridged->nat && (ast_test_flag(bridged, FLAG_NAT_ACTIVE) == FLAG_NAT_ACTIVE))) {
- ast_log(LOG_DEBUG, "RTP Transmission error of packet to %s:%d: %s\n", ast_inet_ntoa(bridged->them.sin_addr), ntohs(bridged->them.sin_port), strerror(errno));
+ if (option_debug)
+ ast_log(LOG_DEBUG, "RTP Transmission error of packet to %s:%d: %s\n", ast_inet_ntoa(bridged->them.sin_addr), ntohs(bridged->them.sin_port), strerror(errno));
} else if (((ast_test_flag(bridged, FLAG_NAT_ACTIVE) == FLAG_NAT_INACTIVE) || rtpdebug) && !ast_test_flag(bridged, FLAG_NAT_INACTIVE_NOWARN)) {
if (option_debug || rtpdebug)
ast_log(LOG_DEBUG, "RTP NAT: Can't write RTP to private address %s:%d, waiting for other end to send audio...\n", ast_inet_ntoa(bridged->them.sin_addr), ntohs(bridged->them.sin_port));
@@ -2517,7 +2524,8 @@ static int ast_rtp_raw_write(struct ast_rtp *rtp, struct ast_frame *f, int codec
res = sendto(rtp->s, (void *)rtpheader, f->datalen + hdrlen, 0, (struct sockaddr *)&rtp->them, sizeof(rtp->them));
if (res <0) {
if (!rtp->nat || (rtp->nat && (ast_test_flag(rtp, FLAG_NAT_ACTIVE) == FLAG_NAT_ACTIVE))) {
- ast_log(LOG_DEBUG, "RTP Transmission error of packet %d to %s:%d: %s\n", rtp->seqno, ast_inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port), strerror(errno));
+ if (option_debug)
+ ast_log(LOG_DEBUG, "RTP Transmission error of packet %d to %s:%d: %s\n", rtp->seqno, ast_inet_ntoa(rtp->them.sin_addr), ntohs(rtp->them.sin_port), strerror(errno));
} else if (((ast_test_flag(rtp, FLAG_NAT_ACTIVE) == FLAG_NAT_INACTIVE) || rtpdebug) && !ast_test_flag(rtp, FLAG_NAT_INACTIVE_NOWARN)) {
/* Only give this error message once if we are not RTP debugging */
if (option_debug || rtpdebug)
@@ -2715,7 +2723,8 @@ static enum ast_bridge_result bridge_native_loop(struct ast_channel *c0, struct
if ((c0->tech_pvt != pvt0) ||
(c1->tech_pvt != pvt1) ||
(c0->masq || c0->masqr || c1->masq || c1->masqr)) {
- ast_log(LOG_DEBUG, "Oooh, something is weird, backing out\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Oooh, something is weird, backing out\n");
if (c0->tech_pvt == pvt0)
if (pr0->set_rtp_peer(c0, NULL, NULL, 0, 0))
ast_log(LOG_WARNING, "Channel '%s' failed to break RTP bridge\n", c0->name);
@@ -2806,7 +2815,8 @@ static enum ast_bridge_result bridge_native_loop(struct ast_channel *c0, struct
} else {
*fo = fr;
*rc = who;
- ast_log(LOG_DEBUG, "Got a FRAME_CONTROL (%d) frame on channel %s\n", fr->subclass, who->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Got a FRAME_CONTROL (%d) frame on channel %s\n", fr->subclass, who->name);
return AST_BRIDGE_COMPLETE;
}
} else {
@@ -2967,7 +2977,8 @@ static enum ast_bridge_result bridge_p2p_loop(struct ast_channel *c0, struct ast
if ((c0->tech_pvt != pvt0) ||
(c1->tech_pvt != pvt1) ||
(c0->masq || c0->masqr || c1->masq || c1->masqr)) {
- ast_log(LOG_DEBUG, "Oooh, something is weird, backing out\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Oooh, something is weird, backing out\n");
res = AST_BRIDGE_RETRY;
break;
}
@@ -3033,7 +3044,8 @@ static enum ast_bridge_result bridge_p2p_loop(struct ast_channel *c0, struct ast
} else {
*fo = fr;
*rc = who;
- ast_log(LOG_DEBUG, "Got a FRAME_CONTROL (%d) frame on channel %s\n", fr->subclass, who->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Got a FRAME_CONTROL (%d) frame on channel %s\n", fr->subclass, who->name);
res = AST_BRIDGE_COMPLETE;
break;
}
diff --git a/main/say.c b/main/say.c
index 623a3425d..45f67dc9e 100644
--- a/main/say.c
+++ b/main/say.c
@@ -476,7 +476,8 @@ static int ast_say_number_full_en(struct ast_channel *chan, int num, const char
num = num % 1000000;
snprintf(fn, sizeof(fn), "digits/million");
} else {
- ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
res = -1;
}
}
@@ -705,7 +706,8 @@ static int ast_say_number_full_da(struct ast_channel *chan, int num, const char
snprintf(fn, sizeof(fn), "digits/millions");
num = num % 1000000;
} else {
- ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
res = -1;
}
}
@@ -840,7 +842,8 @@ static int ast_say_number_full_de(struct ast_channel *chan, int num, const char
snprintf(fn, sizeof(fn), "digits/milliards");
}
} else {
- ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
res = -1;
}
if (!res) {
@@ -925,7 +928,8 @@ static int ast_say_number_full_en_GB(struct ast_channel *chan, int num, const ch
if (num && num < 100)
playa++;
} else {
- ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
res = -1;
}
@@ -1026,7 +1030,8 @@ static int ast_say_number_full_es(struct ast_channel *chan, int num, const char
}
num = num % 1000000;
} else {
- ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
res = -1;
}
}
@@ -1122,7 +1127,8 @@ static int ast_say_number_full_fr(struct ast_channel *chan, int num, const char
snprintf(fn, sizeof(fn), "digits/million");
num = num % 1000000;
} else {
- ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
res = -1;
}
if (!res) {
@@ -1268,7 +1274,8 @@ static int ast_say_number_full_he(struct ast_channel *chan, int num,
snprintf(fn, sizeof(fn), "digits/million");
num = num % 1000000;
} else {
- ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
res = -1;
}
if (!res) {
@@ -1418,7 +1425,8 @@ static int ast_say_number_full_it(struct ast_channel *chan, int num, const char
else
snprintf(fn, sizeof(fn), "digits/millions");
} else {
- ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
res = -1;
}
}
@@ -1494,7 +1502,8 @@ static int ast_say_number_full_nl(struct ast_channel *chan, int num, const char
num = num % 1000000;
snprintf(fn, sizeof(fn), "digits/million");
} else {
- ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
res = -1;
}
}
@@ -1589,7 +1598,8 @@ static int ast_say_number_full_no(struct ast_channel *chan, int num, const char
if (num && num < 100)
playa++;
} else {
- ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
res = -1;
}
@@ -1640,7 +1650,8 @@ static void pl_odtworz_plik(struct ast_channel *chan, const char *language, int
{
char file_name[255] = "digits/";
strcat(file_name, fn);
- ast_log(LOG_DEBUG, "Trying to play: %s\n", file_name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Trying to play: %s\n", file_name);
if (!ast_streamfile(chan, file_name, language)) {
if ((audiofd > -1) && (ctrlfd > -1))
ast_waitstream_full(chan, ints, audiofd, ctrlfd);
@@ -2049,7 +2060,8 @@ static int ast_say_number_full_se(struct ast_channel *chan, int num, const char
num = num % 1000000;
snprintf(fn, sizeof(fn), "digits/million");
} else {
- ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
res = -1;
}
}
@@ -2114,7 +2126,8 @@ static int ast_say_number_full_tw(struct ast_channel *chan, int num, const char
num = num % 1000000;
snprintf(fn, sizeof(fn), "digits/million");
} else {
- ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
res = -1;
}
}
@@ -2223,8 +2236,9 @@ static int ast_say_number_full_ru(struct ast_channel *chan, int num, const char
}
num %= 1000000;
} else {
- ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
- res = -1;
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
+ res = -1;
}
if (!res) {
if (!ast_streamfile(chan, fn, language)) {
@@ -2337,7 +2351,8 @@ static int ast_say_enumeration_full_en(struct ast_channel *chan, int num, const
snprintf(fn, sizeof(fn), "digits/h-last");
num = 0;
} else {
- ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
res = -1;
}
@@ -2490,7 +2505,8 @@ static int ast_say_enumeration_full_da(struct ast_channel *chan, int num, const
snprintf(fn, sizeof(fn), "digits/h-last%s", gender);
num = 0;
} else {
- ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
res = -1;
}
@@ -2653,7 +2669,8 @@ static int ast_say_enumeration_full_de(struct ast_channel *chan, int num, const
snprintf(fn, sizeof(fn), "digits/h-last%s", gender);
num = 0;
} else {
- ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
res = -1;
}
@@ -2955,7 +2972,8 @@ int ast_say_date_with_format_en(struct ast_channel *chan, time_t time, const cha
ast_localtime(&time,&tm,timezone);
for (offset=0 ; format[offset] != '\0' ; offset++) {
- ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
switch (format[offset]) {
/* NOTE: if you add more options here, please try to be consistent with strftime(3) */
case '\'':
@@ -3197,7 +3215,8 @@ int ast_say_date_with_format_da(struct ast_channel *chan, time_t time, const cha
ast_localtime(&time,&tm,timezone);
for (offset=0 ; format[offset] != '\0' ; offset++) {
- ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
switch (format[offset]) {
/* NOTE: if you add more options here, please try to be consistent with strftime(3) */
case '\'':
@@ -3402,7 +3421,8 @@ int ast_say_date_with_format_de(struct ast_channel *chan, time_t time, const cha
ast_localtime(&time,&tm,timezone);
for (offset=0 ; format[offset] != '\0' ; offset++) {
- ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
switch (format[offset]) {
/* NOTE: if you add more options here, please try to be consistent with strftime(3) */
case '\'':
@@ -3632,7 +3652,8 @@ int ast_say_date_with_format_he(struct ast_channel *chan, time_t time,
ast_localtime(&time,&tm,timezone);
for (offset=0 ; format[offset] != '\0' ; offset++) {
- ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
switch (format[offset]) {
/* NOTE: if you add more options here, please try to be consistent with strftime(3) */
case '\'':
@@ -3814,7 +3835,8 @@ int ast_say_date_with_format_es(struct ast_channel *chan, time_t time, const cha
ast_localtime(&time,&tm,timezone);
for (offset=0 ; format[offset] != '\0' ; offset++) {
- ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
switch (format[offset]) {
/* NOTE: if you add more options here, please try to be consistent with strftime(3) */
case '\'':
@@ -4006,7 +4028,8 @@ int ast_say_date_with_format_fr(struct ast_channel *chan, time_t time, const cha
ast_localtime(&time,&tm,timezone);
for (offset=0 ; format[offset] != '\0' ; offset++) {
- ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
switch (format[offset]) {
/* NOTE: if you add more options here, please try to be consistent with strftime(3) */
case '\'':
@@ -4204,7 +4227,8 @@ int ast_say_date_with_format_it(struct ast_channel *chan, time_t time, const cha
ast_localtime(&time,&tm,timezone);
for (offset=0 ; format[offset] != '\0' ; offset++) {
- ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
switch (format[offset]) {
/* NOTE: if you add more options here, please try to be consistent with strftime(3) */
case '\'':
@@ -4437,7 +4461,8 @@ int ast_say_date_with_format_nl(struct ast_channel *chan, time_t time, const cha
ast_localtime(&time,&tm,timezone);
for (offset=0 ; format[offset] != '\0' ; offset++) {
- ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
switch (format[offset]) {
/* NOTE: if you add more options here, please try to be consistent with strftime(3) */
case '\'':
@@ -4668,7 +4693,8 @@ int ast_say_date_with_format_pl(struct ast_channel *chan, time_t thetime, const
for (offset = 0 ; format[offset] != '\0' ; offset++) {
int remainder;
- ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
switch (format[offset]) {
/* NOTE: if you add more options here, please try to be consistent with strftime(3) */
case '\'':
@@ -4886,7 +4912,8 @@ int ast_say_date_with_format_pt(struct ast_channel *chan, time_t time, const cha
ast_localtime(&time,&tm,timezone);
for (offset=0 ; format[offset] != '\0' ; offset++) {
- ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
switch (format[offset]) {
/* NOTE: if you add more options here, please try to be consistent with strftime(3) */
case '\'':
@@ -5109,7 +5136,8 @@ int ast_say_date_with_format_tw(struct ast_channel *chan, time_t time, const cha
ast_localtime(&time,&tm,timezone);
for (offset=0 ; format[offset] != '\0' ; offset++) {
- ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
switch (format[offset]) {
/* NOTE: if you add more options here, please try to be consistent with strftime(3) */
case '\'':
@@ -6076,7 +6104,8 @@ static int ast_say_number_full_gr(struct ast_channel *chan, int num, const char
num = num % 1000000;
snprintf(fn, sizeof(fn), "digits/millions");
} else {
- ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Number '%d' is too big for me\n", num);
res = -1;
}
}
@@ -6240,7 +6269,8 @@ static int ast_say_date_with_format_gr(struct ast_channel *chan, time_t time, co
ast_localtime(&time,&tm,timezone);
for (offset=0 ; format[offset] != '\0' ; offset++) {
- ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Parsing %c (offset %d) in %s\n", format[offset], offset, format);
switch (format[offset]) {
/* NOTE: if you add more options here, please try to be consistent with strftime(3) */
case '\'':
diff --git a/main/sched.c b/main/sched.c
index 30b0af243..5fc0ef9ed 100644
--- a/main/sched.c
+++ b/main/sched.c
@@ -201,7 +201,8 @@ static int sched_settime(struct timeval *tv, int when)
*tv = now;
*tv = ast_tvadd(*tv, ast_samp2tv(when, 1000));
if (ast_tvcmp(*tv, now) < 0) {
- ast_log(LOG_DEBUG, "Request to schedule in the past?!?!\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Request to schedule in the past?!?!\n");
*tv = now;
}
return 0;
@@ -296,26 +297,29 @@ void ast_sched_dump(const struct sched_context *con)
struct sched *q;
struct timeval tv = ast_tvnow();
#ifdef SCHED_MAX_CACHE
- ast_log(LOG_DEBUG, "Asterisk Schedule Dump (%d in Q, %d Total, %d Cache)\n", con->schedcnt, con->eventcnt - 1, con->schedccnt);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Asterisk Schedule Dump (%d in Q, %d Total, %d Cache)\n", con->schedcnt, con->eventcnt - 1, con->schedccnt);
#else
- ast_log(LOG_DEBUG, "Asterisk Schedule Dump (%d in Q, %d Total)\n", con->schedcnt, con->eventcnt - 1);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Asterisk Schedule Dump (%d in Q, %d Total)\n", con->schedcnt, con->eventcnt - 1);
#endif
+ if (option_debug) {
ast_log(LOG_DEBUG, "=============================================================\n");
ast_log(LOG_DEBUG, "|ID Callback Data Time (sec:ms) |\n");
ast_log(LOG_DEBUG, "+-----+-----------------+-----------------+-----------------+\n");
- AST_LIST_TRAVERSE(&con->schedq, q, list) {
- struct timeval delta = ast_tvsub(q->when, tv);
-
- ast_log(LOG_DEBUG, "|%.4d | %-15p | %-15p | %.6ld : %.6ld |\n",
- q->id,
- q->callback,
- q->data,
- delta.tv_sec,
- (long int)delta.tv_usec);
+ AST_LIST_TRAVERSE(&con->schedq, q, list) {
+ struct timeval delta = ast_tvsub(q->when, tv);
+
+ ast_log(LOG_DEBUG, "|%.4d | %-15p | %-15p | %.6ld : %.6ld |\n",
+ q->id,
+ q->callback,
+ q->data,
+ delta.tv_sec,
+ (long int)delta.tv_usec);
+ }
+ ast_log(LOG_DEBUG, "=============================================================\n");
}
- ast_log(LOG_DEBUG, "=============================================================\n");
-
}
/*! \brief
diff --git a/main/udptl.c b/main/udptl.c
index 72f316f7e..1e0e518cc 100644
--- a/main/udptl.c
+++ b/main/udptl.c
@@ -664,13 +664,15 @@ struct ast_frame *ast_udptl_read(struct ast_udptl *udptl)
if ((udptl->them.sin_addr.s_addr != sin.sin_addr.s_addr) ||
(udptl->them.sin_port != sin.sin_port)) {
memcpy(&udptl->them, &sin, sizeof(udptl->them));
- ast_log(LOG_DEBUG, "UDPTL NAT: Using address %s:%d\n", ast_inet_ntoa(udptl->them.sin_addr), ntohs(udptl->them.sin_port));
+ if (option_debug)
+ ast_log(LOG_DEBUG, "UDPTL NAT: Using address %s:%d\n", ast_inet_ntoa(udptl->them.sin_addr), ntohs(udptl->them.sin_port));
}
}
if (udptl_debug_test_addr(&sin)) {
- ast_verbose("Got UDPTL packet from %s:%d (type %d, seq %d, len %d)\n",
- ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), 0, seqno, res);
+ if (option_verbose)
+ ast_verbose("Got UDPTL packet from %s:%d (type %d, seq %d, len %d)\n",
+ ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), 0, seqno, res);
}
#if 0
printf("Got UDPTL packet from %s:%d (seq %d, len = %d)\n", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port), seqno, res);
@@ -1035,7 +1037,8 @@ int ast_udptl_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
if ((c0->tech_pvt != pvt0) ||
(c1->tech_pvt != pvt1) ||
(c0->masq || c0->masqr || c1->masq || c1->masqr)) {
- ast_log(LOG_DEBUG, "Oooh, something is weird, backing out\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Oooh, something is weird, backing out\n");
/* Tell it to try again later */
return -3;
}
@@ -1043,22 +1046,27 @@ int ast_udptl_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
ast_udptl_get_peer(p1, &t1);
ast_udptl_get_peer(p0, &t0);
if (inaddrcmp(&t1, &ac1)) {
- ast_log(LOG_DEBUG, "Oooh, '%s' changed end address to %s:%d\n",
- c1->name, ast_inet_ntoa(t1.sin_addr), ntohs(t1.sin_port));
- ast_log(LOG_DEBUG, "Oooh, '%s' was %s:%d\n",
- c1->name, ast_inet_ntoa(ac1.sin_addr), ntohs(ac1.sin_port));
+ if (option_debug) {
+ ast_log(LOG_DEBUG, "Oooh, '%s' changed end address to %s:%d\n",
+ c1->name, ast_inet_ntoa(t1.sin_addr), ntohs(t1.sin_port));
+ ast_log(LOG_DEBUG, "Oooh, '%s' was %s:%d\n",
+ c1->name, ast_inet_ntoa(ac1.sin_addr), ntohs(ac1.sin_port));
+ }
memcpy(&ac1, &t1, sizeof(ac1));
}
if (inaddrcmp(&t0, &ac0)) {
- ast_log(LOG_DEBUG, "Oooh, '%s' changed end address to %s:%d\n",
- c0->name, ast_inet_ntoa(t0.sin_addr), ntohs(t0.sin_port));
- ast_log(LOG_DEBUG, "Oooh, '%s' was %s:%d\n",
- c0->name, ast_inet_ntoa(ac0.sin_addr), ntohs(ac0.sin_port));
+ if (option_debug) {
+ ast_log(LOG_DEBUG, "Oooh, '%s' changed end address to %s:%d\n",
+ c0->name, ast_inet_ntoa(t0.sin_addr), ntohs(t0.sin_port));
+ ast_log(LOG_DEBUG, "Oooh, '%s' was %s:%d\n",
+ c0->name, ast_inet_ntoa(ac0.sin_addr), ntohs(ac0.sin_port));
+ }
memcpy(&ac0, &t0, sizeof(ac0));
}
who = ast_waitfor_n(cs, 2, &to);
if (!who) {
- ast_log(LOG_DEBUG, "Ooh, empty read...\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Ooh, empty read...\n");
/* check for hangup / whentohangup */
if (ast_check_hangup(c0) || ast_check_hangup(c1))
break;
@@ -1068,7 +1076,8 @@ int ast_udptl_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags,
if (!f) {
*fo = f;
*rc = who;
- ast_log(LOG_DEBUG, "Oooh, got a %s\n", f ? "digit" : "hangup");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Oooh, got a %s\n", f ? "digit" : "hangup");
/* That's all we needed */
return 0;
} else {
diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c
index 5d62c641d..e1308306f 100644
--- a/pbx/pbx_dundi.c
+++ b/pbx/pbx_dundi.c
@@ -405,7 +405,8 @@ static void reset_global_eid(void)
snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "eth%d", x);
if (!ioctl(s, SIOCGIFHWADDR, &ifr)) {
memcpy(&global_eid, ((unsigned char *)&ifr.ifr_hwaddr) + 2, sizeof(global_eid));
- ast_log(LOG_DEBUG, "Seeding global EID '%s' from '%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &global_eid), ifr.ifr_name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Seeding global EID '%s' from '%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &global_eid), ifr.ifr_name);
close(s);
return;
}
@@ -425,7 +426,8 @@ static void reset_global_eid(void)
memcpy(
&(global_eid.eid),
sdp->sdl_data + sdp->sdl_nlen, 6);
- ast_log(LOG_DEBUG, "Seeding global EID '%s' from '%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &global_eid), ifap->ifa_name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Seeding global EID '%s' from '%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &global_eid), ifap->ifa_name);
freeifaddrs(ifap);
return;
}
@@ -598,8 +600,9 @@ static void *dundi_lookup_thread(void *data)
int max = 999999;
int expiration = dundi_cache_time;
- ast_log(LOG_DEBUG, "Whee, looking up '%s@%s' for '%s'\n", st->called_number, st->called_context,
- st->eids[0] ? dundi_eid_to_str(eid_str, sizeof(eid_str), st->eids[0]) : "ourselves");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Whee, looking up '%s@%s' for '%s'\n", st->called_number, st->called_context,
+ st->eids[0] ? dundi_eid_to_str(eid_str, sizeof(eid_str), st->eids[0]) : "ourselves");
memset(&ied, 0, sizeof(ied));
memset(&dr, 0, sizeof(dr));
memset(&hmd, 0, sizeof(hmd));
@@ -630,7 +633,8 @@ static void *dundi_lookup_thread(void *data)
if (!ast_test_flag_nonstd(&hmd, DUNDI_HINT_DONT_ASK))
hmd.exten[0] = '\0';
if (ast_test_flag(st->trans, FLAG_DEAD)) {
- ast_log(LOG_DEBUG, "Our transaction went away!\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Our transaction went away!\n");
st->trans->thread = 0;
destroy_trans(st->trans, 0);
} else {
@@ -657,8 +661,9 @@ static void *dundi_precache_thread(void *data)
struct dundi_hint_metadata hmd;
char eid_str[20];
- ast_log(LOG_DEBUG, "Whee, precaching '%s@%s' for '%s'\n", st->called_number, st->called_context,
- st->eids[0] ? dundi_eid_to_str(eid_str, sizeof(eid_str), st->eids[0]) : "ourselves");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Whee, precaching '%s@%s' for '%s'\n", st->called_number, st->called_context,
+ st->eids[0] ? dundi_eid_to_str(eid_str, sizeof(eid_str), st->eids[0]) : "ourselves");
memset(&ied, 0, sizeof(ied));
/* Now produce precache */
@@ -669,7 +674,8 @@ static void *dundi_precache_thread(void *data)
if (!ast_test_flag_nonstd(&hmd, DUNDI_HINT_DONT_ASK))
hmd.exten[0] = '\0';
if (ast_test_flag(st->trans, FLAG_DEAD)) {
- ast_log(LOG_DEBUG, "Our transaction went away!\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Our transaction went away!\n");
st->trans->thread = 0;
destroy_trans(st->trans, 0);
} else {
@@ -691,14 +697,17 @@ static void *dundi_query_thread(void *data)
struct dundi_hint_metadata hmd;
char eid_str[20];
int res;
- ast_log(LOG_DEBUG, "Whee, looking up '%s@%s' for '%s'\n", st->called_number, st->called_context,
- st->eids[0] ? dundi_eid_to_str(eid_str, sizeof(eid_str), st->eids[0]) : "ourselves");
+
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Whee, looking up '%s@%s' for '%s'\n", st->called_number, st->called_context,
+ st->eids[0] ? dundi_eid_to_str(eid_str, sizeof(eid_str), st->eids[0]) : "ourselves");
memset(&ied, 0, sizeof(ied));
memset(&dei, 0, sizeof(dei));
memset(&hmd, 0, sizeof(hmd));
if (!dundi_eid_cmp(&st->trans->us_eid, &st->reqeid)) {
/* Ooh, it's us! */
- ast_log(LOG_DEBUG, "Neat, someone look for us!\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Neat, someone look for us!\n");
ast_copy_string(dei.orgunit, dept, sizeof(dei.orgunit));
ast_copy_string(dei.org, org, sizeof(dei.org));
ast_copy_string(dei.locality, locality, sizeof(dei.locality));
@@ -713,7 +722,8 @@ static void *dundi_query_thread(void *data)
}
AST_LIST_LOCK(&peers);
if (ast_test_flag(st->trans, FLAG_DEAD)) {
- ast_log(LOG_DEBUG, "Our transaction went away!\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Our transaction went away!\n");
st->trans->thread = 0;
destroy_trans(st->trans, 0);
} else {
@@ -772,7 +782,8 @@ static int dundi_answer_entity(struct dundi_transaction *trans, struct dundi_ies
*st->eids[x-skipfirst] = *ies->eids[x];
s += sizeof(dundi_eid);
}
- ast_log(LOG_DEBUG, "Answering EID query for '%s@%s'!\n", dundi_eid_to_str(eid_str, sizeof(eid_str), ies->reqeid), ies->called_context);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Answering EID query for '%s@%s'!\n", dundi_eid_to_str(eid_str, sizeof(eid_str), ies->reqeid), ies->called_context);
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
trans->thread = 1;
@@ -824,9 +835,11 @@ static int cache_save_hint(dundi_eid *eidpeer, struct dundi_request *req, struct
snprintf(data, sizeof(data), "%ld|", (long)(timeout));
ast_db_put("dundi/cache", key1, data);
- ast_log(LOG_DEBUG, "Caching hint at '%s'\n", key1);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Caching hint at '%s'\n", key1);
ast_db_put("dundi/cache", key2, data);
- ast_log(LOG_DEBUG, "Caching hint at '%s'\n", key2);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Caching hint at '%s'\n", key2);
return 0;
}
@@ -998,7 +1011,8 @@ static int dundi_prop_precache(struct dundi_transaction *trans, struct dundi_ies
}
}
st->nummaps = mapcount;
- ast_log(LOG_DEBUG, "Forwarding precache for '%s@%s'!\n", ies->called_number, ies->called_context);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Forwarding precache for '%s@%s'!\n", ies->called_number, ies->called_context);
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
trans->thread = 1;
@@ -1084,7 +1098,8 @@ static int dundi_answer_query(struct dundi_transaction *trans, struct dundi_ies
}
}
st->nummaps = mapcount;
- ast_log(LOG_DEBUG, "Answering query for '%s@%s'!\n", ies->called_number, ies->called_context);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Answering query for '%s@%s'!\n", ies->called_number, ies->called_context);
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
trans->thread = 1;
@@ -1125,7 +1140,8 @@ static int cache_lookup_internal(time_t now, struct dundi_request *req, char *ke
if (!ast_get_time_t(ptr, &timeout, 0, &length)) {
int expiration = timeout - now;
if (expiration > 0) {
- ast_log(LOG_DEBUG, "Found cache expiring in %d seconds!\n", expiration);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Found cache expiring in %d seconds!\n", expiration);
ptr += length + 1;
while((sscanf(ptr, "%d/%d/%d/%n", &(flags.flags), &weight, &tech, &length) == 3)) {
ptr += length;
@@ -1138,8 +1154,9 @@ static int cache_lookup_internal(time_t now, struct dundi_request *req, char *ke
src++;
} else
src = "";
- ast_log(LOG_DEBUG, "Found cached answer '%s/%s' originally from '%s' with flags '%s' on behalf of '%s'\n",
- tech2str(tech), ptr, src, dundi_flags2str(fs, sizeof(fs), flags.flags), eid_str_full);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Found cached answer '%s/%s' originally from '%s' with flags '%s' on behalf of '%s'\n",
+ tech2str(tech), ptr, src, dundi_flags2str(fs, sizeof(fs), flags.flags), eid_str_full);
/* Make sure it's not already there */
for (z=0;z<req->respcount;z++) {
if ((req->dr[z].techint == tech) &&
@@ -1260,7 +1277,8 @@ static int do_register_expire(void *data)
{
struct dundi_peer *peer = data;
char eid_str[20];
- ast_log(LOG_DEBUG, "Register expired for '%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &peer->eid));
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Register expired for '%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &peer->eid));
peer->registerexpire = -1;
peer->lastms = 0;
memset(&peer->addr, 0, sizeof(peer->addr));
@@ -1354,7 +1372,8 @@ static struct dundi_hdr *dundi_decrypt(struct dundi_transaction *trans, unsigned
*h = *ohdr;
bytes = space - 6;
if (uncompress(dst + 6, &bytes, decrypt_space, srclen) != Z_OK) {
- ast_log(LOG_DEBUG, "Ouch, uncompress failed :(\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Ouch, uncompress failed :(\n");
return NULL;
}
/* Update length */
@@ -1380,7 +1399,8 @@ static int dundi_encrypt(struct dundi_transaction *trans, struct dundi_packet *p
bytes = len;
res = compress(compress_space, &bytes, pack->data + 6, pack->datalen - 6);
if (res != Z_OK) {
- ast_log(LOG_DEBUG, "Ouch, compression failed!\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Ouch, compression failed!\n");
return -1;
}
memset(&ied, 0, sizeof(ied));
@@ -1475,7 +1495,8 @@ static int check_key(struct dundi_peer *peer, unsigned char *newkey, unsigned ch
return 0;
}
/* Decrypted, passes signature */
- ast_log(LOG_DEBUG, "Wow, new key combo passed signature and decrypt!\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Wow, new key combo passed signature and decrypt!\n");
memcpy(peer->rxenckey, newkey, 128);
memcpy(peer->rxenckey + 128, newsig, 128);
peer->them_keycrc32 = crc32(0L, peer->rxenckey, 128);
@@ -1507,7 +1528,8 @@ static int handle_command_response(struct dundi_transaction *trans, struct dundi
return -1;
/* Make a copy for parsing */
memcpy(bufcpy, hdr->ies, datalen);
- ast_log(LOG_DEBUG, "Got canonical message %d (%d), %d bytes data%s\n", cmd, hdr->oseqno, datalen, final ? " (Final)" : "");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Got canonical message %d (%d), %d bytes data%s\n", cmd, hdr->oseqno, datalen, final ? " (Final)" : "");
if (dundi_parse_ies(&ies, bufcpy, datalen) < 0) {
ast_log(LOG_WARNING, "Failed to parse DUNDI information elements!\n");
return -1;
@@ -1621,7 +1643,8 @@ static int handle_command_response(struct dundi_transaction *trans, struct dundi
/* A dialplan response, lets see what we got... */
if (ies.cause < 1) {
/* Success of some sort */
- ast_log(LOG_DEBUG, "Looks like success of some sort (%d), %d answers\n", ies.cause, ies.anscount);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Looks like success of some sort (%d), %d answers\n", ies.cause, ies.anscount);
if (ast_test_flag(trans, FLAG_ENCRYPT)) {
authpass = encrypted;
} else
@@ -1705,7 +1728,8 @@ static int handle_command_response(struct dundi_transaction *trans, struct dundi
/* A dialplan response, lets see what we got... */
if (ies.cause < 1) {
/* Success of some sort */
- ast_log(LOG_DEBUG, "Looks like success of some sort (%d)\n", ies.cause);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Looks like success of some sort (%d)\n", ies.cause);
if (ast_test_flag(trans, FLAG_ENCRYPT)) {
authpass = encrypted;
} else
@@ -1771,8 +1795,9 @@ static int handle_command_response(struct dundi_transaction *trans, struct dundi
dundi_send(trans, DUNDI_COMMAND_CANCEL, 0, 1, &ied);
}
} else {
- ast_log(LOG_DEBUG, "Yay, we've registered as '%s' to '%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &trans->us_eid),
- dundi_eid_to_str(eid_str2, sizeof(eid_str2), &trans->them_eid));
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Yay, we've registered as '%s' to '%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &trans->us_eid),
+ dundi_eid_to_str(eid_str2, sizeof(eid_str2), &trans->them_eid));
/* Close connection if not final */
if (!final)
dundi_send(trans, DUNDI_COMMAND_CANCEL, 0, 1, NULL);
@@ -1854,8 +1879,10 @@ static int handle_command_response(struct dundi_transaction *trans, struct dundi
/* Carry back final flag */
hdr->cmdresp |= dhdr->cmdresp & 0x80;
break;
- } else
- ast_log(LOG_DEBUG, "Ouch, decrypt failed :(\n");
+ } else {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Ouch, decrypt failed :(\n");
+ }
}
}
if (!final) {
@@ -1947,7 +1974,8 @@ static int handle_frame(struct dundi_hdr *h, struct sockaddr_in *sin, int datale
dundi_ack(trans, 0);
} else {
/* Out of window -- simply drop */
- ast_log(LOG_DEBUG, "Dropping packet out of window!\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Dropping packet out of window!\n");
}
return 0;
}
@@ -3154,7 +3182,8 @@ static int precache_transactions(struct dundi_request *dr, struct dundi_mapping
AST_LIST_TRAVERSE_SAFE_BEGIN(&dr->trans, trans, parentlist) {
trans->thread = 0;
if (ast_test_flag(trans, FLAG_DEAD)) {
- ast_log(LOG_DEBUG, "Our transaction went away!\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Our transaction went away!\n");
/* This is going to remove the transaction from the dundi_request's list, as well
* as the global transactions list */
destroy_trans(trans, 0);
@@ -3247,10 +3276,14 @@ static int append_transaction(struct dundi_request *dr, struct dundi_peer *p, in
return 0;
if (p->maxms && ((p->lastms < 0) || (p->lastms >= p->maxms)))
return 0;
- if (ast_strlen_zero(dr->number))
- ast_log(LOG_DEBUG, "Will query peer '%s' for '%s' (context '%s')\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &p->eid), dundi_eid_to_str(eid_str2, sizeof(eid_str2), &dr->query_eid), dr->dcontext);
- else
- ast_log(LOG_DEBUG, "Will query peer '%s' for '%s@%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &p->eid), dr->number, dr->dcontext);
+
+ if (option_debug) {
+ if (ast_strlen_zero(dr->number))
+ ast_log(LOG_DEBUG, "Will query peer '%s' for '%s' (context '%s')\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &p->eid), dundi_eid_to_str(eid_str2, sizeof(eid_str2), &dr->query_eid), dr->dcontext);
+ else
+ ast_log(LOG_DEBUG, "Will query peer '%s' for '%s@%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &p->eid), dr->number, dr->dcontext);
+ }
+
trans = create_transaction(p);
if (!trans)
return -1;
@@ -3335,8 +3368,10 @@ static void build_transactions(struct dundi_request *dr, int ttl, int order, int
if (!avoid[x] && (!blockempty || !dundi_eid_zero(&p->us_eid))) {
/* Check for a matching or 0 cache entry */
append_transaction(dr, p, ttl, avoid);
- } else
- ast_log(LOG_DEBUG, "Avoiding '%s' in transaction\n", dundi_eid_to_str(eid_str, sizeof(eid_str), avoid[x]));
+ } else {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Avoiding '%s' in transaction\n", dundi_eid_to_str(eid_str, sizeof(eid_str), avoid[x]));
+ }
}
}
*foundcache |= res;
@@ -3360,16 +3395,18 @@ static int register_request(struct dundi_request *dr, struct dundi_request **pen
if (!strcasecmp(cur->dcontext, dr->dcontext) &&
!strcasecmp(cur->number, dr->number) &&
(!dundi_eid_cmp(&cur->root_eid, &dr->root_eid) || (cur->crc32 == dr->crc32))) {
- ast_log(LOG_DEBUG, "Found existing query for '%s@%s' for '%s' crc '%08lx'\n",
- cur->dcontext, cur->number, dundi_eid_to_str(eid_str, sizeof(eid_str), &cur->root_eid), cur->crc32);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Found existing query for '%s@%s' for '%s' crc '%08lx'\n",
+ cur->dcontext, cur->number, dundi_eid_to_str(eid_str, sizeof(eid_str), &cur->root_eid), cur->crc32);
*pending = cur;
res = 1;
break;
}
}
if (!res) {
- ast_log(LOG_DEBUG, "Registering request for '%s@%s' on behalf of '%s' crc '%08lx'\n",
- dr->number, dr->dcontext, dundi_eid_to_str(eid_str, sizeof(eid_str), &dr->root_eid), dr->crc32);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Registering request for '%s@%s' on behalf of '%s' crc '%08lx'\n",
+ dr->number, dr->dcontext, dundi_eid_to_str(eid_str, sizeof(eid_str), &dr->root_eid), dr->crc32);
/* Go ahead and link us in since nobody else is searching for this */
AST_LIST_INSERT_HEAD(&requests, dr, list);
*pending = NULL;
@@ -3458,15 +3495,17 @@ static int dundi_lookup_internal(struct dundi_result *result, int maxret, struct
if (rooteid && !dundi_eid_cmp(&dr.root_eid, &pending->root_eid)) {
/* This is on behalf of someone else. Go ahead and close this out since
they'll get their answer anyway. */
- ast_log(LOG_DEBUG, "Oooh, duplicate request for '%s@%s' for '%s'\n",
- dr.number,dr.dcontext,dundi_eid_to_str(eid_str, sizeof(eid_str), &dr.root_eid));
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Oooh, duplicate request for '%s@%s' for '%s'\n",
+ dr.number,dr.dcontext,dundi_eid_to_str(eid_str, sizeof(eid_str), &dr.root_eid));
close(dr.pfds[0]);
close(dr.pfds[1]);
return -2;
} else {
/* Wait for the cache to populate */
- ast_log(LOG_DEBUG, "Waiting for similar request for '%s@%s' for '%s'\n",
- dr.number,dr.dcontext,dundi_eid_to_str(eid_str, sizeof(eid_str), &pending->root_eid));
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Waiting for similar request for '%s@%s' for '%s'\n",
+ dr.number,dr.dcontext,dundi_eid_to_str(eid_str, sizeof(eid_str), &pending->root_eid));
start = ast_tvnow();
while(check_request(pending) && (ast_tvdiff_ms(ast_tvnow(), start) < ttlms) && (!chan || !chan->_softhangup)) {
/* XXX Would be nice to have a way to poll/select here XXX */
@@ -3505,7 +3544,7 @@ static int dundi_lookup_internal(struct dundi_result *result, int maxret, struct
ms = 100;
ast_waitfor_n_fd(dr.pfds, 1, &ms, NULL);
}
- if (chan && chan->_softhangup)
+ if (chan && chan->_softhangup && option_debug)
ast_log(LOG_DEBUG, "Hrm, '%s' hungup before their query for %s@%s finished\n", chan->name, dr.number, dr.dcontext);
cancel_request(&dr);
unregister_request(&dr);
@@ -3602,7 +3641,8 @@ static int dundi_precache_internal(const char *context, const char *number, int
int foundcache, skipped, ttlms, ms;
if (!context)
context = "e164";
- ast_log(LOG_DEBUG, "Precache internal (%s@%s)!\n", number, context);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Precache internal (%s@%s)!\n", number, context);
AST_LIST_LOCK(&peers);
AST_LIST_TRAVERSE(&mappings, cur, list) {
@@ -3955,7 +3995,8 @@ static int do_register(void *data)
struct dundi_peer *peer = data;
char eid_str[20];
char eid_str2[20];
- ast_log(LOG_DEBUG, "Register us as '%s' to '%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &peer->us_eid), dundi_eid_to_str(eid_str2, sizeof(eid_str2), &peer->eid));
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Register us as '%s' to '%s'\n", dundi_eid_to_str(eid_str, sizeof(eid_str), &peer->us_eid), dundi_eid_to_str(eid_str2, sizeof(eid_str2), &peer->eid));
peer->registerid = ast_sched_add(sched, default_expiration * 1000, do_register, data);
/* Destroy old transaction if there is one */
if (peer->regtrans)
diff --git a/res/res_adsi.c b/res/res_adsi.c
index cea172767..9cc085dbb 100644
--- a/res/res_adsi.c
+++ b/res/res_adsi.c
@@ -52,6 +52,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/module.h"
#include "asterisk/config.h"
#include "asterisk/file.h"
+#include "asterisk/options.h"
#define DEFAULT_ADSI_MAX_RETRIES 3
@@ -230,7 +231,8 @@ 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 */
- ast_log(LOG_DEBUG, "No ADSI CPE detected (%d)\n", res);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "No ADSI CPE detected (%d)\n", res);
if (!chan->adsicpe)
chan->adsicpe = AST_ADSI_UNAVAILABLE;
errno = ENOSYS;
@@ -239,7 +241,8 @@ static int __adsi_transmit_messages(struct ast_channel *chan, unsigned char **ms
waittime = res;
f = ast_read(chan);
if (!f) {
- ast_log(LOG_DEBUG, "Hangup in ADSI\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Hangup in ADSI\n");
return -1;
}
if (f->frametype == AST_FRAME_DTMF) {
@@ -250,7 +253,8 @@ static int __adsi_transmit_messages(struct ast_channel *chan, unsigned char **ms
break;
} else {
if (f->subclass == 'D') {
- ast_log(LOG_DEBUG, "Off-hook capable CPE only, not ADSI\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Off-hook capable CPE only, not ADSI\n");
} else
ast_log(LOG_WARNING, "Unknown ADSI response '%c'\n", f->subclass);
if (!chan->adsicpe)
@@ -262,9 +266,12 @@ static int __adsi_transmit_messages(struct ast_channel *chan, unsigned char **ms
ast_frfree(f);
}
- ast_log(LOG_DEBUG, "ADSI Compatible CPE Detected\n");
- } else
- ast_log(LOG_DEBUG, "Already in data mode\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "ADSI Compatible CPE Detected\n");
+ } else {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Already in data mode\n");
+ }
x = 0;
pos = 0;
@@ -277,8 +284,9 @@ 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;
}
- ast_log(LOG_DEBUG, "Message %d, of %d input bytes, %d output bytes\n",
- x + 1, msglen[x], res);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Message %d, of %d input bytes, %d output bytes\n",
+ x + 1, msglen[x], res);
pos += res;
x++;
}
@@ -291,7 +299,8 @@ static int __adsi_transmit_messages(struct ast_channel *chan, unsigned char **ms
if (res)
return -1;
- ast_log(LOG_DEBUG, "Sent total spill of %d bytes\n", pos);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Sent total spill of %d bytes\n", pos);
memset(ack, 0, sizeof(ack));
/* Get real result */
@@ -300,13 +309,15 @@ static int __adsi_transmit_messages(struct ast_channel *chan, unsigned char **ms
if (res < 0)
return -1;
if (ack[0] == 'D') {
- ast_log(LOG_DEBUG, "Acked up to message %d\n", atoi(ack + 1));
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Acked up to message %d\n", atoi(ack + 1));
start += atoi(ack + 1);
if (start >= x)
break;
else {
retries++;
- ast_log(LOG_DEBUG, "Retransmitting (%d), from %d\n", retries, start + 1);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Retransmitting (%d), from %d\n", retries, start + 1);
}
} else {
retries++;
@@ -337,7 +348,8 @@ int ast_adsi_begin_download(struct ast_channel *chan, char *service, unsigned ch
return -1;
if (ack[0] == 'B')
return 0;
- ast_log(LOG_DEBUG, "Download was denied by CPE\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Download was denied by CPE\n");
return -1;
}
@@ -372,13 +384,15 @@ int ast_adsi_transmit_message_full(struct ast_channel *chan, unsigned char *msg,
for (x=0;x<msglen;x+=(msg[x+1]+2)) {
if (msg[x] == ADSI_SWITCH_TO_DATA) {
- ast_log(LOG_DEBUG, "Switch to data is sent!\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Switch to data is sent!\n");
waitforswitch++;
newdatamode = ADSI_FLAG_DATAMODE;
}
if (msg[x] == ADSI_SWITCH_TO_VOICE) {
- ast_log(LOG_DEBUG, "Switch to voice is sent!\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Switch to voice is sent!\n");
waitforswitch++;
newdatamode = 0;
}
@@ -411,8 +425,13 @@ int ast_adsi_transmit_message_full(struct ast_channel *chan, unsigned char *msg,
res = __adsi_transmit_messages(chan, msgs, msglens, msgtypes);
if (dowait) {
- ast_log(LOG_DEBUG, "Wait for switch is '%d'\n", waitforswitch);
- while(waitforswitch-- && ((res = ast_waitfordigit(chan, 1000)) > 0)) { res = 0; ast_log(LOG_DEBUG, "Waiting for 'B'...\n"); }
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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");
+ }
}
if (!res)
@@ -994,14 +1013,17 @@ int ast_adsi_load_session(struct ast_channel *chan, unsigned char *app, int ver,
if (res < 0)
return -1;
if (res) {
- ast_log(LOG_DEBUG, "No response from CPE about version. Assuming not there.\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "No response from CPE about version. Assuming not there.\n");
return 0;
}
if (!strcmp(resp, "B")) {
- ast_log(LOG_DEBUG, "CPE has script '%s' version %d already loaded\n", app, ver);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "CPE has script '%s' version %d already loaded\n", app, ver);
return 1;
} else if (!strcmp(resp, "A")) {
- ast_log(LOG_DEBUG, "CPE hasn't script '%s' version %d already loaded\n", app, ver);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 e38cef2c2..f6adf290e 100644
--- a/res/res_agi.c
+++ b/res/res_agi.c
@@ -563,7 +563,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)
+ if (vfs && option_debug)
ast_log(LOG_DEBUG, "Ooh, found a video stream, too\n");
if (option_verbose > 2)
@@ -628,7 +628,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)
+ if (vfs && option_debug)
ast_log(LOG_DEBUG, "Ooh, found a video stream, too\n");
if (option_verbose > 2)
@@ -1840,7 +1840,8 @@ 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) {
- ast_log(LOG_DEBUG, "%s hungup\n", chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "%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 11dec3f40..cebad75a8 100644
--- a/res/res_config_pgsql.c
+++ b/res/res_config_pgsql.c
@@ -132,9 +132,11 @@ 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");
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql);
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s\n",
- PQerrorMessage(pgsqlConn));
+ 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_mutex_unlock(&pgsql_lock);
return NULL;
} else {
@@ -144,15 +146,18 @@ 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");
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql);
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s (%s)\n",
- PQresultErrorMessage(result), PQresStatus(result_status));
+ 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",
+ PQresultErrorMessage(result), PQresStatus(result_status));
+ }
ast_mutex_unlock(&pgsql_lock);
return NULL;
}
}
- ast_log(LOG_DEBUG, "1Postgresql RealTime: Result=%p Query: %s\n", result, sql);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "1Postgresql RealTime: Result=%p Query: %s\n", result, sql);
if ((num_rows = PQntuples(result)) > 0) {
int i = 0;
@@ -160,7 +165,8 @@ static struct ast_variable *realtime_pgsql(const char *database, const char *tab
int numFields = PQnfields(result);
char **fieldnames = NULL;
- ast_log(LOG_DEBUG, "Postgresql RealTime: Found %d rows.\n", num_rows);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Postgresql RealTime: Found %d rows.\n", num_rows);
if (!(fieldnames = ast_calloc(1, numFields * sizeof(char *)))) {
ast_mutex_unlock(&pgsql_lock);
@@ -278,9 +284,11 @@ 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");
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql);
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s\n",
- PQerrorMessage(pgsqlConn));
+ 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_mutex_unlock(&pgsql_lock);
return NULL;
} else {
@@ -290,15 +298,18 @@ 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");
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql);
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s (%s)\n",
- PQresultErrorMessage(result), PQresStatus(result_status));
+ 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",
+ PQresultErrorMessage(result), PQresStatus(result_status));
+ }
ast_mutex_unlock(&pgsql_lock);
return NULL;
}
}
- ast_log(LOG_DEBUG, "2Postgresql RealTime: Result=%p Query: %s\n", result, sql);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "2Postgresql RealTime: Result=%p Query: %s\n", result, sql);
if ((num_rows = PQntuples(result)) > 0) {
int numFields = PQnfields(result);
@@ -306,7 +317,8 @@ static struct ast_config *realtime_multi_pgsql(const char *database, const char
int rowIndex = 0;
char **fieldnames = NULL;
- ast_log(LOG_DEBUG, "Postgresql RealTime: Found %d rows.\n", num_rows);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Postgresql RealTime: Found %d rows.\n", num_rows);
if (!(fieldnames = ast_calloc(1, numFields * sizeof(char *)))) {
ast_mutex_unlock(&pgsql_lock);
@@ -386,7 +398,8 @@ 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);
- ast_log(LOG_DEBUG, "Postgresql RealTime: Update SQL: %s\n", sql);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
@@ -398,9 +411,11 @@ 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");
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql);
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s\n",
- PQerrorMessage(pgsqlConn));
+ 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_mutex_unlock(&pgsql_lock);
return -1;
} else {
@@ -410,9 +425,11 @@ 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");
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql);
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s (%s)\n",
- PQresultErrorMessage(result), PQresStatus(result_status));
+ 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",
+ PQresultErrorMessage(result), PQresStatus(result_status));
+ }
ast_mutex_unlock(&pgsql_lock);
return -1;
}
@@ -421,8 +438,9 @@ static int update_pgsql(const char *database, const char *table, const char *key
numrows = atoi(PQcmdTuples(result));
ast_mutex_unlock(&pgsql_lock);
- ast_log(LOG_DEBUG, "Postgresql RealTime: Updated %d rows on table: %s\n", numrows,
- table);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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
@@ -459,7 +477,8 @@ static struct ast_config *config_pgsql(const char *database, const char *table,
"SELECT category, var_name, var_val, cat_metric FROM %s WHERE filename='%s' and commented=0 ORDER BY filename, cat_metric desc, var_metric asc, category, var_name, var_val, id",
table, file);
- ast_log(LOG_DEBUG, "Postgresql RealTime: Static SQL: %s\n", sql);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Postgresql RealTime: Static SQL: %s\n", sql);
/* We now have our complete statement; Lets connect to the server and execute it. */
ast_mutex_lock(&pgsql_lock);
@@ -471,9 +490,11 @@ static struct ast_config *config_pgsql(const char *database, const char *table,
if (!(result = PQexec(pgsqlConn, sql))) {
ast_log(LOG_WARNING,
"Postgresql RealTime: Failed to query database. Check debug for more info.\n");
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql);
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s\n",
- PQerrorMessage(pgsqlConn));
+ 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_mutex_unlock(&pgsql_lock);
return NULL;
} else {
@@ -483,9 +504,11 @@ 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");
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query: %s\n", sql);
- ast_log(LOG_DEBUG, "Postgresql RealTime: Query Failed because: %s (%s)\n",
- PQresultErrorMessage(result), PQresStatus(result_status));
+ 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",
+ PQresultErrorMessage(result), PQresStatus(result_status));
+ }
ast_mutex_unlock(&pgsql_lock);
return NULL;
}
@@ -497,7 +520,8 @@ static struct ast_config *config_pgsql(const char *database, const char *table,
int rowIndex = 0;
char **fieldnames = NULL;
- ast_log(LOG_DEBUG, "Postgresql RealTime: Found %ld rows.\n", num_rows);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Postgresql RealTime: Found %ld rows.\n", num_rows);
if (!(fieldnames = ast_calloc(1, numFields * sizeof(char *)))) {
ast_mutex_unlock(&pgsql_lock);
@@ -561,8 +585,9 @@ static int load_module(void)
if (!pgsql_reconnect(NULL)) {
ast_log(LOG_WARNING,
"Postgresql RealTime: Couldn't establish connection. Check debug.\n");
- ast_log(LOG_DEBUG, "Postgresql RealTime: Cannot Connect: %s\n",
- PQerrorMessage(pgsqlConn));
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Postgresql RealTime: Cannot Connect: %s\n",
+ PQerrorMessage(pgsqlConn));
}
ast_config_engine_register(&pgsql_engine);
@@ -613,8 +638,9 @@ static int reload(void)
if (!pgsql_reconnect(NULL)) {
ast_log(LOG_WARNING,
"Postgresql RealTime: Couldn't establish connection. Check debug.\n");
- ast_log(LOG_DEBUG, "Postgresql RealTime: Cannot Connect: %s\n",
- PQerrorMessage(pgsqlConn));
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Postgresql RealTime: Cannot Connect: %s\n",
+ PQerrorMessage(pgsqlConn));
}
ast_verbose(VERBOSE_PREFIX_2 "Postgresql RealTime reloaded.\n");
@@ -685,15 +711,17 @@ static int parse_config(void)
}
ast_config_destroy(config);
- if (dbhost) {
- ast_log(LOG_DEBUG, "Postgresql RealTime Host: %s\n", dbhost);
- ast_log(LOG_DEBUG, "Postgresql RealTime Port: %i\n", dbport);
- } else {
- ast_log(LOG_DEBUG, "Postgresql RealTime Socket: %s\n", dbsock);
+ 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);
+ } else {
+ ast_log(LOG_DEBUG, "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_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);
return 1;
}
@@ -723,26 +751,32 @@ 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);
- ast_log(LOG_DEBUG, "%u connInfo=%s\n", size, connInfo);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "%u connInfo=%s\n", size, connInfo);
pgsqlConn = PQconnectdb(connInfo);
- ast_log(LOG_DEBUG, "%u connInfo=%s\n", size, connInfo);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "%u connInfo=%s\n", size, connInfo);
free(connInfo);
connInfo = NULL;
- ast_log(LOG_DEBUG, "pgsqlConn=%p\n", pgsqlConn);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "pgsqlConn=%p\n", pgsqlConn);
if (pgsqlConn && PQstatus(pgsqlConn) == CONNECTION_OK) {
- ast_log(LOG_DEBUG, "Postgresql RealTime: Successfully connected to database.\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
- ast_log(LOG_DEBUG, "Postgresql RealTime: Cannot Connect: %s\n",
- PQresultErrorMessage(NULL));
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Postgresql RealTime: Cannot Connect: %s\n",
+ PQresultErrorMessage(NULL));
return 0;
}
} else {
- ast_log(LOG_DEBUG, "Postgresql RealTime: Everything is fine.\n");
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Postgresql RealTime: Everything is fine.\n");
return 1;
}
}
diff --git a/res/res_crypto.c b/res/res_crypto.c
index c12c11a51..055716789 100644
--- a/res/res_crypto.c
+++ b/res/res_crypto.c
@@ -433,7 +433,8 @@ 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) {
- ast_log(LOG_DEBUG, "Key failed verification: %s\n", key->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Key failed verification: %s\n", key->name);
return -1;
}
/* Pass */
@@ -487,7 +488,8 @@ static void crypto_load(int ifd, int ofd)
while(key) {
nkey = key->next;
if (key->delme) {
- ast_log(LOG_DEBUG, "Deleting key %s type %d\n", key->name, key->ktype);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Deleting key %s type %d\n", key->name, key->ktype);
/* Do the delete */
if (last)
last->next = nkey;
diff --git a/res/res_jabber.c b/res/res_jabber.c
index 9a4b52db6..3340423c5 100644
--- a/res/res_jabber.c
+++ b/res/res_jabber.c
@@ -1239,8 +1239,10 @@ static void aji_handle_presence(struct aji_client *client, ikspak *pak)
found->cap = aji_find_version(node, ver, pak);
if(gtalk_yuck(pak->x)) /* gtalk should do discover */
found->cap->jingle = 1;
- if(found->cap->jingle && option_debug > 4)
- ast_log(LOG_DEBUG,"Special case for google till they support discover.\n");
+ if(found->cap->jingle && option_debug > 4) {
+ if (option_debug)
+ ast_log(LOG_DEBUG,"Special case for google till they support discover.\n");
+ }
else {
iks *iq, *query;
iq = iks_new("iq");
diff --git a/res/res_monitor.c b/res/res_monitor.c
index b1739f977..793921b42 100644
--- a/res/res_monitor.c
+++ b/res/res_monitor.c
@@ -47,6 +47,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/app.h"
#include "asterisk/utils.h"
#include "asterisk/config.h"
+#include "asterisk/options.h"
AST_MUTEX_DEFINE_STATIC(monitorlock);
@@ -221,8 +222,9 @@ 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 {
- ast_log(LOG_DEBUG,"Cannot start monitoring %s, already monitored\n",
- chan->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG,"Cannot start monitoring %s, already monitored\n",
+ chan->name);
res = -1;
}
@@ -295,7 +297,8 @@ 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));
}
- ast_log(LOG_DEBUG,"monitor executing %s\n",tmp);
+ if (option_debug)
+ ast_log(LOG_DEBUG,"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 ce630b0b4..41f588c0e 100644
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -533,8 +533,10 @@ static void *monmp3thread(void *data)
kill(class->pid, SIGKILL);
class->pid = 0;
}
- } else
- ast_log(LOG_DEBUG, "Read %d bytes of audio while expecting %d\n", res2, len);
+ } else {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Read %d bytes of audio while expecting %d\n", res2, len);
+ }
continue;
}
pthread_testcancel();
@@ -819,7 +821,8 @@ static int moh_register(struct mohclass *moh, int reload)
AST_LIST_LOCK(&mohclasses);
if (get_mohbyname(moh->name)) {
if (reload) {
- ast_log(LOG_DEBUG, "Music on Hold class '%s' left alone from initial load.\n", moh->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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);
}
@@ -1041,7 +1044,8 @@ static void ast_moh_destroy(void)
AST_LIST_LOCK(&mohclasses);
while ((moh = AST_LIST_REMOVE_HEAD(&mohclasses, list))) {
if (moh->pid > 1) {
- ast_log(LOG_DEBUG, "killing %d!\n", moh->pid);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "killing %d!\n", moh->pid);
stime = time(NULL) + 2;
pid = moh->pid;
moh->pid = 0;
@@ -1055,7 +1059,8 @@ 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;
- ast_log(LOG_DEBUG, "mpg123 pid %d and child died after %d bytes read\n", pid, tbytes);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "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 c0c7f8927..87540e48f 100644
--- a/res/res_smdi.c
+++ b/res/res_smdi.c
@@ -112,7 +112,8 @@ int ast_smdi_mwi_set(struct ast_smdi_interface *iface, const char *mailbox)
fclose(file);
ASTOBJ_UNLOCK(iface);
- ast_log(LOG_DEBUG, "Sent MWI set message for %s on %s\n", mailbox, iface->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Sent MWI set message for %s on %s\n", mailbox, iface->name);
return 0;
}
@@ -143,7 +144,8 @@ int ast_smdi_mwi_unset(struct ast_smdi_interface *iface, const char *mailbox)
fclose(file);
ASTOBJ_UNLOCK(iface);
- ast_log(LOG_DEBUG, "Sent MWI unset message for %s on %s\n", mailbox, iface->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Sent MWI unset message for %s on %s\n", mailbox, iface->name);
return 0;
}
@@ -412,7 +414,8 @@ 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);
- ast_log(LOG_DEBUG, "Recieved SMDI MD message on %s\n", iface->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Recieved SMDI MD message on %s\n", iface->name);
ASTOBJ_UNREF(md_msg, ast_smdi_md_message_destroy);
@@ -455,7 +458,8 @@ 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);
- ast_log(LOG_DEBUG, "Recieved SMDI MWI message on %s\n", iface->name);
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Recieved SMDI MWI message on %s\n", iface->name);
ASTOBJ_UNREF(mwi_msg, ast_smdi_mwi_message_destroy);
} else {