Add attempt at debug logging for naughty SS

This commit is contained in:
Aronai Sieyes
2021-05-10 21:55:19 -04:00
parent 45c04fa7ce
commit 56a1b17011
5 changed files with 121 additions and 0 deletions
@@ -60,6 +60,49 @@ SUBSYSTEM_DEF(processing)
to_chat(usr, "[name] - Debug mode [debug_original_process_proc ? "en" : "dis"]abled")
/datum/controller/subsystem/processing/proc/log_recent()
var/msg = "Debug output from the [name] subsystem:\n"
msg += "- Process subsystems are processed tail-first -\n"
if(!currentrun || !processing)
msg += "ERROR: A critical list [currentrun ? 'processing' : 'currentrun'] is gone!"
log_game(msg)
log_server(msg)
return
msg += "Lists: current_run: [currentrun.len], processing: [processing.len]\n"
if(!currentrun.len)
msg += "!!The subsystem just finished the processing list, and currentrun is empty (or has never run).\n"
msg += "!!The info below is the tail of processing instead of currentrun.\n"
var/datum/D = currentrun.len ? currentrun[currentrun.len] : processing[processing.len]
msg += "Tail entry: [whatIsThis(D)] (this is likely the item AFTER the problem item)\n"
var/position = processing.Find(D)
if(!position)
msg += "Unable to find context of tail entry in processing list.\n"
else
if(position != processing.len)
var/additional = processing.Find(D, position+1)
if(additional)
msg += "WARNING: Tail entry found more than once in processing list! Context is for the first found.\n"
var/start = clamp(position-2,1,processing.len)
var/end = clamp(position+2,1,processing.len)
msg += "2 previous elements, then tail, then 2 next elements of processing list for context:\n"
msg += "---\n"
for(var/i in start to finish)
msg += "[whatIsThis([processing[i])]\n"
msg += "---\n"
log_game(msg)
log_server(msg)
/datum/controller/subsystem/processing/fail()
..()
log_recent()
/datum/controller/subsystem/processing/critfail()
..()
log_recent()
/datum/proc/DebugSubsystemProcess(var/wait, var/times_fired, var/datum/controller/subsystem/processing/subsystem)
subsystem.debug_last_thing = src
var/start_tick = world.time