Public Logging Update (#1545)

Use Regex to be smarter.

<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## 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.

<!-- Please make sure to actually test your PRs. If you have not tested
your PR mention it. -->

## 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

<!-- Compile and run your code locally. Make sure it works. This is the
place to show off your changes! We are not responsible for testing your
features. -->

## Changelog

<!-- If your PR modifies aspects of the game that can be concretely
observed by players or admins you should add a changelog. If your change
does NOT meet this description, remove this section. Be sure to properly
mark your PRs to prevent unnecessary GBP loss. You can read up on GBP
and it's effects on PRs in the tgstation guides for contributors. Please
note that maintainers freely reserve the right to remove and add tags
should they deem it appropriate. You can attempt to finagle the system
all you want, but it's best to shoot for clear communication right off
the bat. -->

🆑
refactor: public logging uses regex for cases of mechanics now. 
/🆑

<!-- Both 🆑's are required for the changelog to work! You can put
your name to the right of the first 🆑 if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->

<!-- By opening a pull request. You have read and understood the
repository rules located on the main README.md on this project. -->

Co-authored-by: Waterpig <49160555+Majkl-J@users.noreply.github.com>
This commit is contained in:
nevimer
2024-11-25 18:54:51 -05:00
committed by GitHub
co-authored by Waterpig
parent 20b059f92a
commit 356efbfb3e
11 changed files with 24 additions and 20 deletions
+3 -3
View File
@@ -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)
. += "<a href='?priv_msg=[ckey]'>"
. += key
. += ("\'([key])\'") // BUBBER EDIT
if(!C)
. += "\[DC\]"
+1 -2
View File
@@ -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]"
+1 -1
View File
@@ -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 ..()
+1 -1
View File
@@ -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
+4 -4
View File
@@ -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
+1 -1
View File
@@ -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.
+3 -3
View File
@@ -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
+1 -1
View File
@@ -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()
@@ -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)
@@ -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 ..()
@@ -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)