mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-25 22:19:30 +01:00
query debug logging as a config option
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
/datum/config_entry/string/address
|
||||
config_entry_value = "localhost"
|
||||
protection = CONFIG_ENTRY_LOCKED | CONFIG_ENTRY_HIDDEN
|
||||
|
||||
|
||||
/datum/config_entry/number/port
|
||||
config_entry_value = 3306
|
||||
min_val = 0
|
||||
@@ -24,3 +24,8 @@
|
||||
|
||||
/datum/config_entry/string/feedback_tableprefix
|
||||
protection = CONFIG_ENTRY_LOCKED | CONFIG_ENTRY_HIDDEN
|
||||
|
||||
/datum/config_entry/number/query_debug_log_timeout
|
||||
config_entry_value = 70
|
||||
min_val = 1
|
||||
protection = CONFIG_ENTRY_LOCKED | CONFIG_ENTRY_HIDDEN
|
||||
|
||||
@@ -231,20 +231,24 @@ Delayed insert mode was removed in mysql 7 and only works with MyISAM type table
|
||||
to_chat(usr, "<span class='danger'>A SQL error occurred during this operation, check the server logs.</span>")
|
||||
|
||||
/datum/DBQuery/proc/Execute(sql_query = sql, cursor_handler = default_cursor, log_error = TRUE)
|
||||
log_qdl("Query execution started at [SQLtime()] | [REALTIMEOFDAY]")
|
||||
var/stime = REALTIMEOFDAY
|
||||
log_qdl("Query used: [sql]")
|
||||
var/start_time
|
||||
var/timeout = CONFIG_GET(number/query_debug_log_timeout)
|
||||
if(timeout)
|
||||
log_query_debug("Query execution started at [SQLtime()] | [REALTIMEOFDAY]")
|
||||
start_time = REALTIMEOFDAY
|
||||
log_query_debug("Query used: [sql]")
|
||||
Close()
|
||||
. = _dm_db_execute(_db_query, sql_query, db_connection._db_con, cursor_handler, null)
|
||||
if(!. && log_error)
|
||||
log_sql("[ErrorMsg()] | Query used: [sql]")
|
||||
log_qdl("Query execution ended at [SQLtime()] | [REALTIMEOFDAY]")
|
||||
if((REALTIMEOFDAY - stime) > 70)
|
||||
log_qdl("Possible query overrun detected.")
|
||||
bother_admins()
|
||||
log_query_debug("Query execution ended at [SQLtime()] | [REALTIMEOFDAY]")
|
||||
if(timeout)
|
||||
if((REALTIMEOFDAY - start_time) > timeout)
|
||||
log_query_debug("Possible slow query timeout detected.")
|
||||
slow_query_check()
|
||||
|
||||
/proc/bother_admins()
|
||||
message_admins("HEY! A database query may have overrun. Did the server just hang? <a href='?_src_=holder;[HrefToken()];slowquery=yes'>\[YES\]</a>|<a href='?_src_=holder;[HrefToken()];slowquery=no'>\[NO\]</a>")
|
||||
/datum/DBQuery/proc/slow_query_check()
|
||||
message_admins("HEY! A database query may have timed out. Did the server just hang? <a href='?_src_=holder;[HrefToken()];slowquery=yes'>\[YES\]</a>|<a href='?_src_=holder;[HrefToken()];slowquery=no'>\[NO\]</a>")
|
||||
|
||||
/datum/DBQuery/proc/NextRow()
|
||||
return _dm_db_next_row(_db_query,item,conversions)
|
||||
|
||||
Reference in New Issue
Block a user