[asterisk-addons-commits] qwell: trunk r408 - in /trunk: ./ asterisk-ooh323c/src/

SVN commits to the Asterisk addons project asterisk-addons-commits at lists.digium.com
Fri Jul 6 16:28:36 CDT 2007


Author: qwell
Date: Fri Jul  6 16:28:35 2007
New Revision: 408

URL: http://svn.digium.com/view/asterisk-addons?view=rev&rev=408
Log:
Convert all of asterisk-addons to use ast_debug instead of ast_log(LOG_DEBUG, ...)

Closes issue #10085, initial patch by IgorG, with the rest done by me.

Modified:
    trunk/app_addon_sql_mysql.c
    trunk/asterisk-ooh323c/src/chan_h323.c
    trunk/asterisk-ooh323c/src/ooh323cDriver.c
    trunk/cdr_addon_mysql.c
    trunk/chan_mobile.c
    trunk/res_config_mysql.c

Modified: trunk/app_addon_sql_mysql.c
URL: http://svn.digium.com/view/asterisk-addons/trunk/app_addon_sql_mysql.c?view=diff&rev=408&r1=407&r2=408
==============================================================================
--- trunk/app_addon_sql_mysql.c (original)
+++ trunk/app_addon_sql_mysql.c Fri Jul  6 16:28:35 2007
@@ -32,6 +32,7 @@
 #include <asterisk/linkedlists.h>
 #include <asterisk/chanvars.h>
 #include <asterisk/lock.h>
+#include <asterisk/options.h>
 
 #define AST_MODULE "app_addon_sql_mysql"
 
@@ -348,12 +349,12 @@
 					pbx_builtin_setvar_helper(chan,s5, s6 ? s6 : "NULL");
 				}
 #if EXTRA_LOG
-				ast_log(LOG_DEBUG,"ast_MYSQL_fetch: numFields=%d\n",numFields);
+				ast_debug(1,"ast_MYSQL_fetch: numFields=%d\n",numFields);
 #endif
 				set_asterisk_int(chan,fetchid_var,1); // try more rows
 			} else {
 #if EXTRA_LOG
-				ast_log(LOG_DEBUG,"ast_MYSQL_fetch : EOF\n");
+				ast_debug(1,"ast_MYSQL_fetch : EOF\n");
 #endif
 				set_asterisk_int(chan,fetchid_var,0); // no more rows
 			}

Modified: trunk/asterisk-ooh323c/src/chan_h323.c
URL: http://svn.digium.com/view/asterisk-addons/trunk/asterisk-ooh323c/src/chan_h323.c?view=diff&rev=408&r1=407&r2=408
==============================================================================
--- trunk/asterisk-ooh323c/src/chan_h323.c (original)
+++ trunk/asterisk-ooh323c/src/chan_h323.c Fri Jul  6 16:28:35 2007
@@ -242,7 +242,7 @@
    struct ast_channel *ch = NULL;
    int fmt;
    if(gH323Debug)
-      ast_log(LOG_DEBUG, "---   ooh323_new - %s\n", host);
+      ast_debug(1, "---   ooh323_new - %s\n", host);
 
 
    /* Don't hold a h323 pvt lock while we allocate a channel */
@@ -344,7 +344,7 @@
    if(ch)   ast_mutex_unlock(&ch->lock);
 
    if(gH323Debug)
-      ast_log(LOG_DEBUG, "+++   h323_new\n");
+      ast_debug(1, "+++   h323_new\n");
 
    return ch;
 }
@@ -356,7 +356,7 @@
    struct ooh323_pvt *pvt = NULL;
    struct in_addr ipAddr;
    if(gH323Debug)
-      ast_log(LOG_DEBUG, "---   ooh323_alloc\n");
+      ast_debug(1, "---   ooh323_alloc\n");
 
    pvt = (struct ooh323_pvt*) malloc(sizeof(struct ooh323_pvt));
    if(!pvt)
@@ -439,7 +439,7 @@
   ast_mutex_unlock(&iflock);
 
   if(gH323Debug)
-    ast_log(LOG_DEBUG, "+++   ooh323_alloc\n");
+    ast_debug(1, "+++   ooh323_alloc\n");
 
   return pvt;
 }
