[asterisk-commits] rizzo: branch rizzo/astobj2 r76057 - /team/rizzo/astobj2/channels/chan_sip.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jul 20 11:53:34 CDT 2007


Author: rizzo
Date: Fri Jul 20 11:53:33 2007
New Revision: 76057

URL: http://svn.digium.com/view/asterisk?view=rev&rev=76057
Log:
massive (but incomplete) ast_log(LOG_DEBUG, ...) --> ast_debug(...) replacement


Modified:
    team/rizzo/astobj2/channels/chan_sip.c

Modified: team/rizzo/astobj2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/channels/chan_sip.c?view=diff&rev=76057&r1=76056&r2=76057
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Fri Jul 20 11:53:33 2007
@@ -1903,15 +1903,13 @@
 static void sip_registry_destroy(struct sip_registry *reg)
 {
 	/* Really delete */
-	if (option_debug > 2)
-		ast_log(LOG_DEBUG, "Destroying registry entry for %s@%s\n", reg->username, reg->hostname);
+	ast_debug(3, "Destroying registry entry for %s@%s\n", reg->username, reg->hostname);
 
 	if (reg->register_pvt) {
 		/* Clear registry before destroying to ensure
 		   we don't get reentered trying to grab the registry lock */
 		reg->register_pvt->registry = NULL;	/* XXX cannot be different or we would not be here! */
-		if (option_debug > 2)
-			ast_log(LOG_DEBUG, "Destroying active SIP dialog for registry %s@%s\n", reg->username, reg->hostname);
+		ast_debug(3, "Destroying active SIP dialog for registry %s@%s\n", reg->username, reg->hostname);
 		reg->register_pvt = sip_destroy(reg->register_pvt);
 	}
 	if (reg->timeout > -1)
@@ -1923,8 +1921,7 @@
 
 static void *registry_unref(struct sip_registry *reg)
 {
-	if (option_debug > 2)
-		ast_log(LOG_DEBUG, "SIP Registry %s: refcount now %d\n", reg->hostname, reg->refcount - 1);
+	ast_debug(3, "SIP Registry %s: refcount now %d\n", reg->hostname, reg->refcount - 1);
 	ASTOBJ_UNREF(reg, sip_registry_destroy);
 	return NULL;
 }
@@ -1932,8 +1929,7 @@
 /*! \brief Add object reference to SIP registry */
 static struct sip_registry *registry_addref(struct sip_registry *reg)
 {
-	if (option_debug > 2)
-		ast_log(LOG_DEBUG, "SIP Registry %s: refcount now %d\n", reg->hostname, reg->refcount + 1);
+	ast_debug(3, "SIP Registry %s: refcount now %d\n", reg->hostname, reg->refcount + 1);
 	return ASTOBJ_REF(reg); /* Add pointer to registry in packet */
 }
 
@@ -1947,8 +1943,7 @@
 	} while (0));
 
 	ASTOBJ_CONTAINER_DESTROYALL(&regl, sip_registry_destroy);
-	if (option_debug > 3)
-		ast_log(LOG_DEBUG, "--------------- Done destroying registry list\n");
+	ast_debug(4, "--------------- Done destroying registry list\n");
 }
 
 
