r5sdk/r5dev/tier0/platform.cpp
Kawe Mazidjatari 3d6d6644bd Logging bug fix and error handling improvements
* Replaced the boolean 'fatal' parameter with a error code parameter, anything non-null will prompt a message (fatal) and terminate the process with given error code.
* Fixed bug where the global ostreamsink for spdlog did NOT get cleared in 'SQVM_PrintFunc' when cvar 'sq_showvmoutput' was < 3. Moved to global scope.
* Added error message for when detouring the process has failed, with the error code.
* Only call 'Plat_GetProcessUpTime()' once per log, (improves performance and fixes bug where the error message box would show a different time stamp than what is logged into the console or file).
* All TIER0 loggers only log to notify and console when the SDK engine has fully initialized and detoured all functions.
2022-09-14 00:39:38 +02:00

42 lines
1.4 KiB
C++

#include "core/stdafx.h"
#include "tier0/platform_internal.h"
//-----------------------------------------------------------------------------
// Purpose: gets the process up time in seconds
// Output : double
//-----------------------------------------------------------------------------
double Plat_FloatTime()
{
return v_Plat_FloatTime();
}
//-----------------------------------------------------------------------------
// Purpose: gets the process up time in milliseconds
// Output : uint64_t
//-----------------------------------------------------------------------------
uint64_t Plat_MSTime()
{
return v_Plat_MSTime();
}
//-----------------------------------------------------------------------------
// Purpose: gets the process up time ( !! INTERNAL ONLY !! DO NOT USE !! ).
// Output : const char*
//-----------------------------------------------------------------------------
const char* Plat_GetProcessUpTime()
{
static char szBuf[4096];
sprintf_s(szBuf, sizeof(szBuf), "[%.3f] ", Plat_FloatTime());
return szBuf;
}
//-----------------------------------------------------------------------------
// Purpose: gets the process up time.
// Input : *szBuf -
// nSize -
//-----------------------------------------------------------------------------
void Plat_GetProcessUpTime(char* szBuf, size_t nSize)
{
sprintf_s(szBuf, nSize, "[%.3f] ", Plat_FloatTime());
}