From eac4df19acc95bff1fb485ab486326ff4c7e881f Mon Sep 17 00:00:00 2001 From: Watermelon914 <37270891+Watermelon914@users.noreply.github.com> Date: Fri, 3 Jan 2025 18:02:27 +0000 Subject: [PATCH] Adds TTS logging when something goes wrong (#88841) ## About The Pull Request Logs whenever there's a HTTP error on the DM side of TTS. ## Why It's Good For The Game Can help identify bugs and errors. --------- Co-authored-by: Watermelon914 <3052169-Watermelon914@users.noreply.gitlab.com> --- code/__DEFINES/logging.dm | 1 + code/__HELPERS/logging/debug.dm | 4 ++++ code/controllers/subsystem/tts.dm | 6 ++++++ code/datums/http.dm | 10 ++++++++++ code/modules/logging/categories/log_category_debug.dm | 4 ++++ 5 files changed, 25 insertions(+) diff --git a/code/__DEFINES/logging.dm b/code/__DEFINES/logging.dm index c2f0999a34f..93245670782 100644 --- a/code/__DEFINES/logging.dm +++ b/code/__DEFINES/logging.dm @@ -129,6 +129,7 @@ #define LOG_CATEGORY_DEBUG_ASSET "debug-asset" #define LOG_CATEGORY_DEBUG_JOB "debug-job" #define LOG_CATEGORY_DEBUG_LUA "debug-lua" +#define LOG_CATEGORY_DEBUG_TTS "debug-tts" #define LOG_CATEGORY_DEBUG_MAPPING "debug-mapping" #define LOG_CATEGORY_DEBUG_MOBTAG "debug-mobtag" #define LOG_CATEGORY_DEBUG_SQL "debug-sql" diff --git a/code/__HELPERS/logging/debug.dm b/code/__HELPERS/logging/debug.dm index ad5670d2d11..8a47ea2dc9b 100644 --- a/code/__HELPERS/logging/debug.dm +++ b/code/__HELPERS/logging/debug.dm @@ -15,6 +15,10 @@ /proc/log_job_debug(text, list/data) logger.Log(LOG_CATEGORY_DEBUG_JOB, text, data) +/// Logging for TTS +/proc/log_tts(text, list/data) + logger.Log(LOG_CATEGORY_DEBUG_TTS, text, data) + /// Logging for lua scripting /proc/log_lua(text, list/data) logger.Log(LOG_CATEGORY_DEBUG_LUA, text, data) diff --git a/code/controllers/subsystem/tts.dm b/code/controllers/subsystem/tts.dm index 8d893f12f38..dc206522bca 100644 --- a/code/controllers/subsystem/tts.dm +++ b/code/controllers/subsystem/tts.dm @@ -183,6 +183,12 @@ SUBSYSTEM_DEF(tts) var/identifier = current_request.identifier if(current_request.requests_errored()) current_request.timed_out = TRUE + var/datum/http_response/normal_response = current_request.request.into_response() + var/datum/http_response/blips_response = current_request.request_blips.into_response() + log_tts("TTS HTTP request errored | Normal: [normal_response.error] | Blips: [blips_response.error]", list( + "normal" = normal_response, + "blips" = blips_response + )) continue current_request.audio_length = text2num(response.headers["audio-length"]) * 10 if(!current_request.audio_length) diff --git a/code/datums/http.dm b/code/datums/http.dm index 49b183fde6c..8665b351ab7 100644 --- a/code/datums/http.dm +++ b/code/datums/http.dm @@ -80,3 +80,13 @@ var/errored = FALSE var/error + +/datum/http_response/serialize_list(list/options, list/semvers) + . = ..() + .["status_code"] = status_code + .["body"] = body + .["headers"] = headers + + .["errored"] = errored + .["error"] = error + return . diff --git a/code/modules/logging/categories/log_category_debug.dm b/code/modules/logging/categories/log_category_debug.dm index 8833a59b1a0..8d9318485b5 100644 --- a/code/modules/logging/categories/log_category_debug.dm +++ b/code/modules/logging/categories/log_category_debug.dm @@ -9,6 +9,10 @@ category = LOG_CATEGORY_DEBUG_LUA master_category = /datum/log_category/debug +/datum/log_category/debug_tts + category = LOG_CATEGORY_DEBUG_TTS + master_category = /datum/log_category/debug + // This is not in the debug master category on purpose, do not add it /datum/log_category/debug_runtime category = LOG_CATEGORY_RUNTIME