@@ -1992,12 +1987,10 @@
  */
 static void initialize_initreq(struct sip_pvt *p, struct sip_msg_out *req)
 {
-	if (option_debug) {
-		if (p->initreq.headers)
-			ast_log(LOG_DEBUG, "Initializing already initialized SIP dialog %s (presumably reinvite)\n", p->callid);
-		else
-			ast_log(LOG_DEBUG, "Initializing initreq for method %s - callid %s\n", sip_methods[req->method].text, p->callid);
-	}
+	if (p->initreq.headers)
+		ast_debug(1, "Initializing already initialized SIP dialog %s (presumably reinvite)\n", p->callid);
+	else
+		ast_debug(1, "Initializing initreq for method %s - callid %s\n", sip_methods[req->method].text, p->callid);
 	/* Use this as the basis */
 	parse_copy(&p->initreq, req);	/* XXX check this */
 	/* req has no SIP_PKT_DEBUG flag. If we want to print something,
@@ -2010,8 +2003,7 @@
 /*! \brief Encapsulate setting of SIP_ALREADYGONE to be able to trace it with debugging */
 static void sip_alreadygone(struct sip_pvt *dialog)
 {
-	if (option_debug > 2)
-		ast_log(LOG_DEBUG, "Setting SIP_ALREADYGONE on dialog %s\n", dialog->callid);
+	ast_debug(3, "Setting SIP_ALREADYGONE on dialog %s\n", dialog->callid);
 	ast_set_flag(&dialog->flags[0], SIP_ALREADYGONE);
 }
 
@@ -2050,19 +2042,19 @@
 static struct sip_proxy *obproxy_get(struct sip_pvt *dialog, struct sip_peer *peer)
 {
 	if (peer && peer->outboundproxy) {
-		if (option_debug && sipdebug)
-			ast_log(LOG_DEBUG, "OBPROXY: Applying peer OBproxy to this call\n");
+		if (sipdebug)
+			ast_debug(1, "OBPROXY: Applying peer OBproxy to this call\n");
 		append_history(dialog, "OBproxy", "Using peer obproxy %s", peer->outboundproxy->name);
 		return peer->outboundproxy;
 	}
 	if (global_outboundproxy.name[0]) {
-		if (option_debug && sipdebug)
-			ast_log(LOG_DEBUG, "OBPROXY: Applying global OBproxy to this call\n");
+		if (sipdebug)
+			ast_debug(1, "OBPROXY: Applying global OBproxy to this call\n");
 		append_history(dialog, "OBproxy", "Using global obproxy %s", global_outboundproxy.name);
 		return &global_outboundproxy;
 	}
-	if (option_debug && sipdebug)
-		ast_log(LOG_DEBUG, "OBPROXY: Not applying OBproxy to this call\n");
+	if (sipdebug)
+		ast_debug(1, "OBPROXY: Not applying OBproxy to this call\n");
 	return NULL;
 }
 
@@ -2107,30 +2099,30 @@
 		return 0;
 	temp = ast_strdupa(supported);
 
-	if (option_debug > 2 && sipdebug)
-		ast_log(LOG_DEBUG, "Begin: parsing SIP \"Supported: %s\"\n", supported);
+	if (sipdebug)
+		ast_debug(3, "Begin: parsing SIP \"Supported: %s\"\n", supported);
 
 	for (next = temp; next; next = sep) {
 		found = FALSE;
 		if ( (sep = strchr(next, ',')) != NULL)
 			*sep++ = '\0';
 		next = ast_skip_blanks(next);
-		if (option_debug > 2 && sipdebug)
-			ast_log(LOG_DEBUG, "Found SIP option: -%s-\n", next);
+		if (sipdebug)
+			ast_debug(3, "Found SIP option: -%s-\n", next);
 		for (i=0; i < (sizeof(sip_options) / sizeof(sip_options[0])); i++) {
 			if (!strcasecmp(next, sip_options[i].text)) {
 				profile |= sip_options[i].id;
 				found = TRUE;
-				if (option_debug > 2 && sipdebug)
-					ast_log(LOG_DEBUG, "Matched SIP option: %s\n", next);
+				if (sipdebug)
+					ast_debug(3, "Matched SIP option: %s\n", next);
 				break;
 			}
 		}
-		if (!found && option_debug > 2 && sipdebug) {
+		if (!found && sipdebug) {
 			if (!strncasecmp(next, "x-", 2))
-				ast_log(LOG_DEBUG, "Found private SIP option, not supported: %s\n", next);
+				ast_debug(3, "Found private SIP option, not supported: %s\n", next);
 			else
-				ast_log(LOG_DEBUG, "Found no match for SIP option: %s (Please file bug report!)\n", next);
+				ast_debug(3, "Found no match for SIP option: %s (Please file bug report!)\n", next);
 		}
 	}
 
@@ -2258,10 +2250,8 @@
 			*us = externip;
 		else
 			ast_log(LOG_WARNING, "stun failed\n");
-		if (option_debug) {
-			ast_log(LOG_DEBUG, "Target address %s is not local, substituting externip\n", 
+		ast_debug(1, "Target address %s is not local, substituting externip\n", 
 				ast_inet_ntoa(*(struct in_addr *)&them->s_addr));
-		}
 	} else if (bindaddr.sin_addr.s_addr) {
 		/* remapping is not allowed, but we bind to
 		 * a specific address, so use it.
@@ -2365,8 +2355,8 @@
 
 		append_history(pvt, "ReTx", "%d %s", reschedule, pkt->data);
 		__sip_xmit(pvt, pkt->data, pkt->packetlen);
-		if (sipdebug && option_debug > 3)
-			ast_log(LOG_DEBUG, "** SIP timers: Rescheduling retransmission %d to %d ms (t1 %d ms t_a %d Retrans id #%d:%s)\n",
+		if (sipdebug)
+			ast_debug(4, "** SIP timers: Rescheduling retransmission %d to %d ms (t1 %d ms t_a %d Retrans id #%d:%s)\n",
 				pkt->retrans+1, reschedule, pkt->timer_t1, pkt->timer_a,
 				pkt->retransid, sip_methods[pkt->method].text);
 
@@ -2449,8 +2439,8 @@
 
 	/* Schedule retransmission */
 	pkt->retransid = ast_sched_add_variable(sched, siptimer_a, retrans_pkt, pkt, 1);
-	if (option_debug > 3 && sipdebug)
-		ast_log(LOG_DEBUG, "*** SIP TIMER: Initalizing retransmit timer on packet: Id  #%d\n", pkt->retransid);
+	if (sipdebug)
+		ast_debug(4, "*** SIP TIMER: Initalizing retransmit timer on packet: Id  #%d\n", pkt->retransid);
 	/* link at the head of the list */
 	pkt->next = p->packets;
 	p->packets = pkt;
@@ -2475,8 +2465,7 @@
 		transmit_state_notify(p, AST_EXTENSION_DEACTIVATED, 1, TRUE);	/* Send last notification */
 		p->subscribed = NONE;
 		append_history(p, "Subscribestatus", "timeout");
-		if (option_debug > 2)
-			ast_log(LOG_DEBUG, "Re-scheduled destruction of SIP subsription %s\n", p->callid ? p->callid : "<unknown>");
+		ast_debug(3, "Re-scheduled destruction of SIP subsription %s\n", p->callid ? p->callid : "<unknown>");
 		return 10000;	/* Reschedule this destruction so that we know that it's gone */
 	}
 
@@ -2491,16 +2480,14 @@
 		ast_log(LOG_WARNING, "Autodestruct on dialog '%s' with owner in place (Method: %s)\n", p->callid, sip_methods[p->method].text);
 		ast_queue_hangup(p->owner);
 	} else if (p->refer) {
-		if (option_debug > 2)
-			ast_log(LOG_DEBUG, "Finally hanging up channel after transfer: %s\n", p->callid);
+		ast_debug(3, "Finally hanging up channel after transfer: %s\n", p->callid);
 		transmit_request_with_auth(p, SIP_BYE, 0, XMIT_RELIABLE, 1);
 		append_history(p, "ReferBYE", "Sending BYE on transferer call leg %s", p->callid);
 		sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
 		pvt_unref(p);
 	} else {
 		append_history(p, "AutoDestroy", "%s", p->callid);
-		if (option_debug)
-			ast_log(LOG_DEBUG, "Auto destroying SIP dialog '%s'\n", p->callid);
+		ast_debug(1, "Auto destroying SIP dialog '%s'\n", p->callid);
 		sip_destroy(p);	/* Go ahead and destroy dialog. All attempts to recover is done */
 		/* also absorbs the reference we have */
 	}
@@ -2558,13 +2545,12 @@
 		if (cur->is_resp || cur->method == sipmethod) {
 			msg = "Found";
 			if (!resp && (seqno == p->pendinginvite)) {
-				if (option_debug)
-					ast_log(LOG_DEBUG, "Acked pending invite %d\n", p->pendinginvite);
+				ast_debug(1, "Acked pending invite %d\n", p->pendinginvite);
 				p->pendinginvite = 0;
 			}
 			if (cur->retransid > -1) {
-				if (sipdebug && option_debug > 3)
-					ast_log(LOG_DEBUG, "** SIP TIMER: Cancelling retransmit of packet (reply received) Retransid #%d\n", cur->retransid);
+				if (sipdebug)
+					ast_debug(4, "** SIP TIMER: Cancelling retransmit of packet (reply received) Retransid #%d\n", cur->retransid);
 				ast_sched_del(sched, cur->retransid);
 				cur->retransid = -1;
 			}
@@ -2575,8 +2561,7 @@
 		}
 	}
 	sip_pvt_unlock(p);
-	if (option_debug)
-		ast_log(LOG_DEBUG, "Stopping retransmission on '%s' of %s %d: Match %s\n",
+	ast_debug(1, "Stopping retransmission on '%s' of %s %d: Match %s\n",
 			p->callid, resp ? "Response" : "Request", seqno, msg);
 }
 
