mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Logging system light refactor
* Use responceid from server to determine in which context to log. * Moved all script loggers from combined enums to minus instead (SERVER = -3, CLIENT = -2, UI = -1 SERVER_CODE = 0, etc), this makes it much easier to align stuff in combined systems such as the RUI logger or NetMsg(). * Color log networked RCON messages properly on the client. * Added dedicated logger for all received RCON messages (net_console.log). * Log commands submitted through in-game console (allows for easier debugging when going through log files).
This commit is contained in:
parent
19d057fc5e
commit
3f8476db88
@ -45,14 +45,17 @@ void SpdLog_Init(void)
|
|||||||
* ROTATE LOGGER SETUP *
|
* ROTATE LOGGER SETUP *
|
||||||
************************/
|
************************/
|
||||||
{
|
{
|
||||||
spdlog::rotating_logger_mt<spdlog::synchronous_factory>("sqvm_warn" , "platform\\logs\\sqvm_warn.log" , SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v");
|
spdlog::rotating_logger_mt<spdlog::synchronous_factory>("sqvm_warn" , "platform\\logs\\sqvm_warn.log" , SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v");
|
||||||
spdlog::rotating_logger_mt<spdlog::synchronous_factory>("sqvm_info" , "platform\\logs\\sqvm_info.log" , SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v");
|
spdlog::rotating_logger_mt<spdlog::synchronous_factory>("sqvm_info" , "platform\\logs\\sqvm_info.log" , SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v");
|
||||||
spdlog::rotating_logger_mt<spdlog::synchronous_factory>("sdk_info" , "platform\\logs\\sdk_info.log" , SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v");
|
spdlog::rotating_logger_mt<spdlog::synchronous_factory>("sdk_info" , "platform\\logs\\sdk_info.log" , SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v");
|
||||||
spdlog::rotating_logger_mt<spdlog::synchronous_factory>("sdk_warn" , "platform\\logs\\sdk_warn.log" , SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v");
|
spdlog::rotating_logger_mt<spdlog::synchronous_factory>("sdk_warn" , "platform\\logs\\sdk_warn.log" , SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v");
|
||||||
spdlog::rotating_logger_mt<spdlog::synchronous_factory>("sdk_error" , "platform\\logs\\sdk_error.log" , SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v");
|
spdlog::rotating_logger_mt<spdlog::synchronous_factory>("sdk_error" , "platform\\logs\\sdk_error.log" , SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v");
|
||||||
spdlog::rotating_logger_mt<spdlog::synchronous_factory>("qhull_info", "platform\\logs\\qhull_info.log", SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v");
|
spdlog::rotating_logger_mt<spdlog::synchronous_factory>("qhull_info", "platform\\logs\\qhull_info.log" , SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v");
|
||||||
spdlog::rotating_logger_mt<spdlog::synchronous_factory>("net_trace" , "platform\\logs\\net_trace.log" , SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v");
|
spdlog::rotating_logger_mt<spdlog::synchronous_factory>("net_trace" , "platform\\logs\\net_trace.log" , SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v");
|
||||||
spdlog::rotating_logger_mt<spdlog::synchronous_factory>("fs_warn" , "platform\\logs\\fs_warn.log" , SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v");
|
#ifndef DEDICATED
|
||||||
|
spdlog::rotating_logger_mt<spdlog::synchronous_factory>("net_con" , "platform\\logs\\net_console.log", SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v");
|
||||||
|
#endif // !DEDICATED
|
||||||
|
spdlog::rotating_logger_mt<spdlog::synchronous_factory>("fs_warn" , "platform\\logs\\fs_warn.log" , SPDLOG_MAX_SIZE, SPDLOG_NUM_FILE)->set_pattern("[%Y-%m-%d %H:%M:%S.%e] %v");
|
||||||
}
|
}
|
||||||
|
|
||||||
spdlog::set_level(spdlog::level::trace);
|
spdlog::set_level(spdlog::level::trace);
|
||||||
|
@ -289,49 +289,7 @@ void CRConClient::ProcessMessage(const sv_rcon::response& sv_response) const
|
|||||||
}
|
}
|
||||||
case sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG:
|
case sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG:
|
||||||
{
|
{
|
||||||
// !TODO: Network the enum for this.
|
NetMsg(sv_response.responseid(), svOut.c_str());
|
||||||
if (svOut.find(SQVM_LOG_T[0]))
|
|
||||||
{
|
|
||||||
SQVM_PrintFunc(nullptr, const_cast<char*>("%s"), svOut.c_str());
|
|
||||||
}
|
|
||||||
else // This has to be done for RUI color logging.
|
|
||||||
{
|
|
||||||
if (svOut.find(sDLL_T[0]))
|
|
||||||
{
|
|
||||||
StringReplace(svOut, sDLL_T[0], "");
|
|
||||||
DevMsg(eDLL_T::SERVER, "%s", svOut.c_str());
|
|
||||||
}
|
|
||||||
if (svOut.find(sDLL_T[1]))
|
|
||||||
{
|
|
||||||
StringReplace(svOut, sDLL_T[1], "");
|
|
||||||
DevMsg(eDLL_T::CLIENT, "%s", svOut.c_str());
|
|
||||||
}
|
|
||||||
if (svOut.find(sDLL_T[2]))
|
|
||||||
{
|
|
||||||
StringReplace(svOut, sDLL_T[2], "");
|
|
||||||
DevMsg(eDLL_T::UI, "%s", svOut.c_str());
|
|
||||||
}
|
|
||||||
if (svOut.find(sDLL_T[3]))
|
|
||||||
{
|
|
||||||
StringReplace(svOut, sDLL_T[3], "");
|
|
||||||
DevMsg(eDLL_T::ENGINE, "%s", svOut.c_str());
|
|
||||||
}
|
|
||||||
if (svOut.find(sDLL_T[4]))
|
|
||||||
{
|
|
||||||
StringReplace(svOut, sDLL_T[4], "");
|
|
||||||
DevMsg(eDLL_T::FS, "%s", svOut.c_str());
|
|
||||||
}
|
|
||||||
if (svOut.find(sDLL_T[5]))
|
|
||||||
{
|
|
||||||
StringReplace(svOut, sDLL_T[5], "");
|
|
||||||
DevMsg(eDLL_T::RTECH, "%s", svOut.c_str());
|
|
||||||
}
|
|
||||||
if (svOut.find(sDLL_T[6]))
|
|
||||||
{
|
|
||||||
StringReplace(svOut, sDLL_T[6], "");
|
|
||||||
DevMsg(eDLL_T::MS, "%s", svOut.c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -195,7 +195,7 @@ void CRConServer::Send(SocketHandle_t hSocket, const std::string& svMessage) con
|
|||||||
void CRConServer::Recv(void)
|
void CRConServer::Recv(void)
|
||||||
{
|
{
|
||||||
int nCount = m_pSocket->GetAcceptedSocketCount();
|
int nCount = m_pSocket->GetAcceptedSocketCount();
|
||||||
static char szRecvBuf[1024]{};
|
static char szRecvBuf[1024];
|
||||||
|
|
||||||
for (m_nConnIndex = nCount - 1; m_nConnIndex >= 0; m_nConnIndex--)
|
for (m_nConnIndex = nCount - 1; m_nConnIndex >= 0; m_nConnIndex--)
|
||||||
{
|
{
|
||||||
@ -250,11 +250,11 @@ void CRConServer::Recv(void)
|
|||||||
// response_t -
|
// response_t -
|
||||||
// Output : serialized results as string
|
// Output : serialized results as string
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
std::string CRConServer::Serialize(const std::string& svRspBuf, const std::string& svRspVal, sv_rcon::response_t response_t) const
|
std::string CRConServer::Serialize(const std::string& svRspBuf, const std::string& svRspVal, sv_rcon::response_t response_t, int nResponseId) const
|
||||||
{
|
{
|
||||||
sv_rcon::response sv_response;
|
sv_rcon::response sv_response;
|
||||||
|
|
||||||
sv_response.set_responseid(-1); // TODO
|
sv_response.set_responseid(nResponseId);
|
||||||
sv_response.set_responsetype(response_t);
|
sv_response.set_responsetype(response_t);
|
||||||
|
|
||||||
switch (response_t)
|
switch (response_t)
|
||||||
|
@ -26,7 +26,7 @@ public:
|
|||||||
void Send(SocketHandle_t hSocket, const std::string& svMessage) const;
|
void Send(SocketHandle_t hSocket, const std::string& svMessage) const;
|
||||||
void Recv(void);
|
void Recv(void);
|
||||||
|
|
||||||
std::string Serialize(const std::string& svRspBuf, const std::string& svRspVal, sv_rcon::response_t response_t) const;
|
std::string Serialize(const std::string& svRspBuf, const std::string& svRspVal, sv_rcon::response_t response_t, int nResponseId = -4) const;
|
||||||
cl_rcon::request Deserialize(const std::string& svBuf) const;
|
cl_rcon::request Deserialize(const std::string& svBuf) const;
|
||||||
|
|
||||||
void Authenticate(const cl_rcon::request& cl_request, CConnectedNetConsoleData* pData);
|
void Authenticate(const cl_rcon::request& cl_request, CConnectedNetConsoleData* pData);
|
||||||
|
@ -8,10 +8,10 @@
|
|||||||
int HSys_Error_Internal(char* fmt, va_list args)
|
int HSys_Error_Internal(char* fmt, va_list args)
|
||||||
{
|
{
|
||||||
char buffer[2048]{};
|
char buffer[2048]{};
|
||||||
Error(eDLL_T::NONE, "_______________________________________________________________\n");
|
Error(eDLL_T::COMMON, "_______________________________________________________________\n");
|
||||||
Error(eDLL_T::NONE, "] ENGINE ERROR ################################################\n");
|
Error(eDLL_T::COMMON, "] ENGINE ERROR ################################################\n");
|
||||||
vsprintf(buffer, fmt, args);
|
vsprintf(buffer, fmt, args);
|
||||||
Error(eDLL_T::NONE, "%s\n", buffer);
|
Error(eDLL_T::COMMON, "%s\n", buffer);
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
return Sys_Error_Internal(fmt, args);
|
return Sys_Error_Internal(fmt, args);
|
||||||
|
@ -58,7 +58,7 @@ void* HSys_Warning(int level, char* fmt, ...)
|
|||||||
va_end(args);
|
va_end(args);
|
||||||
}/////////////////////////////
|
}/////////////////////////////
|
||||||
|
|
||||||
Warning(eDLL_T::NONE, "Warning(%d):%s\n", level, buf);
|
Warning(eDLL_T::COMMON, "Warning(%d):%s\n", level, buf);
|
||||||
return v_Sys_Warning(level, buf);
|
return v_Sys_Warning(level, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -528,7 +528,7 @@ void CConsole::FindFromPartial(void)
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void CConsole::ProcessCommand(const char* pszCommand)
|
void CConsole::ProcessCommand(const char* pszCommand)
|
||||||
{
|
{
|
||||||
AddLog(ImVec4(1.00f, 0.80f, 0.60f, 1.00f), "%s] %s\n", Plat_GetProcessUpTime(), pszCommand);
|
DevMsg(eDLL_T::COMMON, "] %s\n", pszCommand);
|
||||||
|
|
||||||
std::thread t(CEngineClient_CommandExecute, this, pszCommand);
|
std::thread t(CEngineClient_CommandExecute, this, pszCommand);
|
||||||
t.detach(); // Detach from render thread.
|
t.detach(); // Detach from render thread.
|
||||||
|
@ -32,20 +32,25 @@
|
|||||||
SQRESULT SQVM_PrintFunc(HSQUIRRELVM v, SQChar* fmt, ...)
|
SQRESULT SQVM_PrintFunc(HSQUIRRELVM v, SQChar* fmt, ...)
|
||||||
{
|
{
|
||||||
SQCONTEXT context;
|
SQCONTEXT context;
|
||||||
|
int nResponseId;
|
||||||
// We use the sqvm pointer as index for SDK usage as the function prototype has to match assembly.
|
// We use the sqvm pointer as index for SDK usage as the function prototype has to match assembly.
|
||||||
switch (static_cast<SQCONTEXT>(reinterpret_cast<int>(v)))
|
switch (static_cast<SQCONTEXT>(reinterpret_cast<int>(v)))
|
||||||
{
|
{
|
||||||
case SQCONTEXT::SERVER:
|
case SQCONTEXT::SERVER:
|
||||||
context = SQCONTEXT::SERVER;
|
context = SQCONTEXT::SERVER;
|
||||||
|
nResponseId = -3;
|
||||||
break;
|
break;
|
||||||
case SQCONTEXT::CLIENT:
|
case SQCONTEXT::CLIENT:
|
||||||
context = SQCONTEXT::CLIENT;
|
context = SQCONTEXT::CLIENT;
|
||||||
|
nResponseId = -2;
|
||||||
break;
|
break;
|
||||||
case SQCONTEXT::UI:
|
case SQCONTEXT::UI:
|
||||||
context = SQCONTEXT::UI;
|
context = SQCONTEXT::UI;
|
||||||
|
nResponseId = -1;
|
||||||
break;
|
break;
|
||||||
case SQCONTEXT::NONE:
|
case SQCONTEXT::NONE:
|
||||||
context = SQCONTEXT::NONE;
|
context = SQCONTEXT::NONE;
|
||||||
|
nResponseId = -4;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
#if !defined (GAMEDLL_S0) && !defined (GAMEDLL_S1) && !defined (GAMEDLL_S2)
|
#if !defined (GAMEDLL_S0) && !defined (GAMEDLL_S1) && !defined (GAMEDLL_S2)
|
||||||
@ -53,8 +58,27 @@ SQRESULT SQVM_PrintFunc(HSQUIRRELVM v, SQChar* fmt, ...)
|
|||||||
#else // Nothing equal to 'rdx + 18h' exist in the vm structs for anything below S3.
|
#else // Nothing equal to 'rdx + 18h' exist in the vm structs for anything below S3.
|
||||||
context = SQVM_GetContextIndex(v);
|
context = SQVM_GetContextIndex(v);
|
||||||
#endif
|
#endif
|
||||||
|
switch (context)
|
||||||
|
{
|
||||||
|
case SQCONTEXT::SERVER:
|
||||||
|
nResponseId = -3;
|
||||||
|
break;
|
||||||
|
case SQCONTEXT::CLIENT:
|
||||||
|
nResponseId = -2;
|
||||||
|
break;
|
||||||
|
case SQCONTEXT::UI:
|
||||||
|
nResponseId = -1;
|
||||||
|
break;
|
||||||
|
case SQCONTEXT::NONE:
|
||||||
|
nResponseId = -4;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
nResponseId = -4;
|
||||||
|
break;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SQChar buf[4096] = {};
|
static SQChar buf[4096] = {};
|
||||||
static std::string vmStr;
|
static std::string vmStr;
|
||||||
static std::regex rxAnsiExp("\\\033\\[.*?m");
|
static std::regex rxAnsiExp("\\\033\\[.*?m");
|
||||||
@ -89,7 +113,7 @@ SQRESULT SQVM_PrintFunc(HSQUIRRELVM v, SQChar* fmt, ...)
|
|||||||
{
|
{
|
||||||
wconsole->debug(vmStr);
|
wconsole->debug(vmStr);
|
||||||
#ifdef DEDICATED
|
#ifdef DEDICATED
|
||||||
RCONServer()->Send(RCONServer()->Serialize(vmStr, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG));
|
RCONServer()->Send(RCONServer()->Serialize(vmStr, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG, nResponseId));
|
||||||
#endif // DEDICATED
|
#endif // DEDICATED
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -135,7 +159,7 @@ SQRESULT SQVM_PrintFunc(HSQUIRRELVM v, SQChar* fmt, ...)
|
|||||||
vmStrAnsi.append(buf);
|
vmStrAnsi.append(buf);
|
||||||
wconsole->debug(vmStrAnsi);
|
wconsole->debug(vmStrAnsi);
|
||||||
#ifdef DEDICATED
|
#ifdef DEDICATED
|
||||||
RCONServer()->Send(RCONServer()->Serialize(vmStrAnsi, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG));
|
RCONServer()->Send(RCONServer()->Serialize(vmStrAnsi, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG, nResponseId));
|
||||||
#endif // DEDICATED
|
#endif // DEDICATED
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,7 +199,7 @@ SQRESULT SQVM_PrintFunc(HSQUIRRELVM v, SQChar* fmt, ...)
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_pConsole->AddLog(ConLog_t(g_spd_sys_w_oss.str(), color));
|
g_pConsole->AddLog(ConLog_t(g_spd_sys_w_oss.str(), color));
|
||||||
g_pLogSystem.AddLog(static_cast<LogType_t>(context), g_spd_sys_w_oss.str());
|
g_pLogSystem.AddLog(static_cast<LogType_t>(nResponseId), g_spd_sys_w_oss.str());
|
||||||
|
|
||||||
g_spd_sys_w_oss.str("");
|
g_spd_sys_w_oss.str("");
|
||||||
g_spd_sys_w_oss.clear();
|
g_spd_sys_w_oss.clear();
|
||||||
@ -198,6 +222,7 @@ SQRESULT SQVM_PrintFunc(HSQUIRRELVM v, SQChar* fmt, ...)
|
|||||||
SQRESULT SQVM_WarningFunc(HSQUIRRELVM v, SQInteger a2, SQInteger a3, SQInteger* nStringSize, SQChar** ppString)
|
SQRESULT SQVM_WarningFunc(HSQUIRRELVM v, SQInteger a2, SQInteger a3, SQInteger* nStringSize, SQChar** ppString)
|
||||||
{
|
{
|
||||||
static void* retaddr = reinterpret_cast<void*>(p_SQVM_WarningCmd.Offset(0x10).FindPatternSelf("85 ?? ?? 99", CMemory::Direction::DOWN).GetPtr());
|
static void* retaddr = reinterpret_cast<void*>(p_SQVM_WarningCmd.Offset(0x10).FindPatternSelf("85 ?? ?? 99", CMemory::Direction::DOWN).GetPtr());
|
||||||
|
int nResponseId;
|
||||||
SQCONTEXT context;
|
SQCONTEXT context;
|
||||||
SQRESULT result = v_SQVM_WarningFunc(v, a2, a3, nStringSize, ppString);
|
SQRESULT result = v_SQVM_WarningFunc(v, a2, a3, nStringSize, ppString);
|
||||||
|
|
||||||
@ -213,6 +238,25 @@ SQRESULT SQVM_WarningFunc(HSQUIRRELVM v, SQInteger a2, SQInteger a3, SQInteger*
|
|||||||
context = SQVM_GetContextIndex(v);
|
context = SQVM_GetContextIndex(v);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
switch (context)
|
||||||
|
{
|
||||||
|
case SQCONTEXT::SERVER:
|
||||||
|
nResponseId = -3;
|
||||||
|
break;
|
||||||
|
case SQCONTEXT::CLIENT:
|
||||||
|
nResponseId = -2;
|
||||||
|
break;
|
||||||
|
case SQCONTEXT::UI:
|
||||||
|
nResponseId = -1;
|
||||||
|
break;
|
||||||
|
case SQCONTEXT::NONE:
|
||||||
|
nResponseId = -4;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
nResponseId = -4;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
static std::shared_ptr<spdlog::logger> iconsole = spdlog::get("game_console");
|
static std::shared_ptr<spdlog::logger> iconsole = spdlog::get("game_console");
|
||||||
static std::shared_ptr<spdlog::logger> wconsole = spdlog::get("win_console");
|
static std::shared_ptr<spdlog::logger> wconsole = spdlog::get("win_console");
|
||||||
static std::shared_ptr<spdlog::logger> sqlogger = spdlog::get("sqvm_warn");
|
static std::shared_ptr<spdlog::logger> sqlogger = spdlog::get("sqvm_warn");
|
||||||
@ -229,7 +273,7 @@ SQRESULT SQVM_WarningFunc(HSQUIRRELVM v, SQInteger a2, SQInteger a3, SQInteger*
|
|||||||
{
|
{
|
||||||
wconsole->debug(vmStr);
|
wconsole->debug(vmStr);
|
||||||
#ifdef DEDICATED
|
#ifdef DEDICATED
|
||||||
RCONServer()->Send(RCONServer()->Serialize(vmStr, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG));
|
RCONServer()->Send(RCONServer()->Serialize(vmStr, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG, nResponseId));
|
||||||
#endif // DEDICATED
|
#endif // DEDICATED
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -239,7 +283,7 @@ SQRESULT SQVM_WarningFunc(HSQUIRRELVM v, SQInteger a2, SQInteger a3, SQInteger*
|
|||||||
vmStrAnsi.append(svConstructor);
|
vmStrAnsi.append(svConstructor);
|
||||||
wconsole->debug(vmStrAnsi);
|
wconsole->debug(vmStrAnsi);
|
||||||
#ifdef DEDICATED
|
#ifdef DEDICATED
|
||||||
RCONServer()->Send(RCONServer()->Serialize(vmStrAnsi, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG));
|
RCONServer()->Send(RCONServer()->Serialize(vmStrAnsi, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG, nResponseId));
|
||||||
#endif // DEDICATED
|
#endif // DEDICATED
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include "tier0/dbg.h"
|
#include "tier0/dbg.h"
|
||||||
#include "tier0/platform.h"
|
#include "tier0/platform.h"
|
||||||
#include "tier0/threadtools.h"
|
#include "tier0/threadtools.h"
|
||||||
#include <tier0/commandline.h>
|
#include "tier0/commandline.h"
|
||||||
#ifndef DEDICATED
|
#ifndef DEDICATED
|
||||||
#include "vgui/vgui_debugpanel.h"
|
#include "vgui/vgui_debugpanel.h"
|
||||||
#include "gameui/IConsole.h"
|
#include "gameui/IConsole.h"
|
||||||
@ -89,9 +89,199 @@ PLATFORM_INTERFACE void AssertValidWStringPtr(const wchar_t* ptr, int maxchar/*
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// Purpose: Netconsole log
|
||||||
|
// Input : context -
|
||||||
|
// *fmt - ... -
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
void NetMsg(int context, const char* fmt, ...)
|
||||||
|
{
|
||||||
|
#ifndef DEDICATED
|
||||||
|
static char szBuf[4096] = {};
|
||||||
|
static std::string svOut;
|
||||||
|
static std::regex rxAnsiExp("\\\033\\[.*?m");
|
||||||
|
static std::shared_ptr<spdlog::logger> iconsole = spdlog::get("game_console");
|
||||||
|
static std::shared_ptr<spdlog::logger> wconsole = spdlog::get("win_console");
|
||||||
|
static std::shared_ptr<spdlog::logger> ntlogger = spdlog::get("net_con");
|
||||||
|
switch (context)
|
||||||
|
{
|
||||||
|
case -3:
|
||||||
|
case -2:
|
||||||
|
case -1:
|
||||||
|
{
|
||||||
|
s_LogMutex.lock();
|
||||||
|
{/////////////////////////////
|
||||||
|
va_list args{};
|
||||||
|
va_start(args, fmt);
|
||||||
|
|
||||||
|
vsnprintf(szBuf, sizeof(szBuf), fmt, args);
|
||||||
|
|
||||||
|
szBuf[sizeof(szBuf) - 1] = 0;
|
||||||
|
va_end(args);
|
||||||
|
}/////////////////////////////
|
||||||
|
|
||||||
|
svOut = szBuf;
|
||||||
|
if (svOut.back() != '\n')
|
||||||
|
{
|
||||||
|
svOut.append("\n");
|
||||||
|
}
|
||||||
|
ImVec4 color;
|
||||||
|
|
||||||
|
if (svOut.find("\033[38;2;255;255;000m") != std::string::npos)
|
||||||
|
{ // Warning.
|
||||||
|
color = ImVec4(1.00f, 1.00f, 0.00f, 0.80f);
|
||||||
|
context = static_cast<int>(LogType_t::WARNING_C);
|
||||||
|
}
|
||||||
|
else if (svOut.find("\033[38;2;255;000;000m") != std::string::npos)
|
||||||
|
{ // Error.
|
||||||
|
color = ImVec4(1.00f, 0.00f, 0.00f, 0.80f);
|
||||||
|
context = static_cast<int>(LogType_t::ERROR_C);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (context)
|
||||||
|
{
|
||||||
|
case -3: // [ SERVER ]
|
||||||
|
color = ImVec4(0.59f, 0.58f, 0.73f, 1.00f);
|
||||||
|
break;
|
||||||
|
case -2: // [ CLIENT ]
|
||||||
|
color = ImVec4(0.59f, 0.58f, 0.63f, 1.00f);
|
||||||
|
break;
|
||||||
|
case -1: // [ UI ]
|
||||||
|
color = ImVec4(0.59f, 0.48f, 0.53f, 1.00f);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
color = ImVec4(0.59f, 0.58f, 0.63f, 1.00f);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_bSpdLog_UseAnsiClr)
|
||||||
|
{
|
||||||
|
wconsole->debug(svOut);
|
||||||
|
svOut = std::regex_replace(svOut, rxAnsiExp, "");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
svOut = std::regex_replace(svOut, rxAnsiExp, "");
|
||||||
|
wconsole->debug(svOut);
|
||||||
|
}
|
||||||
|
|
||||||
|
ntlogger->debug(svOut);
|
||||||
|
iconsole->debug(svOut);
|
||||||
|
|
||||||
|
g_pConsole->AddLog(ConLog_t(g_spd_sys_w_oss.str(), color));
|
||||||
|
g_pLogSystem.AddLog(static_cast<LogType_t>(context), g_spd_sys_w_oss.str());
|
||||||
|
|
||||||
|
g_spd_sys_w_oss.str("");
|
||||||
|
g_spd_sys_w_oss.clear();
|
||||||
|
|
||||||
|
s_LogMutex.unlock();
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 0:
|
||||||
|
case 1:
|
||||||
|
case 2:
|
||||||
|
case 3:
|
||||||
|
case 4:
|
||||||
|
case 5:
|
||||||
|
case 6:
|
||||||
|
{
|
||||||
|
s_LogMutex.lock();
|
||||||
|
{/////////////////////////////
|
||||||
|
va_list args{};
|
||||||
|
va_start(args, fmt);
|
||||||
|
|
||||||
|
vsnprintf(szBuf, sizeof(szBuf), fmt, args);
|
||||||
|
|
||||||
|
szBuf[sizeof(szBuf) - 1] = 0;
|
||||||
|
va_end(args);
|
||||||
|
}/////////////////////////////
|
||||||
|
|
||||||
|
svOut = szBuf;
|
||||||
|
if (svOut.back() != '\n')
|
||||||
|
{
|
||||||
|
svOut.append("\n");
|
||||||
|
}
|
||||||
|
ImVec4 color;
|
||||||
|
|
||||||
|
if (svOut.find("\033[38;2;255;255;000;") != std::string::npos)
|
||||||
|
{ // Warning.
|
||||||
|
color = ImVec4(1.00f, 1.00f, 0.00f, 0.80f);
|
||||||
|
context = static_cast<int>(LogType_t::WARNING_C);
|
||||||
|
}
|
||||||
|
else if (svOut.find("\033[38;2;255;000;000;") != std::string::npos)
|
||||||
|
{ // Error.
|
||||||
|
color = ImVec4(1.00f, 0.00f, 0.00f, 0.80f);
|
||||||
|
context = static_cast<int>(LogType_t::ERROR_C);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (static_cast<eDLL_T>(context))
|
||||||
|
{
|
||||||
|
case eDLL_T::SERVER:
|
||||||
|
color = ImVec4(0.23f, 0.47f, 0.85f, 1.00f);
|
||||||
|
break;
|
||||||
|
case eDLL_T::CLIENT:
|
||||||
|
color = ImVec4(0.46f, 0.46f, 0.46f, 1.00f);
|
||||||
|
break;
|
||||||
|
case eDLL_T::UI:
|
||||||
|
color = ImVec4(0.59f, 0.35f, 0.46f, 1.00f);
|
||||||
|
break;
|
||||||
|
case eDLL_T::ENGINE:
|
||||||
|
color = ImVec4(0.70f, 0.70f, 0.70f, 1.00f);
|
||||||
|
break;
|
||||||
|
case eDLL_T::FS:
|
||||||
|
color = ImVec4(0.32f, 0.64f, 0.72f, 1.00f);
|
||||||
|
break;
|
||||||
|
case eDLL_T::RTECH:
|
||||||
|
color = ImVec4(0.36f, 0.70f, 0.35f, 1.00f);
|
||||||
|
break;
|
||||||
|
case eDLL_T::MS:
|
||||||
|
color = ImVec4(0.75f, 0.41f, 0.67f, 1.00f);
|
||||||
|
break;
|
||||||
|
case eDLL_T::NETCON:
|
||||||
|
color = ImVec4(0.81f, 0.81f, 0.81f, 1.00f);
|
||||||
|
break;
|
||||||
|
case eDLL_T::COMMON:
|
||||||
|
color = ImVec4(1.00f, 0.80f, 0.60f, 1.00f);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
color = ImVec4(0.81f, 0.81f, 0.81f, 1.00f);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_bSpdLog_UseAnsiClr)
|
||||||
|
{
|
||||||
|
wconsole->debug(svOut);
|
||||||
|
svOut = std::regex_replace(svOut, rxAnsiExp, "");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
svOut = std::regex_replace(svOut, rxAnsiExp, "");
|
||||||
|
wconsole->debug(svOut);
|
||||||
|
}
|
||||||
|
|
||||||
|
ntlogger->debug(svOut);
|
||||||
|
iconsole->info(svOut);
|
||||||
|
|
||||||
|
g_pConsole->AddLog(ConLog_t(g_spd_sys_w_oss.str(), color));
|
||||||
|
g_pLogSystem.AddLog(static_cast<LogType_t>(context), g_spd_sys_w_oss.str());
|
||||||
|
|
||||||
|
g_spd_sys_w_oss.str("");
|
||||||
|
g_spd_sys_w_oss.clear();
|
||||||
|
s_LogMutex.unlock();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // !DEDICATED
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: Show logs to all console interfaces
|
// Purpose: Show logs to all console interfaces
|
||||||
// Input : idx -
|
// Input : context -
|
||||||
// *fmt - ... -
|
// *fmt - ... -
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void DevMsg(eDLL_T context, const char* fmt, ...)
|
void DevMsg(eDLL_T context, const char* fmt, ...)
|
||||||
@ -132,7 +322,7 @@ void DevMsg(eDLL_T context, const char* fmt, ...)
|
|||||||
{
|
{
|
||||||
wconsole->debug(svOut);
|
wconsole->debug(svOut);
|
||||||
#ifdef DEDICATED
|
#ifdef DEDICATED
|
||||||
RCONServer()->Send(RCONServer()->Serialize(svOut, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG));
|
RCONServer()->Send(RCONServer()->Serialize(svOut, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG, static_cast<int>(context)));
|
||||||
#endif // DEDICATED
|
#endif // DEDICATED
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -147,7 +337,7 @@ void DevMsg(eDLL_T context, const char* fmt, ...)
|
|||||||
}
|
}
|
||||||
wconsole->debug(svAnsiOut);
|
wconsole->debug(svAnsiOut);
|
||||||
#ifdef DEDICATED
|
#ifdef DEDICATED
|
||||||
RCONServer()->Send(RCONServer()->Serialize(svAnsiOut, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG));
|
RCONServer()->Send(RCONServer()->Serialize(svAnsiOut, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG, static_cast<int>(context)));
|
||||||
#endif // DEDICATED
|
#endif // DEDICATED
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,10 +346,9 @@ void DevMsg(eDLL_T context, const char* fmt, ...)
|
|||||||
#ifndef DEDICATED
|
#ifndef DEDICATED
|
||||||
iconsole->info(svOut);
|
iconsole->info(svOut);
|
||||||
|
|
||||||
int nLog = static_cast<int>(context) + 3; // RUI log enum is shifted by 3 for scripts.
|
LogType_t tLog = static_cast<LogType_t>(context);
|
||||||
LogType_t tLog = static_cast<LogType_t>(nLog);
|
|
||||||
|
|
||||||
ImVec4 color;
|
ImVec4 color;
|
||||||
|
|
||||||
switch (context)
|
switch (context)
|
||||||
{
|
{
|
||||||
case eDLL_T::SERVER:
|
case eDLL_T::SERVER:
|
||||||
@ -183,6 +372,12 @@ void DevMsg(eDLL_T context, const char* fmt, ...)
|
|||||||
case eDLL_T::MS:
|
case eDLL_T::MS:
|
||||||
color = ImVec4(0.75f, 0.41f, 0.67f, 1.00f);
|
color = ImVec4(0.75f, 0.41f, 0.67f, 1.00f);
|
||||||
break;
|
break;
|
||||||
|
case eDLL_T::NETCON:
|
||||||
|
color = ImVec4(0.81f, 0.81f, 0.81f, 1.00f);
|
||||||
|
break;
|
||||||
|
case eDLL_T::COMMON:
|
||||||
|
color = ImVec4(1.00f, 0.80f, 0.60f, 1.00f);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
color = ImVec4(0.81f, 0.81f, 0.81f, 1.00f);
|
color = ImVec4(0.81f, 0.81f, 0.81f, 1.00f);
|
||||||
break;
|
break;
|
||||||
@ -199,7 +394,7 @@ void DevMsg(eDLL_T context, const char* fmt, ...)
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: Print engine and SDK errors
|
// Purpose: Print engine and SDK errors
|
||||||
// Input : idx -
|
// Input : context -
|
||||||
// *fmt - ... -
|
// *fmt - ... -
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Warning(eDLL_T context, const char* fmt, ...)
|
void Warning(eDLL_T context, const char* fmt, ...)
|
||||||
@ -240,7 +435,7 @@ void Warning(eDLL_T context, const char* fmt, ...)
|
|||||||
{
|
{
|
||||||
wconsole->debug(svOut);
|
wconsole->debug(svOut);
|
||||||
#ifdef DEDICATED
|
#ifdef DEDICATED
|
||||||
RCONServer()->Send(RCONServer()->Serialize(svOut, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG));
|
RCONServer()->Send(RCONServer()->Serialize(svOut, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG, static_cast<int>(context)));
|
||||||
#endif // DEDICATED
|
#endif // DEDICATED
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -256,7 +451,7 @@ void Warning(eDLL_T context, const char* fmt, ...)
|
|||||||
}
|
}
|
||||||
wconsole->debug(svAnsiOut);
|
wconsole->debug(svAnsiOut);
|
||||||
#ifdef DEDICATED
|
#ifdef DEDICATED
|
||||||
RCONServer()->Send(RCONServer()->Serialize(svAnsiOut, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG));
|
RCONServer()->Send(RCONServer()->Serialize(svAnsiOut, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG, static_cast<int>(context)));
|
||||||
#endif // DEDICATED
|
#endif // DEDICATED
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,7 +471,7 @@ void Warning(eDLL_T context, const char* fmt, ...)
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: Print engine and SDK errors
|
// Purpose: Print engine and SDK errors
|
||||||
// Input : idx -
|
// Input : context -
|
||||||
// *fmt - ... -
|
// *fmt - ... -
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void Error(eDLL_T context, const char* fmt, ...)
|
void Error(eDLL_T context, const char* fmt, ...)
|
||||||
@ -317,7 +512,7 @@ void Error(eDLL_T context, const char* fmt, ...)
|
|||||||
{
|
{
|
||||||
wconsole->debug(svOut);
|
wconsole->debug(svOut);
|
||||||
#ifdef DEDICATED
|
#ifdef DEDICATED
|
||||||
RCONServer()->Send(RCONServer()->Serialize(svOut, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG));
|
RCONServer()->Send(RCONServer()->Serialize(svOut, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG, static_cast<int>(context)));
|
||||||
#endif // DEDICATED
|
#endif // DEDICATED
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -333,7 +528,7 @@ void Error(eDLL_T context, const char* fmt, ...)
|
|||||||
}
|
}
|
||||||
wconsole->debug(svAnsiOut);
|
wconsole->debug(svAnsiOut);
|
||||||
#ifdef DEDICATED
|
#ifdef DEDICATED
|
||||||
RCONServer()->Send(RCONServer()->Serialize(svAnsiOut, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG));
|
RCONServer()->Send(RCONServer()->Serialize(svAnsiOut, "", sv_rcon::response_t::SERVERDATA_RESPONSE_CONSOLE_LOG, static_cast<int>(context)));
|
||||||
#endif // DEDICATED
|
#endif // DEDICATED
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ enum class eDLL_T : int
|
|||||||
RTECH = 5, // RTech API
|
RTECH = 5, // RTech API
|
||||||
MS = 6, // Material System
|
MS = 6, // Material System
|
||||||
NETCON = 7, // Net Console
|
NETCON = 7, // Net Console
|
||||||
NONE = 8
|
COMMON = 8
|
||||||
};
|
};
|
||||||
|
|
||||||
const string sDLL_T[9] =
|
const string sDLL_T[9] =
|
||||||
@ -49,7 +49,7 @@ const static string sANSI_DLL_T[9] =
|
|||||||
"\033[38;2;092;181;089mNative(R):",
|
"\033[38;2;092;181;089mNative(R):",
|
||||||
"\033[38;2;192;105;173mNative(M):",
|
"\033[38;2;192;105;173mNative(M):",
|
||||||
"\033[38;2;204;204;204mNetcon(X):",
|
"\033[38;2;204;204;204mNetcon(X):",
|
||||||
""
|
"\033[38;2;255;204;153m"
|
||||||
};
|
};
|
||||||
extern std::mutex s_LogMutex;
|
extern std::mutex s_LogMutex;
|
||||||
|
|
||||||
@ -58,6 +58,7 @@ extern std::mutex s_LogMutex;
|
|||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// These functions do not return.
|
// These functions do not return.
|
||||||
|
PLATFORM_INTERFACE void NetMsg(int context, const char* fmt, ...) FMTFUNCTION(2, 3);
|
||||||
PLATFORM_INTERFACE void DevMsg(eDLL_T context, const char* fmt, ...) FMTFUNCTION(2, 3);
|
PLATFORM_INTERFACE void DevMsg(eDLL_T context, const char* fmt, ...) FMTFUNCTION(2, 3);
|
||||||
PLATFORM_INTERFACE void Warning(eDLL_T context, const char* fmt, ...) FMTFUNCTION(1, 2);
|
PLATFORM_INTERFACE void Warning(eDLL_T context, const char* fmt, ...) FMTFUNCTION(1, 2);
|
||||||
PLATFORM_INTERFACE void Error(eDLL_T context, const char* fmt, ...) FMTFUNCTION(1, 2);
|
PLATFORM_INTERFACE void Error(eDLL_T context, const char* fmt, ...) FMTFUNCTION(1, 2);
|
||||||
|
@ -256,6 +256,8 @@ Color CLogSystem::GetLogColorForType(LogType_t type) const
|
|||||||
return { cl_conoverlay_native_ms_clr->GetColor() };
|
return { cl_conoverlay_native_ms_clr->GetColor() };
|
||||||
case LogType_t::NETCON_S:
|
case LogType_t::NETCON_S:
|
||||||
return { cl_conoverlay_netcon_clr->GetColor() };
|
return { cl_conoverlay_netcon_clr->GetColor() };
|
||||||
|
case LogType_t::COMMON_C:
|
||||||
|
return { cl_conoverlay_common_clr->GetColor() };
|
||||||
case LogType_t::WARNING_C:
|
case LogType_t::WARNING_C:
|
||||||
return { cl_conoverlay_warning_clr->GetColor() };
|
return { cl_conoverlay_warning_clr->GetColor() };
|
||||||
case LogType_t::ERROR_C:
|
case LogType_t::ERROR_C:
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
enum class LogType_t : int
|
enum class LogType_t : int
|
||||||
{
|
{
|
||||||
SCRIPT_SERVER,
|
SCRIPT_SERVER = -3,
|
||||||
SCRIPT_CLIENT,
|
SCRIPT_CLIENT,
|
||||||
SCRIPT_UI,
|
SCRIPT_UI,
|
||||||
NATIVE_SERVER,
|
NATIVE_SERVER,
|
||||||
@ -15,6 +15,7 @@ enum class LogType_t : int
|
|||||||
NATIVE_RTECH,
|
NATIVE_RTECH,
|
||||||
NATIVE_MS,
|
NATIVE_MS,
|
||||||
NETCON_S,
|
NETCON_S,
|
||||||
|
COMMON_C,
|
||||||
WARNING_C,
|
WARNING_C,
|
||||||
ERROR_C,
|
ERROR_C,
|
||||||
NONE
|
NONE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user