Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[s] Better logging. #27832

Merged
merged 2 commits into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 56 additions & 20 deletions code/__HELPERS/_logging.dm
Original file line number Diff line number Diff line change
Expand Up @@ -51,82 +51,118 @@ GLOBAL_PROTECT(log_end)
if(GLOB.configuration.logging.vote_logging)
rustg_log_write(GLOB.world_game_log, "VOTE: [text][GLOB.log_end]")

/proc/log_if_mismatch(mob/who, message)
if(!isnull(usr) && usr != who)
rustg_log_write(GLOB.world_game_log, "LOG USER MISMATCH: [usr.simple_info_line()] was usr for [message][GLOB.log_end]")

/proc/log_access_in(client/new_client)
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].[new_client.byond_build]"
rustg_log_write(GLOB.world_game_log, "ACCESS IN: [message][GLOB.log_end]")
var/message = "ACCESS IN: [key_name(new_client)] - IP:[new_client.address] - CID:[new_client.computer_id] - BYOND v[new_client.byond_version].[new_client.byond_build]"
rustg_log_write(GLOB.world_game_log, "[message][GLOB.log_end]")
log_if_mismatch(new_client.mob, message)

/proc/log_access_out(mob/last_mob)
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]")
var/message = "ACCESS OUT: [key_name(last_mob)] - IP:[last_mob.lastKnownIP] - CID:[last_mob.computer_id] - BYOND Logged Out"
rustg_log_write(GLOB.world_game_log, "[message][GLOB.log_end]")
log_if_mismatch(last_mob, message)

/proc/log_say(text, mob/speaker)
if(GLOB.configuration.logging.say_logging)
rustg_log_write(GLOB.world_game_log, "SAY: [speaker.simple_info_line()]: [html_decode(text)][GLOB.log_end]")
var/message = "SAY: [speaker.simple_info_line()]: [html_decode(text)]"
rustg_log_write(GLOB.world_game_log, "[message][GLOB.log_end]")
log_if_mismatch(speaker, message)

/proc/log_whisper(text, mob/speaker)
if(GLOB.configuration.logging.whisper_logging)
rustg_log_write(GLOB.world_game_log, "WHISPER: [speaker.simple_info_line()]: [html_decode(text)][GLOB.log_end]")
var/message = "WHISPER: [speaker.simple_info_line()]: [html_decode(text)]"
rustg_log_write(GLOB.world_game_log, "[message][GLOB.log_end]")
log_if_mismatch(speaker, message)

/proc/log_ooc(text, client/user)
if(GLOB.configuration.logging.ooc_logging)
rustg_log_write(GLOB.world_game_log, "OOC: [user.simple_info_line()]: [html_decode(text)][GLOB.log_end]")
var/message = "OOC: [user.simple_info_line()]: [html_decode(text)]"
rustg_log_write(GLOB.world_game_log, "[message][GLOB.log_end]")
log_if_mismatch(user, message)

/proc/log_aooc(text, client/user)
if(GLOB.configuration.logging.ooc_logging)
rustg_log_write(GLOB.world_game_log, "AOOC: [user.simple_info_line()]: [html_decode(text)][GLOB.log_end]")
var/message = "AOOC: [user.simple_info_line()]: [html_decode(text)]"
rustg_log_write(GLOB.world_game_log, "[message][GLOB.log_end]")
log_if_mismatch(user, message)

/proc/log_looc(text, client/user)
if(GLOB.configuration.logging.ooc_logging)
rustg_log_write(GLOB.world_game_log, "LOOC: [user.simple_info_line()]: [html_decode(text)][GLOB.log_end]")
var/message = "LOOC: [user.simple_info_line()]: [html_decode(text)]"
rustg_log_write(GLOB.world_game_log, "[message][GLOB.log_end]")
log_if_mismatch(user, message)

/proc/log_emote(text, mob/speaker)
if(GLOB.configuration.logging.emote_logging)
rustg_log_write(GLOB.world_game_log, "EMOTE: [speaker.simple_info_line()]: [html_decode(text)][GLOB.log_end]")
var/message = "EMOTE: [speaker.simple_info_line()]: [html_decode(text)]"
rustg_log_write(GLOB.world_game_log, "[message][GLOB.log_end]")
log_if_mismatch(speaker, message)

/proc/log_attack(attacker, defender, message)
/proc/log_attack(attacker, defender, attack_message)
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?
var/message = "ATTACK: [attacker] against [defender]: [attack_message]"
rustg_log_write(GLOB.world_game_log, "[message][GLOB.log_end]")
log_if_mismatch(attacker, message)