@@ -2613,8 +2598,8 @@
 		if (cur->is_resp || cur->method == sipmethod) {
 			/* this is our baby */
 			if (cur->retransid > -1) {
-				if (option_debug > 3 && sipdebug)
-					ast_log(LOG_DEBUG, "*** SIP TIMER: Cancelling retransmission #%d - %s (got response)\n", cur->retransid, sip_methods[sipmethod].text);
+				if (sipdebug)
+					ast_debug(4, "*** SIP TIMER: Cancelling retransmission #%d - %s (got response)\n", cur->retransid, sip_methods[sipmethod].text);
 				ast_sched_del(sched, cur->retransid);
 				cur->retransid = -1;
 			}
@@ -2622,8 +2607,7 @@
 			break;
 		}
 	}
-	if (option_debug)
-		ast_log(LOG_DEBUG, "(Provisional) Stopping retransmission (but retaining packet) on '%s' %s %d: %s\n", p->callid, resp ? "Response" : "Request", seqno, res ? "Not Found" : "Found");
+	ast_debug(1, "(Provisional) Stopping retransmission (but retaining packet) on '%s' %s %d: %s\n", p->callid, resp ? "Response" : "Request", seqno, res ? "Not Found" : "Found");
 	return res;
 }
 
@@ -2942,8 +2926,7 @@
 /*! \brief Destroy peer object from memory */
 static void sip_destroy_peer(struct sip_peer *peer)
 {
-	if (option_debug > 2)
-		ast_log(LOG_DEBUG, "Destroying SIP peer %s\n", peer->name);
+	ast_debug(3, "Destroying SIP peer %s\n", peer->name);
 
 	if (peer->outboundproxy)
 		free(peer->outboundproxy);
@@ -2976,8 +2959,7 @@
 		apeerobjs--;
 	else if (ast_test_flag(&peer->flags[0], SIP_REALTIME)) {
 		rpeerobjs--;
-		if (option_debug > 2)
-			ast_log(LOG_DEBUG,"-REALTIME- peer Destroyed. Name: %s. Realtime Peer objects: %d\n", peer->name, rpeerobjs);
+		ast_debug(3,"-REALTIME- peer Destroyed. Name: %s. Realtime Peer objects: %d\n", peer->name, rpeerobjs);
 	} else
 		speerobjs--;
 	clear_realm_authentication(peer->auth);
@@ -3074,8 +3056,7 @@
 		return NULL;
 	}
 
-	if (option_debug > 2)
-		ast_log(LOG_DEBUG,"-REALTIME- loading peer from database to memory. Name: %s. Peer objects: %d\n", peer->name, rpeerobjs);
+	ast_debug(3, "-REALTIME- loading peer from database to memory. Name: %s. Peer objects: %d\n", peer->name, rpeerobjs);
 
 	if (ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS)) {
 		/* Cache peer */
@@ -3126,8 +3107,7 @@
 /*! \brief Remove user object from in-memory storage */
 static void sip_destroy_user(struct sip_user *user)
 {
-	if (option_debug > 2)
-		ast_log(LOG_DEBUG, "Destroying user object from memory: %s\n", user->name);
+	ast_debug(3, "Destroying user object from memory: %s\n", user->name);
 	ast_free_ha(user->ha);
 	if (user->chanvars) {
 		ast_variables_destroy(user->chanvars);
@@ -3201,23 +3181,19 @@
 	const char *mode = natflags ? "On" : "Off";
 
 	if (p->rtp) {
-		if (option_debug)
-			ast_log(LOG_DEBUG, "Setting NAT on RTP to %s\n", mode);
+		ast_debug(1, "Setting NAT on RTP to %s\n", mode);
 		ast_rtp_setnat(p->rtp, natflags);
 	}
 	if (p->vrtp) {
-		if (option_debug)
-			ast_log(LOG_DEBUG, "Setting NAT on VRTP to %s\n", mode);
+		ast_debug(1, "Setting NAT on VRTP to %s\n", mode);
 		ast_rtp_setnat(p->vrtp, natflags);
 	}
 	if (p->udptl) {
-		if (option_debug)
-			ast_log(LOG_DEBUG, "Setting NAT on UDPTL to %s\n", mode);
+		ast_debug(1, "Setting NAT on UDPTL to %s\n", mode);
 		ast_udptl_setnat(p->udptl, natflags);
 	}
 	if (p->trtp) {
-		if (option_debug)
-			ast_log(LOG_DEBUG, "Setting NAT on TRTP to %s\n", mode);
+		ast_debug(1, "Setting NAT on TRTP to %s\n", mode);
 		ast_rtp_setnat(p->trtp, natflags);
 	}
 }
@@ -3256,8 +3232,7 @@
 			else if (ast_udptl_get_error_correction_scheme(dialog->udptl) == UDPTL_ERROR_CORRECTION_NONE )
 				dialog->t38.capability |= T38FAX_UDP_EC_NONE;
 			dialog->t38.capability |= T38FAX_RATE_MANAGEMENT_TRANSFERED_TCF;
-			if (option_debug > 1)
-				ast_log(LOG_DEBUG,"Our T38 capability (%d)\n", dialog->t38.capability);
+			ast_debug(2,"Our T38 capability (%d)\n", dialog->t38.capability);
 		}
 		dialog->t38.jointcapability = dialog->t38.capability;
 	} else if (dialog->udptl) {
@@ -3461,8 +3436,7 @@
 			p->options->replaces = ast_var_value(current);
 		} else if (!strcasecmp(ast_var_name(current), "T38CALL")) {
 			p->t38.state = T38_LOCAL_DIRECT;
-			if (option_debug)
-				ast_log(LOG_DEBUG,"T38State change to %d on channel %s\n", p->t38.state, ast->name);
+			ast_debug(1,"T38State change to %d on channel %s\n", p->t38.state, ast->name);
 		}
 
 	}
@@ -3474,15 +3448,14 @@
 		char buf[BUFSIZ/2];
 
 		if (referer) {
-			if (sipdebug && option_debug > 2)
-				ast_log(LOG_DEBUG, "Call for %s transfered by %s\n", p->username, referer);
+			if (sipdebug)
+				ast_debug(3, "Call for %s transfered by %s\n", p->username, referer);
 			snprintf(buf, sizeof(buf)-1, "-> %s (via %s)", p->cid_name, referer);
 		} else 
 			snprintf(buf, sizeof(buf)-1, "-> %s", p->cid_name);
 		ast_string_field_set(p, cid_name, buf);
 	} 
-	if (option_debug)
-		ast_log(LOG_DEBUG, "Outgoing Call for %s\n", p->username);
+	ast_debug(1, "Outgoing Call for %s\n", p->username);
 
 	res = update_call_counter(p, INC_CALL_RINGING);
 	if (res == -1)
