瀏覽代碼

- port mysql driver and db API to new logging system

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@2733 689a6050-402a-0410-94f2-e92a70836424
Henning Westerholt 18 年之前
父節點
當前提交
53d94439d3
共有 5 個文件被更改,包括 25 次插入25 次删除
  1. 13 13
      lib/srdb1/db.c
  2. 3 3
      lib/srdb1/db_id.c
  3. 4 4
      lib/srdb1/db_pool.c
  4. 4 4
      lib/srdb1/db_res.c
  5. 1 1
      lib/srdb1/db_row.c

+ 13 - 13
lib/srdb1/db.c

@@ -47,11 +47,11 @@ int bind_dbmod(char* mod, db_func_t* mydbf)
 	db_func_t dbf;
 
 	if (!mod) {
-		LOG(L_CRIT, "BUG: bind_dbmod(): null database module name\n");
+		LM_CRIT("null database module name\n");
 		return -1;
 	}
 	if (mydbf==0) {
-		LOG(L_CRIT, "BUG: bind_dbmod(): null dbf parameter\n");
+		LM_CRIT("null dbf parameter\n");
 		return -1;
 	}
 	/* for safety we initialize mydbf with 0 (this will cause
@@ -64,7 +64,7 @@ int bind_dbmod(char* mod, db_func_t* mydbf)
 		len = p - mod;
 		tmp = (char*)pkg_malloc(len + 1);
 		if (!tmp) {
-			LOG(L_ERR, "ERROR: bind_dbmod(): No memory left\n");
+			LM_ERR("no private memory left\n");
 			return -1;
 		}
 		memcpy(tmp, mod, len);
@@ -78,21 +78,21 @@ int bind_dbmod(char* mod, db_func_t* mydbf)
 	     /* All modules must export db_use_table */
 	dbf.use_table = (db_use_table_f)find_mod_export(tmp, "db_use_table", 2, 0);
 	if (dbf.use_table == 0) {
-		LOG(L_ERR, "bind_dbmod: Module %s does not export db_use_table function\n", tmp);
+		LM_ERR("module %s does not export db_use_table function\n", tmp);
 		goto err;
 	}
 
 	     /* All modules must export db_init */
 	dbf.init = (db_init_f)find_mod_export(tmp, "db_init", 1, 0);
 	if (dbf.init == 0) {
-		LOG(L_ERR, "bind_dbmod: Module %s does not export db_init function\n", tmp);
+		LM_ERR("module %s does not export db_init function\n", tmp);
 		goto err;
 	}
 
 	     /* All modules must export db_close */
 	dbf.close = (db_close_f)find_mod_export(tmp, "db_close", 2, 0);
 	if (dbf.close == 0) {
-		LOG(L_ERR, "bind_dbmod: Module %s does not export db_close function\n", tmp);
+		LM_ERR("module %s does not export db_close function\n", tmp);
 		goto err;
 	}
 
@@ -118,7 +118,7 @@ int bind_dbmod(char* mod, db_func_t* mydbf)
 	dbf.free_result = (db_free_result_f)find_mod_export(tmp, "db_free_result", 2, 0);
 	if ((dbf.cap & (DB_CAP_QUERY | DB_CAP_RAW_QUERY))
 	    && (dbf.free_result == 0)) {
-		LOG(L_ERR, "bind_dbmod: Module %s supports queries but does not export free_result function\n", tmp);
+		LM_ERR("module %s supports queries but does not export free_result function\n", tmp);
 		goto err;
 	}
 
@@ -175,12 +175,12 @@ int table_version(db_func_t* dbf, db_con_t* connection, const str* table)
 	int ret;
 
 	if (!dbf||!connection || !table) {
-		LOG(L_CRIT, "BUG: table_version(): Invalid parameter value\n");
+		LM_CRIT("invalid parameter value\n");
 		return -1;
 	}
 
 	if (dbf->use_table(connection, VERSION_TABLE) < 0) {
-		LOG(L_ERR, "table_version(): Error while changing table\n");
+		LM_ERR("error while changing table\n");
 		return -1;
 	}
 