/proc/log_adminsay(text, mob/speaker)
if(GLOB.configuration.logging.adminchat_logging)
rustg_log_write(GLOB.world_game_log, "ADMINSAY: [speaker.simple_info_line()]: [html_decode(text)][GLOB.log_end]")
var/message = "ADMINSAY: [speaker.simple_info_line()]: [html_decode(text)]"
rustg_log_write(GLOB.world_game_log, "[message][GLOB.log_end]")
log_if_mismatch(speaker, message)

/proc/log_ping_all_admins(text, mob/speaker)
if(GLOB.configuration.logging.adminchat_logging)
rustg_log_write(GLOB.world_game_log, "ALL ADMIN PING: [speaker.simple_info_line()]: [html_decode(text)][GLOB.log_end]")
var/message = "ALL ADMIN PING: [speaker.simple_info_line()]: [html_decode(text)]"
rustg_log_write(GLOB.world_game_log, "[message][GLOB.log_end]")
log_if_mismatch(speaker, message)

/proc/log_qdel(text)
rustg_log_write(GLOB.world_qdel_log, "QDEL: [text][GLOB.log_end]")

/proc/log_mentorsay(text, mob/speaker)
if(GLOB.configuration.logging.adminchat_logging)
rustg_log_write(GLOB.world_game_log, "MENTORSAY: [speaker.simple_info_line()]: [html_decode(text)][GLOB.log_end]")
var/message = "MENTORSAY: [speaker.simple_info_line()]: [html_decode(text)]"
rustg_log_write(GLOB.world_game_log, "[message][GLOB.log_end]")
log_if_mismatch(speaker, message)

/proc/log_devsay(text, mob/speaker)
if(GLOB.configuration.logging.adminchat_logging)
rustg_log_write(GLOB.world_game_log, "DEVSAY: [speaker.simple_info_line()]: [html_decode(text)][GLOB.log_end]")
var/message = "DEVSAY: [speaker.simple_info_line()]: [html_decode(text)]"
rustg_log_write(GLOB.world_game_log, "[message][GLOB.log_end]")
log_if_mismatch(speaker, message)

/proc/log_ghostsay(text, mob/speaker)
if(GLOB.configuration.logging.say_logging)
rustg_log_write(GLOB.world_game_log, "DEADCHAT: [speaker.simple_info_line()]: [html_decode(text)][GLOB.log_end]")
var/message = "DEADCHAT: [speaker.simple_info_line()]: [html_decode(text)]"
rustg_log_write(GLOB.world_game_log, "[message][GLOB.log_end]")
log_if_mismatch(speaker, message)

/proc/log_ghostemote(text, mob/speaker)
if(GLOB.configuration.logging.emote_logging)
rustg_log_write(GLOB.world_game_log, "DEADEMOTE: [speaker.simple_info_line()]: [html_decode(text)][GLOB.log_end]")
var/message = "DEADEMOTE: [speaker.simple_info_line()]: [html_decode(text)]"
rustg_log_write(GLOB.world_game_log, "[message][GLOB.log_end]")
log_if_mismatch(speaker, message)

/proc/log_adminwarn(text)
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(GLOB.configuration.logging.pda_logging)
rustg_log_write(GLOB.world_game_log, "PDA: [speaker.simple_info_line()]: [html_decode(text)][GLOB.log_end]")
var/message = "PDA: [speaker.simple_info_line()]: [html_decode(text)]"
rustg_log_write(GLOB.world_game_log, "[message][GLOB.log_end]")
log_if_mismatch(speaker, message)

/proc/log_chat(text, mob/speaker)
if(GLOB.configuration.logging.pda_logging)
rustg_log_write(GLOB.world_game_log, "CHAT: [speaker.simple_info_line()] [html_decode(text)][GLOB.log_end]")
var/message = "CHAT: [speaker.simple_info_line()] [html_decode(text)]"
rustg_log_write(GLOB.world_game_log, "[message][GLOB.log_end]")
log_if_mismatch(speaker, message)

/proc/log_tgs(text, level)
GLOB.tgs_log += "\[[time_stamp()]] \[[level]] [text]"
Expand Down
17 changes: 17 additions & 0 deletions code/datums/log_record.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@
var/raw_time // When did this happen?
var/what // What happened
var/who // Who did it
var/who_usr // The current usr, if not who.
var/target // Who/what was targeted
var/where // Where did it happen

