mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-16 20:52:33 +00:00
* Handles Log_Globally Being True When Log Type is LOG_VICTIM (#72643) ## About The Pull Request Victim procs would cause a [runtime, click on me for a link to the runtimebus entry](https://runtimes.moth.fans/runtime/Invalid%20individual%20logging%20type%3A%20524288.%20Defaulting%20to%204096%20(LOG_GAME).%20(code%2F__HELPERS%2Flogging%2F_logging.dm%3A120)_______%2Fproc%2F_stack_trace) when you tried to put a victim log in globally. This was the runtime error for future reference, via https://tgstation13.download/parsed-logs/manuel/data/logs/2023/01/06/round-197717/runtime.condensed.txt - ``` The following runtime has occurred 3155 time(s). runtime error: Invalid individual logging type: 524288. Defaulting to 4096 (LOG_GAME). (code/__HELPERS/logging/_logging.dm:120) proc name: stack trace (/proc/_stack_trace) source file: stack_trace.dm,4 usr: 0 src: null ``` `524288` is the bitflag for `LOG_VICTIM`. I added in a custom error message for passing in LOG_VICTIM without adding log_globally just so that we can pick up on it faster without having to look up the bitflags. I think I prefer it failing loudly as opposed to just returning, so that people can much more easily pick up on this behavior being a wrong one. The pattern across the codebase prior to this PR was pass in log_globally as false along with LOG_VICTIM in the args to `log_message()`, so I decided to enforce doing that in this PR. Alternative fix could be to just early return on LOG_VICTIM, but that would leave a larger footprint and might be better suited for a different PR, preferably after this one at least gets all of our ducks in a row. ## Why It's Good For The Game runtimes bad, actual logging of important stuff good. apologies if i screwed up how LOG_VICTIM is meant to be used, but something is definitely wrong and should be addressed. i'm pretty sure victim logs are only done in addition to a proper log that gets sent globally, and this is good just for visibility? ## Changelog Nothing that players would notice. * Handles Log_Globally Being True When Log Type is LOG_VICTIM Co-authored-by: san7890 <the@san7890.com>
251 lines
6.9 KiB
Plaintext
251 lines
6.9 KiB
Plaintext
//print a warning message to world.log
|
|
#define WARNING(MSG) warning("[MSG] in [__FILE__] at line [__LINE__] src: [UNLINT(src)] usr: [usr].")
|
|
/proc/warning(msg)
|
|
msg = "## WARNING: [msg]"
|
|
log_world(msg)
|
|
|
|
//not an error or a warning, but worth to mention on the world log, just in case.
|
|
#define NOTICE(MSG) notice(MSG)
|
|
/proc/notice(msg)
|
|
msg = "## NOTICE: [msg]"
|
|
log_world(msg)
|
|
|
|
//print a testing-mode debug message to world.log and world
|
|
#ifdef TESTING
|
|
#define testing(msg) log_world("## TESTING: [msg]"); to_chat(world, "## TESTING: [msg]")
|
|
|
|
GLOBAL_LIST_INIT(testing_global_profiler, list("_PROFILE_NAME" = "Global"))
|
|
// we don't really check if a word or name is used twice, be aware of that
|
|
#define testing_profile_start(NAME, LIST) LIST[NAME] = world.timeofday
|
|
#define testing_profile_current(NAME, LIST) round((world.timeofday - LIST[NAME])/10,0.1)
|
|
#define testing_profile_output(NAME, LIST) testing("[LIST["_PROFILE_NAME"]] profile of [NAME] is [testing_profile_current(NAME,LIST)]s")
|
|
#define testing_profile_output_all(LIST) { for(var/_NAME in LIST) { testing_profile_current(,_NAME,LIST); }; };
|
|
#else
|
|
#define testing(msg)
|
|
#define testing_profile_start(NAME, LIST)
|
|
#define testing_profile_current(NAME, LIST)
|
|
#define testing_profile_output(NAME, LIST)
|
|
#define testing_profile_output_all(LIST)
|
|
#endif
|
|
|
|
#define testing_profile_global_start(NAME) testing_profile_start(NAME,GLOB.testing_global_profiler)
|
|
#define testing_profile_global_current(NAME) testing_profile_current(NAME, GLOB.testing_global_profiler)
|
|
#define testing_profile_global_output(NAME) testing_profile_output(NAME, GLOB.testing_global_profiler)
|
|
#define testing_profile_global_output_all testing_profile_output_all(GLOB.testing_global_profiler)
|
|
|
|
#define testing_profile_local_init(PROFILE_NAME) var/list/_timer_system = list( "_PROFILE_NAME" = PROFILE_NAME, "_start_of_proc" = world.timeofday )
|
|
#define testing_profile_local_start(NAME) testing_profile_start(NAME, _timer_system)
|
|
#define testing_profile_local_current(NAME) testing_profile_current(NAME, _timer_system)
|
|
#define testing_profile_local_output(NAME) testing_profile_output(NAME, _timer_system)
|
|
#define testing_profile_local_output_all testing_profile_output_all(_timer_system)
|
|
|
|
#if defined(UNIT_TESTS) || defined(SPACEMAN_DMM)
|
|
/proc/log_test(text)
|
|
WRITE_LOG(GLOB.test_log, text)
|
|
SEND_TEXT(world.log, text)
|
|
#endif
|
|
|
|
#if defined(REFERENCE_DOING_IT_LIVE)
|
|
#define log_reftracker(msg) log_harddel("## REF SEARCH [msg]")
|
|
|
|
/proc/log_harddel(text)
|
|
WRITE_LOG(GLOB.harddel_log, text)
|
|
|
|
#elif defined(REFERENCE_TRACKING) // Doing it locally
|
|
#define log_reftracker(msg) log_world("## REF SEARCH [msg]")
|
|
|
|
#else //Not tracking at all
|
|
#define log_reftracker(msg)
|
|
#endif
|
|
|
|
/**
|
|
* Generic logging helper
|
|
*
|
|
* reads the type of the log
|
|
* and writes it to the respective log file
|
|
* unless log_globally is FALSE
|
|
* Arguments:
|
|
* * message - The message being logged
|
|
* * message_type - the type of log the message is(ATTACK, SAY, etc)
|
|
* * 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)
|
|
if(!log_globally)
|
|
return
|
|
//SKYRAT EDIT ADDITION BEGIN
|
|
#ifndef SPACEMAN_DMM
|
|
if(CONFIG_GET(flag/sql_game_log) && CONFIG_GET(flag/sql_enabled))
|
|
SSdbcore.add_log_to_mass_insert_queue(
|
|
format_table_name("game_log"),
|
|
list(
|
|
"datetime" = SQLtime(),
|
|
"round_id" = "[GLOB.round_id]",
|
|
"ckey" = key_name(src),
|
|
"loc" = loc_name(src),
|
|
"type" = message_type,
|
|
"message" = message,
|
|
)
|
|
)
|
|
if(!CONFIG_GET(flag/file_game_log))
|
|
return
|
|
#endif
|
|
//SKYRAT EDIT ADDITION END
|
|
var/log_text = "[key_name(src)] [message] [loc_name(src)]"
|
|
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)
|
|
log_attack(log_text)
|
|
if(LOG_SAY)
|
|
log_say(log_text)
|
|
if(LOG_WHISPER)
|
|
log_whisper(log_text)
|
|
if(LOG_EMOTE)
|
|
log_emote(log_text)
|
|
//SKYRAT EDIT ADDITION BEGIN
|
|
if(LOG_SUBTLER)
|
|
log_subtler(log_text)
|
|
//SKYRAT EDIT ADDITION END
|
|
if(LOG_RADIO_EMOTE)
|
|
log_radio_emote(log_text)
|
|
if(LOG_DSAY)
|
|
log_dsay(log_text)
|
|
if(LOG_PDA)
|
|
log_pda(log_text)
|
|
if(LOG_CHAT)
|
|
log_chat(log_text)
|
|
if(LOG_COMMENT)
|
|
log_comment(log_text)
|
|
if(LOG_TELECOMMS)
|
|
log_telecomms(log_text)
|
|
if(LOG_ECON)
|
|
log_econ(log_text)
|
|
if(LOG_OOC)
|
|
log_ooc(log_text)
|
|
if(LOG_ADMIN)
|
|
log_admin(log_text)
|
|
if(LOG_ADMIN_PRIVATE)
|
|
log_admin_private(log_text)
|
|
if(LOG_ASAY)
|
|
log_adminsay(log_text)
|
|
if(LOG_OWNERSHIP)
|
|
log_game(log_text)
|
|
if(LOG_GAME)
|
|
log_game(log_text)
|
|
if(LOG_MECHA)
|
|
log_mecha(log_text)
|
|
if(LOG_SHUTTLE)
|
|
log_shuttle(log_text)
|
|
if(LOG_SPEECH_INDICATORS)
|
|
log_speech_indicators(log_text)
|
|
else
|
|
stack_trace("Invalid individual logging type: [message_type]. Defaulting to [LOG_GAME] (LOG_GAME).")
|
|
log_game(log_text)
|
|
|
|
/* For logging round startup. */
|
|
/proc/start_log(log)
|
|
WRITE_LOG(log, "Starting up round ID [GLOB.round_id].\n-------------------------")
|
|
|
|
/* Close open log handles. This should be called as late as possible, and no logging should hapen after. */
|
|
/proc/shutdown_logging()
|
|
rustg_log_close_all()
|
|
|
|
/* Helper procs for building detailed log lines */
|
|
/proc/key_name(whom, include_link = null, include_name = TRUE)
|
|
var/mob/M
|
|
var/client/C
|
|
var/key
|
|
var/ckey
|
|
var/fallback_name
|
|
|
|
if(!whom)
|
|
return "*null*"
|
|
if(istype(whom, /client))
|
|
C = whom
|
|
M = C.mob
|
|
key = C.key
|
|
ckey = C.ckey
|
|
else if(ismob(whom))
|
|
M = whom
|
|
C = M.client
|
|
key = M.key
|
|
ckey = M.ckey
|
|
else if(istext(whom))
|
|
key = whom
|
|
ckey = ckey(whom)
|
|
C = GLOB.directory[ckey]
|
|
if(C)
|
|
M = C.mob
|
|
else if(istype(whom,/datum/mind))
|
|
var/datum/mind/mind = whom
|
|
key = mind.key
|
|
ckey = ckey(key)
|
|
if(mind.current)
|
|
M = mind.current
|
|
if(M.client)
|
|
C = M.client
|
|
else
|
|
fallback_name = mind.name
|
|
else // Catch-all cases if none of the types above match
|
|
var/swhom = null
|
|
|
|
if(istype(whom, /atom))
|
|
var/atom/A = whom
|
|
swhom = "[A.name]"
|
|
else if(isdatum(whom))
|
|
swhom = "[whom]"
|
|
|
|
if(!swhom)
|
|
swhom = "*invalid*"
|
|
|
|
return "\[[swhom]\]"
|
|
|
|
. = ""
|
|
|
|
if(!ckey)
|
|
include_link = FALSE
|
|
|
|
if(key)
|
|
if(C?.holder && C.holder.fakekey && !include_name)
|
|
if(include_link)
|
|
. += "<a href='?priv_msg=[C.getStealthKey()]'>"
|
|
. += "Administrator"
|
|
else
|
|
if(include_link)
|
|
. += "<a href='?priv_msg=[ckey]'>"
|
|
. += key
|
|
if(!C)
|
|
. += "\[DC\]"
|
|
|
|
if(include_link)
|
|
. += "</a>"
|
|
else
|
|
. += "*no key*"
|
|
|
|
if(include_name)
|
|
if(M)
|
|
if(M.real_name)
|
|
. += "/([M.real_name])"
|
|
else if(M.name)
|
|
. += "/([M.name])"
|
|
else if(fallback_name)
|
|
. += "/([fallback_name])"
|
|
|
|
return .
|
|
|
|
/proc/key_name_admin(whom, include_name = TRUE)
|
|
return key_name(whom, TRUE, include_name)
|
|
|
|
/proc/loc_name(atom/A)
|
|
if(!istype(A))
|
|
return "(INVALID LOCATION)"
|
|
|
|
var/turf/T = A
|
|
if (!istype(T))
|
|
T = get_turf(A)
|
|
|
|
if(istype(T))
|
|
return "([AREACOORD(T)])"
|
|
else if(A.loc)
|
|
return "(UNKNOWN (?, ?, ?))"
|