[asterisk-commits] mogorman: trunk r44253 - in /trunk: apps/ cdr/ channels/ funcs/ main/ pbx/ res/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Oct 3 08:53:08 MST 2006


Author: mogorman
Date: Tue Oct  3 10:53:07 2006
New Revision: 44253

URL: http://svn.digium.com/view/asterisk?rev=44253&view=rev
Log:
bug #8076 check option_debug before printing to debug channel.
patch provided in bugnote, with minor changes.

Modified:
    trunk/apps/app_alarmreceiver.c
    trunk/apps/app_db.c
    trunk/apps/app_dial.c
    trunk/apps/app_directed_pickup.c
    trunk/apps/app_disa.c
    trunk/apps/app_externalivr.c
    trunk/apps/app_festival.c
    trunk/apps/app_ices.c
    trunk/apps/app_macro.c
    trunk/apps/app_meetme.c
    trunk/apps/app_mp3.c
    trunk/apps/app_nbscat.c
    trunk/apps/app_osplookup.c
    trunk/apps/app_queue.c
    trunk/apps/app_record.c
    trunk/apps/app_talkdetect.c
    trunk/apps/app_test.c
    trunk/apps/app_voicemail.c
    trunk/apps/app_waitforsilence.c
    trunk/apps/app_zapbarge.c
    trunk/apps/app_zapras.c
    trunk/apps/app_zapscan.c
    trunk/cdr/cdr_csv.c
    trunk/cdr/cdr_odbc.c
    trunk/cdr/cdr_tds.c
    trunk/channels/chan_agent.c
    trunk/channels/chan_alsa.c
    trunk/channels/chan_features.c
    trunk/channels/chan_gtalk.c
    trunk/channels/chan_iax2.c
    trunk/channels/chan_jingle.c
    trunk/channels/chan_mgcp.c
    trunk/channels/chan_misdn.c
    trunk/channels/chan_nbs.c
    trunk/channels/chan_phone.c
    trunk/channels/chan_sip.c
    trunk/channels/chan_skinny.c
    trunk/channels/chan_zap.c
    trunk/channels/iax2-provision.c
    trunk/funcs/func_db.c
    trunk/funcs/func_rand.c
    trunk/funcs/func_strings.c
    trunk/main/app.c
    trunk/main/channel.c
    trunk/main/db.c
    trunk/main/dns.c
    trunk/main/dsp.c
    trunk/main/enum.c
    trunk/main/file.c
    trunk/main/http.c
    trunk/main/loader.c
    trunk/main/logger.c
    trunk/main/manager.c
    trunk/main/pbx.c
    trunk/main/rtp.c
    trunk/main/say.c
    trunk/main/sched.c
    trunk/main/udptl.c
    trunk/pbx/pbx_dundi.c
    trunk/res/res_adsi.c
    trunk/res/res_agi.c
    trunk/res/res_config_pgsql.c
    trunk/res/res_crypto.c
    trunk/res/res_jabber.c
    trunk/res/res_monitor.c
    trunk/res/res_musiconhold.c
    trunk/res/res_smdi.c

Modified: trunk/apps/app_alarmreceiver.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_alarmreceiver.c?rev=44253&r1=44252&r2=44253&view=diff
==============================================================================
--- trunk/apps/app_alarmreceiver.c (original)
+++ trunk/apps/app_alarmreceiver.c Tue Oct  3 10:53:07 2006
@@ -251,14 +251,16 @@
 			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 @@
 		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 @@
 		
 		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 @@
 		
 		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 @@
 			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 @@
 				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 @@
 	*/
 	
 	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);
 	}
 

Modified: trunk/apps/app_db.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_db.c?rev=44253&r1=44252&r2=44253&view=diff
==============================================================================
--- trunk/apps/app_db.c (original)
+++ trunk/apps/app_db.c Tue Oct  3 10:53:07 2006
@@ -78,7 +78,8 @@
 		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 @@
 		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 @@
 				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);

Modified: trunk/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_dial.c?rev=44253&r1=44252&r2=44253&view=diff
==============================================================================
--- trunk/apps/app_dial.c (original)
+++ trunk/apps/app_dial.c Tue Oct  3 10:53:07 2006
@@ -1466,7 +1466,8 @@
 			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");

Modified: trunk/apps/app_directed_pickup.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_directed_pickup.c?rev=44253&r1=44252&r2=44253&view=diff
==============================================================================
--- trunk/apps/app_directed_pickup.c (original)
+++ trunk/apps/app_directed_pickup.c Tue Oct  3 10:53:07 2006
@@ -41,6 +41,7 @@
 #include "asterisk/module.h"
 #include "asterisk/lock.h"
 #include "asterisk/app.h"