@@ -3498,8 +3471,7 @@
 		res = -1;
 	} else {
 		p->t38.jointcapability = p->t38.capability;
-		if (option_debug > 1)
-			ast_log(LOG_DEBUG,"Our T38 capability (%d), joint T38 capability (%d)\n", p->t38.capability, p->t38.jointcapability);
+		ast_debug(2,"Our T38 capability (%d), joint T38 capability (%d)\n", p->t38.capability, p->t38.jointcapability);
 		transmit_invite(p, SIP_INVITE, 1, 2);
 
 		p->invitestate = INV_CALLING;
@@ -3546,8 +3518,7 @@
 		ast_verbose("Really destroying SIP dialog '%s' Method: %s\n", p->callid, sip_methods[p->method].text);
 	if (ast_test_flag(&p->flags[0], SIP_INC_COUNT)) {
 		update_call_counter(p, DEC_CALL_LIMIT);
-		if (option_debug > 1)
-			ast_log(LOG_DEBUG, "This call did not properly clean up call limits. Call ID %s\n", p->callid);
+		ast_debug(2, "This call did not properly clean up call limits. Call ID %s\n", p->callid);
 	}
 
 	/* Remove link from peer to subscription of MWI */
@@ -3638,8 +3609,7 @@
 		ast_verbose("pvt_destructor %p owner->tech_pvt %p\n",
 			p, p->owner->tech_pvt);
 		ast_channel_lock(p->owner);
-		if (option_debug)
-			ast_log(LOG_DEBUG, "Detaching from %s\n", p->owner->name);
+		ast_debug(1, "Detaching from %s\n", p->owner->name);
 		p->owner->tech_pvt = pvt_unref(p->owner->tech_pvt);	/* self pointer, basically */
 		ast_channel_unlock(p->owner);
 	}
@@ -3665,8 +3635,7 @@
 /*! \brief Destroy SIP call structure (after unlinking it from the list) */
 static struct sip_pvt *sip_destroy(struct sip_pvt *p)
 {
-	if (option_debug > 2)
-		ast_log(LOG_DEBUG, "Destroying SIP dialog %s\n", p->callid);
+	ast_debug(3, "Destroying SIP dialog %s\n", p->callid);
 	sip_pvt_unlink(p);
 	__sip_destroy(p);
 	return NULL;
@@ -3694,8 +3663,7 @@
 	struct sip_user *u = NULL;
 	struct sip_peer *p = NULL;
 
-	if (option_debug > 2)
-		ast_log(LOG_DEBUG, "Updating call counter for %s call\n", outgoing ? "outgoing" : "incoming");
+	ast_debug(3, "Updating call counter for %s call\n", outgoing ? "outgoing" : "incoming");
 
 	/* Test if we need to check call limits, in order to avoid 
 	   realtime lookups if we do not need it */
@@ -3716,8 +3684,7 @@
 		ast_copy_string(name, fup->peername, sizeof(name));
 	} 
 	if (!p && !u) {
-		if (option_debug > 1)
-			ast_log(LOG_DEBUG, "%s is not a local device, no call limit\n", name);
+		ast_debug(2, "%s is not a local device, no call limit\n", name);
 		return 0;
 	}
 
@@ -3938,8 +3905,7 @@
 			
 		case AST_CAUSE_NOTDEFINED:
 		default:
-			if (option_debug)
-				ast_log(LOG_DEBUG, "AST hangup cause %d (no match found in SIP)\n", cause);
+			ast_debug(1, "AST hangup cause %d (no match found in SIP)\n", cause);
 			return NULL;
 	}
 
@@ -3958,19 +3924,17 @@
 	struct ast_channel *oldowner = ast;
 
 	if (!p) {
-		if (option_debug)
-			ast_log(LOG_DEBUG, "Asked to hangup channel that was not connected\n");
+		ast_debug(1, "Asked to hangup channel that was not connected\n");
 		return 0;
 	}
 
 	if (ast_test_flag(&p->flags[0], SIP_DEFER_BYE_ON_TRANSFER)) {
 		if (ast_test_flag(&p->flags[0], SIP_INC_COUNT)) {
-			if (option_debug && sipdebug)
-				ast_log(LOG_DEBUG, "update_call_counter(%s) - decrement call limit counter on hangup\n", p->username);
+			if (sipdebug)
+				ast_debug(1, "update_call_counter(%s) - decrement call limit counter on hangup\n", p->username);
 			update_call_counter(p, DEC_CALL_LIMIT);
 		}
-		if (option_debug >3)
-			ast_log(LOG_DEBUG, "SIP Transfer: Not hanging up right now... Rescheduling hangup for %s.\n", p->callid);
+		ast_debug(4, "SIP Transfer: Not hanging up right now... Rescheduling hangup for %s.\n", p->callid);
 		sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);	/* also cancels previous one if there */
 		ast_clear_flag(&p->flags[0], SIP_DEFER_BYE_ON_TRANSFER);	/* Really hang up next time */
 		clear_destroy(p);
@@ -3980,21 +3944,17 @@
 		p->owner = NULL;  /* Owner will be gone after we return, so take it away */
 		return 0;
 	}
-	if (option_debug) {
-		if (ast_test_flag(ast, AST_FLAG_ZOMBIE) && p->refer && option_debug)
-         		ast_log(LOG_DEBUG, "SIP Transfer: Hanging up Zombie channel %s after transfer ... Call-ID: %s\n", ast->name, p->callid);
-		else  {
-			if (option_debug)
-				ast_log(LOG_DEBUG, "Hangup call %s, SIP callid %s)\n", ast->name, p->callid);
-		}
-	}
-	if (option_debug && ast_test_flag(ast, AST_FLAG_ZOMBIE)) 
-		ast_log(LOG_DEBUG, "Hanging up zombie call. Be scared.\n");
+	if (ast_test_flag(ast, AST_FLAG_ZOMBIE) && p->refer)
+		ast_debug(1, "SIP Transfer: Hanging up Zombie channel %s after transfer ... Call-ID: %s\n", ast->name, p->callid);
+	else
+		ast_debug(1, "Hangup call %s, SIP callid %s)\n", ast->name, p->callid);
+	if (ast_test_flag(ast, AST_FLAG_ZOMBIE)) 
+		ast_debug(1, "Hanging up zombie call. Be scared.\n");
 
 	sip_pvt_lock(p);
 	if (ast_test_flag(&p->flags[0], SIP_INC_COUNT)) {
-		if (option_debug && sipdebug)
-			ast_log(LOG_DEBUG, "update_call_counter(%s) - decrement call limit counter on hangup\n", p->username);
+		if (sipdebug)
+			ast_debug(1, "update_call_counter(%s) - decrement call limit counter on hangup\n", p->username);
 		update_call_counter(p, DEC_CALL_LIMIT);
 	}
 
