[svn-commits] branch bweschke/findme_followme r31812 - /team/bweschke/findme_followme/apps/

svn-commits at lists.digium.com svn-commits at lists.digium.com
Sat Jun 3 12:44:49 MST 2006


Author: bweschke
Date: Sat Jun  3 14:44:48 2006
New Revision: 31812

URL: http://svn.digium.com/view/asterisk?rev=31812&view=rev
Log:
 Cleanup logging and messaging from the app out to the logger and the CLI. Don't be "too chatty" when VERBOSE and DEBUG levels ask that the app not be.


Modified:
    team/bweschke/findme_followme/apps/app_followme.c

Modified: team/bweschke/findme_followme/apps/app_followme.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/findme_followme/apps/app_followme.c?rev=31812&r1=31811&r2=31812&view=diff
==============================================================================
--- team/bweschke/findme_followme/apps/app_followme.c (original)
+++ team/bweschke/findme_followme/apps/app_followme.c Sat Jun  3 14:44:48 2006
@@ -197,7 +197,7 @@
 			*tmp = '\0';
 		}
 		ast_copy_string(cur->number, number, sizeof(cur->number));
-		if (option_debug > 2)
+		if (option_debug)
 			ast_log(LOG_DEBUG, "Created a number, %s, with a timeout of %ld.\n", cur->number, cur->timeout);
 	}
 
@@ -246,7 +246,7 @@
 			if (!strcasecmp(f->name, cat))
 				break;
 		}
-		if (option_debug > 2)
+		if (option_debug)
 			ast_log(LOG_DEBUG, "New profile %s.\n", cat);
 		if (!f) {
 			/* Make one then */
@@ -279,7 +279,7 @@
 					AST_LIST_INSERT_HEAD(&f->numbers, cur, entry);
 				} else {
 					profile_set_param(f, var->name, var->value, var->lineno, 1);
-					if (option_debug > 2)
+					if (option_debug)
 						ast_log(LOG_DEBUG, "Logging parameter %s with value %s from lineno %d\n", var->name, var->value, var->lineno);
 				}
 				var = var->next;
