Skip to content

Commit fb0945a

Browse files
Add query to debug logs in the most places where (assumed) that people get most errors
This way we don't have to turn on LOG_DEBUG if we have massive constant MySQL usage!
1 parent 5fd3535 commit fb0945a

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/CMySQLQuery.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ bool CMySQLQuery::Execute(MYSQL *mysql_connection)
6565
int error_id = mysql_errno(mysql_connection);
6666
string error_str(mysql_error(mysql_connection));
6767

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

7070
if (!Unthreaded)
7171
{

src/CMySQLResult.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const char *CMySQLResult::GetRowData(unsigned int row, unsigned int fieldidx)
3636
}
3737
else
3838
{
39-
CLog::Get()->LogFunction(LOG_WARNING, "CMySQLResult::GetRowData", "invalid row ('%d') or field index ('%d')", row, fieldidx);
39+
CLog::Get()->LogFunction(LOG_WARNING, "CMySQLResult::GetRowData", "invalid row ('%d') or field index ('%d') (Query: \"%s\")", row, fieldidx, m_Query.c_str());
4040
return NULL;
4141
}
4242
}

src/CScripting.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ AMX_DECLARE_NATIVE(Native::mysql_tquery)
898898
return ERROR_INVALID_CONNECTION_HANDLE("mysql_tquery", connection_id);
899899

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

903903

904904
CMySQLHandle *Handle = CMySQLHandle::GetHandle(connection_id);
@@ -1300,7 +1300,7 @@ AMX_DECLARE_NATIVE(Native::mysql_escape_string)
13001300
if(source_str != NULL)
13011301
{
13021302
if(strlen(source_str) >= max_size)
1303-
return CLog::Get()->LogFunction(LOG_ERROR, "mysql_escape_string", "destination size is too small (must be at least as big as source)");
1303+
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);
13041304

13051305
CMySQLHandle::GetHandle(connection_id)->GetMainConnection()->EscapeString(source_str, escaped_str);
13061306
}

0 commit comments

Comments
 (0)