mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Changed all loggers to use the internal 'CoreMsg/CoreMsgV' functions. Significantly reduced duplicate code and CPU time. Code is also much more robust. * Code now only acquires mutex lock when the actual logging part takes place. * Code now only checks and strip ANSI rows if its enabled to begin with. * Code now supports setting log levels, which ultimately could be tweaked with a cvar. * Changed logger and file names to be more readable. TODO: * The RCON protocol has to be modified to accommodate these changes.
121 lines
2.9 KiB
C++
121 lines
2.9 KiB
C++
//===========================================================================//
|
|
//
|
|
// Purpose: stub implementation of 'tier0/dbg.cpp'
|
|
//
|
|
//===========================================================================//
|
|
|
|
#include "core/stdafx.h"
|
|
|
|
void LogStub(const char* fmt, ...)
|
|
{
|
|
static char szBuf[4096] = {};
|
|
|
|
{/////////////////////////////
|
|
va_list args{};
|
|
va_start(args, fmt);
|
|
|
|
vsnprintf(szBuf, sizeof(szBuf), fmt, args);
|
|
|
|
szBuf[sizeof(szBuf) - 1] = '\0';
|
|
va_end(args);
|
|
}/////////////////////////////
|
|
|
|
printf("%s", szBuf);
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Purpose: Netconsole log
|
|
// Input : context -
|
|
// *fmt - ... -
|
|
//-----------------------------------------------------------------------------
|
|
void NetMsg(eDLL_T context, const char* fmt, ...)
|
|
{
|
|
static char szBuf[4096] = {};
|
|
|
|
{/////////////////////////////
|
|
va_list args{};
|
|
va_start(args, fmt);
|
|
|
|
vsnprintf(szBuf, sizeof(szBuf), fmt, args);
|
|
|
|
szBuf[sizeof(szBuf) - 1] = '\0';
|
|
va_end(args);
|
|
}/////////////////////////////
|
|
|
|
printf("%s", szBuf);
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Purpose: Show logs to all console interfaces
|
|
// Input : context -
|
|
// *fmt - ... -
|
|
//-----------------------------------------------------------------------------
|
|
void DevMsg(eDLL_T context, const char* fmt, ...)
|
|
{
|
|
static char szBuf[4096] = {};
|
|
|
|
{/////////////////////////////
|
|
va_list args{};
|
|
va_start(args, fmt);
|
|
|
|
vsnprintf(szBuf, sizeof(szBuf), fmt, args);
|
|
|
|
szBuf[sizeof(szBuf) - 1] = '\0';
|
|
va_end(args);
|
|
}/////////////////////////////
|
|
|
|
printf("%s", szBuf);
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Purpose: Print engine and SDK errors
|
|
// Input : context -
|
|
// *fmt - ... -
|
|
//-----------------------------------------------------------------------------
|
|
void Warning(eDLL_T context, const char* fmt, ...)
|
|
{
|
|
static char szBuf[4096] = {};
|
|
|
|
{/////////////////////////////
|
|
va_list args{};
|
|
va_start(args, fmt);
|
|
|
|
vsnprintf(szBuf, sizeof(szBuf), fmt, args);
|
|
|
|
szBuf[sizeof(szBuf) - 1] = '\0';
|
|
va_end(args);
|
|
}/////////////////////////////
|
|
|
|
printf("%s", szBuf);
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Purpose: Print engine and SDK errors
|
|
// Input : context -
|
|
// code -
|
|
// *fmt - ... -
|
|
//-----------------------------------------------------------------------------
|
|
void Error(eDLL_T context, const UINT code, const char* fmt, ...)
|
|
{
|
|
static char szBuf[4096] = {};
|
|
|
|
{/////////////////////////////
|
|
va_list args{};
|
|
va_start(args, fmt);
|
|
|
|
vsnprintf(szBuf, sizeof(szBuf), fmt, args);
|
|
|
|
szBuf[sizeof(szBuf) - 1] = '\0';
|
|
va_end(args);
|
|
}/////////////////////////////
|
|
|
|
printf("%s", szBuf);
|
|
if (code) // Terminate the process if an exit code was passed.
|
|
{
|
|
if (MessageBoxA(NULL, szBuf, "SDK Error", MB_ICONERROR | MB_OK))
|
|
{
|
|
TerminateProcess(GetCurrentProcess(), code);
|
|
}
|
|
}
|
|
}
|