@@ -866,8 +866,7 @@
    {
       ast_mutex_lock(&ast->lock);
       ast_setstate(ast, AST_STATE_UP);
-      if (option_debug)
-         ast_log(LOG_DEBUG, "ooh323_answer(%s)\n", ast->name);
+      ast_debug(1, "ooh323_answer(%s)\n", ast->name);
       ast_mutex_unlock(&ast->lock);
       ast_mutex_lock(&ooh323c_cmd_lock);
       ooAnswerCall(p->callToken);
@@ -1140,7 +1139,7 @@
    struct ast_frame f;
    int res;
 
-   ast_log(LOG_DEBUG, "Received Digit: %c\n", digit);
+   ast_debug(1, "Received Digit: %c\n", digit);
    p = find_call(call);
    if(!p) {
       ast_log(LOG_ERROR, "Failed to find a matching call.\n");
@@ -1336,7 +1335,7 @@
 
       if(!ast_strlen_zero(p->caller_dialedDigits)){
          if(gH323Debug) {
-            ast_log(LOG_DEBUG, "Setting dialed digits %s\n", 
+            ast_debug(1, "Setting dialed digits %s\n", 
                p->caller_dialedDigits);
          }
          ooCallAddAliasDialedDigits(call, p->caller_dialedDigits);
@@ -1406,7 +1405,7 @@
    
    while(ast_mutex_trylock(&p->owner->lock))
    {
-      ast_log(LOG_DEBUG,"Failed to grab lock, trying again\n");
+      ast_debug(1,"Failed to grab lock, trying again\n");
       ast_mutex_unlock(&p->lock);
       usleep(1);
       ast_mutex_lock(&p->lock);
@@ -1444,7 +1443,7 @@
    while(p->owner) {
       if(ast_mutex_trylock(&p->owner->lock)) {
          ooTrace(OOTRCLVLINFO, "Failed to grab lock, trying again\n");
-         ast_log(LOG_DEBUG,"Failed to grab lock, trying again\n");
+         ast_debug(1,"Failed to grab lock, trying again\n");
          ast_mutex_unlock(&p->lock);
          usleep(1);
          ast_mutex_lock(&p->lock);
@@ -2699,7 +2698,7 @@
       /* Unlink us from the owner if we have one */
       if (cur->owner) {
          ast_mutex_lock(&cur->owner->lock);
-         ast_log(LOG_DEBUG, "Detaching from %s\n", cur->owner->name);
+         ast_debug(1, "Detaching from %s\n", cur->owner->name);
          cur->owner->tech_pvt = NULL;
          ast_mutex_unlock(&cur->owner->lock);
          cur->owner = NULL;
@@ -3165,7 +3164,7 @@
       {
          if (f->subclass != p->owner->nativeformats) 
          {
-            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 = f->subclass;
             ast_set_read_format(p->owner, p->owner->readformat);
             ast_set_write_format(p->owner, p->owner->writeformat);
@@ -3174,7 +3173,7 @@
          {
             f = ast_dsp_process(p->owner, p->vad, f);
             if (f && (f->frametype == AST_FRAME_DTMF)) 
-               ast_log(LOG_DEBUG, "* Detected inband DTMF '%c'\n",f->subclass);
+               ast_debug(1, "* Detected inband DTMF '%c'\n",f->subclass);
          }
       }
    }

Modified: trunk/asterisk-ooh323c/src/ooh323cDriver.c
URL: http://svn.digium.com/view/asterisk-addons/trunk/asterisk-ooh323c/src/ooh323cDriver.c?view=diff&rev=408&r1=407&r2=408
==============================================================================
--- trunk/asterisk-ooh323c/src/ooh323cDriver.c (original)
+++ trunk/asterisk-ooh323c/src/ooh323cDriver.c Fri Jul  6 16:28:35 2007
@@ -18,6 +18,7 @@
 
 #include <asterisk/pbx.h>
 #include <asterisk/logger.h>
+#include <asterisk/options.h>
 
 extern OOBOOL gH323Debug;
 /* ooh323c stack thread. */
@@ -258,7 +259,7 @@
          ooH323EpAddAliasEmailID(cur->value);
          break;
       default:
-         ast_log(LOG_DEBUG, "Ignoring unknown alias type\n");
+         ast_debug(1, "Ignoring unknown alias type\n");
       }
       cur = cur->next;
    }
@@ -323,7 +324,7 @@
       case OO_G7231:
          return AST_FORMAT_G723_1;
       default:
-         ast_log(LOG_DEBUG, "Cap %d is not supported by driver yet\n");
+         ast_debug(1, "Cap %d is not supported by driver yet\n");
          return -1;
    }
 

Modified: trunk/cdr_addon_mysql.c
URL: http://svn.digium.com/view/asterisk-addons/trunk/cdr_addon_mysql.c?view=diff&rev=408&r1=407&r2=408
==============================================================================
--- trunk/cdr_addon_mysql.c (original)
+++ trunk/cdr_addon_mysql.c Fri Jul  6 16:28:35 2007
@@ -213,7 +213,7 @@
 		return -1;
 	}
 
-	ast_log(LOG_DEBUG, "cdr_mysql: inserting a CDR record.\n");
+	ast_debug(1, "cdr_mysql: inserting a CDR record.\n");
 
 	if (userfield && userfielddata) {
 		if (loguniqueid)
@@ -227,7 +227,7 @@
 			snprintf(sqlcmd, sizeof(sqlcmd), "INSERT INTO %s (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s) VALUES ('%s','%s','%s','%s','%s', '%s','%s','%s','%s',%i,%i,'%s',%i,'%s')", dbtable->str, calldate_field->str, clid_field->str, src_field->str, dst_field->str, dcontext_field->str, channel_field->str, dstchannel_field->str, lastapp_field->str, lastdata_field->str, duration_field->str, billsec_field->str, disposition_field->str, amaflags_field->str, accountcode_field->str, timestr, clid, cdr->src, cdr->dst, dcontext,channel, dstchannel, lastapp, lastdata, cdr->duration, cdr->billsec, ast_cdr_disp2str(cdr->disposition), cdr->amaflags, cdr->accountcode);
 	}
 	
-	ast_log(LOG_DEBUG, "cdr_mysql: SQL command as follows: %s\n", sqlcmd);
+	ast_debug(1, "cdr_mysql: SQL command as follows: %s\n", sqlcmd);
 	
 	if (connected) {
 		if (mysql_real_query(&mysql, sqlcmd, strlen(sqlcmd))) {
@@ -375,30 +375,30 @@
 	
 	ast_config_destroy(cfg);
 
-	ast_log(LOG_DEBUG, "cdr_mysql: got hostname of %s\n", hostname->str);
-	ast_log(LOG_DEBUG, "cdr_mysql: got port of %d\n", dbport);
-	ast_log(LOG_DEBUG, "cdr_mysql: got a timeout of %d\n", timeout);
+	ast_debug(1, "cdr_mysql: got hostname of %s\n", hostname->str);
+	ast_debug(1, "cdr_mysql: got port of %d\n", dbport);
+	ast_debug(1, "cdr_mysql: got a timeout of %d\n", timeout);
 	if (dbsock)
-		ast_log(LOG_DEBUG, "cdr_mysql: got sock file of %s\n", dbsock->str);
-	ast_log(LOG_DEBUG, "cdr_mysql: got user of %s\n", dbuser->str);
-	ast_log(LOG_DEBUG, "cdr_mysql: got dbname of %s\n", dbname->str);
-	ast_log(LOG_DEBUG, "cdr_mysql: got password of %s\n", password->str);
-
-	ast_log(LOG_DEBUG, "cdr_mysql: got calldate field of %s\n", calldate_field->str);
-	ast_log(LOG_DEBUG, "cdr_mysql: got clid field of %s\n", clid_field->str);
-	ast_log(LOG_DEBUG, "cdr_mysql: got src field of %s\n", src_field->str);
-	ast_log(LOG_DEBUG, "cdr_mysql: got dst field of %s\n", dst_field->str);
-	ast_log(LOG_DEBUG, "cdr_mysql: got dcontext field of %s\n", dcontext_field->str);
-	ast_log(LOG_DEBUG, "cdr_mysql: got channel field of %s\n", channel_field->str);
-	ast_log(LOG_DEBUG, "cdr_mysql: got dstchannel field of %s\n", dstchannel_field->str);
-	ast_log(LOG_DEBUG, "cdr_mysql: got lastapp field of %s\n", lastapp_field->str);
-	ast_log(LOG_DEBUG, "cdr_mysql: got lastdata field of %s\n", lastdata_field->str);
-	ast_log(LOG_DEBUG, "cdr_mysql: got duration field of %s\n", duration_field->str);
-	ast_log(LOG_DEBUG, "cdr_mysql: got billsec field of %s\n", billsec_field->str);
-	ast_log(LOG_DEBUG, "cdr_mysql: got amaflags field of %s\n", amaflags_field->str);
-	ast_log(LOG_DEBUG, "cdr_mysql: got accountcode field of %s\n", accountcode_field->str);
-	ast_log(LOG_DEBUG, "cdr_mysql: got userfield field of %s\n", userfield_field->str);
-	ast_log(LOG_DEBUG, "cdr_mysql: got uniqueid field of %s\n", uniqueid_field->str);
+		ast_debug(1, "cdr_mysql: got sock file of %s\n", dbsock->str);
+	ast_debug(1, "cdr_mysql: got user of %s\n", dbuser->str);
+	ast_debug(1, "cdr_mysql: got dbname of %s\n", dbname->str);
+	ast_debug(1, "cdr_mysql: got password of %s\n", password->str);
+
+	ast_debug(1, "cdr_mysql: got calldate field of %s\n", calldate_field->str);
+	ast_debug(1, "cdr_mysql: got clid field of %s\n", clid_field->str);
+	ast_debug(1, "cdr_mysql: got src field of %s\n", src_field->str);
+	ast_debug(1, "cdr_mysql: got dst field of %s\n", dst_field->str);
+	ast_debug(1, "cdr_mysql: got dcontext field of %s\n", dcontext_field->str);
+	ast_debug(1, "cdr_mysql: got channel field of %s\n", channel_field->str);
+	ast_debug(1, "cdr_mysql: got dstchannel field of %s\n", dstchannel_field->str);
+	ast_debug(1, "cdr_mysql: got lastapp field of %s\n", lastapp_field->str);
+	ast_debug(1, "cdr_mysql: got lastdata field of %s\n", lastdata_field->str);
+	ast_debug(1, "cdr_mysql: got duration field of %s\n", duration_field->str);
+	ast_debug(1, "cdr_mysql: got billsec field of %s\n", billsec_field->str);
+	ast_debug(1, "cdr_mysql: got amaflags field of %s\n", amaflags_field->str);
+	ast_debug(1, "cdr_mysql: got accountcode field of %s\n", accountcode_field->str);
+	ast_debug(1, "cdr_mysql: got userfield field of %s\n", userfield_field->str);
+	ast_debug(1, "cdr_mysql: got uniqueid field of %s\n", uniqueid_field->str);
 
 	mysql_init(&mysql);
 
@@ -411,7 +411,7 @@
 		connected = 0;
 		records = 0;
 	} else {
-		ast_log(LOG_DEBUG, "Successfully connected to MySQL database.\n");
+		ast_debug(1, "Successfully connected to MySQL database.\n");
 		connected = 1;
 		records = 0;
 		connect_time = time(NULL);

Modified: trunk/chan_mobile.c
URL: http://svn.digium.com/view/asterisk-addons/trunk/chan_mobile.c?view=diff&rev=408&r1=407&r2=408
==============================================================================
--- trunk/chan_mobile.c (original)
+++ trunk/chan_mobile.c Fri Jul  6 16:28:35 2007
@@ -481,8 +481,7 @@
 		return -1;
 	}
 
-	if (option_debug)
-		ast_log(LOG_DEBUG, "Calling %s on %s\n", dest, ast->name);
+	ast_debug(1, "Calling %s on %s\n", dest, ast->name);
 
 	if (pvt->type == MBL_TYPE_PHONE) {
 		ast_copy_string(pvt->dial_number, dest_num, sizeof(pvt->dial_number));
@@ -508,8 +507,7 @@
 	}
 	pvt = ast->tech_pvt;
 
-	if (option_debug)
-		ast_log(LOG_DEBUG, "Hanging up device %s.\n", pvt->id);
+	ast_debug(1, "Hanging up device %s.\n", pvt->id);
 
 	ast_channel_lock(ast);
 	ast->fds[0] = -1;
@@ -570,8 +568,7 @@
 	if (pvt->type == MBL_TYPE_HEADSET)
 		return 0;
 
-	if (option_debug)
-		ast_log(LOG_DEBUG, "Dialed %c\n", digit);
+	ast_debug(1, "Dialed %c\n", digit);
 
 	switch(digit) {
 	case '0':
@@ -635,23 +632,20 @@
 				pvt->fr.frametype = AST_FRAME_DTMF_END;
 				pvt->fr.subclass = f->subclass;
 				pvt->skip_frames = pvt->dtmf_skip;
-				if (option_debug)
-					ast_log(LOG_DEBUG, "DTMF digit %c detected.\n", pvt->fr.subclass);
+				ast_debug(1, "DTMF digit %c detected.\n", pvt->fr.subclass);
 			}
 			return &pvt->fr;
 		} else
 			pvt->skip_frames--;
 	} else if (r == -1) {
-		if (option_debug)
-			ast_log(LOG_DEBUG, "mbl_read() read error %d.\n", errno);
+		ast_debug(1, "mbl_read() read error %d.\n", errno);
 		close(pvt->sco_socket);
 		pvt->sco_socket = -1;
 		ast_channel_lock(ast);
 		ast->fds[0] = -1;
 		ast_channel_unlock(ast);
 	} else {
-		if (option_debug)
-			ast_log(LOG_DEBUG, "mbl_read() read short frame. (%d)\n", r);
+		ast_debug(1, "mbl_read() read short frame. (%d)\n", r);
 	}
 
 	return &ast_null_frame;
@@ -683,9 +677,7 @@
 
 	if (frame->datalen > sizeof(pvt->sco_out_buf) - pvt->sco_out_len) {
 		frame->datalen = sizeof(pvt->sco_out_buf) - pvt->sco_out_len;
-		if (option_debug) {
-			ast_log(LOG_DEBUG, "Overrun on sco_out_buf detected.\n");
-		}
+		ast_debug(1, "Overrun on sco_out_buf detected.\n");
 	}
 
 	memmove(pvt->sco_out_ptr, frame->data, frame->datalen);
@@ -730,8 +722,7 @@
 
 	device = ast_strdupa(S_OR(data, ""));
 
-	if (option_debug)
-		ast_log(LOG_DEBUG, "Checking device state for device %s\n", device);
+	ast_debug(1, "Checking device state for device %s\n", device);
 
 	AST_LIST_TRAVERSE(&devices, pvt, entry) {
 		if (!strcmp(pvt->id, device))
@@ -801,8 +792,7 @@
 	str2ba(bdaddr, &dst);
 
 	if ((s = socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM)) < 0) {
-		if (option_debug)
-			ast_log(LOG_DEBUG, "socket() failed (%d).\n", errno);
+		ast_debug(1, "socket() failed (%d).\n", errno);
 		return -1;
 	}
 
@@ -811,8 +801,7 @@
 	bacpy(&addr.rc_bdaddr, &dst);
 	addr.rc_channel = remote_channel;
 	if (connect(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
-		if (option_debug)
-			ast_log(LOG_DEBUG, "connect() failed (%d).\n", errno);
+		ast_debug(1, "connect() failed (%d).\n", errno);
 		close(s);
 		return -1;
 	}
@@ -828,13 +817,12 @@
 	ssize_t num_write;
 	int len;
 
-	if (option_debug)
-		ast_log(LOG_DEBUG, "rfcomm_write() (%s) [%s]\n", pvt->id, buf);
+	ast_debug(1, "rfcomm_write() (%s) [%s]\n", pvt->id, buf);
 	len = strlen(buf);
 	p = buf;
 	while (len > 0) {
 		if ((num_write = write(pvt->rfcomm_socket, p, len)) == -1) {
-			ast_log(LOG_DEBUG, "rfcomm_write() error [%d]\n", errno);
+			ast_debug(1, "rfcomm_write() error [%d]\n", errno);
 			return 0;
 		}
 		len -= num_write;
@@ -921,8 +909,7 @@
 	str2ba(bdaddr, &dst);
 
 	if ((s = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_SCO)) < 0) {
-		if (option_debug)
-			ast_log(LOG_DEBUG, "socket() failed (%d).\n", errno);
+		ast_debug(1, "socket() failed (%d).\n", errno);
 		return -1;
 	}
 
@@ -931,8 +918,7 @@
 	bacpy(&addr.sco_bdaddr, &dst);
 
 	if (connect(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
-		if (option_debug)
-			ast_log(LOG_DEBUG, "sco connect() failed (%d).\n", errno);
+		ast_debug(1, "sco connect() failed (%d).\n", errno);
 		close(s);
 		return -1;
 	}
@@ -964,8 +950,7 @@
 	port = 0;
 	session = sdp_connect(BDADDR_ANY, &bdaddr, SDP_RETRY_IF_BUSY);
 	if (!session) {
-		if (option_debug)
-			ast_log(LOG_DEBUG, "sdp_connect() failed on device %s.\n", addr);
+		ast_debug(1, "sdp_connect() failed on device %s.\n", addr);
 		return 0;
 	}
 
@@ -984,14 +969,11 @@
 			}
 			sdp_record_free(sdprec);
 			sdp_list_free(response_list, 0);
-		} else {
-			if (option_debug)
-				ast_log(LOG_DEBUG, "No responses returned for device %s.\n", addr);
-		}
-	} else {
-		if (option_debug)
-			ast_log(LOG_DEBUG, "sdp_service_search_attr_req() failed on device %s.\n", addr);
-	}
+		} else
+			ast_debug(1, "No responses returned for device %s.\n", addr);
+	} else
+		ast_debug(1, "sdp_service_search_attr_req() failed on device %s.\n", addr);
+
 
 	sdp_list_free(search_list, 0);
 	sdp_list_free(attrid_list, 0);