@@ -4007,8 +3967,7 @@
 	/* In case of re-invites, the call might be UP even though we have an incomplete invite transaction */
 	 if (p->invitestate < INV_COMPLETED && p->owner->_state != AST_STATE_UP) {
 		needcancel = TRUE;
-		if (option_debug > 3)
-			ast_log(LOG_DEBUG, "Hanging up channel in state %s (not UP)\n", ast_state2str(ast->_state));
+		ast_debug(4, "Hanging up channel in state %s (not UP)\n", ast_state2str(ast->_state));
 	}
 
 	/* Disconnect */
@@ -4142,12 +4101,10 @@
 		try_suggested_sip_codec(p);	
 
 		ast_setstate(ast, AST_STATE_UP);
-		if (option_debug)
-			ast_log(LOG_DEBUG, "SIP answering channel: %s\n", ast->name);
+		ast_debug(1, "SIP answering channel: %s\n", ast->name);
 		if (p->t38.state == T38_PEER_DIRECT) {
 			p->t38.state = T38_ENABLED;
-			if (option_debug > 1)
-				ast_log(LOG_DEBUG,"T38State change to %d on channel %s\n", p->t38.state, ast->name);
+			ast_debug(2, "T38State change to %d on channel %s\n", p->t38.state, ast->name);
 			res = transmit_response_with_t38_sdp(p, "200 OK", &p->initreq, XMIT_CRITICAL);
 		} else 
 			res = transmit_response_with_sdp(p, "200 OK", &p->initreq, XMIT_CRITICAL);
@@ -4256,10 +4213,10 @@
 	int ret = -1;
 	struct sip_pvt *p;
 
-	if (newchan && ast_test_flag(newchan, AST_FLAG_ZOMBIE) && option_debug)
-		ast_log(LOG_DEBUG, "New channel is zombie\n");
-	if (oldchan && ast_test_flag(oldchan, AST_FLAG_ZOMBIE) && option_debug)
-		ast_log(LOG_DEBUG, "Old channel is zombie\n");
+	if (newchan && ast_test_flag(newchan, AST_FLAG_ZOMBIE))
+		ast_debug(1, "New channel is zombie\n");
+	if (oldchan && ast_test_flag(oldchan, AST_FLAG_ZOMBIE))
+		ast_debug(1, "Old channel is zombie\n");
 
 	if (!newchan || !newchan->tech_pvt) {
 		if (!newchan)
@@ -4279,8 +4236,7 @@
 		p->owner = newchan;
 		ret = 0;
 	}
-	if (option_debug > 2)
-		ast_log(LOG_DEBUG, "SIP Fixup: New owner for dialogue %s: %s (Old parent: %s)\n", p->callid, p->owner->name, oldchan->name);
+	ast_debug(3, "SIP Fixup: New owner for dialogue %s: %s (Old parent: %s)\n", p->callid, p->owner->name, oldchan->name);
 
 	sip_pvt_unlock(p);
 	return ret;
@@ -4532,14 +4488,10 @@
 			needtext = i->jointcapability & AST_FORMAT_TEXT_MASK;   /* Inbound call */
 	}
 
-	if (option_debug > 2) {
-		if (needvideo) 
-			ast_log(LOG_DEBUG, "This channel can handle video! HOLLYWOOD next!\n");
-		else
-			ast_log(LOG_DEBUG, "This channel will not be able to handle video.\n");
-	}
-
-
+	if (needvideo) 
+		ast_debug(3, "This channel can handle video! HOLLYWOOD next!\n");
+	else
+		ast_debug(3, "This channel will not be able to handle video.\n");
 
 	if (ast_test_flag(&i->flags[0], SIP_DTMF) ==  SIP_DTMF_INBAND) {
 		i->vad = ast_dsp_new();
@@ -4813,14 +4765,11 @@
 
 	if (f->subclass != (p->owner->nativeformats & AST_FORMAT_AUDIO_MASK)) {
 		if (!(f->subclass & p->jointcapability)) {
-			if (option_debug) {
-				ast_log(LOG_DEBUG, "Bogus frame of format '%s' received from '%s'!\n",
+			ast_debug(1, "Bogus frame of format '%s' received from '%s'!\n",
 				ast_getformatname(f->subclass), p->owner->name);
-			}
 			return &ast_null_frame;
 		}
-		if (option_debug)
-			ast_log(LOG_DEBUG, "Oooh, format changed to %d\n", f->subclass);
+		ast_debug(1, "Oooh, format changed to %d\n", f->subclass);
 		p->owner->nativeformats = (p->owner->nativeformats & (AST_FORMAT_VIDEO_MASK | AST_FORMAT_TEXT_MASK) ) | f->subclass;
 		ast_set_read_format(p->owner, p->owner->readformat);
 		ast_set_write_format(p->owner, p->owner->writeformat);
@@ -4829,12 +4778,10 @@
 		f = ast_dsp_process(p->owner, p->vad, f);
 		if (f && f->frametype == AST_FRAME_DTMF) {
 			if (ast_test_flag(&p->t38.t38support, SIP_PAGE2_T38SUPPORT_UDPTL) && f->subclass == 'f') {
-				if (option_debug)
-					ast_log(LOG_DEBUG, "Fax CNG detected on %s\n", ast->name);
+				ast_debug(1, "Fax CNG detected on %s\n", ast->name);
 				*faxdetect = 1;
-			} else if (option_debug) {
-				ast_log(LOG_DEBUG, "* Detected inband DTMF '%c'\n", f->subclass);
-			}
+			} else
+				ast_debug(1, "* Detected inband DTMF '%c'\n", f->subclass);
 		}
 	}
 	return f;
@@ -4856,16 +4803,13 @@
 	if (faxdetected && ast_test_flag(&p->t38.t38support, SIP_PAGE2_T38SUPPORT_UDPTL) && (p->t38.state == T38_DISABLED) && !(ast_bridged_channel(ast))) {
 		if (!ast_test_flag(&p->flags[0], SIP_GOTREFER)) {
 			if (!p->pendinginvite) {
-				if (option_debug > 2)
-					ast_log(LOG_DEBUG, "Sending reinvite on SIP (%s) for T.38 negotiation.\n",ast->name);
+				ast_debug(3, "Sending reinvite on SIP (%s) for T.38 negotiation.\n",ast->name);
 				p->t38.state = T38_LOCAL_REINVITE;
 				transmit_reinvite_with_sdp(p, TRUE);
-				if (option_debug > 1)
-					ast_log(LOG_DEBUG, "T38 state changed to %d on channel %s\n", p->t38.state, ast->name);
+				ast_debug(2, "T38 state changed to %d on channel %s\n", p->t38.state, ast->name);
 			}
 		} else if (!ast_test_flag(&p->flags[0], SIP_PENDINGBYE)) {
-			if (option_debug > 2)
-				ast_log(LOG_DEBUG, "Deferring reinvite on SIP (%s) - it will be re-negotiated for T.38\n", ast->name);
+			ast_debug(3, "Deferring reinvite on SIP (%s) - it will be re-negotiated for T.38\n", ast->name);
 			ast_set_flag(&p->flags[0], SIP_NEEDREINVITE);
 		}
 	}
@@ -5076,8 +5020,7 @@
 	dialoglist = p;
 	dialoglist_unlock();
 #endif
-	if (option_debug)
-		ast_log(LOG_DEBUG, "Allocating new SIP dialog for %s - %s (%s)\n", callid ? callid : "(No Call-ID)", sip_methods[intended_method].text, p->rtp ? "With RTP" : "No RTP");
+	ast_debug(1, "Allocating new SIP dialog for %s - %s (%s)\n", callid ? callid : "(No Call-ID)", sip_methods[intended_method].text, p->rtp ? "With RTP" : "No RTP");
 	ast_mark(prof_init, 0);
 	ast_mark(prof_id, 0);
 	return p;
@@ -5114,8 +5057,7 @@
 		found = (!strcmp(p->callid, arg->callid) && 
 		(!pedanticsipchecking || !arg->tag || ast_strlen_zero(p->theirtag) || !strcmp(p->theirtag, arg->tag))) ;
 
-	if (option_debug > 4)
-		ast_log(LOG_DEBUG, "= %s Their Call ID: %s Their Tag %s Our tag: %s\n", found ? "Found" : "No match", p->callid, p->theirtag, p->tag);
+	ast_debug(5, "= %s Their Call ID: %s Their Tag %s Our tag: %s\n", found ? "Found" : "No match", p->callid, p->theirtag, p->tag);
 
 	/* If we get a new request within an existing to-tag - check the to tag as well */
 	if (pedanticsipchecking && found  && arg->method != SIP_RESPONSE) {	/* SIP Request */
@@ -5127,8 +5069,8 @@
 				found = FALSE;		/* This is not our packet */
 			}
 		}
