1
0
mirror of https://github.com/Mauler125/r5sdk.git synced 2025-02-09 19:15:03 +01:00

Fix bug in script print logger

Fixed bug causing script warnings/errors to not override the log level. Warnings/errors should always be printed to the console. This commit also fixes a bug that causes warnings/errors to not show in red/yellow colors in the imgui console when '-ansicolor' command line parameter isn't used. The imgui console always logs colors and does not rely on '-ansicolor', this is only for the external terminal window.
This commit is contained in:
Kawe Mazidjatari 2023-04-14 00:30:50 +02:00
parent 94ae3e58ce
commit dee5b36088
2 changed files with 17 additions and 5 deletions
r5dev
squirrel
tier0

@ -72,13 +72,21 @@ SQRESULT SQVM_PrintFunc(HSQUIRRELVM v, SQChar* fmt, ...)
break;
}
// Always show script errors.
// Determine whether this is an info or warning log.
bool bLogLevelOverride = (g_bSQAuxError || (g_bSQAuxBadLogic && v == g_pErrorVM));
LogLevel_t level = LogLevel_t(script_show_output->GetInt());
LogType_t type = bLogLevelOverride ? LogType_t::SQ_WARNING : LogType_t::SQ_INFO;
// Always log script related problems to the console.
if (type == LogType_t::SQ_WARNING &&
level == LogLevel_t::LEVEL_DISK_ONLY)
{
level = LogLevel_t::LEVEL_CONSOLE;
}
va_list args;
va_start(args, fmt);
CoreMsgV(type, static_cast<LogLevel_t>(script_show_output->GetInt()), remoteContext, "squirrel_re", fmt, args);
CoreMsgV(type, level, remoteContext, "squirrel_re", fmt, args);
va_end(args);
return SQ_OK;

@ -296,7 +296,7 @@ void CoreMsgV(LogType_t logType, LogLevel_t logLevel, eDLL_T context,
va_end(argsCopy);
#ifndef NETCONSOLE
if (bUseColor && bSquirrel)
if (bSquirrel)
{
if (bWarning && g_bSQAuxError)
{
@ -323,9 +323,13 @@ void CoreMsgV(LogType_t logType, LogLevel_t logLevel, eDLL_T context,
overlayContext = eDLL_T::SYSTEM_ERROR;
overlayColor = ImVec4(1.00f, 0.00f, 0.00f, 0.80f);
#endif // !DEDICATED
message.append(g_svRedF);
if (bUseColor)
{
message.append(g_svRedF);
}
}
else if (bWarning)
else if (bUseColor && bWarning)
{
message.append(g_svYellowF);
}