Converts del logging to proper json, using json objects instead of building a text file (#75636)

## About The Pull Request

It's easier to parse, and makes more sense when you read it. This way
I'll never have to add yet another case to my parser for someone
changing where a space goes or something.

Moves qdel into its own category cause the old name looked ugly (yell if
this is dumb)
Added a bitfield to entries pulled from categories, adds a new flag that
enables pretty printing json lists.


## Why It's Good For The Game

IMPROVES my workflow

## Changelog
🆑
server: del logging is now done by outputting to a json file again, but
this time we're using ACTUAL json and not just a big text string with
newlines and shit
/🆑

---------

Co-authored-by: Zephyr <12817816+ZephyrTFA@users.noreply.github.com>
This commit is contained in:
LemonInTheDark
2023-05-26 12:40:18 -06:00
committed by GitHub
co-authored by Zephyr
parent 08484b259f
commit b304b6523f
8 changed files with 57 additions and 27 deletions
@@ -39,7 +39,3 @@
category = LOG_CATEGORY_DEBUG_ASSET
config_flag = /datum/config_entry/flag/log_asset
master_category = /datum/log_category/debug
/datum/log_category/debug_qdel
category = LOG_CATEGORY_DEBUG_QDEL
master_category = /datum/log_category/debug
@@ -56,3 +56,10 @@
/datum/log_category/speech_indicator
category = LOG_CATEGORY_SPEECH_INDICATOR
config_flag = /datum/config_entry/flag/log_speech_indicators
// Logs seperately, printed into on server shutdown to store hard deletes and such
/datum/log_category/debug_qdel
category = LOG_CATEGORY_QDEL
// We want this human readable so it's easy to see at a glance
entry_flags = ENTRY_USE_DATA_W_READABLE
internal_formatting = FALSE
+5
View File
@@ -10,6 +10,10 @@
/// The master category that contains this category
var/datum/log_category/master_category
/// Flags to apply to our /datum/log_entry's
/// See code/__DEFINES/logging/dm
var/entry_flags = NONE
/// If set this config flag is checked to enable this log category
var/config_flag
@@ -32,6 +36,7 @@ GENERAL_PROTECT_DATUM(/datum/log_category)
timestamp = logger.human_readable_timestamp(),
category = category,
message = message,
flags = entry_flags,
data = data,
semver_store = semver_store,
)
+17 -3
View File
@@ -24,6 +24,10 @@
/// Message of the log entry.
var/message
/// Bitfield that describes how exactly to log stuff exactly
/// See code/__DEFINES/logging/dm
var/flags = NONE
/// Data of the log entry; optional.
var/list/data
@@ -32,12 +36,13 @@
GENERAL_PROTECT_DATUM(/datum/log_entry)
/datum/log_entry/New(timestamp, category, message, list/data, list/semver_store)
/datum/log_entry/New(timestamp, category, message, flags, list/data, list/semver_store)
..()
src.id = next_id++
src.timestamp = timestamp
src.category = category
src.flags = flags
src.message = message
with_data(data)
with_semver_store(semver_store)
@@ -62,10 +67,19 @@ GENERAL_PROTECT_DATUM(/datum/log_entry)
/// Converts the log entry to a human-readable string.
/datum/log_entry/proc/to_readable_text(format = TRUE)
var/output = ""
if(format)
return "\[[timestamp]\] [uppertext(category)]: [message]"
output += "\[[timestamp]\] [uppertext(category)]: [message]"
else
return "[message]"
output += "[message]"
if(flags & ENTRY_USE_DATA_W_READABLE)
#if DM_VERSION >= 515
output += json_encode(data, JSON_PRETTY_PRINT)
#else
output += json_encode(data)
#endif
return output
/// Converts the log entry to a JSON string.
/datum/log_entry/proc/to_json_text()