From bf93b5bf6f29d2076507904cb8bfe696645d1486 Mon Sep 17 00:00:00 2001 From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> Date: Mon, 3 May 2021 20:54:36 +0100 Subject: [PATCH] Logging configuration --- code/__HELPERS/_logging.dm | 42 ++++++------ code/controllers/configuration.dm | 64 ------------------- .../configuration/configuration_core.dm | 4 ++ .../sections/job_configuration.dm | 1 - .../sections/logging_configuration.dm | 53 +++++++++++++++ code/modules/admin/admin_investigate.dm | 2 +- code/modules/admin/admin_verbs.dm | 6 +- code/modules/client/client_procs.dm | 2 +- code/modules/mob/login.dm | 2 +- config/example/config.toml | 2 + paradise.dme | 1 + 11 files changed, 87 insertions(+), 92 deletions(-) create mode 100644 code/controllers/configuration/sections/logging_configuration.dm diff --git a/code/__HELPERS/_logging.dm b/code/__HELPERS/_logging.dm index 34e7f3fda28..161bf9c02be 100644 --- a/code/__HELPERS/_logging.dm +++ b/code/__HELPERS/_logging.dm @@ -28,11 +28,11 @@ GLOBAL_PROTECT(log_end) /proc/log_admin(text) GLOB.admin_log.Add(text) - if(config.log_admin) + if(GLOB.configuration.logging.admin_logging) rustg_log_write(GLOB.world_game_log, "ADMIN: [text][GLOB.log_end]") /proc/log_debug(text) - if(config.log_debug) + if(GLOB.configuration.logging.debug_logging) rustg_log_write(GLOB.world_game_log, "DEBUG: [text][GLOB.log_end]") for(var/client/C in GLOB.admins) @@ -40,80 +40,80 @@ GLOBAL_PROTECT(log_end) to_chat(C, "DEBUG: [text]") /proc/log_game(text) - if(config.log_game) + if(GLOB.configuration.logging.game_logging) rustg_log_write(GLOB.world_game_log, "GAME: [text][GLOB.log_end]") /proc/log_vote(text) - if(config.log_vote) + if(GLOB.configuration.logging.vote_logging) rustg_log_write(GLOB.world_game_log, "VOTE: [text][GLOB.log_end]") /proc/log_access_in(client/new_client) - if(config.log_access) + if(GLOB.configuration.logging.access_logging) var/message = "[key_name(new_client)] - IP:[new_client.address] - CID:[new_client.computer_id] - BYOND v[new_client.byond_version]" rustg_log_write(GLOB.world_game_log, "ACCESS IN: [message][GLOB.log_end]") /proc/log_access_out(mob/last_mob) - if(config.log_access) + if(GLOB.configuration.logging.access_logging) var/message = "[key_name(last_mob)] - IP:[last_mob.lastKnownIP] - CID:[last_mob.computer_id] - BYOND Logged Out" rustg_log_write(GLOB.world_game_log, "ACCESS OUT: [message][GLOB.log_end]") /proc/log_say(text, mob/speaker) - if(config.log_say) + if(GLOB.configuration.logging.say_logging) rustg_log_write(GLOB.world_game_log, "SAY: [speaker.simple_info_line()]: [html_decode(text)][GLOB.log_end]") /proc/log_whisper(text, mob/speaker) - if(config.log_whisper) + if(GLOB.configuration.logging.whisper_logging) rustg_log_write(GLOB.world_game_log, "WHISPER: [speaker.simple_info_line()]: [html_decode(text)][GLOB.log_end]") /proc/log_ooc(text, client/user) - if(config.log_ooc) + if(GLOB.configuration.logging.ooc_logging) rustg_log_write(GLOB.world_game_log, "OOC: [user.simple_info_line()]: [html_decode(text)][GLOB.log_end]") /proc/log_aooc(text, client/user) - if(config.log_ooc) + if(GLOB.configuration.logging.ooc_logging) rustg_log_write(GLOB.world_game_log, "AOOC: [user.simple_info_line()]: [html_decode(text)][GLOB.log_end]") /proc/log_looc(text, client/user) - if(config.log_ooc) + if(GLOB.configuration.logging.ooc_logging) rustg_log_write(GLOB.world_game_log, "LOOC: [user.simple_info_line()]: [html_decode(text)][GLOB.log_end]") /proc/log_emote(text, mob/speaker) - if(config.log_emote) + if(GLOB.configuration.logging.emote_logging) rustg_log_write(GLOB.world_game_log, "EMOTE: [speaker.simple_info_line()]: [html_decode(text)][GLOB.log_end]") /proc/log_attack(attacker, defender, message) - if(config.log_attack) + if(GLOB.configuration.logging.attack_logging) rustg_log_write(GLOB.world_game_log, "ATTACK: [attacker] against [defender]: [message][GLOB.log_end]") //Seperate attack logs? Why? /proc/log_adminsay(text, mob/speaker) - if(config.log_adminchat) + if(GLOB.configuration.logging.adminchat_logging) rustg_log_write(GLOB.world_game_log, "ADMINSAY: [speaker.simple_info_line()]: [html_decode(text)][GLOB.log_end]") /proc/log_qdel(text) rustg_log_write(GLOB.world_qdel_log, "QDEL: [text][GLOB.log_end]") /proc/log_mentorsay(text, mob/speaker) - if(config.log_adminchat) + if(GLOB.configuration.logging.adminchat_logging) rustg_log_write(GLOB.world_game_log, "MENTORSAY: [speaker.simple_info_line()]: [html_decode(text)][GLOB.log_end]") /proc/log_ghostsay(text, mob/speaker) - if(config.log_say) + if(GLOB.configuration.logging.say_logging) rustg_log_write(GLOB.world_game_log, "DEADCHAT: [speaker.simple_info_line()]: [html_decode(text)][GLOB.log_end]") /proc/log_ghostemote(text, mob/speaker) - if(config.log_emote) + if(GLOB.configuration.logging.emote_logging) rustg_log_write(GLOB.world_game_log, "DEADEMOTE: [speaker.simple_info_line()]: [html_decode(text)][GLOB.log_end]") /proc/log_adminwarn(text) - if(config.log_adminwarn) + if(GLOB.configuration.logging.admin_warning_logging) rustg_log_write(GLOB.world_game_log, "ADMINWARN: [html_decode(text)][GLOB.log_end]") /proc/log_pda(text, mob/speaker) - if(config.log_pda) + if(GLOB.configuration.logging.pda_logging) rustg_log_write(GLOB.world_game_log, "PDA: [speaker.simple_info_line()]: [html_decode(text)][GLOB.log_end]") /proc/log_chat(text, mob/speaker) - if(config.log_pda) + if(GLOB.configuration.logging.pda_logging) rustg_log_write(GLOB.world_game_log, "CHAT: [speaker.simple_info_line()] [html_decode(text)][GLOB.log_end]") /proc/log_misc(text) @@ -121,7 +121,7 @@ GLOBAL_PROTECT(log_end) /proc/log_world(text) SEND_TEXT(world.log, text) - if(config && config.log_world_output) + if(GLOB.configuration.logging.world_logging) rustg_log_write(GLOB.world_game_log, "WORLD: [html_decode(text)][GLOB.log_end]") /proc/log_runtime_txt(text) // different from /tg/'s log_runtime because our error handler has a log_runtime proc already that does other stuff diff --git a/code/controllers/configuration.dm b/code/controllers/configuration.dm index 13b2909f37d..bc915727858 100644 --- a/code/controllers/configuration.dm +++ b/code/controllers/configuration.dm @@ -8,22 +8,6 @@ var/nudge_script_path = "nudge.py" // where the nudge.py script is located - var/log_ooc = 0 // log OOC channel - var/log_access = 0 // log login/logout - var/log_say = 0 // log client say - var/log_admin = 0 // log admin actions - var/log_debug = 1 // log debug output - var/log_game = 0 // log game events - var/log_vote = 0 // log voting - var/log_whisper = 0 // log client whisper - var/log_emote = 0 // log emotes - var/log_attack = 0 // log attack messages - var/log_adminchat = 0 // log admin chat messages - var/log_adminwarn = 0 // log warnings admins get about bomb construction and such - var/log_pda = 0 // log pda messages - var/log_world_output = 0 // log world.log << messages - var/log_runtimes = 0 // logs world.log to a file - var/log_hrefs = 0 // logs all links clicked in-game. Could be used for debugging and tracking down exploits var/pregame_timestart = 240 // Time it takes for the server to start the game var/allow_vote_restart = 0 // allow votes to restart var/allow_vote_mode = 0 // allow votes to change mode @@ -305,54 +289,6 @@ if("forum_playerinfo_url") config.forum_playerinfo_url = value - if("log_ooc") - config.log_ooc = 1 - - if("log_access") - config.log_access = 1 - - if("log_say") - config.log_say = 1 - - if("log_admin") - config.log_admin = 1 - - if("log_debug") - config.log_debug = 1 - - if("log_game") - config.log_game = 1 - - if("log_vote") - config.log_vote = 1 - - if("log_whisper") - config.log_whisper = 1 - - if("log_attack") - config.log_attack = 1 - - if("log_emote") - config.log_emote = 1 - - if("log_adminchat") - config.log_adminchat = 1 - - if("log_adminwarn") - config.log_adminwarn = 1 - - if("log_pda") - config.log_pda = 1 - - if("log_world_output") - config.log_world_output = 1 - - if("log_hrefs") - config.log_hrefs = 1 - - if("log_runtime") - config.log_runtimes = 1 - if("pregame_timestart") config.pregame_timestart = text2num(value) diff --git a/code/controllers/configuration/configuration_core.dm b/code/controllers/configuration/configuration_core.dm index 3f8644dea27..4695abc9c46 100644 --- a/code/controllers/configuration/configuration_core.dm +++ b/code/controllers/configuration/configuration_core.dm @@ -15,6 +15,8 @@ GLOBAL_DATUM_INIT(configuration, /datum/server_configuration, new()) var/datum/configuration_section/database_configuration/database /// Holder for the job configuration datum var/datum/configuration_section/job_configuration/jobs + /// Holder for the logging configuration datum + var/datum/configuration_section/logging_configuration/logging /// Holder for the MC configuration datum var/datum/configuration_section/mc_configuration/mc /// Holder for the ruins configuration datum @@ -37,6 +39,7 @@ GLOBAL_DATUM_INIT(configuration, /datum/server_configuration, new()) custom_sprites = new() database = new() jobs = new() + logging = new() mc = new() ruins = new() @@ -53,6 +56,7 @@ GLOBAL_DATUM_INIT(configuration, /datum/server_configuration, new()) custom_sprites.load_data(raw_config_data["custom_sprites_configuration"]) database.load_data(raw_config_data["database_configuration"]) jobs.load_data(raw_config_data["job_configuration"]) + logging.load_data(raw_config_data["logging_configuration"]) mc.load_data(raw_config_data["mc_configuration"]) ruins.load_data(raw_config_data["ruin_configuration"]) diff --git a/code/controllers/configuration/sections/job_configuration.dm b/code/controllers/configuration/sections/job_configuration.dm index ec774567f5e..d56faddfc74 100644 --- a/code/controllers/configuration/sections/job_configuration.dm +++ b/code/controllers/configuration/sections/job_configuration.dm @@ -53,4 +53,3 @@ lowpop_job_map[kvp["name"]] = kvp["lowpop"] if(!isnull(kvp["highpop"])) highpop_job_map[kvp["name"]] = kvp["highpop"] - pass() diff --git a/code/controllers/configuration/sections/logging_configuration.dm b/code/controllers/configuration/sections/logging_configuration.dm new file mode 100644 index 00000000000..ea2cd492057 --- /dev/null +++ b/code/controllers/configuration/sections/logging_configuration.dm @@ -0,0 +1,53 @@ +/// Config holder for all things regarding logging +/datum/configuration_section/logging_configuration + /// Log OOC messages + var/ooc_logging = TRUE + /// Log ingame say messages + var/say_logging = TRUE + /// Log admin actions + var/admin_logging = TRUE + /// Log client access (login/logout) + var/access_logging = TRUE + /// Log game events (roundstart, results, a lot of other things) + var/game_logging = TRUE + /// Enable logging of votes and their results + var/vote_logging = TRUE + /// Enable logging of whipers + var/whisper_logging = TRUE + /// Enable logging of emotes + var/emote_logging = TRUE + /// Enable logging of attacks between players + var/attack_logging = TRUE + /// Enable logging of PDA messages + var/pda_logging = TRUE + /// Enable runtime logging + var/runtime_logging = TRUE + /// Enable world.log output logging + var/world_logging = TRUE + /// Log hrefs + var/href_logging = TRUE + /// Log admin warning messages + var/admin_warning_logging = TRUE + /// Log asay messages + var/adminchat_logging = TRUE + /// Log debug messages + var/debug_logging = TRUE + +/datum/configuration_section/logging_configuration/load_data(list/data) + // Use the load wrappers here. That way the default isnt made 'null' if you comment out the config line + CONFIG_LOAD_BOOL(ooc_logging, data["enable_ooc_logging"]) + CONFIG_LOAD_BOOL(say_logging, data["enable_say_logging"]) + CONFIG_LOAD_BOOL(admin_logging, data["enable_admin_logging"]) + CONFIG_LOAD_BOOL(access_logging, data["enable_access_logging"]) + CONFIG_LOAD_BOOL(game_logging, data["enable_game_logging"]) + CONFIG_LOAD_BOOL(vote_logging, data["enable_vote_logging"]) + CONFIG_LOAD_BOOL(whisper_logging, data["enable_whisper_logging"]) + CONFIG_LOAD_BOOL(emote_logging, data["enable_emote_logging"]) + CONFIG_LOAD_BOOL(attack_logging, data["enable_attack_logging"]) + CONFIG_LOAD_BOOL(pda_logging, data["enable_pda_logging"]) + CONFIG_LOAD_BOOL(runtime_logging, data["enable_runtime_logging"]) + CONFIG_LOAD_BOOL(world_logging, data["enable_world_logging"]) + CONFIG_LOAD_BOOL(href_logging, data["enable_href_logging"]) + CONFIG_LOAD_BOOL(admin_warning_logging, data["enable_admin_warning_logging"]) + CONFIG_LOAD_BOOL(adminchat_logging, data["enable_adminchat_logging"]) + CONFIG_LOAD_BOOL(debug_logging, data["enable_debug_logging"]) diff --git a/code/modules/admin/admin_investigate.dm b/code/modules/admin/admin_investigate.dm index 24ea8f95886..702dcf7cd03 100644 --- a/code/modules/admin/admin_investigate.dm +++ b/code/modules/admin/admin_investigate.dm @@ -43,7 +43,7 @@ watchlist_show() if("hrefs") //persistant logs and stuff - if(config && config.log_hrefs) + if(GLOB.configuration.logging.href_logging) if(GLOB.world_href_log) src << browse(file(GLOB.world_href_log), "window=investigate[subject];size=800x300") else diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index 9cc91cb4a32..b11e173e152 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -759,11 +759,11 @@ GLOBAL_LIST_INIT(admin_verbs_ticket, list( return if(config) - if(config.log_hrefs) - config.log_hrefs = 0 + if(GLOB.configuration.logging.href_logging) + GLOB.configuration.logging.href_logging = FALSE to_chat(src, "Stopped logging hrefs") else - config.log_hrefs = 1 + GLOB.configuration.logging.href_logging = TRUE to_chat(src, "Started logging hrefs") /client/proc/check_ai_laws() diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm index d66fc6fa768..2834a319071 100644 --- a/code/modules/client/client_procs.dm +++ b/code/modules/client/client_procs.dm @@ -122,7 +122,7 @@ //Logs all hrefs - if(config && config.log_hrefs) + if(GLOB.configuration.logging.href_logging) log_href("[src] (usr:[usr]\[[COORD(usr)]\]) : [hsrc ? "[hsrc] " : ""][href]") if(href_list["karmashop"]) diff --git a/code/modules/mob/login.dm b/code/modules/mob/login.dm index 639f3da7aaf..01a7a0f167a 100644 --- a/code/modules/mob/login.dm +++ b/code/modules/mob/login.dm @@ -6,7 +6,7 @@ log_access_in(client) create_attack_log("Logged in at [atom_loc_line(get_turf(src))]") create_log(MISC_LOG, "Logged in") - if(config.log_access) + if(GLOB.configuration.logging.access_logging) for(var/mob/M in GLOB.player_list) if(M == src) continue if( M.key && (M.key != key) ) diff --git a/config/example/config.toml b/config/example/config.toml index 3fcddf8927e..d7d415ea6db 100644 --- a/config/example/config.toml +++ b/config/example/config.toml @@ -498,6 +498,8 @@ enable_href_logging = true enable_admin_warning_logging = true # Log asay messages enable_adminchat_logging = true +# Log debug messages +enable_debug_logging = true ################################################################ diff --git a/paradise.dme b/paradise.dme index b17fe33870e..4e69fd94a76 100644 --- a/paradise.dme +++ b/paradise.dme @@ -190,6 +190,7 @@ #include "code\controllers\configuration\sections\custom_sprites_configuration.dm" #include "code\controllers\configuration\sections\database_configuration.dm" #include "code\controllers\configuration\sections\job_configuration.dm" +#include "code\controllers\configuration\sections\logging_configuration.dm" #include "code\controllers\configuration\sections\mc_configuration.dm" #include "code\controllers\configuration\sections\ruin_configuration.dm" #include "code\controllers\subsystem\acid.dm"