sourcemod
sourcemod copied to clipboard
Include full SQL query in error log
Is it possible to include a full text of SQL query for errors like:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'STEAM_1:0:xxxxxxx'' at line 1
because such error text say not much.
I can't see which source code line number it is related to. Thank you.
You can log callback name when you use LogError or something like that, it helps to find bad queries but if you dont use same callback for different queries (in this case you can put optional data when doing queries, then compare this data in the callback code.
Queries may have passwords and stuff.
dvander, rhetorical question: in such case why SM revealed my secret SteamId in above error log. Logging is anyway executed locally. It's a purely problem of user to post on forum logs having secret information without asterisk them firstly.
Even if so, providing at least the source code line number will be enough.
MAGNAT2645, thanks, it's a walkaround, but visually looks as a bad design.
dvander, rhetorical question: in such case why SM revealed my secret SteamId in above error log. Logging is anyway executed locally. It's a purely problem of user to post on forum logs having secret information without asterisk them firstly.
The error message you see in the log currently is exactly what is provided by the MySQL client library.
Well, I think LogStackTrace() should help then.
hmmm, LogStackTrace say not much.
L 12/15/2021 - 20:45:41: [SM] Called from: xxx.smx
L 12/15/2021 - 20:45:41: [SM] Call stack trace:
L 12/15/2021 - 20:45:41: [SM] [0] LogStackTrace
L 12/15/2021 - 20:45:41: [SM] [1] Line 1424, xxx.sp::SQL_Tx_BackupFailure
only 1 level deep. If common callback is used, it is not helpful. Need at least 2 level.
There is no 2nd level. That's the entire callstack for a threaded query. Such is the misfortune of debugging asynchronous stuff.
It could be possible to grab the callstack at the time the query is created, and pass it through to the thread, for debugging purposes.
Also you can just save query text to Datapack and pass them as data argument.