mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-14 19:51:59 +00:00
Use a rust DLL for logging (#36858)
By moving our logging to a DLL we see a drop in CPU/real time of 2-3 orders of magnitude. This is due to BYOND opening and closing file handles on every write, causing incredible amounts of unneeded overhead. The logging library also handles timestamps for us, further increasing performance gains. This library will also allow for further offloading in the future, such as completely replacing file2text() and friends. A pre-compiled DLL is bundled, but Linux users will have to compile manually. Directions can be found at the rust-g repo. Log output is enhanced with millisecond time stamps: [2018-04-01 15:56:23.522] blah blah blah This includes runtimes as well, which benefit from the same timestamp improvements and no longer have hacky splitting code to add their own timestamps. Log shutdown is handled in a dedicated proc called as late as possible, as rust-g integration expands this will be factored out into a generic native code shutdown proc.
This commit is contained in:
@@ -9,18 +9,13 @@ GLOBAL_VAR_INIT(total_runtimes_skipped, 0)
|
||||
GLOB.total_runtimes++
|
||||
|
||||
if(!istype(E)) //Something threw an unusual exception
|
||||
log_world("\[[time_stamp()]] Uncaught exception: [E]")
|
||||
log_world("uncaught runtime error: [E]")
|
||||
return ..()
|
||||
|
||||
//this is snowflake because of a byond bug (ID:2306577), do not attempt to call non-builtin procs in this if
|
||||
if(copytext(E.name,1,32) == "Maximum recursion level reached")
|
||||
var/list/split = splittext(E.desc, "\n")
|
||||
for (var/i in 1 to split.len)
|
||||
if (split[i] != "")
|
||||
split[i] = "\[[time2text(world.timeofday,"hh:mm:ss")]\][split[i]]"
|
||||
E.desc = jointext(split, "\n")
|
||||
//log to world while intentionally triggering the byond bug.
|
||||
log_world("\[[time2text(world.timeofday,"hh:mm:ss")]\]runtime error: [E.name]\n[E.desc]")
|
||||
log_world("runtime error: [E.name]\n[E.desc]")
|
||||
//if we got to here without silently ending, the byond bug has been fixed.
|
||||
log_world("The bug with recursion runtimes has been fixed. Please remove the snowflake check from world/Error in [__FILE__]:[__LINE__]")
|
||||
return //this will never happen.
|
||||
@@ -130,20 +125,6 @@ GLOBAL_VAR_INIT(total_runtimes_skipped, 0)
|
||||
GLOB.current_test.Fail("[main_line]\n[desclines.Join("\n")]")
|
||||
#endif
|
||||
|
||||
/* This logs the runtime in the old format */
|
||||
|
||||
E.name = "\n\[[time2text(world.timeofday,"hh:mm:ss")]\][E.name]"
|
||||
|
||||
//Original
|
||||
//
|
||||
var/list/split = splittext(E.desc, "\n")
|
||||
for (var/i in 1 to split.len)
|
||||
if (split[i] != "")
|
||||
split[i] = "\[[time2text(world.timeofday,"hh:mm:ss")]\][split[i]]"
|
||||
E.desc = jointext(split, "\n")
|
||||
world.log = GLOB.world_runtime_log
|
||||
..(E)
|
||||
|
||||
world.log = null
|
||||
|
||||
#endif
|
||||
// This writes the regular format (unwrapping newlines and inserting timestamps as needed).
|
||||
log_runtime("runtime error: [E.name]\n[E.desc]")
|
||||
|
||||
Reference in New Issue
Block a user