@@ -1117,8 +1099,7 @@
 		s = rfcomm_read(pvt, buf, 0, t);
 
 		if ((s > 0) && (buf[0] != 0x0) && (buf[0] != '\r')) {
-			if (option_debug)
-				ast_log(LOG_DEBUG, "rfcomm_read() (%s) [%s]\n", pvt->id, buf);
+			ast_debug(1, "rfcomm_read() (%s) [%s]\n", pvt->id, buf);
 			switch (pvt->state) {
 			case MBL_STATE_INIT:
 				if (strstr(buf, "+BRSF:")) {
@@ -1159,8 +1140,7 @@
 					sprintf(pvt->ciev_callsetup_3, "%d,3", callsetupp);
 					if (callsetupp == 0) /* This phone has no call setup indication!! ... */
 						pvt->no_callsetup = 1;
-					if (option_debug)
-						ast_log(LOG_DEBUG, "CIEV_CALL=%d CIEV_CALLSETUP=%d\n", callp, callsetupp);
+					ast_debug(1, "CIEV_CALL=%d CIEV_CALLSETUP=%d\n", callp, callsetupp);
 				}
 				if (strstr(buf, "OK")) {
 					rfcomm_write(pvt, "AT+CIND?\r");
@@ -1211,8 +1191,7 @@
 			case MBL_STATE_PREIDLE: /* Nothing handled here, wait for timeout, then off we go... */
 				break;
 			case MBL_STATE_IDLE:
-				if (option_debug)
-					ast_log(LOG_DEBUG, "Device %s %s [%s]\n", pvt->bdaddr, pvt->id, buf);
+				ast_debug(1, "Device %s %s [%s]\n", pvt->bdaddr, pvt->id, buf);
 				if (strstr(buf, "RING")) {
 					pvt->state = MBL_STATE_RING;
 				} else if (strstr(buf, "+CIEV:")) {
@@ -1395,8 +1374,7 @@
 				pvt->state = MBL_STATE_RING2;
 			} else if (pvt->state == MBL_STATE_HANGUP) {
 				if (pvt->hangup_count == 6) {
-					if (option_debug)
-						ast_log(LOG_DEBUG, "Device %s failed to hangup after 6 tries, disconnecting.\n", pvt->id);
+					ast_debug(1, "Device %s failed to hangup after 6 tries, disconnecting.\n", pvt->id);
 					monitor = 0;
 				}
 				rfcomm_write(pvt, "AT+CHUP\r");
@@ -1465,8 +1443,7 @@
 		s = rfcomm_read(pvt, buf, 0, t);
 
 		if ((s > 0) && (buf[0] != 0x0) && (buf[0] != '\r')) {
-			if (option_debug)
-				ast_log(LOG_DEBUG, "rfcomm_read() (%s) [%s]\n", pvt->id, buf);
+			ast_debug(1, "rfcomm_read() (%s) [%s]\n", pvt->id, buf);
 			switch (pvt->state) {
 			case MBL_STATE_RING2:
 				if (strstr(buf, "AT+CKPD=")) {
@@ -1632,8 +1609,7 @@
 			len = sizeof(so);
 			getsockopt(ns, SOL_SCO, SCO_OPTIONS, &so, &len);
 
-			if (option_debug)
-				ast_log(LOG_DEBUG, "Incoming Audio Connection from device %s MTU is %d\n", saddr, so.mtu);
+			ast_debug(1, "Incoming Audio Connection from device %s MTU is %d\n", saddr, so.mtu);
 
 			pvt = NULL;
 			AST_LIST_TRAVERSE(&devices, pvt, entry) {
@@ -1649,8 +1625,8 @@
 					pvt->owner->fds[0] = ns;
 					ast_channel_unlock(pvt->owner);
 				}
-			} else if (option_debug)
-				ast_log(LOG_DEBUG, "Could not find device for incoming Audio Connection.\n");
+			} else
+				ast_debug(1, "Could not find device for incoming Audio Connection.\n");
 		}
 	}
 
@@ -1679,8 +1655,7 @@
 	cat = ast_category_browse(cfg, NULL);
 	while (cat) {
 		if (strcasecmp(cat, "general")) {
-			if (option_debug)
-				ast_log(LOG_DEBUG, "Loading device %s.\n", cat);
+			ast_debug(1, "Loading device %s.\n", cat);
 			address = ast_variable_retrieve(cfg, cat, "address");
 			port = ast_variable_retrieve(cfg, cat, "port");
 			context = ast_variable_retrieve(cfg, cat, "context");

Modified: trunk/res_config_mysql.c
URL: http://svn.digium.com/view/asterisk-addons/trunk/res_config_mysql.c?view=diff&rev=408&r1=407&r2=408
==============================================================================
--- trunk/res_config_mysql.c (original)
+++ trunk/res_config_mysql.c Fri Jul  6 16:28:35 2007
@@ -147,13 +147,13 @@
 	}
 	va_end(ap);
 
-	ast_log(LOG_DEBUG, "MySQL RealTime: Retrieve SQL: %s\n", sql);
+	ast_debug(1, "MySQL RealTime: Retrieve SQL: %s\n", sql);
 
 	/* Execution. */
 	if (mysql_real_query(&dbread.handle, sql, strlen(sql))) {
 		ast_log(LOG_WARNING, "MySQL RealTime: Failed to query database. Check debug for more info.\n");
-		ast_log(LOG_DEBUG, "MySQL RealTime: Query: %s\n", sql);
-		ast_log(LOG_DEBUG, "MySQL RealTime: Query Failed because: %s\n", mysql_error(&dbread.handle));
+		ast_debug(1, "MySQL RealTime: Query: %s\n", sql);
+		ast_debug(1, "MySQL RealTime: Query Failed because: %s\n", mysql_error(&dbread.handle));
 		ast_mutex_unlock(&dbread.lock);
 		return NULL;
 	}
@@ -268,13 +268,13 @@
 
 	va_end(ap);
 
-	ast_log(LOG_DEBUG, "MySQL RealTime: Retrieve SQL: %s\n", sql);
+	ast_debug(1, "MySQL RealTime: Retrieve SQL: %s\n", sql);
 
 	/* Execution. */
 	if (mysql_real_query(&dbread.handle, sql, strlen(sql))) {
 		ast_log(LOG_WARNING, "MySQL RealTime: Failed to query database. Check debug for more info.\n");
-		ast_log(LOG_DEBUG, "MySQL RealTime: Query: %s\n", sql);
-		ast_log(LOG_DEBUG, "MySQL RealTime: Query Failed because: %s\n", mysql_error(&dbread.handle));
+		ast_debug(1, "MySQL RealTime: Query: %s\n", sql);
+		ast_debug(1, "MySQL RealTime: Query Failed because: %s\n", mysql_error(&dbread.handle));
 		ast_mutex_unlock(&dbread.lock);
 		ast_config_destroy(cfg);
 		return NULL;
@@ -364,13 +364,13 @@
 	mysql_real_escape_string(&dbwrite.handle, buf, lookup, valsz);
 	snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), " WHERE %s = '%s'", keyfield, buf);
 
-	ast_log(LOG_DEBUG,"MySQL RealTime: Update SQL: %s\n", sql);
+	ast_debug(1,"MySQL RealTime: Update SQL: %s\n", sql);
 
 	/* Execution. */
 	if (mysql_real_query(&dbwrite.handle, sql, strlen(sql))) {
 		ast_log(LOG_WARNING, "MySQL RealTime: Failed to query database. Check debug for more info.\n");
-		ast_log(LOG_DEBUG, "MySQL RealTime: Query: %s\n", sql);
-		ast_log(LOG_DEBUG, "MySQL RealTime: Query Failed because: %s\n", mysql_error(&dbwrite.handle));
+		ast_debug(1, "MySQL RealTime: Query: %s\n", sql);
+		ast_debug(1, "MySQL RealTime: Query Failed because: %s\n", mysql_error(&dbwrite.handle));
 		ast_mutex_unlock(&dbwrite.lock);
 		return -1;
 	}
@@ -378,7 +378,7 @@
 	numrows = mysql_affected_rows(&dbwrite.handle);
 	ast_mutex_unlock(&dbwrite.lock);
 
-	ast_log(LOG_DEBUG,"MySQL RealTime: Updated %llu rows on table: %s\n", numrows, table);
+	ast_debug(1,"MySQL RealTime: Updated %llu rows on table: %s\n", numrows, table);
 
 	/* From http://dev.mysql.com/doc/mysql/en/mysql-affected-rows.html
 	 * An integer greater than zero indicates the number of rows affected
@@ -441,13 +441,13 @@
 	}
 	va_end(ap);
 	snprintf(sql, sizeof(sql), "INSERT into %s (%s) values (%s)", table, fields, values);
-	ast_log(LOG_DEBUG,"MySQL RealTime: Insert SQL: %s\n", sql);
+	ast_debug(1,"MySQL RealTime: Insert SQL: %s\n", sql);
 
 	/* Execution. */
 	if (mysql_real_query(&dbwrite.handle, sql, strlen(sql))) {
 		ast_log(LOG_WARNING, "MySQL RealTime: Failed to query database. Check debug for more info.\n");
-		ast_log(LOG_DEBUG, "MySQL RealTime: Query: %s\n", sql);
-		ast_log(LOG_DEBUG, "MySQL RealTime: Query Failed because: %s\n", mysql_error(&dbwrite.handle));
+		ast_debug(1, "MySQL RealTime: Query: %s\n", sql);
+		ast_debug(1, "MySQL RealTime: Query Failed because: %s\n", mysql_error(&dbwrite.handle));
 		ast_mutex_unlock(&dbwrite.lock);
 		return -1;
 	}
@@ -455,7 +455,7 @@
 	insertid = mysql_insert_id(&dbwrite.handle);
 	ast_mutex_unlock(&dbwrite.lock);
 
-	ast_log(LOG_DEBUG, "MySQL RealTime: row inserted on table: %s, id: %llu\n", table, insertid);
+	ast_debug(1, "MySQL RealTime: row inserted on table: %s, id: %llu\n", table, insertid);
 
 	/* From http://dev.mysql.com/doc/mysql/en/mysql-affected-rows.html
 	 * An integer greater than zero indicates the number of rows affected
@@ -509,13 +509,13 @@
 	}
 	va_end(ap);
 
-	ast_log(LOG_DEBUG, "MySQL RealTime: Delete SQL: %s\n", sql);
+	ast_debug(1, "MySQL RealTime: Delete SQL: %s\n", sql);
 
 	/* Execution. */
 	if (mysql_real_query(&dbwrite.handle, sql, strlen(sql))) {
 		ast_log(LOG_WARNING, "MySQL RealTime: Failed to query database. Check debug for more info.\n");
-		ast_log(LOG_DEBUG, "MySQL RealTime: Query: %s\n", sql);
-		ast_log(LOG_DEBUG, "MySQL RealTime: Query Failed because: %s\n", mysql_error(&dbwrite.handle));
+		ast_debug(1, "MySQL RealTime: Query: %s\n", sql);
+		ast_debug(1, "MySQL RealTime: Query Failed because: %s\n", mysql_error(&dbwrite.handle));
 		ast_mutex_unlock(&dbwrite.lock);
 		return -1;
 	}
@@ -523,7 +523,7 @@
 	numrows = mysql_affected_rows(&dbwrite.handle);
 	ast_mutex_unlock(&dbwrite.lock);
 
-	ast_log(LOG_DEBUG, "MySQL RealTime: Deleted %llu rows on table: %s\n", numrows, table);
+	ast_debug(1, "MySQL RealTime: Deleted %llu rows on table: %s\n", numrows, table);
 
 	/* From http://dev.mysql.com/doc/mysql/en/mysql-affected-rows.html
 	 * An integer greater than zero indicates the number of rows affected
@@ -554,7 +554,7 @@
 
 	snprintf(sql, sizeof(sql), "SELECT category, var_name, var_val, cat_metric FROM %s WHERE filename='%s' and commented=0 ORDER BY filename, cat_metric desc, var_metric asc, category, var_name, var_val, id", table, file);
 
-	ast_log(LOG_DEBUG, "MySQL RealTime: Static SQL: %s\n", sql);
+	ast_debug(1, "MySQL RealTime: Static SQL: %s\n", sql);
 
 	/* We now have our complete statement; Lets connect to the server and execute it. */
 	ast_mutex_lock(&dbread.lock);
@@ -565,15 +565,15 @@
 
 	if (mysql_real_query(&dbread.handle, sql, strlen(sql))) {
 		ast_log(LOG_WARNING, "MySQL RealTime: Failed to query database. Check debug for more info.\n");
-		ast_log(LOG_DEBUG, "MySQL RealTime: Query: %s\n", sql);
-		ast_log(LOG_DEBUG, "MySQL RealTime: Query Failed because: %s\n", mysql_error(&dbread.handle));
+		ast_debug(1, "MySQL RealTime: Query: %s\n", sql);
+		ast_debug(1, "MySQL RealTime: Query Failed because: %s\n", mysql_error(&dbread.handle));
 		ast_mutex_unlock(&dbread.lock);
 		return NULL;
 	}
 
 	if ((result = mysql_store_result(&dbread.handle))) {
 		num_rows = mysql_num_rows(result);
-		ast_log(LOG_DEBUG, "MySQL RealTime: Found %llu rows.\n", num_rows);
+		ast_debug(1, "MySQL RealTime: Found %llu rows.\n", num_rows);
 
 		/* There might exist a better way to access the column names other than counting,
                    but I believe that would require another loop that we don't need. */
@@ -707,13 +707,13 @@
 	ast_copy_string(conn->sock, "/tmp/mysql.sock", sizeof(conn->sock));
 
 	if (!ast_strlen_zero(conn->host)) {
-		ast_log(LOG_DEBUG, "MySQL RealTime host: %s\n", conn->host);
-		ast_log(LOG_DEBUG, "MySQL RealTime port: %i\n", conn->port);
+		ast_debug(1, "MySQL RealTime host: %s\n", conn->host);
+		ast_debug(1, "MySQL RealTime port: %i\n", conn->port);
 	} else
-		ast_log(LOG_DEBUG, "MySQL RealTime socket: %s\n", conn->sock);
-	ast_log(LOG_DEBUG, "MySQL RealTime database name: %s\n", conn->name);
-	ast_log(LOG_DEBUG, "MySQL RealTime user: %s\n", conn->user);
-	ast_log(LOG_DEBUG, "MySQL RealTime password: %s\n", conn->pass);
+		ast_debug(1, "MySQL RealTime socket: %s\n", conn->sock);
+	ast_debug(1, "MySQL RealTime database name: %s\n", conn->name);
+	ast_debug(1, "MySQL RealTime user: %s\n", conn->user);
+	ast_debug(1, "MySQL RealTime password: %s\n", conn->pass);
 
 	return 0;
 }
@@ -802,13 +802,13 @@
 		ast_copy_string(conn->sock, s, sizeof(conn->sock));
 
 	if (!ast_strlen_zero(conn->host)) {
-		ast_log(LOG_DEBUG, "MySQL RealTime host: %s\n", conn->host);
-		ast_log(LOG_DEBUG, "MySQL RealTime port: %i\n", conn->port);
+		ast_debug(1, "MySQL RealTime host: %s\n", conn->host);
+		ast_debug(1, "MySQL RealTime port: %i\n", conn->port);
 	} else
-		ast_log(LOG_DEBUG, "MySQL RealTime socket: %s\n", conn->sock);
-	ast_log(LOG_DEBUG, "MySQL RealTime database name: %s\n", conn->name);
-	ast_log(LOG_DEBUG, "MySQL RealTime user: %s\n", conn->user);
-	ast_log(LOG_DEBUG, "MySQL RealTime password: %s\n", conn->pass);
+		ast_debug(1, "MySQL RealTime socket: %s\n", conn->sock);
+	ast_debug(1, "MySQL RealTime database name: %s\n", conn->name);
+	ast_debug(1, "MySQL RealTime user: %s\n", conn->user);
+	ast_debug(1, "MySQL RealTime password: %s\n", conn->pass);
 
 	return 1;
 }
@@ -835,13 +835,13 @@
 			 * (as of 5.0.3) so we have to set that option here. */
 			mysql_options(&conn->handle, MYSQL_OPT_RECONNECT, &trueval);
 #endif
-			ast_log(LOG_DEBUG, "MySQL RealTime: Successfully connected to database.\n");
+			ast_debug(1, "MySQL RealTime: Successfully connected to database.\n");
 			conn->connected = 1;
 			conn->connect_time = time(NULL);
 			return 1;
 		} else {
 			ast_log(LOG_ERROR, "MySQL RealTime: Failed to connect database server %s on %s (err %d). Check debug for more info.\n", conn->name, !ast_strlen_zero(conn->host) ? conn->host : conn->sock, mysql_errno(&conn->handle));
-			ast_log(LOG_DEBUG, "MySQL RealTime: Cannot Connect (%d): %s\n", mysql_errno(&conn->handle), mysql_error(&conn->handle));
+			ast_debug(1, "MySQL RealTime: Cannot Connect (%d): %s\n", mysql_errno(&conn->handle), mysql_error(&conn->handle));
 			conn->connected = 0;
 			return 0;
 		}
@@ -851,7 +851,7 @@
 		if (mysql_ping(&conn->handle) != 0 && mysql_ping(&conn->handle) != 0) {
 			conn->connected = 0;
 			ast_log(LOG_ERROR, "MySQL RealTime: Ping failed (%d).  Trying an explicit reconnect.\n", mysql_errno(&conn->handle));
-			ast_log(LOG_DEBUG, "MySQL RealTime: Server Error (%d): %s\n", mysql_errno(&conn->handle), mysql_error(&conn->handle));
+			ast_debug(1, "MySQL RealTime: Server Error (%d): %s\n", mysql_errno(&conn->handle), mysql_error(&conn->handle));
 			goto reconnect_tryagain;
 		}
 
@@ -862,7 +862,7 @@
 			return 0;
 		}
 
-		ast_log(LOG_DEBUG, "MySQL RealTime: Connection okay.\n");
+		ast_debug(1, "MySQL RealTime: Connection okay.\n");
 		return 1;
 	}
 }




More information about the asterisk-addons-commits mailing list