@@ -193,18 +193,18 @@ int table_version(db_func_t* dbf, db_con_t* connection, const str* table)
 	col[0] = VERSION_COLUMN;
 	
 	if (dbf->query(connection, key, 0, val, col, 1, 1, 0, &res) < 0) {
-		LOG(L_ERR, "table_version(): Error in db_query\n");
+		LM_ERR("error in db_query\n");
 		return -1;
 	}
 
 	if (RES_ROW_N(res) == 0) {
-		DBG("table_version(): No row for table %.*s found\n",
+		LM_DBG("no row for table %.*s found\n",
 			table->len, ZSW(table->s));
 		return 0;
 	}
 
 	if (RES_ROW_N(res) != 1) {
-		LOG(L_ERR, "table_version(): Invalid number of rows received:"
+		LM_ERR("invalid number of rows received:"
 			" %d, %.*s\n", RES_ROW_N(res), table->len, ZSW(table->s));
 		dbf->free_result(connection, res);
 		return -1;
@@ -212,7 +212,7 @@ int table_version(db_func_t* dbf, db_con_t* connection, const str* table)
 
 	ver = ROW_VALUES(RES_ROWS(res));
 	if ( VAL_TYPE(ver)!=DB_INT || VAL_NULL(ver) ) {
-		LOG(L_ERR, "table_version(): Invalid type (%d) or nul (%d) version "
+		LM_ERR("invalid type (%d) or nul (%d) version "
 			"columns for %.*s\n", VAL_TYPE(ver), VAL_NULL(ver),
 			table->len, ZSW(table->s));
 		dbf->free_result(connection, res);

+ 3 - 3
lib/srdb1/db_id.c

@@ -212,19 +212,19 @@ struct db_id* new_db_id(const char* url)
 	struct db_id* ptr;
 
 	if (!url) {
-		LOG(L_ERR, "new_db_id: Invalid parameter\n");
+		LM_ERR("invalid parameter\n");
 		return 0;
 	}
 
 	ptr = (struct db_id*)pkg_malloc(sizeof(struct db_id));
 	if (!ptr) {
-		LOG(L_ERR, "new_db_id: No memory left\n");
+		LM_ERR("no private memory left\n");
 		goto err;
 	}
 	memset(ptr, 0, sizeof(struct db_id));
 
 	if (parse_db_url(ptr, url) < 0) {
-		LOG(L_ERR, "new_db_id: Error while parsing database URL: %s\n", url);
+		LM_ERR("error while parsing database URL: %s\n", url);
 		goto err;
 	}
 

+ 4 - 4
lib/srdb1/db_pool.c

@@ -38,7 +38,7 @@ struct pool_con* pool_get(struct db_id* id)
 	struct pool_con* ptr;
 
 	if (!id) {
-		LOG(L_ERR, "pool_get: Invalid parameter value\n");
+		LM_ERR("invalid parameter value\n");
 		return 0;
 	}
 
@@ -87,12 +87,12 @@ int pool_remove(struct pool_con* con)
 		     /* There are still other users, just
 		      * decrease the reference count and return
 		      */
-		DBG("pool_remove: Connection still kept in the pool\n");
+		LM_DBG("connection still kept in the pool\n");
 		con->ref--;
 		return 0;
 	}
 
-	DBG("pool_remove: Removing connection from the pool\n");
+	LM_DBG("removing connection from the pool\n");
 
 	if (db_pool == con) {
 		db_pool = db_pool->next;
@@ -103,7 +103,7 @@ int pool_remove(struct pool_con* con)
 			ptr = ptr->next;
 		}
 		if (!ptr) {
-			LOG(L_ERR, "pool_remove: Weird, connection not found in the pool\n");
+			LM_ERR("weird, connection not found in the pool\n");
 			return -1;
 		} else {
 			     /* Remove the connection from the pool */

+ 4 - 4
lib/srdb1/db_res.c

@@ -35,17 +35,17 @@ inline int db_free_rows(db_res_t* _r)
 	int i;
 
 	if (!_r) {
-		LOG(L_ERR, "ERROR:db_free_rows: Invalid parameter value\n");
+		LM_ERR("invalid parameter value\n");
 		return -1;
 	}
-	LOG(L_DBG, "DEBUG:db_free_rows: Freeing %d rows\n", RES_ROW_N(_r));
+	LM_DBG("freeing %d rows\n", RES_ROW_N(_r));
 
 	for(i = 0; i < RES_ROW_N(_r); i++) {
-		LOG(L_DBG, "DEBUG:db_free_row: Row[%d]=%p\n", i, &(RES_ROWS(_r)[i]));
+		LM_DBG("row[%d]=%p\n", i, &(RES_ROWS(_r)[i]));
 		db_free_row(&(RES_ROWS(_r)[i]));
 	}
 	if (RES_ROWS(_r)) {
-		LOG(L_DBG, "DEBUG:db_free_rows: %p=pkg_free() RES_ROWS\n", RES_ROWS(_r));
+		LM_DBG("%p=pkg_free() RES_ROWS\n", RES_ROWS(_r));
 		pkg_free(RES_ROWS(_r));
 		RES_ROWS(_r) = NULL;
 	}

+ 1 - 1
lib/srdb1/db_row.c

@@ -32,7 +32,7 @@
 inline int db_free_row(db_row_t* _r)
 {
 	if (!_r) {
-		LOG(L_ERR, "ERROR:db_free_row: Invalid parameter value\n");
+		LM_ERR("invalid parameter value\n");
 		return -1;
 	}