Better logging (#16164)

* Initial

* Cleared duplicates

* More work, get rid of log_error

* more

* log_debug() to macro LOG_DEBUG

* More work

* More

* Guh

* Maybe better?

* More work

* gah

* Dear lord

* *inserts swears here*

* gdi

* More work

* More

* dear lord

* fsdfsdafs

* rsdaf

* sadfasf

* sdafsad

* fgsd

* small fuckup fix

* jfsd

* sdafasf

* gdi

* sdfa

* sfdafgds

* sdafasdvf

* sdfasdfg

* sdfsga

* asdf

* dsfasfsagf

* ihibhbjh

* fsadf

* adfas

* sdafsad

* sdfasd

* fsda

* vhb

* asf

* for arrow

* removed source file-line logging, added header for tgui
This commit is contained in:
Fluffy
2023-08-05 21:53:11 +00:00
committed by GitHub
parent 40faa01587
commit b183188689
194 changed files with 1637 additions and 877 deletions
@@ -134,7 +134,7 @@
if(config.ipc_timelock_active)
pref.can_edit_ipc_tag = FALSE
else
log_error("SQL CHARACTER LOAD: Logic error, general/basic/load_special() didn't return any rows when it should have. Character ID: [pref.current_character].")
log_world("ERROR: SQL CHARACTER LOAD: Logic error, general/basic/load_special() didn't return any rows when it should have. Character ID: [pref.current_character].")
/datum/category_item/player_setup_item/general/basic/sanitize_character()
if(!pref.species)
@@ -174,14 +174,14 @@ var/global/list/valid_bloodtypes = list("A+", "A-", "B+", "B-", "AB+", "AB-", "O
try
pref.body_markings = json_decode(pref.body_markings)
catch (var/exception/e)
log_debug("BODY MARKINGS: Caught [e]. Initial value: [before]")
LOG_DEBUG("BODY MARKINGS: Caught [e]. Initial value: [before]")
pref.body_markings = list()
if (istext(pref.disabilities))
var/before = pref.disabilities
try
pref.disabilities = json_decode(pref.disabilities)
catch (var/exception/e)
log_debug("DISABILITIES: Caught [e]. Initial value: [before]")
LOG_DEBUG("DISABILITIES: Caught [e]. Initial value: [before]")
pref.disabilities = list()
var/datum/species/mob_species = all_species[pref.species]
@@ -94,14 +94,14 @@
try
pref.all_underwear = json_decode(pref.all_underwear)
catch(var/exception/e)
log_debug("UNDERWEAR: Caught [e]. Initial value: [before]")
LOG_DEBUG("UNDERWEAR: Caught [e]. Initial value: [before]")
pref.all_underwear = list()
if(istext(pref.all_underwear_metadata))
var/before = pref.all_underwear_metadata
try
pref.all_underwear_metadata = json_decode(pref.all_underwear_metadata)
catch(var/exception/e)
log_debug("UNDERWEAR METADATA: Caught [e]. Initial value: [before]")
LOG_DEBUG("UNDERWEAR METADATA: Caught [e]. Initial value: [before]")
pref.all_underwear_metadata = list()
if(!istype(pref.all_underwear))
@@ -96,7 +96,7 @@ var/list/gear_datums = list()
try
pref.gear_list = json_decode(pref.gear_list)
catch
log_debug("SQL CHARACTER LOAD: Unable to load custom loadout for client [pref.client ? pref.client.ckey : "UNKNOWN"].")
LOG_DEBUG("SQL CHARACTER LOAD: Unable to load custom loadout for client [pref.client ? pref.client.ckey : "UNKNOWN"].")
gear_reset = TRUE
var/mob/preference_mob = preference_mob()
@@ -104,7 +104,7 @@
try
pref.vars[preference] = text2num(jobs[preference])
catch(var/exception/e)
log_debug("LOADING: Bad job preference key: [preference].")
LOG_DEBUG("LOADING: Bad job preference key: [preference].")
log_debug(e.desc)
pref.alternate_option = sanitize_integer(text2num(pref.alternate_option), 0, 1, initial(pref.alternate_option))
@@ -25,7 +25,7 @@
act.deleted_at IS NULL;
"})
if (!ccia_action_query.Execute(list("char_id" = pref.current_character)))
log_error("Error CCIA Actions for character #[pref.current_character]. SQL error message: '[ccia_action_query.ErrorMsg()]'.")
log_world("ERROR: Error CCIA Actions for character #[pref.current_character]. SQL error message: '[ccia_action_query.ErrorMsg()]'.")
while(ccia_action_query.NextRow())
var/list/action = list(
@@ -13,7 +13,7 @@
// We aren't loading this category. Bye.
if (role_type && !(sql_role & role_type))
#ifdef SQL_PREF_DEBUG
log_debug("SQL CHARACTER LOAD: Bad role_type, returned. Looking for: [role_type], had: [sql_role]. Conjunction: [sql_role & role_type].")
LOG_DEBUG("SQL CHARACTER LOAD: Bad role_type, returned. Looking for: [role_type], had: [sql_role]. Conjunction: [sql_role & role_type].")
#endif
return
@@ -78,7 +78,7 @@
query += ";"
#ifdef SQL_PREF_DEBUG
log_debug("SQL CHARACTER LOAD: Cached query [query] with variables [json_encode(var_names)]")
LOG_DEBUG("SQL CHARACTER LOAD: Cached query [query] with variables [json_encode(var_names)]")
#endif
// Save it.
query_cache[type][query] = var_names
@@ -90,21 +90,21 @@
var/list/arg_list = gather_load_parameters()
#ifdef SQL_PREF_DEBUG
log_debug("SQL CHARACTER LOAD: Started loading with arguments: [json_encode(arg_list)]. Role type: [role_type]")
LOG_DEBUG("SQL CHARACTER LOAD: Started loading with arguments: [json_encode(arg_list)]. Role type: [role_type]")
#endif
for (var/query_text in query_cache[type])
var/DBQuery/query = dbcon.NewQuery(query_text)
query.Execute(arg_list)
if (query.ErrorMsg())
log_error("SQL CHARACTER LOAD: SQL query error: [query.ErrorMsg()]")
log_debug("SQL CHARACTER LOAD: query args: [json_encode(arg_list)]")
log_world("ERROR: SQL CHARACTER LOAD: SQL query error: [query.ErrorMsg()]")
LOG_DEBUG("SQL CHARACTER LOAD: query args: [json_encode(arg_list)]")
continue
#ifdef SQL_PREF_DEBUG
else
log_debug("SQL CHARACTER LOAD: Successfully executed query: [query_text]")
LOG_DEBUG("SQL CHARACTER LOAD: Successfully executed query: [query_text]")
#endif
// Each query should only return exactly 1 row.
@@ -118,8 +118,8 @@
else
cc.preferences.vars[layers[1]][layers[2]] = query.item[i]
catch(var/exception/e)
log_error("SQL CHARACTER LOAD: bad variable name: [e.name]")
log_debug("SQL CHARACTER LOAD: var name: [var_names[i]]")
log_world("ERROR: SQL CHARACTER LOAD: bad variable name: [e.name]")
LOG_DEBUG("SQL CHARACTER LOAD: var name: [var_names[i]]")
/datum/category_group/player_setup_category/proc/gather_load_parameters()
var/list/arg_list = list()
@@ -140,7 +140,7 @@
// We aren't loading this category. Bye.
if (role_type && !(sql_role & role_type))
#ifdef SQL_PREF_DEBUG
log_debug("SQL CHARACTER SAVE: Bad role_type, returned. Looking for: [role_type], had: [sql_role]. Conjunction: [sql_role & role_type].")
LOG_DEBUG("SQL CHARACTER SAVE: Bad role_type, returned. Looking for: [role_type], had: [sql_role]. Conjunction: [sql_role & role_type].")
#endif
return
@@ -195,7 +195,7 @@
query = replacetext(query, ",", "", length(query) - 1)
#ifdef SQL_PREF_DEBUG
log_debug("SQL CHARACTER SAVE: Cached query [query].")
LOG_DEBUG("SQL CHARACTER SAVE: Cached query [query].")
#endif
// Save it.
@@ -205,7 +205,7 @@
var/list/arg_list = gather_save_parameters()
#ifdef SQL_PREF_DEBUG
log_debug("SQL CHARACTER SAVE: Started saving with arguments: [json_encode(arg_list)]. Role type: [role_type]")
LOG_DEBUG("SQL CHARACTER SAVE: Started saving with arguments: [json_encode(arg_list)]. Role type: [role_type]")
#endif
// Typecast the collection so we can access its preferences var.
@@ -215,14 +215,14 @@
query.Execute(arg_list)
if (query.ErrorMsg())
log_error("SQL CHARACTER SAVE: SQL query error: [query.ErrorMsg()]")
log_debug("SQL CHARACTER SAVE: query args: [json_encode(arg_list)]")
log_world("ERROR: SQL CHARACTER SAVE: SQL query error: [query.ErrorMsg()]")
LOG_DEBUG("SQL CHARACTER SAVE: query args: [json_encode(arg_list)]")
continue
#ifdef SQL_PREF_DEBUG
else
log_debug("SQL CHARACTER SAVE: Successfully executed query: [query_text]")
LOG_DEBUG("SQL CHARACTER SAVE: Successfully executed query: [query_text]")
#endif
if ((role_type & SQL_CHARACTER) && !cc.preferences.current_character)
@@ -237,13 +237,13 @@
cc.preferences.current_character = text2num(query.item[1])
#ifdef SQL_PREF_DEBUG
log_debug("SQL CHARACTER SAVE: Successfully set character ID to [cc.preferences.current_character]")
LOG_DEBUG("SQL CHARACTER SAVE: Successfully set character ID to [cc.preferences.current_character]")
#endif
else
log_error("SQL CHARACTER SAVE: New ID was not recovered.")
log_world("ERROR: SQL CHARACTER SAVE: New ID was not recovered.")
if (query.ErrorMsg())
log_error("SQL CHARACTER SAVE: SQL query error from last_insert_id: [query.ErrorMsg()]")
log_world("ERROR: SQL CHARACTER SAVE: SQL query error from last_insert_id: [query.ErrorMsg()]")
/datum/category_group/player_setup_category/proc/gather_save_parameters()
var/list/arg_list = list()