[asterisk-commits] jpeeler: branch jpeeler/asterisk-sigwork-trunk r193049 - /team/jpeeler/asteri...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu May 7 17:03:51 CDT 2009


Author: jpeeler
Date: Thu May  7 17:03:48 2009
New Revision: 193049

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=193049
Log:
more ast_debug goodness that I meant to commit earlier

Modified:
    team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.c

Modified: team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.c?view=diff&rev=193049&r1=193048&r2=193049
==============================================================================
--- team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.c (original)
+++ team/jpeeler/asterisk-sigwork-trunk/channels/sig_analog.c Thu May  7 17:03:48 2009
@@ -1979,7 +1979,7 @@
 
 				if (res == 1) {
 					if (ev == ANALOG_EVENT_POLARITY && p->hanguponpolarityswitch && p->polarity == POLARITY_REV) {
-						ast_log(LOG_DEBUG, "Hanging up due to polarity reversal on channel %d while detecting callerid\n", p->channel);
+						ast_debug(1, "Hanging up due to polarity reversal on channel %d while detecting callerid\n", p->channel);
 						p->polarity = POLARITY_IDLE;
 						ast_hangup(chan);
 						return NULL;
@@ -2037,7 +2037,7 @@
 						ast_log(LOG_NOTICE, "Got event %d (%s)...\n", res, event2str(res));
 						/* If we get a PR event, they hung up while processing calerid */
 						if ( res == ANALOG_EVENT_POLARITY && p->hanguponpolarityswitch && p->polarity == POLARITY_REV) {
-							ast_log(LOG_DEBUG, "Hanging up due to polarity reversal on channel %d while detecting callerid\n", p->channel);
+							ast_debug(1, "Hanging up due to polarity reversal on channel %d while detecting callerid\n", p->channel);
 							p->polarity = POLARITY_IDLE;
 							callerid_free(cs);
 							ast_hangup(chan);
@@ -2084,8 +2084,7 @@
 				}
 				if (res == 1) {
 					callerid_get(cs, &name, &number, &flags);
-					if (option_debug)
-						ast_log(LOG_DEBUG, "CallerID number: %s, name: %s, flags=%d\n", number, name, flags);
+					ast_debug(1, "CallerID number: %s, name: %s, flags=%d\n", number, name, flags);
 				}
 				/* Restore linear mode (if appropriate) for Caller*ID processing */
 				dahdi_setlinear(p->subs[index].dfd, p->subs[index].linear);
@@ -2168,8 +2167,7 @@
 
 	res = analog_get_event(p);
 
-	if (option_debug)
-		ast_log(LOG_DEBUG, "Got event %s(%d) on channel %d (index %d)\n", analog_event2str(res), res, p->channel, index);
+	ast_debug(1, "Got event %s(%d) on channel %d (index %d)\n", analog_event2str(res), res, p->channel, index);
 
 	switch (res) {
 #ifdef ANALOG_EVENT_EC_DISABLED
@@ -2274,14 +2272,14 @@
 							return NULL;
 						}
 						mssinceflash = ast_tvdiff_ms(ast_tvnow(), p->flashtime);
-						ast_log(LOG_DEBUG, "Last flash was %d ms ago\n", mssinceflash);
+						ast_debug(1, "Last flash was %d ms ago\n", mssinceflash);
 						if (mssinceflash < MIN_MS_SINCE_FLASH) {
 							/* It hasn't been long enough since the last flashook.  This is probably a bounce on 
 							   hanging up.  Hangup both channels now */
 							if (p->subs[ANALOG_SUB_THREEWAY].owner)
 								ast_queue_hangup(p->subs[ANALOG_SUB_THREEWAY].owner);
 							ast_softhangup_nolock(p->subs[ANALOG_SUB_THREEWAY].owner, AST_SOFTHANGUP_DEV);
-							ast_log(LOG_DEBUG, "Looks like a bounced flash, hanging up both calls on %d\n", p->channel);
+							ast_debug(1, "Looks like a bounced flash, hanging up both calls on %d\n", p->channel);
 							ast_channel_unlock(p->subs[ANALOG_SUB_THREEWAY].owner);
 						} else if ((ast->pbx) || (ast->_state == AST_STATE_UP)) {
 							if (p->transfer) {
@@ -2372,7 +2370,7 @@
 					p->subs[index].f.subclass = AST_CONTROL_ANSWER;
 					/* Make sure it stops ringing */
 					analog_off_hook(p);
-					ast_log(LOG_DEBUG, "channel %d answered\n", p->channel);
+					ast_debug(1, "channel %d answered\n", p->channel);
 					p->dialing = 0;
 					p->callwaitcas = 0;
 					if (!ast_strlen_zero(p->dop.dialstr)) {
@@ -2383,7 +2381,7 @@
 							p->dop.dialstr[0] = '\0';
 							return NULL;
 						} else {
-							ast_log(LOG_DEBUG, "Sent FXO deferred digit string: %s\n", p->dop.dialstr);
+							ast_debug(1, "Sent FXO deferred digit string: %s\n", p->dop.dialstr);
 							p->subs[index].f.frametype = AST_FRAME_NULL;
 							p->subs[index].f.subclass = 0;
 							p->dialing = 1;
@@ -2398,7 +2396,7 @@
 					ast->rings = 1;
 					p->subs[index].f.frametype = AST_FRAME_CONTROL;
 					p->subs[index].f.subclass = AST_CONTROL_OFFHOOK;
-					ast_log(LOG_DEBUG, "channel %d picked up\n", p->channel);
+					ast_debug(1, "channel %d picked up\n", p->channel);
 					return &p->subs[index].f;
 				case AST_STATE_UP:
 					/* Make sure it stops ringing */
@@ -2446,13 +2444,11 @@
 				if (ast->_state == AST_STATE_PRERING)
 					ast_setstate(ast, AST_STATE_RING);
 				if ((ast->_state == AST_STATE_DOWN) || (ast->_state == AST_STATE_RING)) {
-					if (option_debug)
-						ast_log(LOG_DEBUG, "Ring detected\n");
+					ast_debug(1, "Ring detected\n");
 					p->subs[index].f.frametype = AST_FRAME_CONTROL;
 					p->subs[index].f.subclass = AST_CONTROL_RING;
 				} else if (p->outgoing && ((ast->_state == AST_STATE_RINGING) || (ast->_state == AST_STATE_DIALING))) {
-					if (option_debug)
-						ast_log(LOG_DEBUG, "Line answered\n");
+					ast_debug(1, "Line answered\n");
 					p->subs[index].f.frametype = AST_FRAME_CONTROL;
 					p->subs[index].f.subclass = AST_CONTROL_ANSWER;
 					ast_setstate(ast, AST_STATE_UP);
@@ -2531,7 +2527,7 @@
 					analog_swap_subs(p, ANALOG_SUB_REAL, ANALOG_SUB_CALLWAIT);
 					analog_play_tone(p, ANALOG_SUB_REAL, -1);
 					p->owner = p->subs[ANALOG_SUB_REAL].owner;
-					ast_log(LOG_DEBUG, "Making %s the new owner\n", p->owner->name);
+					ast_debug(1, "Making %s the new owner\n", p->owner->name);
 					if (previous_state == AST_STATE_RINGING) {
 						ast_queue_control(p->subs[ANALOG_SUB_REAL].owner, AST_CONTROL_ANSWER);
 					}
@@ -2569,7 +2565,7 @@
 						if (!((ast->pbx) ||
 						      (ast->_state == AST_STATE_UP) ||
 						      (ast->_state == AST_STATE_RING))) {
-							ast_log(LOG_DEBUG, "Flash when call not up or ringing\n");
+							ast_debug(1, "Flash when call not up or ringing\n");
 								goto winkflashdone;
 						}
 						if (analog_alloc_sub(p, ANALOG_SUB_THREEWAY)) {
@@ -2630,8 +2626,7 @@
 					/* Already have a 3 way call */
 					if (p->subs[ANALOG_SUB_THREEWAY].inthreeway) {
 						/* Call is already up, drop the last person */
-						if (option_debug)
-							ast_log(LOG_DEBUG, "Got flash with three way call up, dropping last call on %d\n", p->channel);
+						ast_debug(1, "Got flash with three way call up, dropping last call on %d\n", p->channel);
 						/* If the primary call isn't answered yet, use it */
 						if ((p->subs[ANALOG_SUB_REAL].owner->_state != AST_STATE_UP) && (p->subs[ANALOG_SUB_THREEWAY].owner->_state == AST_STATE_UP)) {
 							/* Swap back -- we're dropping the real 3-way that isn't finished yet*/
@@ -2673,7 +2668,7 @@
 								ast_queue_control(p->subs[otherindex].owner, AST_CONTROL_UNHOLD);
 							p->owner = p->subs[ANALOG_SUB_REAL].owner;
 							if (ast->_state == AST_STATE_RINGING) {
-								ast_log(LOG_DEBUG, "Enabling ringtone on real and threeway\n");
+								ast_debug(1, "Enabling ringtone on real and threeway\n");
 								analog_play_tone(p, ANALOG_SUB_REAL, ANALOG_TONE_RINGTONE);
 								analog_play_tone(p, ANALOG_SUB_THREEWAY, ANALOG_TONE_RINGTONE);
 							}
@@ -2703,14 +2698,14 @@
 			case ANALOG_SIG_FXSLS:
 			case ANALOG_SIG_FXSGS:
 				if (p->dialing)
-					ast_log(LOG_DEBUG, "Ignoring wink on channel %d\n", p->channel);
+					ast_debug(1, "Ignoring wink on channel %d\n", p->channel);
 				else
-					ast_log(LOG_DEBUG, "Got wink in weird state %d on channel %d\n", ast->_state, p->channel);
+					ast_debug(1, "Got wink in weird state %d on channel %d\n", ast->_state, p->channel);
 				break;
 			case ANALOG_SIG_FEATDMF_TA:
 				switch (p->whichwink) {
 				case 0:
-					ast_log(LOG_DEBUG, "ANI2 set to '%d' and ANI is '%s'\n", p->owner->cid.cid_ani2, p->owner->cid.cid_ani);
+					ast_debug(1, "ANI2 set to '%d' and ANI is '%s'\n", p->owner->cid.cid_ani2, p->owner->cid.cid_ani);
 					snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "M*%d%s#", p->owner->cid.cid_ani2, p->owner->cid.cid_ani);
 					break;
 				case 1:
@@ -2737,7 +2732,7 @@
 						p->dop.dialstr[0] = '\0';
 						return NULL;
 					} else 
-						ast_log(LOG_DEBUG, "Sent deferred digit string on channel %d: %s\n", p->channel, p->dop.dialstr);
+						ast_debug(1, "Sent deferred digit string on channel %d: %s\n", p->channel, p->dop.dialstr);
 				}
 				p->dop.dialstr[0] = '\0';
 				break;
@@ -2765,7 +2760,7 @@
 						p->dop.dialstr[0] = '\0';
 						return NULL;
 					} else 
-						ast_log(LOG_DEBUG, "Sent deferred digit string on channel %d: %s\n", p->channel, p->dop.dialstr);
+						ast_debug(1, "Sent deferred digit string on channel %d: %s\n", p->channel, p->dop.dialstr);
 				}
 				p->dop.dialstr[0] = '\0';
 				p->dop.op = ANALOG_DIAL_OP_REPLACE;
@@ -2778,7 +2773,7 @@
 			case ANALOG_SIG_FEATB:
 			case ANALOG_SIG_SF_FEATDMF:
 			case ANALOG_SIG_SF_FEATB:
-				ast_log(LOG_DEBUG, "Got hook complete in MF FGD, waiting for wink now on channel %d\n",p->channel);
+				ast_debug(1, "Got hook complete in MF FGD, waiting for wink now on channel %d\n",p->channel);
 				break;
 			default:
 				break;
@@ -2796,13 +2791,13 @@
 				if (p->answeronpolarityswitch &&
 				    ((ast->_state == AST_STATE_DIALING) ||
 					 (ast->_state == AST_STATE_RINGING))) {
-					ast_log(LOG_DEBUG, "Answering on polarity switch!\n");
+					ast_debug(1, "Answering on polarity switch!\n");
 					ast_setstate(p->owner, AST_STATE_UP);
 					if (p->hanguponpolarityswitch) {
 						gettimeofday(&p->polaritydelaytv, NULL);
 					}
 				} else
-					ast_log(LOG_DEBUG, "Ignore switch to REVERSED Polarity on channel %d, state %d\n", p->channel, ast->_state);
+					ast_debug(1, "Ignore switch to REVERSED Polarity on channel %d, state %d\n", p->channel, ast->_state);
 			} 
 			/* Removed else statement from here as it was preventing hangups from ever happening*/
 			/* Added AST_STATE_RING in if statement below to deal with calling party hangups that take place when ringing */
@@ -2811,24 +2806,24 @@
 			       (p->polarity == POLARITY_REV) &&
 				((ast->_state == AST_STATE_UP) || (ast->_state == AST_STATE_RING)) ) {
                                 /* Added log_debug information below to provide a better indication of what is going on */
-				ast_log(LOG_DEBUG, "Polarity Reversal event occured - DEBUG 1: channel %d, state %d, pol= %d, aonp= %d, honp= %d, pdelay= %d, tv= %d\n", p->channel, ast->_state, p->polarity, p->answeronpolarityswitch, p->hanguponpolarityswitch, p->polarityonanswerdelay, ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) );
+				ast_debug(1, "Polarity Reversal event occured - DEBUG 1: channel %d, state %d, pol= %d, aonp= %d, honp= %d, pdelay= %d, tv= %d\n", p->channel, ast->_state, p->polarity, p->answeronpolarityswitch, p->hanguponpolarityswitch, p->polarityonanswerdelay, ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) );
 			
 				if (ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) > p->polarityonanswerdelay) {
-					ast_log(LOG_DEBUG, "Polarity Reversal detected and now Hanging up on channel %d\n", p->channel);
+					ast_debug(1, "Polarity Reversal detected and now Hanging up on channel %d\n", p->channel);
 					ast_softhangup(p->owner, AST_SOFTHANGUP_EXPLICIT);
 					p->polarity = POLARITY_IDLE;
 				} else {
-					ast_log(LOG_DEBUG, "Polarity Reversal detected but NOT hanging up (too close to answer event) on channel %d, state %d\n", p->channel, ast->_state);
+					ast_debug(1, "Polarity Reversal detected but NOT hanging up (too close to answer event) on channel %d, state %d\n", p->channel, ast->_state);
 				}
 			} else {
 				p->polarity = POLARITY_IDLE;
-				ast_log(LOG_DEBUG, "Ignoring Polarity switch to IDLE on channel %d, state %d\n", p->channel, ast->_state);
+				ast_debug(1, "Ignoring Polarity switch to IDLE on channel %d, state %d\n", p->channel, ast->_state);
 			}
                      	/* Added more log_debug information below to provide a better indication of what is going on */