-		if (!found && option_debug > 4)
-			ast_log(LOG_DEBUG, "= Being pedantic: This is not our match on request: Call ID: %s Ourtag <null> Totag %s Method %s\n", p->callid, arg->totag, sip_methods[arg->method].text);
+		if (!found)
+			ast_debug(5, "= Being pedantic: This is not our match on request: Call ID: %s Ourtag <null> Totag %s Method %s\n", p->callid, arg->totag, sip_methods[arg->method].text);
 	}
     }
 	ast_mark(prof_id, 0);
@@ -5189,19 +5131,16 @@
 
 		arg.tag = (req->method == SIP_RESPONSE) ? totag : fromtag;
 
-		if (option_debug > 4 )
-			ast_log(LOG_DEBUG, "= Looking for  Call ID: %s (Checking %s) --From tag %s --To-tag %s  \n", callid, req->method==SIP_RESPONSE ? "To" : "From", fromtag, totag);
+		ast_debug(5, "= Looking for  Call ID: %s (Checking %s) --From tag %s --To-tag %s  \n", callid, req->method==SIP_RESPONSE ? "To" : "From", fromtag, totag);
 
 		/* All messages must always have From: tag */
 		if (ast_strlen_zero(fromtag)) {
-			if (option_debug > 4 )
-				ast_log(LOG_DEBUG, "%s request has no from tag, dropping callid: %s from: %s\n", sip_methods[req->method].text , callid, from );
+			ast_debug(5, "%s request has no from tag, dropping callid: %s from: %s\n", sip_methods[req->method].text , callid, from );
 			return NULL;
 		}
 		/* reject requests that must always have a To: tag */
 		if (ast_strlen_zero(totag) && (req->method == SIP_ACK || req->method == SIP_BYE || req->method == SIP_INFO )) {
-			if (option_debug > 4)
-				ast_log(LOG_DEBUG, "%s must have a to tag. dropping callid: %s from: %s\n", sip_methods[req->method].text , callid, from );
+			ast_debug(5, "%s must have a to tag. dropping callid: %s from: %s\n", sip_methods[req->method].text , callid, from );
 			return NULL;
 		}
 	}
@@ -5256,8 +5195,7 @@
 					Sorry, we apologize for the inconvienience
 				*/
 				transmit_response_using_temp(callid, sin, 1, intended_method, req, "500 Server internal error");
-				if (option_debug > 3)
-					ast_log(LOG_DEBUG, "Failed allocating SIP dialog, sending 500 Server internal error and giving up\n");
+				ast_debug(4, "Failed allocating SIP dialog, sending 500 Server internal error and giving up\n");
 			}
 		}
 		ast_mark(prof_tail, 0);
@@ -5265,18 +5203,16 @@
 	} else if( sip_methods[intended_method].can_create == CAN_CREATE_DIALOG_UNSUPPORTED_METHOD) {
 		/* A method we do not support, let's take it on the volley */
 		transmit_response_using_temp(callid, sin, 1, intended_method, req, "501 Method Not Implemented");
-		if (option_debug > 1 )
-			ast_log(LOG_DEBUG, "Got a request with unsupported SIP method.\n");
+		ast_debug(2, "Got a request with unsupported SIP method.\n");
 	} else if (intended_method != SIP_RESPONSE && intended_method != SIP_ACK) {
 		/* This is a request outside of a dialog that we don't know about */
 		transmit_response_using_temp(callid, sin, 1, intended_method, req, "481 Call leg/transaction does not exist");
-		if (option_debug > 1)
-			ast_log(LOG_DEBUG, "That's odd...  Got a request in unknown dialog. Callid %s\n", callid ? callid : "<unknown>");
+		ast_debug(2, "That's odd...  Got a request in unknown dialog. Callid %s\n", callid ? callid : "<unknown>");
 	}
 	/* We do not respond to responses for dialogs that we don't know about, we just drop
 	   the session quickly */
