]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Make error message slightly more verbose.
authorEliot Gable <egable@gmail.com>
Mon, 8 Oct 2012 20:56:05 +0000 (20:56 +0000)
committerEliot Gable <egable@gmail.com>
Mon, 8 Oct 2012 20:56:05 +0000 (20:56 +0000)
src/switch_core_sqldb.c

index 23b08ace75d2fa19e94900d147999bd16085a4ea..2888131698429d7c3103e975205c85ca5fff1650 100644 (file)
@@ -607,6 +607,7 @@ static switch_status_t switch_cache_db_execute_sql_real(switch_cache_db_handle_t
        switch_status_t status = SWITCH_STATUS_FALSE;
        char *errmsg = NULL;
        char *tmp = NULL;
+       char *type = NULL;
        switch_mutex_t *io_mutex = dbh->io_mutex;
        
        if (io_mutex) switch_mutex_lock(io_mutex);
@@ -618,17 +619,20 @@ static switch_status_t switch_cache_db_execute_sql_real(switch_cache_db_handle_t
        switch (dbh->type) {
        case SCDB_TYPE_PGSQL:
                {
+                       type = "PGSQL";
                        status = switch_pgsql_handle_exec(dbh->native_handle.pgsql_dbh, sql, &errmsg);
                }
                break;
        case SCDB_TYPE_ODBC:
                {
+                       type = "ODBC";
                        status = switch_odbc_handle_exec(dbh->native_handle.odbc_dbh, sql, NULL, &errmsg);
                }
                break;
        case SCDB_TYPE_CORE_DB:
                {
                        int ret = switch_core_db_exec(dbh->native_handle.core_db_dbh, sql, NULL, NULL, &errmsg);
+                       type = "NATIVE";
 
                        if (ret == SWITCH_CORE_DB_OK) {
                                status = SWITCH_STATUS_SUCCESS;
@@ -645,7 +649,7 @@ static switch_status_t switch_cache_db_execute_sql_real(switch_cache_db_handle_t
 
        if (errmsg) {
                if (!switch_stristr("already exists", errmsg) && !switch_stristr("duplicate key name", errmsg)) {
-                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL ERR [%s]\n%s\n", errmsg, sql);
+                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s SQL ERR [%s]\n%s\n", (type ? type : "Unknown"), errmsg, sql);
                }
                if (err) {
                        *err = errmsg;