+#include "asterisk/options.h"
 
 #define PICKUPMARK "PICKUPMARK"
 
@@ -109,14 +110,16 @@
 			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) {

Modified: trunk/apps/app_disa.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_disa.c?rev=44253&r1=44252&r2=44253&view=diff
==============================================================================
--- trunk/apps/app_disa.c (original)
+++ trunk/apps/app_disa.c Tue Oct  3 10:53:07 2006
@@ -48,6 +48,7 @@
 #include "asterisk/ulaw.h"
 #include "asterisk/callerid.h"
 #include "asterisk/stringfields.h"
+#include "asterisk/options.h"
 
 static char *app = "DISA";
 
@@ -154,8 +155,10 @@
 		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 @@
 	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 @@
 	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 @@
 		  /* 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 @@
 
 							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 @@
 
 					}
 					 /* 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 @@
 					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;
 				}
 			}

Modified: trunk/apps/app_externalivr.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_externalivr.c?rev=44253&r1=44252&r2=44253&view=diff
==============================================================================
--- trunk/apps/app_externalivr.c (original)
+++ trunk/apps/app_externalivr.c Tue Oct  3 10:53:07 2006
@@ -103,7 +103,8 @@
 	}
 
 	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 @@
 
 				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;

Modified: trunk/apps/app_festival.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_festival.c?rev=44253&r1=44252&r2=44253&view=diff
==============================================================================
--- trunk/apps/app_festival.c (original)
+++ trunk/apps/app_festival.c Tue Oct  3 10:53:07 2006
@@ -210,7 +210,8 @@
 				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 @@
 						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 @@
 			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);
-
-    	if (fd < 0) {
+	fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+
+	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;
-	}
-        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");
+		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");
 			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 @@
     			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 @@
 	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 @@
 	
 	/* 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 @@
 		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 @@
                }
 		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);

Modified: trunk/apps/app_ices.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_ices.c?rev=44253&r1=44252&r2=44253&view=diff
==============================================================================
--- trunk/apps/app_ices.c (original)
+++ trunk/apps/app_ices.c Tue Oct  3 10:53:07 2006
@@ -156,13 +156,15 @@
 			/* 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;
 			}

Modified: trunk/apps/app_macro.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_macro.c?rev=44253&r1=44252&r2=44253&view=diff
==============================================================================
--- trunk/apps/app_macro.c (original)
+++ trunk/apps/app_macro.c Tue Oct  3 10:53:07 2006
@@ -164,7 +164,8 @@
 
 	/* 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 @@
 			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 @@
 		}
 		/* 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 @@
 
 	/* 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;

Modified: trunk/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_meetme.c?rev=44253&r1=44252&r2=44253&view=diff
==============================================================================
--- trunk/apps/app_meetme.c (original)
+++ trunk/apps/app_meetme.c Tue Oct  3 10:53:07 2006
@@ -825,7 +825,10 @@
 		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 @@
 	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 @@
 		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 @@
 						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 @@
 					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 @@
 	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 @@
 				}
 			}
 			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 @@
 	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 @@
 	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;

Modified: trunk/apps/app_mp3.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_mp3.c?rev=44253&r1=44252&r2=44253&view=diff
==============================================================================
--- trunk/apps/app_mp3.c (original)
+++ trunk/apps/app_mp3.c Tue Oct  3 10:53:07 2006
@@ -183,7 +183,8 @@
 						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 @@
 			} 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;

Modified: trunk/apps/app_nbscat.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_nbscat.c?rev=44253&r1=44252&r2=44253&view=diff
==============================================================================
--- trunk/apps/app_nbscat.c (original)
+++ trunk/apps/app_nbscat.c Tue Oct  3 10:53:07 2006
@@ -165,7 +165,8 @@
 						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 @@
 			} 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;

Modified: trunk/apps/app_osplookup.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_osplookup.c?rev=44253&r1=44252&r2=44253&view=diff
==============================================================================
--- trunk/apps/app_osplookup.c (original)
+++ trunk/apps/app_osplookup.c Tue Oct  3 10:53:07 2006
@@ -179,14 +179,16 @@
 			} 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 @@
 				} 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 @@
 		} 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 @@
 		} 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 @@
 		} 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 @@
 		} 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 @@
 		} 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 @@
 
 	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 @@
 		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 @@
 	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 @@
 		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 @@
 		&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 @@
 	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 @@
 	}
 
 	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 @@
 	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 @@
 	*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 @@
 			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 @@
 			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 @@
 	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 @@
 	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 @@
 	}
 
 	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 @@
 	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 @@
 
 	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) {

[... 6503 lines stripped ...]


More information about the asterisk-commits mailing list