Optimize sqvm and net logger

This commit is contained in:
Amos 2021-08-06 14:43:52 -07:00
parent 7b39eb1b42
commit 92673caebd
3 changed files with 12 additions and 11 deletions

View File

@ -8,6 +8,9 @@ namespace Hooks
NET_SendDatagramFn originalNET_SendDatagram = nullptr;
}
static std::ostringstream oss;
static auto ostream_sink = std::make_shared<spdlog::sinks::ostream_sink_st>(oss);
//-----------------------------------------------------------------------------
// Purpose: log the clients signonstate to the console
//-----------------------------------------------------------------------------
@ -18,8 +21,8 @@ void Hooks::NET_PrintFunc(const char* fmt, ...)
static auto iconsole = spdlog::stdout_logger_mt("net_iconsole"); // in-game console
static auto wconsole = spdlog::stdout_logger_mt("net_wconsole"); // windows console
std::ostringstream oss;
auto ostream_sink = std::make_shared<spdlog::sinks::ostream_sink_st>(oss);
oss.str("");
oss.clear();
iconsole = std::make_shared<spdlog::logger>("ostream", ostream_sink);
iconsole->set_pattern("[%S.%e] %v");

View File

@ -7,6 +7,9 @@ namespace Hooks
SQVM_LoadScriptFn originalSQVM_LoadScript = nullptr;
}
static std::ostringstream oss;
static auto ostream_sink = std::make_shared<spdlog::sinks::ostream_sink_st>(oss);
//---------------------------------------------------------------------------------
// Purpose: prints the output of each VM to the console
//---------------------------------------------------------------------------------
@ -21,8 +24,9 @@ void* Hooks::SQVM_Print(void* sqvm, char* fmt, ...)
static auto wconsole = spdlog::stdout_logger_mt("sqvm_wconsole"); // windows console
std::string vmStr = vmType[vmIdx].c_str();
std::ostringstream oss;
auto ostream_sink = std::make_shared<spdlog::sinks::ostream_sink_st>(oss);
oss.str("");
oss.clear();
iconsole = std::make_shared<spdlog::logger>("ostream", ostream_sink);
iconsole->set_pattern("[%S.%e] %v");

View File

@ -550,10 +550,4 @@ void SetupDXSwapChain()
{
CloseHandle(hThread);
}
}
//#################################################################################
// UTILS
//#################################################################################
}