From a24353f2731d9adbea07dfaa2cc5d12c0cc42336 Mon Sep 17 00:00:00 2001 From: Vladisvell Date: Mon, 9 Dec 2024 23:12:51 +0500 Subject: [PATCH] Adds config to disable shelleo logging --- code/__HELPERS/shell.dm | 27 ++++++++++++------- .../configuration/entries/testing.dm | 3 +++ config/example/testing.txt | 5 +++- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/code/__HELPERS/shell.dm b/code/__HELPERS/shell.dm index 79baa1ffade..d3ed78c0c2f 100644 --- a/code/__HELPERS/shell.dm +++ b/code/__HELPERS/shell.dm @@ -23,22 +23,31 @@ shelleo_ids[seo_id] = TRUE shelleo_id = "[seo_id]" break + if(!shelleo_id) shelleo_id = "[shelleo_ids.len + 1]" shelleo_ids += shelleo_id shelleo_ids[shelleo_id] = TRUE + out_file = "[SHELLEO_NAME][shelleo_id][SHELLEO_OUT]" err_file = "[SHELLEO_NAME][shelleo_id][SHELLEO_ERR]" - if(world.system_type == UNIX) - errorcode = shell("[interpreter] \"[replacetext(command, "\"", "\\\"")]\" > [out_file] 2> [err_file]") + if(CONFIG_GET(flag/enable_shelleo_logging)) + if(world.system_type == UNIX) + errorcode = shell("[interpreter] \"[replacetext(command, "\"", "\\\"")]\" > [out_file] 2> [err_file]") + else + errorcode = shell("[interpreter] \"[command]\" > [out_file] 2> [err_file]") + if(fexists(out_file)) + stdout = file2text(out_file) + fdel(out_file) + if(fexists(err_file)) + stderr = file2text(err_file) + fdel(err_file) else - errorcode = shell("[interpreter] \"[command]\" > [out_file] 2> [err_file]") - if(fexists(out_file)) - stdout = file2text(out_file) - fdel(out_file) - if(fexists(err_file)) - stderr = file2text(err_file) - fdel(err_file) + if(world.system_type == UNIX) + errorcode = shell("[interpreter] \"[replacetext(command, "\"", "\\\"")]\"") + else + errorcode = shell("[interpreter] \"[command]\"") + shelleo_ids[shelleo_id] = FALSE else CRASH("Operating System: [world.system_type] not supported") // If you encounter this error, you are encouraged to update this proc with support for the new operating system diff --git a/code/controllers/configuration/entries/testing.dm b/code/controllers/configuration/entries/testing.dm index 009cc38beed..5682bea993e 100644 --- a/code/controllers/configuration/entries/testing.dm +++ b/code/controllers/configuration/entries/testing.dm @@ -10,3 +10,6 @@ ///Do not load station /datum/config_entry/flag/load_no_station + +///Enable /proc/shelleo logging. +/datum/config_entry/flag/enable_shelleo_logging diff --git a/config/example/testing.txt b/config/example/testing.txt index fb5571838e4..8a1c53878bd 100644 --- a/config/example/testing.txt +++ b/config/example/testing.txt @@ -1,4 +1,7 @@ #Entries here contain flags that are used only on testing. ## Enables bombarda craft. -ENABLE_BOMBARDA_CRAFT \ No newline at end of file +ENABLE_BOMBARDA_CRAFT + +## Enables logging for /proc/shelleo. Note: Makes file writing on each call. +ENABLE_SHELLEO_LOGGING