From 356efbfb3e68a3bc67308be62818db7513c92b61 Mon Sep 17 00:00:00 2001 From: nevimer <77420409+nevimer@users.noreply.github.com> Date: Mon, 25 Nov 2024 18:54:51 -0500 Subject: [PATCH] Public Logging Update (#1545) Use Regex to be smarter. ## About The Pull Request Public logging finds ckeys via regex to remove them from lines now. Not used for player say, at the moment. Not needed there either, as ckeys are only used by key_name() and thats passed down as a string. rather than just edit every instance of the proc, ill just regex them out by adding identifiers into the ckey blocks in logs and snip them that way. ## Why It's Good For The Game Public logs are little more private. We want them only to have characters, no keys. ## Proof Of Testing ## Changelog :cl: refactor: public logging uses regex for cases of mechanics now. /:cl: Co-authored-by: Waterpig <49160555+Majkl-J@users.noreply.github.com> --- code/__HELPERS/logging/_logging.dm | 6 +++--- code/__HELPERS/logging/attack.dm | 3 +-- code/__HELPERS/logging/mecha.dm | 2 +- code/__HELPERS/logging/mob.dm | 2 +- code/__HELPERS/logging/talk.dm | 8 ++++---- code/datums/components/butchering.dm | 2 +- code/datums/elements/strippable.dm | 6 +++--- code/game/objects/items.dm | 2 +- code/modules/mob/living/carbon/human/human_stripping.dm | 2 +- code/modules/vehicles/mecha/equipment/mecha_equipment.dm | 2 +- .../code/modules/public_logging/public_logging.dm | 9 +++++++-- 11 files changed, 24 insertions(+), 20 deletions(-) diff --git a/code/__HELPERS/logging/_logging.dm b/code/__HELPERS/logging/_logging.dm index 2c1760009d7..61f3f034f38 100644 --- a/code/__HELPERS/logging/_logging.dm +++ b/code/__HELPERS/logging/_logging.dm @@ -95,7 +95,7 @@ GLOBAL_LIST_INIT(testing_global_profiler, list("_PROFILE_NAME" = "Global")) * * color - color of the log text * * log_globally - boolean checking whether or not we write this log to the log file */ -/atom/proc/log_message(message, message_type, color = null, log_globally = TRUE, list/data, redacted_copy) +/atom/proc/log_message(message, message_type, color = null, log_globally = TRUE, list/data) if(!log_globally) return @@ -118,7 +118,7 @@ GLOBAL_LIST_INIT(testing_global_profiler, list("_PROFILE_NAME" = "Global")) #endif //SKYRAT EDIT ADDITION END var/log_text = "[key_name_and_tag(src)] [message] [loc_name(src)]" - var/redacted_log_text = "[(src)]: [redacted_copy ? redacted_copy : message] @ [loc_name(src)]" // BUBBER EDIT ADDITION + var/redacted_log_text = "[(src)]: [message] @ [loc_name(src)]" // BUBBER EDIT ADDITION switch(message_type) /// ship both attack logs and victim logs to the end of round attack.log just to ensure we don't lose information if(LOG_ATTACK, LOG_VICTIM) @@ -245,7 +245,7 @@ GLOBAL_LIST_INIT(testing_global_profiler, list("_PROFILE_NAME" = "Global")) else if(include_link) . += "" - . += key + . += ("\'([key])\'") // BUBBER EDIT if(!C) . += "\[DC\]" diff --git a/code/__HELPERS/logging/attack.dm b/code/__HELPERS/logging/attack.dm index 149a05a5aff..8ea87e1b2cb 100644 --- a/code/__HELPERS/logging/attack.dm +++ b/code/__HELPERS/logging/attack.dm @@ -28,9 +28,8 @@ saddition = " [addition]" var/postfix = "[sobject][saddition][hp]" - var/redacted_copy = "[what_done] [target][postfix]" var/message = "[what_done] [starget][postfix]" - user.log_message(message, LOG_ATTACK, color="red", redacted_copy = redacted_copy) // BUBBER EDIT + user.log_message(message, LOG_ATTACK, color="red") // BUBBER EDIT if(user != target) var/reverse_message = "was [what_done] by [ssource][postfix]" diff --git a/code/__HELPERS/logging/mecha.dm b/code/__HELPERS/logging/mecha.dm index 8557d0c7ce4..7cca11f856c 100644 --- a/code/__HELPERS/logging/mecha.dm +++ b/code/__HELPERS/logging/mecha.dm @@ -3,7 +3,7 @@ logger.Log(LOG_CATEGORY_MECHA, text, data) /// Logging for equipment installed in a mecha -/obj/item/mecha_parts/mecha_equipment/log_message(message, message_type = LOG_MECHA, color = null, log_globally, list/data, redacted_copy) // BUBBER EDIT +/obj/item/mecha_parts/mecha_equipment/log_message(message, message_type = LOG_MECHA, color = null, log_globally, list/data) if(chassis) return chassis.log_message("ATTACHMENT: [src] [message]", message_type, color) return ..() diff --git a/code/__HELPERS/logging/mob.dm b/code/__HELPERS/logging/mob.dm index 403fa343423..eaa825735c9 100644 --- a/code/__HELPERS/logging/mob.dm +++ b/code/__HELPERS/logging/mob.dm @@ -11,7 +11,7 @@ /// Logs a message in a mob's individual log, and in the global logs as well if log_globally is true -/mob/log_message(message, message_type, color = null, log_globally = TRUE, list/data, redacted_copy) // BUBBER EDIT +/mob/log_message(message, message_type, color = null, log_globally = TRUE, list/data) if(!LAZYLEN(message)) stack_trace("Empty message") return diff --git a/code/__HELPERS/logging/talk.dm b/code/__HELPERS/logging/talk.dm index 6f166a9b910..6d9c534287f 100644 --- a/code/__HELPERS/logging/talk.dm +++ b/code/__HELPERS/logging/talk.dm @@ -19,12 +19,12 @@ /// Logging for generic spoken messages /proc/log_say(text, list/data, redacted_log_text) // BUBBER EDIT logger.Log(LOG_CATEGORY_GAME_SAY, text, data) - log_public_file(redacted_log_text) // BUBBER EDIT + log_public_file(redacted_log_text, no_regex_needed = TRUE) // BUBBER EDIT /// Logging for whispered messages /proc/log_whisper(text, list/data, redacted_log_text) // BUBBER EDIT logger.Log(LOG_CATEGORY_GAME_WHISPER, text, data) - log_public_file(redacted_log_text) // BUBBER EDIT + log_public_file(redacted_log_text, no_regex_needed = TRUE) // BUBBER EDIT /// Helper for logging of messages with only one sender and receiver (i.e. mind links) /proc/log_directed_talk(atom/source, atom/target, message, message_type, tag) @@ -39,9 +39,9 @@ /// Logging for speech taking place over comms, as well as tcomms equipment /proc/log_telecomms(text, list/data, redacted_log_text) // BUBBER EDIT logger.Log(LOG_CATEGORY_TELECOMMS, text, data) - log_public_file(redacted_log_text) // BUBBER EDIT + log_public_file(redacted_log_text, no_regex_needed = TRUE) // BUBBER EDIT /// Logging for speech indicators. /proc/log_speech_indicators(text, list/data, redacted_log_text) // BUBBER EDIT logger.Log(LOG_CATEGORY_SPEECH_INDICATOR, text, data) - log_public_file(redacted_log_text) // BUBBER EDIT + log_public_file(redacted_log_text, no_regex_needed = TRUE) // BUBBER EDIT diff --git a/code/datums/components/butchering.dm b/code/datums/components/butchering.dm index 42724b4a5b0..1f432efc734 100644 --- a/code/datums/components/butchering.dm +++ b/code/datums/components/butchering.dm @@ -172,7 +172,7 @@ span_notice("You butcher [target].")) butcher_callback?.Invoke(butcher, target) target.harvest(butcher) - target.log_message("has been butchered by [key_name(butcher)]", LOG_ATTACK, redacted_copy = "has been butchered by [butcher]") // BUBBER EDIT - PUBLIC LOGS + target.log_message("has been butchered by [key_name(butcher)]", LOG_ATTACK) target.gib(DROP_BRAIN|DROP_ORGANS) ///Enables the butchering mechanic for the mob who has equipped us. diff --git a/code/datums/elements/strippable.dm b/code/datums/elements/strippable.dm index 5a88d94d057..a668fa5ba5d 100644 --- a/code/datums/elements/strippable.dm +++ b/code/datums/elements/strippable.dm @@ -156,7 +156,7 @@ //SKYRAT EDIT CHANGE END to_chat(user, span_danger("You try to remove [source]'s [item.name]...")) - user.log_message("is stripping [key_name(source)] of [item].", LOG_ATTACK, color="red", redacted_copy = "is stripping [source] of [item].") // BUBBER EDIT - PUBLIC LOGGING + user.log_message("is stripping [key_name(source)] of [item].", LOG_ATTACK, color="red") source.log_message("is being stripped of [item] by [key_name(user)].", LOG_VICTIM, color="orange", log_globally=FALSE) item.add_fingerprint(src) @@ -292,7 +292,7 @@ /// A utility function for `/datum/strippable_item`s to finish equipping an item to a mob. /proc/finish_equip_mob(obj/item/item, mob/source, mob/user) - user.log_message("has put [item] on [key_name(source)].", LOG_ATTACK, color="red", redacted_copy = "has put [item] on [source].") // BUBBER EDIT- PUBLIC LOGS + user.log_message("has put [item] on [key_name(source)].", LOG_ATTACK, color="red") source.log_message("had [item] put on them by [key_name(user)].", LOG_VICTIM, color="orange", log_globally=FALSE) /// A utility function for `/datum/strippable_item`s to start unequipping an item from a mob. @@ -307,7 +307,7 @@ if (!item.doStrip(user, source)) return FALSE - user.log_message("has stripped [key_name(source)] of [item].", LOG_ATTACK, color="red", redacted_copy = "has stripped [source] of [item])") // BUBBER EDIT - PUBLIC LOGS + user.log_message("has stripped [key_name(source)] of [item].", LOG_ATTACK, color="red") source.log_message("has been stripped of [item] by [key_name(user)].", LOG_VICTIM, color="orange", log_globally=FALSE) // Updates speed in case stripped speed affecting item diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index ef1823100fa..f7a1d8988f5 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -1758,7 +1758,7 @@ to_chat(user, span_notice("You try to put [equipping] on [target]...")) - user.log_message("is putting [equipping] on [key_name(target)]", LOG_ATTACK, color="red", redacted_copy = "is putting [equipping] on [target]") // BUBBER EDIT - PUBLIC LOGS + user.log_message("is putting [equipping] on [key_name(target)]", LOG_ATTACK, color="red") target.log_message("is having [equipping] put on them by [key_name(user)]", LOG_VICTIM, color="orange", log_globally=FALSE) /obj/item/update_atom_colour() diff --git a/code/modules/mob/living/carbon/human/human_stripping.dm b/code/modules/mob/living/carbon/human/human_stripping.dm index 6dccf98e5d5..b2dce5234b4 100644 --- a/code/modules/mob/living/carbon/human/human_stripping.dm +++ b/code/modules/mob/living/carbon/human/human_stripping.dm @@ -218,7 +218,7 @@ GLOBAL_LIST_INIT(strippable_human_items, create_strippable_list(list( to_chat(user, span_notice("You try to empty [source]'s [pocket_side] pocket.")) - user.log_message("is pickpocketing [key_name(source)] of [item] ([pocket_side])", LOG_ATTACK, color="red", redacted_copy = "is pickpocketing [source] of [item] ([pocket_side])") // BUBBER EDIT - PUBLIC LOGS + user.log_message("is pickpocketing [key_name(source)] of [item] ([pocket_side])", LOG_ATTACK, color="red") source.log_message("is being pickpocketed of [item] by [key_name(user)] ([pocket_side])", LOG_VICTIM, color="orange", log_globally=FALSE) item.add_fingerprint(src) diff --git a/code/modules/vehicles/mecha/equipment/mecha_equipment.dm b/code/modules/vehicles/mecha/equipment/mecha_equipment.dm index 09ccf46aa9e..2ad10ae028d 100644 --- a/code/modules/vehicles/mecha/equipment/mecha_equipment.dm +++ b/code/modules/vehicles/mecha/equipment/mecha_equipment.dm @@ -220,7 +220,7 @@ /obj/item/mecha_parts/mecha_equipment/proc/set_active(active) src.active = active -/obj/item/mecha_parts/mecha_equipment/log_message(message, message_type=LOG_GAME, color=null, log_globally, list/data, redacted_copy) // BUBBER EDIT +/obj/item/mecha_parts/mecha_equipment/log_message(message, message_type=LOG_GAME, color=null, log_globally, list/data) if(chassis) return chassis.log_message("ATTACHMENT: [src] [message]", message_type, color) return ..() diff --git a/modular_zubbers/code/modules/public_logging/public_logging.dm b/modular_zubbers/code/modules/public_logging/public_logging.dm index 098b1a41f93..5015f1a6910 100644 --- a/modular_zubbers/code/modules/public_logging/public_logging.dm +++ b/modular_zubbers/code/modules/public_logging/public_logging.dm @@ -3,6 +3,11 @@ GLOBAL_PROTECT(public_log_directory) GLOBAL_VAR(master_public_log_file) -/proc/log_public_file(redacted_log_text) +/proc/log_public_file(redacted_log_text, no_regex_needed) if(fexists(GLOB.master_public_log_file) && !isnull(redacted_log_text)) - rustg_file_append("\[[time2text(world.timeofday)]\] : [redacted_log_text]\n", GLOB.master_public_log_file) + if(no_regex_needed) + rustg_file_append("\[[time2text(world.timeofday)]\] : [redacted_log_text]\n", GLOB.master_public_log_file) + return + var/regex/stripping = regex(@"\((\w+)\)", "i") + var/stripped_copy = replacetext(redacted_log_text, stripping, "redacted key") + rustg_file_append("\[[time2text(world.timeofday)]\] : [stripped_copy]\n", GLOB.master_public_log_file)