mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Log process uptime
Log actual process uptime in all (post init) loggers. The actual process uptime is obtained from the engine (Plat_FloatTime()).
This commit is contained in:
parent
85462806d1
commit
0de09217bc
@ -5,6 +5,7 @@
|
||||
//=============================================================================//
|
||||
|
||||
#include "core/stdafx.h"
|
||||
#include "core/logdef.h"
|
||||
#include "core/init.h"
|
||||
#include "tier0/jobthread.h"
|
||||
#include "tier0/threadtools.h"
|
||||
@ -233,6 +234,8 @@ void Systems_Init()
|
||||
#ifdef DEDICATED
|
||||
Dedicated_Init();
|
||||
#endif // DEDICATED
|
||||
|
||||
SpdLog_PostInit();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
@ -60,3 +60,18 @@ void SpdLog_Init(void)
|
||||
|
||||
bInitialized = true;
|
||||
}
|
||||
|
||||
void SpdLog_PostInit()
|
||||
{
|
||||
std::shared_ptr<spdlog::logger> iconsole = spdlog::get("game_console");
|
||||
std::shared_ptr<spdlog::logger> wconsole = spdlog::get("win_console");
|
||||
|
||||
iconsole->set_pattern("%v");
|
||||
|
||||
if (strstr(g_svCmdLine.c_str(), "-ansiclr"))
|
||||
{
|
||||
wconsole->set_pattern("%v\u001b[0m");
|
||||
g_bSpdLog_UseAnsiClr = true;
|
||||
}
|
||||
else { wconsole->set_pattern("%v"); }
|
||||
}
|
@ -11,3 +11,4 @@ inline std::ostringstream g_spd_sys_w_oss;
|
||||
inline auto g_spd_sys_p_ostream_sink = std::make_shared<spdlog::sinks::ostream_sink_st>(g_spd_sys_w_oss);
|
||||
|
||||
void SpdLog_Init(void);
|
||||
void SpdLog_PostInit(void);
|
||||
|
@ -542,7 +542,7 @@ void CConsole::FindFromPartial(void)
|
||||
//-----------------------------------------------------------------------------
|
||||
void CConsole::ProcessCommand(const char* pszCommand)
|
||||
{
|
||||
AddLog(ImVec4(1.00f, 0.80f, 0.60f, 1.00f), "] %s\n", PrintPercentageEscape(pszCommand).c_str());
|
||||
AddLog(ImVec4(1.00f, 0.80f, 0.60f, 1.00f), "%s] %s\n", Plat_GetProcessUpTime(), PrintPercentageEscape(pszCommand).c_str());
|
||||
|
||||
std::thread t(CEngineClient_CommandExecute, this, pszCommand);
|
||||
t.detach(); // Detach from render thread.
|
||||
|
@ -54,7 +54,8 @@ SQRESULT SQVM_PrintFunc(HSQUIRRELVM v, SQChar* fmt, ...)
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
static SQChar buf[1024] = {};
|
||||
static SQChar buf[4096] = {};
|
||||
static std::string vmStr;
|
||||
static std::regex rxAnsiExp("\\\033\\[.*?m");
|
||||
|
||||
static std::shared_ptr<spdlog::logger> iconsole = spdlog::get("game_console");
|
||||
@ -72,7 +73,8 @@ SQRESULT SQVM_PrintFunc(HSQUIRRELVM v, SQChar* fmt, ...)
|
||||
va_end(args);
|
||||
}/////////////////////////////
|
||||
|
||||
std::string vmStr = SQVM_LOG_T[static_cast<SQInteger>(context)];
|
||||
vmStr = Plat_GetProcessUpTime();
|
||||
vmStr.append(SQVM_LOG_T[static_cast<SQInteger>(context)]);
|
||||
vmStr.append(buf);
|
||||
|
||||
if (sq_showvmoutput->GetInt() > 0) {
|
||||
@ -91,17 +93,20 @@ SQRESULT SQVM_PrintFunc(HSQUIRRELVM v, SQChar* fmt, ...)
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string vmStrAnsi;
|
||||
static std::string vmStrAnsi;
|
||||
if (g_bSQAuxError)
|
||||
{
|
||||
bColorOverride = true;
|
||||
if (strstr(buf, "SCRIPT ERROR:") || strstr(buf, " -> "))
|
||||
{
|
||||
bError = true;
|
||||
vmStrAnsi = SQVM_ERROR_ANSI_LOG_T[static_cast<SQInteger>(context)];
|
||||
vmStrAnsi = Plat_GetProcessUpTime();
|
||||
vmStrAnsi.append(SQVM_ERROR_ANSI_LOG_T[static_cast<SQInteger>(context)]);
|
||||
}
|
||||
else {
|
||||
vmStrAnsi = SQVM_WARNING_ANSI_LOG_T[static_cast<SQInteger>(context)];
|
||||
else
|
||||
{
|
||||
vmStrAnsi = Plat_GetProcessUpTime();
|
||||
vmStrAnsi.append(SQVM_WARNING_ANSI_LOG_T[static_cast<SQInteger>(context)]);
|
||||
}
|
||||
}
|
||||
else if (g_bSQAuxBadLogic)
|
||||
@ -111,14 +116,20 @@ SQRESULT SQVM_PrintFunc(HSQUIRRELVM v, SQChar* fmt, ...)
|
||||
bError = true;
|
||||
bColorOverride = true;
|
||||
g_bSQAuxBadLogic = false;
|
||||
vmStrAnsi = SQVM_ERROR_ANSI_LOG_T[static_cast<SQInteger>(context)];
|
||||
|
||||
vmStrAnsi = Plat_GetProcessUpTime();
|
||||
vmStrAnsi.append(SQVM_ERROR_ANSI_LOG_T[static_cast<SQInteger>(context)]);
|
||||
}
|
||||
else {
|
||||
vmStrAnsi = SQVM_ANSI_LOG_T[static_cast<SQInteger>(context)];
|
||||
else
|
||||
{
|
||||
vmStrAnsi = Plat_GetProcessUpTime();
|
||||
vmStrAnsi.append(SQVM_ANSI_LOG_T[static_cast<SQInteger>(context)]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
vmStrAnsi = SQVM_ANSI_LOG_T[static_cast<SQInteger>(context)];
|
||||
else
|
||||
{
|
||||
vmStrAnsi = vmStrAnsi = Plat_GetProcessUpTime();;
|
||||
vmStrAnsi.append(SQVM_ANSI_LOG_T[static_cast<SQInteger>(context)]);
|
||||
}
|
||||
vmStrAnsi.append(buf);
|
||||
wconsole->debug(vmStrAnsi);
|
||||
@ -205,7 +216,8 @@ SQRESULT SQVM_WarningFunc(HSQUIRRELVM v, SQInteger a2, SQInteger a3, SQInteger*
|
||||
static std::shared_ptr<spdlog::logger> wconsole = spdlog::get("win_console");
|
||||
static std::shared_ptr<spdlog::logger> sqlogger = spdlog::get("sqvm_warn");
|
||||
|
||||
std::string vmStr = SQVM_LOG_T[static_cast<int>(context)];
|
||||
std::string vmStr = Plat_GetProcessUpTime();
|
||||
vmStr.append(SQVM_LOG_T[static_cast<int>(context)]);
|
||||
std::string svConstructor(*ppString, *nStringSize); // Get string from memory via std::string constructor.
|
||||
vmStr.append(svConstructor);
|
||||
|
||||
@ -221,7 +233,8 @@ SQRESULT SQVM_WarningFunc(HSQUIRRELVM v, SQInteger a2, SQInteger a3, SQInteger*
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string vmStrAnsi = SQVM_WARNING_ANSI_LOG_T[static_cast<int>(context)];
|
||||
std::string vmStrAnsi = Plat_GetProcessUpTime();
|
||||
vmStrAnsi.append(SQVM_WARNING_ANSI_LOG_T[static_cast<int>(context)]);
|
||||
vmStrAnsi.append(svConstructor);
|
||||
wconsole->debug(vmStrAnsi);
|
||||
#ifdef DEDICATED
|
||||
|
@ -82,7 +82,7 @@ PLATFORM_INTERFACE void AssertValidWStringPtr(const wchar_t* ptr, int maxchar/*
|
||||
//-----------------------------------------------------------------------------
|
||||
void DevMsg(eDLL_T context, const char* fmt, ...)
|
||||
{
|
||||
static char szBuf[2048] = {};
|
||||
static char szBuf[4096] = {};
|
||||
|
||||
static std::string svOut;
|
||||
static std::string svAnsiOut;
|
||||
@ -104,7 +104,8 @@ void DevMsg(eDLL_T context, const char* fmt, ...)
|
||||
va_end(args);
|
||||
}/////////////////////////////
|
||||
|
||||
svOut = sDLL_T[static_cast<int>(context)];
|
||||
svOut = Plat_GetProcessUpTime();
|
||||
svOut.append(sDLL_T[static_cast<int>(context)]);
|
||||
svOut.append(szBuf);
|
||||
svOut = std::regex_replace(svOut, rxAnsiExp, "");
|
||||
|
||||
@ -122,7 +123,8 @@ void DevMsg(eDLL_T context, const char* fmt, ...)
|
||||
}
|
||||
else
|
||||
{
|
||||
svAnsiOut = sANSI_DLL_T[static_cast<int>(context)];
|
||||
svAnsiOut = Plat_GetProcessUpTime();
|
||||
svAnsiOut.append(sANSI_DLL_T[static_cast<int>(context)]);
|
||||
svAnsiOut.append(szBuf);
|
||||
|
||||
if (svAnsiOut.back() != '\n')
|
||||
@ -188,7 +190,7 @@ void DevMsg(eDLL_T context, const char* fmt, ...)
|
||||
//-----------------------------------------------------------------------------
|
||||
void Warning(eDLL_T context, const char* fmt, ...)
|
||||
{
|
||||
static char szBuf[2048] = {};
|
||||
static char szBuf[4096] = {};
|
||||
|
||||
static std::string svOut;
|
||||
static std::string svAnsiOut;
|
||||
@ -210,7 +212,8 @@ void Warning(eDLL_T context, const char* fmt, ...)
|
||||
va_end(args);
|
||||
}/////////////////////////////
|
||||
|
||||
svOut = sDLL_T[static_cast<int>(context)];
|
||||
svOut = Plat_GetProcessUpTime();
|
||||
svOut.append(sDLL_T[static_cast<int>(context)]);
|
||||
svOut.append(szBuf);
|
||||
svOut = std::regex_replace(svOut, rxAnsiExp, "");
|
||||
|
||||
@ -228,7 +231,8 @@ void Warning(eDLL_T context, const char* fmt, ...)
|
||||
}
|
||||
else
|
||||
{
|
||||
svAnsiOut = sANSI_DLL_T[static_cast<int>(context)];
|
||||
svAnsiOut = Plat_GetProcessUpTime();
|
||||
svAnsiOut.append(sANSI_DLL_T[static_cast<int>(context)]);
|
||||
svAnsiOut.append(g_svYellowF);
|
||||
svAnsiOut.append(szBuf);
|
||||
|
||||
@ -263,7 +267,7 @@ void Warning(eDLL_T context, const char* fmt, ...)
|
||||
//-----------------------------------------------------------------------------
|
||||
void Error(eDLL_T context, const char* fmt, ...)
|
||||
{
|
||||
static char szBuf[2048] = {};
|
||||
static char szBuf[4096] = {};
|
||||
|
||||
static std::string svOut;
|
||||
static std::string svAnsiOut;
|
||||
@ -285,7 +289,8 @@ void Error(eDLL_T context, const char* fmt, ...)
|
||||
va_end(args);
|
||||
}/////////////////////////////
|
||||
|
||||
svOut = sDLL_T[static_cast<int>(context)];
|
||||
svOut = Plat_GetProcessUpTime();
|
||||
svOut.append(sDLL_T[static_cast<int>(context)]);
|
||||
svOut.append(szBuf);
|
||||
svOut = std::regex_replace(svOut, rxAnsiExp, "");
|
||||
|
||||
@ -303,7 +308,8 @@ void Error(eDLL_T context, const char* fmt, ...)
|
||||
}
|
||||
else
|
||||
{
|
||||
svAnsiOut = sANSI_DLL_T[static_cast<int>(context)];
|
||||
svAnsiOut = Plat_GetProcessUpTime();
|
||||
svAnsiOut.append(sANSI_DLL_T[static_cast<int>(context)]);
|
||||
svAnsiOut.append(g_svRedF);
|
||||
svAnsiOut.append(szBuf);
|
||||
|
||||
|
@ -10,3 +10,11 @@ uint64_t Plat_MSTime()
|
||||
{
|
||||
return v_Plat_MSTime();
|
||||
}
|
||||
|
||||
const char* Plat_GetProcessUpTime()
|
||||
{
|
||||
static char szBuf[4096];
|
||||
sprintf_s(szBuf, sizeof(szBuf), "[%.3f] ", Plat_FloatTime());
|
||||
|
||||
return szBuf;
|
||||
}
|
@ -171,6 +171,7 @@ inline uint64_t Plat_Rdtsc()
|
||||
}
|
||||
double Plat_FloatTime();
|
||||
uint64_t Plat_MSTime();
|
||||
const char* Plat_GetProcessUpTime();
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Silences a number of warnings on 360 compiles
|
||||
|
Loading…
x
Reference in New Issue
Block a user