/datum/log_record/New(_log_type, _who, _what, _target, _where, _raw_time)
log_type = _log_type

who = get_subject_text(_who, _log_type)
if(!isnull(usr) && usr != _who)
who_usr = "<br><font color='red'>FORCED</font> by [get_subject_text(usr, _log_type)]"
else
who_usr = ""
what = _what
target = get_subject_text(_target, _log_type)
if(!istext(_where) && !isturf(_where))
Expand Down Expand Up @@ -55,3 +60,15 @@
if(!time_diff) // Same time
return cmp_text_asc(A.log_type, B.log_type)
return time_diff

/datum/log_record/vv_edit_var(var_name, var_value)
message_admins("<span class='userdanger'>[key_name_admin(src)] attempted to VV edit a logging object. Inform the host <u>at once</u>.</span>")
log_admin("[key_name(src)] attempted to VV edit a logging object. Inform the host at once.")
GLOB.discord_manager.send2discord_simple(DISCORD_WEBHOOK_ADMIN, "[key_name(src)] attempted to VV edit a logging object. Inform the host at once.")
return FALSE

/datum/log_record/can_vv_delete()
message_admins("<span class='userdanger'>[key_name_admin(src)] attempted to VV edit a logging object. Inform the host <u>at once</u>.</span>")
log_admin("[key_name(src)] attempted to VV edit a logging object. Inform the host at once.")
GLOB.discord_manager.send2discord_simple(DISCORD_WEBHOOK_ADMIN, "[key_name(src)] attempted to VV edit a logging object. Inform the host at once.")
return FALSE
2 changes: 1 addition & 1 deletion code/datums/log_viewer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ if(!result || result.ckey != __ckey){\
var/time = gameTimestamp(wtime = L.raw_time - 9.99) // The time rounds up for some reason. Will result in weird filtering results

dat +="<tr style='[trStyle]'><td style='[tdStyleTime]'>[time]</td><td style='[tdStyleType]background: [get_logtype_color(L.log_type)]'>[L.log_type]</td>\
<td style='[tdStyleWho]'>[L.who]</td><td style='background: [get_logtype_color(L.log_type)];'>[L.what]</td>\
<td style='[tdStyleWho]'>[L.who][L.who_usr]</td><td style='background: [get_logtype_color(L.log_type)];'>[L.what]</td>\
<td style='[tdStyleWho]'>[L.target]</td><td style='[tdStyleWhere]'>[L.where]</td></tr>"
dat += "</table>"
dat += "</div>"
Expand Down
12 changes: 12 additions & 0 deletions code/datums/logging.dm
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,15 @@
if(!log_records)
return list()
return log_records

/datum/logging/vv_edit_var(var_name, var_value)
message_admins("<span class='userdanger'>[key_name_admin(src)] attempted to VV edit a logging object. Inform the host <u>at once</u>.</span>")
log_admin("[key_name(src)] attempted to VV edit a logging object. Inform the host at once.")
GLOB.discord_manager.send2discord_simple(DISCORD_WEBHOOK_ADMIN, "[key_name(src)] attempted to VV edit a logging object. Inform the host at once.")
return FALSE

/datum/logging/can_vv_delete()
message_admins("<span class='userdanger'>[key_name_admin(src)] attempted to VV edit a logging object. Inform the host <u>at once</u>.</span>")
log_admin("[key_name(src)] attempted to VV edit a logging object. Inform the host at once.")
GLOB.discord_manager.send2discord_simple(DISCORD_WEBHOOK_ADMIN, "[key_name(src)] attempted to VV edit a logging object. Inform the host at once.")
return FALSE
6 changes: 6 additions & 0 deletions code/modules/admin/verbs/debug.dm
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ GLOBAL_PROTECT(AdminProcCallSpamPrevention)
if(!check_rights(R_PROCCALL))
return

if(istype(A, /datum/logging) || istype(A, /datum/log_record))
message_admins("<span class='userdanger'>[key_name_admin(src)] attempted to proc call on a logging object. Inform the host <u>at once</u>.</span>")
log_admin("[key_name(src)] attempted to proc call on a logging object. Inform the host at once.")
GLOB.discord_manager.send2discord_simple(DISCORD_WEBHOOK_ADMIN, "[key_name(src)] attempted to proc call on a logging object. Inform the host at once.")
return

var/procname = clean_input("Proc name, eg: fake_blood","Proc:", null)
if(!procname)
return
Expand Down
Loading