@@ -363,7 +363,8 @@
 	if (!AST_LIST_EMPTY(findme_user_list))
 	{
 		if (!caller) {
-			ast_log(LOG_NOTICE, "Original caller hungup. Cleanup.\n");
+			if (option_verbose > 2)
+				ast_verbose(VERBOSE_PREFIX_3 "Original caller hungup. Cleanup.\n");
 			clear_calling_tree(findme_user_list);
 			free(to);
 			return 0;
@@ -381,7 +382,8 @@
 			AST_LIST_TRAVERSE(findme_user_list, tmpuser, entry) {
 				if (tmpuser->state >= 0 && tmpuser->ochan) {
 					if (tmpuser->digts && (tmpuser->digts - totalwait) > featuredigittimeout) {
-						ast_log(LOG_NOTICE, "We've been waiting for digits longer than we should have.\n");
+						if (option_verbose > 2)
+							ast_verbose(VERBOSE_PREFIX_3 "We've been waiting for digits longer than we should have.\n");
 						tmpuser->state = 1;
 						tmpuser->digts = 0;
 						if (!ast_streamfile(tmpuser->ochan, callfromname, tmpuser->ochan->language)) {
@@ -400,7 +402,8 @@
 						else if (tmpto < 0) {
 							ast_stopstream(tmpuser->ochan);
 							if (tmpuser->state == 1) {
-								ast_log(LOG_NOTICE, "Playback of the file appears to be done.\n");
+								if (option_verbose > 2)
+									ast_verbose(VERBOSE_PREFIX_3 "Playback of the call-from file appears to be done.\n");
 								if (!ast_streamfile(tmpuser->ochan, namerecloc, tmpuser->ochan->language)) {
 									tmpuser->state = 2;
 								} else {
@@ -409,7 +412,8 @@
 									return NULL;
 								}
 							} else if (tmpuser->state == 2) {
-								ast_log(LOG_NOTICE, "Playback of name file appears to be done.\n");
+								if (option_verbose > 2)
+									ast_verbose(VERBOSE_PREFIX_3 "Playback of name file appears to be done.\n");
 								memset(tmpuser->yn, 0, sizeof(tmpuser->yn));
 								tmpuser->ynidx = 0;
 								tmpuser->digts = 0;
@@ -421,7 +425,8 @@
 									return NULL;
 								} 
 							} else if (tmpuser->state == 3) {
-								ast_log(LOG_NOTICE, "Playback of the next step file appears to be done.\n");
+								if (option_verbose > 2)
+									ast_verbose(VERBOSE_PREFIX_3 "Playback of the next step file appears to be done.\n");
 							}
 						}
 					}
@@ -435,7 +440,8 @@
 			tmpto -= *to;
 			totalwait -= tmpto;
 			if (totalwait <= 0) {
-				ast_log(LOG_NOTICE, "We've hit our timeout for this step. Drop everyone and move on to the next one. %ld\n", totalwait);
+				if (option_verbose > 2)	
+					ast_verbose(VERBOSE_PREFIX_3 "We've hit our timeout for this step. Drop everyone and move on to the next one. %ld\n", totalwait);
 				clear_calling_tree(findme_user_list);
 				free(to);
 				return 0;
@@ -522,7 +528,7 @@
 								ast_verbose( VERBOSE_PREFIX_3 "%s stopped sounds\n", winner->name);
 							break;
 						default:
-							if (option_debug > 2)
+							if (option_debug)
 								ast_log(LOG_DEBUG, "Dunno what to do with control type %d\n", f->subclass);
 							break;
 						}
@@ -532,37 +538,45 @@
 							ast_stopstream(winner);
 						if (!tmpuser->digts)
 							tmpuser->digts = totalwait;
-						ast_log(LOG_NOTICE, "DTMF received: %c\n",(char) f->subclass);
+						if (option_debug)
+							ast_log(LOG_DEBUG, "DTMF received: %c\n",(char) f->subclass);
 						tmpuser->yn[tmpuser->ynidx] = (char) f->subclass;
 						tmpuser->ynidx++;
-						ast_log(LOG_NOTICE, "DTMF string: %s\n", tmpuser->yn);
+						if (option_debug)
+							ast_log(LOG_DEBUG, "DTMF string: %s\n", tmpuser->yn);
 						if (tmpuser->ynidx >= ynlongest) {
-							ast_log(LOG_NOTICE, "reached longest possible match\n");
+							if (option_debug)
+								ast_log(LOG_DEBUG, "reached longest possible match - doing evals\n");
 							if (!strcmp(tmpuser->yn, takecall)) {
-								ast_log(LOG_NOTICE, "Match to take the call!\n");
+								if (option_debug)
+									ast_log(LOG_DEBUG, "Match to take the call!\n");
 								free(to);
 								return tmpuser->ochan;	
 							}
 							if (!strcmp(tmpuser->yn, nextindp)) {
-								ast_log(LOG_NOTICE, "Next in dial plan step requested.\n");
+								if (option_debug)
+									ast_log(LOG_DEBUG, "Next in dial plan step requested.\n");
 								*status = 1;
 								free(to);
 								return 0;
 							}	
 							if (!strcmp(tmpuser->yn, nextinfmfm)) {
-								ast_log(LOG_NOTICE, "Next in find me/follow me step requested.\n");
+								if (option_debug)
+									ast_log(LOG_DEBUG, "Next in find me/follow me step requested.\n");
 								*status = 2;
 								free(to);
 								return 0;
 							}	
 							if (!strcmp(tmpuser->yn, blindxferexten)) {
-								ast_log(LOG_NOTICE, "Blind Transfer requested.\n");
+								if (option_debug)
+									ast_log(LOG_DEBUG, "Blind Transfer requested.\n");
 								*status = 3;
 								free(to);
 								return 0;
 							}	
 							if (!strcmp(tmpuser->yn, atxferexten)) {
-								ast_log(LOG_NOTICE, "Attended Transfer requested.\n");
+								if (option_debug)
+									ast_log(LOG_DEBUG, "Attended Transfer requested.\n");
 								*status = 4;
 								free(to);
 								return 0;
@@ -574,8 +588,8 @@
 					ast_frfree(f);
 				} else {
 					if (winner) {
-
-						ast_log(LOG_NOTICE, "we didn't get a frame. hanging up. dg is %d\n",dg);					      
+						if (option_debug)
+							ast_log(LOG_DEBUG, "we didn't get a frame. hanging up. dg is %d\n",dg);					      
 						if (!dg) {
 							clear_calling_tree(findme_user_list);
 							free(to);
@@ -584,9 +598,11 @@
 							tmpuser->state = -1;
 						 	ast_hangup(winner);  
 							livechannels--;
-							ast_log(LOG_NOTICE, "live channels left %d\n", livechannels);
+							if (option_debug)
+								ast_log(LOG_DEBUG, "live channels left %d\n", livechannels);
 							if (!livechannels) {
-								ast_log(LOG_NOTICE, "no live channels left. exiting.\n");
+								if (option_verbose > 2)
+									ast_verbose(VERBOSE_PREFIX_3 "no live channels left. exiting.\n");
 								free(to);
 								return 0;
 							}
@@ -600,7 +616,8 @@
 	}
 	else
 	{
-		ast_log(LOG_NOTICE, "couldn't reach at this number.\n");
+		if (option_verbose > 2)
+			ast_verbose(VERBOSE_PREFIX_3 "couldn't reach at this number.\n");
 	}
 	
 	/* --- WAIT FOR WINNER NUMBER END! -----------*/
@@ -648,12 +665,13 @@
 
 	caller = tpargs->chan;
 	AST_LIST_TRAVERSE(&tpargs->cnumbers, nm, entry) {
-		if (option_debug > 2)	
+		if (option_debug)	
 			ast_log(LOG_DEBUG, "Number %s timeout %ld\n",nm->number,nm->timeout);
 		time(&start_time);
 
 		number = ast_strdupa(nm->number);
-		ast_log(LOG_NOTICE, "examining %s\n", number);
+		if (option_debug)
+			ast_log(LOG_DEBUG, "examining %s\n", number);
 		do {
 			rest = strchr(number, '&');
 			if (rest) {
@@ -676,14 +694,16 @@
 			if (outbound) {
 				ast_set_callerid(outbound, caller->cid.cid_num, caller->cid.cid_name, caller->cid.cid_num);
 				ast_channel_inherit_variables(tpargs->chan, outbound);
-				ast_log(LOG_NOTICE, "calling %s\n", dialarg);
+				if (option_verbose > 2)
+					ast_verbose(VERBOSE_PREFIX_3 "calling %s\n", dialarg);
 				if (!ast_call(outbound,dialarg,0)) {
 					tmpuser->ochan = outbound;
 					tmpuser->state = 0;
 					ast_copy_string(tmpuser->dialarg, dialarg, sizeof(dialarg));
 					AST_LIST_INSERT_TAIL(findme_user_list, tmpuser, entry);
-				} else { 
-					ast_log(LOG_NOTICE, "couldn't reach at this number.\n"); 
+				} else {
+					if (option_verbose > 2) 
+						ast_verbose(VERBOSE_PREFIX_3 "couldn't reach at this number.\n"); 
 					if (outbound) {
 						if (!outbound->cdr) {
 							outbound->cdr = ast_cdr_alloc();
@@ -782,7 +802,7 @@
 			}
 			AST_LIST_UNLOCK(&followmes);
 
-			if (option_debug > 2)
+			if (option_debug)
 				ast_log(LOG_DEBUG, "New profile %s.\n", args.followmeid);
 			if (!f)
 			{ 



More information about the svn-commits mailing list