Tier0: emit text to debug console if debugger is attached

Small quality of life improvement while debugging the application.
This commit is contained in:
Kawe Mazidjatari 2024-02-19 19:44:38 +01:00
parent 802e1f42eb
commit def6d4da68
2 changed files with 30 additions and 0 deletions

View File

@ -271,6 +271,10 @@ void EngineLoggerSink(LogType_t logType, LogLevel_t logLevel, eDLL_T context,
}
}
// If a debugger is attached, emit the text there too
if (Plat_IsInDebugSession())
Plat_DebugString(message.c_str());
#ifndef _TOOLS
// Output is always logged to the file.
std::shared_ptr<spdlog::logger> ntlogger = spdlog::get(pszLogger); // <-- Obtain by 'pszLogger'.

View File

@ -406,6 +406,32 @@ uint64_t Plat_MSTime();
const char* Plat_GetProcessUpTime();
void Plat_GetProcessUpTime(char* szBuf, size_t nSize);
inline bool Plat_IsInDebugSession()
{
#if defined( _X360 )
return (XBX_IsDebuggerPresent() != 0);
#elif defined( _WIN32 )
return (IsDebuggerPresent() != 0);
#elif defined( _PS3 ) && !defined(_CERT)
return snIsDebuggerPresent();
#else
return false;
#endif
}
inline void Plat_DebugString(const char* psz)
{
#if defined( _X360 )
XBX_OutputDebugString(psz);
#elif defined( _WIN32 )
::OutputDebugStringA(psz);
#elif defined(_PS3)
printf("%s", psz);
#else
// do nothing?
#endif
}
#if defined( _X360 )
#define Plat_FastMemset XMemSet
#define Plat_FastMemcpy XMemCpy