-	if (option_debug > 1 && intended_method == SIP_RESPONSE)
-		ast_log(LOG_DEBUG, "That's odd...  Got a response on a call we dont know about. Callid %s\n", callid ? callid : "<unknown>");
+	if (intended_method == SIP_RESPONSE)
+		ast_debug(2, "That's odd...  Got a response on a call we dont know about. Callid %s\n", callid ? callid : "<unknown>");
 
 	ast_mark(prof_tail, 0);
 	return NULL;
@@ -5426,8 +5362,8 @@
 			*c = '\0';
 		else if (*c == '\n') { /* end of this line */
 			*c = '\0';
-			if (sipdebug && option_debug > 3)
-				ast_log(LOG_DEBUG, "%7s %2d [%3d]: %s\n",
+			if (sipdebug)
+				ast_debug(4, "%7s %2d [%3d]: %s\n",
 					req->headers < 0 ? "Header" : "Body",
 					i, (int)strlen(dst[i]), dst[i]);
 			if (ast_strlen_zero(dst[i]) && req->headers < 0) {
@@ -5446,8 +5382,8 @@
 	   but since some devices send without, we'll be generous in what we accept.
 	*/
 	if (!ast_strlen_zero(dst[i])) {
-		if (sipdebug && option_debug > 3)
-			ast_log(LOG_DEBUG, "%7s %2d [%3d]: %s\n",
+		if (sipdebug)
+			ast_debug(4, "%7s %2d [%3d]: %s\n",
 				req->headers < 0 ? "Header" : "Body",
 				i, (int)strlen(dst[i]), dst[i]);
 		i++;
@@ -5716,12 +5652,10 @@
 			
 			if (p->owner && p->lastinvite) {
 				p->t38.state = T38_PEER_REINVITE; /* T38 Offered in re-invite from remote party */
-				if (option_debug > 1)
-					ast_log(LOG_DEBUG, "T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>" );
+				ast_debug(2, "T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>" );
 			} else {
 				p->t38.state = T38_PEER_DIRECT; /* T38 Offered directly from peer in first invite */
-				if (option_debug > 1)
-					ast_log(LOG_DEBUG, "T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
+				ast_debug(2, "T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
 			}
 		} else 
 			ast_log(LOG_WARNING, "Unsupported SDP media type in offer: %s\n", m);
@@ -5780,7 +5714,7 @@
 		if (udptlportno > 0) {
 			sin.sin_port = htons(udptlportno);
 			ast_udptl_set_peer(p->udptl, &sin);
-			if (debug)
+			if (debug) /* XXX really ? */
 				ast_log(LOG_DEBUG,"Peer T.38 UDPTL is at port %s:%d\n",ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
 		} else {
 			ast_udptl_stop(p->udptl);
@@ -5877,8 +5811,7 @@
 				framing = strtol(tmp, NULL, 10);
 				if (framing == LONG_MIN || framing == LONG_MAX) {
 					framing = 0;
-					if (option_debug)
-						ast_log(LOG_DEBUG, "Can't read framing from SDP: %s\n", a);
+					ast_debug(1, "Can't read framing from SDP: %s\n", a);
 				}
 			}
 			if (framing && last_rtpmap_codec) {
@@ -5890,8 +5823,7 @@
 						format = ast_rtp_codec_getformat(found_rtpmap_codecs[codec_n]);
 						if (!format)	/* non-codec or not found */
 							continue;
-						if (option_debug)
-							ast_log(LOG_DEBUG, "Setting framing for %d to %ld\n", format, framing);
+						ast_debug(1, "Setting framing for %d to %ld\n", format, framing);
 						ast_codec_pref_setsize(pref, format, framing);
 					}
 					ast_rtp_codec_setpref(p->rtp, pref);
@@ -5933,12 +5865,10 @@
 		while ((a = get_sdp_iterate(&iterator, req, "a"))[0] != '\0') {
 			if ((sscanf(a, "T38FaxMaxBuffer:%d", &x) == 1)) {
 				found = 1;
-				if (option_debug > 2)
-					ast_log(LOG_DEBUG, "MaxBufferSize:%d\n",x);
+				ast_debug(3, "MaxBufferSize:%d\n",x);
 			} else if ((sscanf(a, "T38MaxBitRate:%d", &x) == 1)) {
 				found = 1;
-				if (option_debug > 2)
-					ast_log(LOG_DEBUG,"T38MaxBitRate: %d\n",x);
+				ast_debug(3,"T38MaxBitRate: %d\n",x);
 				switch (x) {
 				case 14400:
 					peert38capability |= T38FAX_RATE_14400 | T38FAX_RATE_12000 | T38FAX_RATE_9600 | T38FAX_RATE_7200 | T38FAX_RATE_4800 | T38FAX_RATE_2400;
@@ -5961,49 +5891,42 @@
 				}
 			} else if ((sscanf(a, "T38FaxVersion:%d", &x) == 1)) {
 				found = 1;
-				if (option_debug > 2)
-					ast_log(LOG_DEBUG, "FaxVersion: %d\n",x);
+				ast_debug(3, "FaxVersion: %d\n",x);
 				if (x == 0)
 					peert38capability |= T38FAX_VERSION_0;
 				else if (x == 1)
 					peert38capability |= T38FAX_VERSION_1;
 			} else if ((sscanf(a, "T38FaxMaxDatagram:%d", &x) == 1)) {
 				found = 1;
-				if (option_debug > 2)
-					ast_log(LOG_DEBUG, "FaxMaxDatagram: %d\n",x);
+				ast_debug(3, "FaxMaxDatagram: %d\n",x);
 				ast_udptl_set_far_max_datagram(p->udptl, x);
 				ast_udptl_set_local_max_datagram(p->udptl, x);
 			} else if ((sscanf(a, "T38FaxFillBitRemoval:%d", &x) == 1)) {
 				found = 1;
-				if (option_debug > 2)
-					ast_log(LOG_DEBUG, "FillBitRemoval: %d\n",x);
+				ast_debug(3, "FillBitRemoval: %d\n",x);
 				if (x == 1)
 					peert38capability |= T38FAX_FILL_BIT_REMOVAL;
 			} else if ((sscanf(a, "T38FaxTranscodingMMR:%d", &x) == 1)) {
 				found = 1;
-				if (option_debug > 2)
-					ast_log(LOG_DEBUG, "Transcoding MMR: %d\n",x);
+				ast_debug(3, "Transcoding MMR: %d\n",x);
 				if (x == 1)
 					peert38capability |= T38FAX_TRANSCODING_MMR;
 			}
 			if ((sscanf(a, "T38FaxTranscodingJBIG:%d", &x) == 1)) {
 				found = 1;
-				if (option_debug > 2)
-					ast_log(LOG_DEBUG, "Transcoding JBIG: %d\n",x);
+				ast_debug(3, "Transcoding JBIG: %d\n",x);
 				if (x == 1)
 					peert38capability |= T38FAX_TRANSCODING_JBIG;
 			} else if ((sscanf(a, "T38FaxRateManagement:%255s", s) == 1)) {
 				found = 1;
-				if (option_debug > 2)
-					ast_log(LOG_DEBUG, "RateManagement: %s\n", s);
+				ast_debug(3, "RateManagement: %s\n", s);
 				if (!strcasecmp(s, "localTCF"))
 					peert38capability |= T38FAX_RATE_MANAGEMENT_LOCAL_TCF;
 				else if (!strcasecmp(s, "transferredTCF"))
 					peert38capability |= T38FAX_RATE_MANAGEMENT_TRANSFERED_TCF;
 			} else if ((sscanf(a, "T38FaxUdpEC:%255s", s) == 1)) {
 				found = 1;
-				if (option_debug > 2)
-					ast_log(LOG_DEBUG, "UDP EC: %s\n", s);
+				ast_debug(3, "UDP EC: %s\n", s);
 				if (!strcasecmp(s, "t38UDPRedundancy")) {
 					peert38capability |= T38FAX_UDP_EC_REDUNDANCY;
 					ast_udptl_set_error_correction_scheme(p->udptl, UDPTL_ERROR_CORRECTION_REDUNDANCY);
@@ -6029,8 +5952,7 @@
 				p->t38.jointcapability);
 	} else {
 		p->t38.state = T38_DISABLED;
-		if (option_debug > 2)
-			ast_log(LOG_DEBUG, "T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
+		ast_debug(3, "T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
 	}
 
 	/* Now gather all of the codecs that we are asked for: */
@@ -6066,8 +5988,7 @@
 			/* Do NOT Change current setting */
 			return -1;
 		} else {
-			if (option_debug > 2)
-				ast_log(LOG_DEBUG, "Have T.38 but no audio codecs, accepting offer anyway\n");
+			ast_debug(3, "Have T.38 but no audio codecs, accepting offer anyway\n");
 			return 0;
 		}
 	}
@@ -6126,8 +6047,7 @@
 	if (!p->owner) 	/* There's no open channel owning us so we can return here. For a re-invite or so, we proceed */
 		return 0;
 
-	if (option_debug > 3)
-		ast_log(LOG_DEBUG, "We have an owner, now see if we need to change this call\n");
+	ast_debug(4, "We have an owner, now see if we need to change this call\n");
 
 	if (!(p->owner->nativeformats & p->jointcapability) && (p->jointcapability & AST_FORMAT_AUDIO_MASK)) {
 		if (debug) {
@@ -6918,32 +6838,25 @@
 	int maxrate = (t38cap & (T38FAX_RATE_14400 | T38FAX_RATE_12000 | T38FAX_RATE_9600 | T38FAX_RATE_7200 | T38FAX_RATE_4800 | T38FAX_RATE_2400));
 	
 	if (maxrate & T38FAX_RATE_14400) {
-		if (option_debug > 1)
-			ast_log(LOG_DEBUG, "T38MaxFaxRate 14400 found\n");
+		ast_debug(2, "T38MaxFaxRate 14400 found\n");
 		return 14400;
 	} else if (maxrate & T38FAX_RATE_12000) {
-		if (option_debug > 1)
-			ast_log(LOG_DEBUG, "T38MaxFaxRate 12000 found\n");
+		ast_debug(2, "T38MaxFaxRate 12000 found\n");
 		return 12000;
 	} else if (maxrate & T38FAX_RATE_9600) {
-		if (option_debug > 1)
-			ast_log(LOG_DEBUG, "T38MaxFaxRate 9600 found\n");
+		ast_debug(2, "T38MaxFaxRate 9600 found\n");
 		return 9600;
 	} else if (maxrate & T38FAX_RATE_7200) {
-		if (option_debug > 1)
-			ast_log(LOG_DEBUG, "T38MaxFaxRate 7200 found\n");
+		ast_debug(2, "T38MaxFaxRate 7200 found\n");
 		return 7200;
 	} else if (maxrate & T38FAX_RATE_4800) {
-		if (option_debug > 1)
-			ast_log(LOG_DEBUG, "T38MaxFaxRate 4800 found\n");
+		ast_debug(2, "T38MaxFaxRate 4800 found\n");
 		return 4800;
 	} else if (maxrate & T38FAX_RATE_2400) {
-		if (option_debug > 1)
-			ast_log(LOG_DEBUG, "T38MaxFaxRate 2400 found\n");
+		ast_debug(2, "T38MaxFaxRate 2400 found\n");
 		return 2400;
 	} else {
-		if (option_debug > 1)
-			ast_log(LOG_DEBUG, "Strange, T38MaxFaxRate NOT found in peers T38 SDP.\n");
+		ast_debug(2, "Strange, T38MaxFaxRate NOT found in peers T38 SDP.\n");
 		return 0;
 	}
 }
@@ -7162,10 +7075,9 @@
 	if ((capability & AST_FORMAT_VIDEO_MASK) && !ast_test_flag(&p->flags[0], SIP_NOVIDEO)) {
 		if (p->vrtp) {
 			needvideo = TRUE;
-			if (option_debug > 1)
-				ast_log(LOG_DEBUG, "This call needs video offers!\n");
-		} else if (option_debug > 1)
-			ast_log(LOG_DEBUG, "This call needs video offers, but there's no video support enabled!\n");
+			ast_debug(2, "This call needs video offers!\n");
+		} else
+			ast_debug(2, "This call needs video offers, but there's no video support enabled!\n");
 	}
 
 	/* Get our media addresses */
@@ -7193,10 +7105,9 @@
 			if (sipdebug_text)
 				ast_verbose("And we have a text rtp object\n");
 			needtext = TRUE;
-			if (option_debug > 1)
-				ast_log(LOG_DEBUG, "This call needs text offers! \n");
-		} else if (option_debug > 1)
-			ast_log(LOG_DEBUG, "This call needs text offers, but there's no text support enabled ! \n");
+			ast_debug(2, "This call needs text offers! \n");
+		} else
+			ast_debug(2, "This call needs text offers, but there's no text support enabled ! \n");
 	}
 
 	/* Ok, we need text. Let's add what we need for text and set codecs.
@@ -7298,8 +7209,7 @@
 		add_noncodec_to_sdp(p, x, 8000, &m_audio, &a_audio, debug);
 	}
 
-	if (option_debug > 2)
-		ast_log(LOG_DEBUG, "-- Done with adding codecs to SDP\n");

[... 760 lines stripped ...]



More information about the asterisk-commits mailing list