From 4a1aaf52ae4189e660ad57ba69253f54603a2beb Mon Sep 17 00:00:00 2001 From: mogorman Date: Tue, 3 Oct 2006 15:53:07 +0000 Subject: 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 --- apps/app_alarmreceiver.c | 32 +++-- apps/app_db.c | 9 +- apps/app_dial.c | 3 +- apps/app_directed_pickup.c | 7 +- apps/app_disa.c | 34 +++-- apps/app_externalivr.c | 6 +- apps/app_festival.c | 74 ++++++----- apps/app_ices.c | 6 +- apps/app_macro.c | 14 ++- apps/app_meetme.c | 29 +++-- apps/app_mp3.c | 12 +- apps/app_nbscat.c | 12 +- apps/app_osplookup.c | 304 +++++++++++++++++++++++++++++---------------- apps/app_queue.c | 30 +++-- apps/app_record.c | 3 +- apps/app_talkdetect.c | 16 ++- apps/app_test.c | 6 +- apps/app_voicemail.c | 138 +++++++++++++------- apps/app_waitforsilence.c | 6 +- apps/app_zapbarge.c | 9 +- apps/app_zapras.c | 3 +- apps/app_zapscan.c | 9 +- 22 files changed, 499 insertions(+), 263 deletions(-) (limited to 'apps') 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; } -- cgit v1.2.3