From 7edaf9ef0b5b3fcdd1cd4aa910deaa0ec669f344 Mon Sep 17 00:00:00 2001 From: Sean Lewis Date: Sun, 22 Sep 2019 13:29:13 -0700 Subject: [PATCH] Add get5_pretty_print_json cvar. --- scripting/get5.sp | 4 +++- scripting/get5/eventlogger.sp | 2 +- scripting/get5_apistats.sp | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/scripting/get5.sp b/scripting/get5.sp index e5891f30d..8d2ea5d1b 100644 --- a/scripting/get5.sp +++ b/scripting/get5.sp @@ -69,6 +69,7 @@ ConVar g_MaxPausesCvar; ConVar g_MaxPauseTimeCvar; ConVar g_MessagePrefixCvar; ConVar g_PausingEnabledCvar; +ConVar g_PrettyPrintJsonCvar; ConVar g_ResetPausesEachHalfCvar; ConVar g_ServerIdCvar; ConVar g_SetClientClanTagCvar; @@ -299,6 +300,7 @@ public void OnPluginStart() { CreateConVar("get5_reset_pauses_each_half", "1", "Whether pause limits will be reset each halftime period"); g_PausingEnabledCvar = CreateConVar("get5_pausing_enabled", "1", "Whether pausing is allowed."); + g_PrettyPrintJsonCvar = CreateConVar("get5_pretty_print_json", "1", "Whether all JSON output is in pretty-print format."); g_ServerIdCvar = CreateConVar( "get5_server_id", "0", "Integer that identifies your server. This is used in temp files to prevent collisions."); @@ -1353,7 +1355,7 @@ public Action Command_Status(int client, int args) { } char buffer[4096]; - json.Encode(buffer, sizeof(buffer), true); + json.Encode(buffer, sizeof(buffer), g_PrettyPrintJsonCvar.BoolValue); ReplyToCommand(client, buffer); json.Cleanup(); diff --git a/scripting/get5/eventlogger.sp b/scripting/get5/eventlogger.sp index b8568056d..9bfec40ac 100644 --- a/scripting/get5/eventlogger.sp +++ b/scripting/get5/eventlogger.sp @@ -12,7 +12,7 @@ static void EventLogger_LogEvent(const char[] eventName, JSON_Object params) { const int kMaxCharacters = 1000; char buffer[2048]; - json.Encode(buffer, sizeof(buffer)); + json.Encode(buffer, sizeof(buffer), g_PrettyPrintJsonCvar.BoolValue); if (strlen(buffer) > kMaxCharacters) { LogError("Event JSON too long (%d characters, %d max): %s", eventName, strlen(buffer), kMaxCharacters); diff --git a/scripting/get5_apistats.sp b/scripting/get5_apistats.sp index ff9bb6203..a12bfecad 100644 --- a/scripting/get5_apistats.sp +++ b/scripting/get5_apistats.sp @@ -85,7 +85,7 @@ public Action Command_Avaliable(int client, int args) { json.SetInt("available", 1); json.SetString("plugin_version", versionString); - char buffer[128]; + char buffer[256]; json.Encode(buffer, sizeof(buffer), true); ReplyToCommand(client, buffer);