Skip to content

Commit

Permalink
Merge pull request #105 from karimcambridge/issue-54
Browse files Browse the repository at this point in the history
Add query to debug logs in the most places where (assumed) that peopl…
  • Loading branch information
maddinat0r committed Aug 25, 2016
2 parents 5fd3535 + 807485c commit b89d115
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/CMySQLQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ bool CMySQLQuery::Execute(MYSQL *mysql_connection)
int error_id = mysql_errno(mysql_connection);
string error_str(mysql_error(mysql_connection));

CLog::Get()->LogFunction(LOG_ERROR, log_funcname, "(error #%d) %s", error_id, error_str.c_str());
CLog::Get()->LogFunction(LOG_ERROR, log_funcname, "(error #%d) %s (Query: \"%s\")", error_id, error_str.c_str(), Query.c_str());

if (!Unthreaded)
{
Expand Down
10 changes: 5 additions & 5 deletions src/CMySQLResult.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const char *CMySQLResult::GetFieldName(unsigned int idx)
}
else
{
CLog::Get()->LogFunction(LOG_WARNING, "CMySQLResult::GetFieldName", "invalid field index ('%d')", idx);
CLog::Get()->LogFunction(LOG_WARNING, "CMySQLResult::GetFieldName", "invalid field index ('%d') (Query: \"%s\")", idx, m_Query.c_str());
return NULL;
}
}
Expand All @@ -36,7 +36,7 @@ const char *CMySQLResult::GetRowData(unsigned int row, unsigned int fieldidx)
}
else
{
CLog::Get()->LogFunction(LOG_WARNING, "CMySQLResult::GetRowData", "invalid row ('%d') or field index ('%d')", row, fieldidx);
CLog::Get()->LogFunction(LOG_WARNING, "CMySQLResult::GetRowData", "invalid row ('%d') or field index ('%d') (Query: \"%s\")", row, fieldidx, m_Query.c_str());
return NULL;
}
}
Expand All @@ -45,13 +45,13 @@ const char *CMySQLResult::GetRowDataByName(unsigned int row, const char *field)
{
if(row >= m_Rows || m_Fields == 0)
{
CLog::Get()->LogFunction(LOG_ERROR, "CMySQLResult::GetRowDataByName()", "invalid row index ('%d')", row);
CLog::Get()->LogFunction(LOG_ERROR, "CMySQLResult::GetRowDataByName()", "invalid row index ('%d') (Query: \"%s\")", row, m_Query.c_str());
return NULL;
}

if(field == NULL)
{
CLog::Get()->LogFunction(LOG_ERROR, "CMySQLResult::GetRowDataByName()", "empty field name specified");
CLog::Get()->LogFunction(LOG_ERROR, "CMySQLResult::GetRowDataByName()", "empty field name specified (Query: \"%s\")", m_Query.c_str());
return NULL;
}

Expand All @@ -70,7 +70,7 @@ const char *CMySQLResult::GetRowDataByName(unsigned int row, const char *field)
return m_Data[row][i];
}
}
CLog::Get()->LogFunction(LOG_WARNING, "CMySQLResult::GetRowDataByName", "field not found (\"%s\")", field);
CLog::Get()->LogFunction(LOG_WARNING, "CMySQLResult::GetRowDataByName", "field not found (\"%s\") (Query: \"%s\")", field, m_Query.c_str());
return NULL;
}

Expand Down
8 changes: 3 additions & 5 deletions src/CScripting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ AMX_DECLARE_NATIVE(Native::mysql_pquery)
return ERROR_INVALID_CONNECTION_HANDLE("mysql_pquery", connection_id);

if (cb_format != NULL && strlen(cb_format) != ((params[0] / 4) - ConstParamCount))
return CLog::Get()->LogFunction(LOG_ERROR, "mysql_pquery", "callback parameter count does not match format specifier length");
return CLog::Get()->LogFunction(LOG_ERROR, "mysql_pquery", "callback parameter count does not match format specifier length (Query: \"%s\")", query_str ? query_str : "");


CMySQLHandle *Handle = CMySQLHandle::GetHandle(connection_id);
Expand Down Expand Up @@ -898,7 +898,7 @@ AMX_DECLARE_NATIVE(Native::mysql_tquery)
return ERROR_INVALID_CONNECTION_HANDLE("mysql_tquery", connection_id);

if (cb_format != NULL && strlen(cb_format) != ((params[0] / 4) - ConstParamCount))
return CLog::Get()->LogFunction(LOG_ERROR, "mysql_tquery", "callback parameter count does not match format specifier length");
return CLog::Get()->LogFunction(LOG_ERROR, "mysql_tquery", "callback parameter count does not match format specifier length (Query: \"%s\")", query_str ? query_str : "");


CMySQLHandle *Handle = CMySQLHandle::GetHandle(connection_id);
Expand Down Expand Up @@ -1300,7 +1300,7 @@ AMX_DECLARE_NATIVE(Native::mysql_escape_string)
if(source_str != NULL)
{
if(strlen(source_str) >= max_size)
return CLog::Get()->LogFunction(LOG_ERROR, "mysql_escape_string", "destination size is too small (must be at least as big as source)");
return CLog::Get()->LogFunction(LOG_ERROR, "mysql_escape_string", "destination size is too small (must be at least as big as source) (Query: \"%s\")", source_str);

CMySQLHandle::GetHandle(connection_id)->GetMainConnection()->EscapeString(source_str, escaped_str);
}
Expand Down Expand Up @@ -1338,8 +1338,6 @@ AMX_DECLARE_NATIVE(Native::mysql_errno)
ERROR_INVALID_CONNECTION_HANDLE("mysql_errno", connection_id);
return -1; //don't return 0 since it means that there are no errors
}


return static_cast<cell>(mysql_errno(CMySQLHandle::GetHandle(connection_id)->GetMainConnection()->GetMysqlPtr()));
}

Expand Down

0 comments on commit b89d115

Please sign in to comment.