-			ast_log(LOG_DEBUG, "Polarity Reversal event occured - DEBUG 2: channel %d, state %d, pol= %d, aonp= %d, honp= %d, pdelay= %d, tv= %d\n", p->channel, ast->_state, p->polarity, p->answeronpolarityswitch, p->hanguponpolarityswitch, p->polarityonanswerdelay, ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) );
+			ast_debug(1, "Polarity Reversal event occured - DEBUG 2: channel %d, state %d, pol= %d, aonp= %d, honp= %d, pdelay= %d, tv= %d\n", p->channel, ast->_state, p->polarity, p->answeronpolarityswitch, p->hanguponpolarityswitch, p->polarityonanswerdelay, ast_tvdiff_ms(ast_tvnow(), p->polaritydelaytv) );
 			break;
 		default:
-			ast_log(LOG_DEBUG, "Dunno what to do with event %d on channel %d\n", res, p->channel);
+			ast_debug(1, "Dunno what to do with event %d on channel %d\n", res, p->channel);
 	}
 	return &p->subs[index].f;
 }
@@ -2866,7 +2861,7 @@
 		/* Switch to real if there is one and this isn't something really silly... */
 		if ((res != ANALOG_EVENT_RINGEROFF) && (res != ANALOG_EVENT_RINGERON) &&
 			(res != ANALOG_EVENT_HOOKCOMPLETE)) {
-			ast_log(LOG_DEBUG, "Restoring owner of channel %d on event %d\n", p->channel, res);
+			ast_debug(1, "Restoring owner of channel %d on event %d\n", p->channel, res);
 			p->owner = p->subs[ANALOG_SUB_REAL].owner;
 			if (p->owner && ast_bridged_channel(p->owner))
 				ast_queue_control(p->owner, AST_CONTROL_UNHOLD);
@@ -2922,8 +2917,7 @@
 		f = &p->subs[index].f;
 		return f;
 	}
-	if (option_debug) 
-		ast_log(LOG_DEBUG, "Exception on %d, channel %d\n", ast->fds[0],p->channel);
+	ast_debug(1, "Exception on %d, channel %d\n", ast->fds[0],p->channel);
 	/* If it's not us, return NULL immediately */
 	if (ast != p->owner) {
 		ast_log(LOG_WARNING, "We're %s, not %s\n", ast->name, p->owner->name);
@@ -2941,8 +2935,7 @@
 	pthread_attr_t attr;
 	struct ast_channel *chan;
 
-	if (option_debug) {
-		ast_log(LOG_DEBUG, "channel (%d) - signaling (%d) - event (%s)\n", 
+	ast_debug(1, "channel (%d) - signaling (%d) - event (%s)\n", 
 				i->channel, i->sig, analog_event2str(event));
 	}
 




More information about the asterisk-commits mailing list