diff --git a/r5dev/core/logger.cpp b/r5dev/core/logger.cpp index e6d34f2f..d98b0825 100644 --- a/r5dev/core/logger.cpp +++ b/r5dev/core/logger.cpp @@ -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 ntlogger = spdlog::get(pszLogger); // <-- Obtain by 'pszLogger'. diff --git a/r5dev/public/tier0/platform.h b/r5dev/public/tier0/platform.h index 15a8ac37..31bb5279 100644 --- a/r5dev/public/tier0/platform.h +++ b/r5dev/public/tier0/platform.h @@ -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