From 27f9d6b1106b1130980be7abdd11ff0d1c5a4a7a Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Sun, 14 Aug 2022 15:20:28 +0200 Subject: [PATCH] SQVM logging improvements * Allow setting logging level in retail mode. * Also color log on error to the in-game console overlays when log level < 2. --- r5dev/squirrel/sqvm.cpp | 9 ++++++--- r5dev/tier1/IConVar.cpp | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/r5dev/squirrel/sqvm.cpp b/r5dev/squirrel/sqvm.cpp index a1eac93c..5a1beaab 100644 --- a/r5dev/squirrel/sqvm.cpp +++ b/r5dev/squirrel/sqvm.cpp @@ -102,8 +102,11 @@ SQRESULT SQVM_PrintFunc(HSQUIRRELVM v, SQChar* fmt, ...) if (sq_showvmoutput->GetInt() > 0) { sqlogger->debug(vmStr); } - if (sq_showvmoutput->GetInt() > 1 || - (g_bSQAuxError || g_bSQAuxBadLogic && v == g_pErrorVM)) + + // Always show script errors. + bool bLogLevelOverride = (g_bSQAuxError || g_bSQAuxBadLogic && v == g_pErrorVM); + + if (sq_showvmoutput->GetInt() > 1 || bLogLevelOverride) { bool bError = false; bool bColorOverride = false; @@ -165,7 +168,7 @@ SQRESULT SQVM_PrintFunc(HSQUIRRELVM v, SQChar* fmt, ...) vmStr = std::regex_replace(vmStr, rxAnsiExp, ""); iconsole->debug(vmStr); - if (sq_showvmoutput->GetInt() > 2) + if (sq_showvmoutput->GetInt() > 2 || bLogLevelOverride) { ImVec4 color; if (bColorOverride) diff --git a/r5dev/tier1/IConVar.cpp b/r5dev/tier1/IConVar.cpp index f2b27678..4e5ee157 100644 --- a/r5dev/tier1/IConVar.cpp +++ b/r5dev/tier1/IConVar.cpp @@ -184,8 +184,8 @@ void ConVar::Init(void) const // SQUIRREL | sq_showrsonloading = ConVar::Create("sq_showrsonloading" , "0", FCVAR_DEVELOPMENTONLY, "Logs all 'rson' files loaded by the SQVM ( !slower! ).", false, 0.f, false, 0.f, nullptr, nullptr); sq_showscriptloading = ConVar::Create("sq_showscriptloading", "0", FCVAR_DEVELOPMENTONLY, "Logs all scripts loaded by the SQVM to be pre-compiled ( !slower! ).", false, 0.f, false, 0.f, nullptr, nullptr); - sq_showvmoutput = ConVar::Create("sq_showvmoutput" , "0", FCVAR_DEVELOPMENTONLY, "Prints the VM output to the console.", false, 0.f, false, 0.f, nullptr, "1 = Log to file. 2 = 1 + log to game console. 3 = 1 + 2 + log to overhead console."); - sq_showvmwarning = ConVar::Create("sq_showvmwarning" , "0", FCVAR_DEVELOPMENTONLY, "Prints the VM warning output to the console.", false, 0.f, false, 0.f, nullptr, "1 = Log to file. 2 = 1 + log to game console and overhead console."); + sq_showvmoutput = ConVar::Create("sq_showvmoutput" , "0", FCVAR_RELEASE, "Prints the VM output to the console.", false, 0.f, false, 0.f, nullptr, "1 = Log to file. 2 = 1 + log to game console. 3 = 1 + 2 + log to overhead console."); + sq_showvmwarning = ConVar::Create("sq_showvmwarning" , "0", FCVAR_RELEASE, "Prints the VM warning output to the console.", false, 0.f, false, 0.f, nullptr, "1 = Log to file. 2 = 1 + log to game console and overhead console."); //------------------------------------------------------------------------- // NETCHANNEL | net_tracePayload = ConVar::Create("net_tracePayload" , "0", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT , "Log the payload of the send/recv datagram to a file on the disk.", false, 0.f, false, 0.f, nullptr, nullptr);