Debug Utilities
Logging, crash handling, runtime flags, and diagnostics in Nevo projects.
DebugManager Setup
Initialize logging near the start of main.cpp:
#include <debug/DebugManager.hpp>
Public::Debug::DebugManager::getInstance().Initialize("game.log");
Public::Debug::DebugManager::getInstance().EnableConsoleOutput(true);
Public::Debug::DebugManager::getInstance().SetMinLogLevel(
Public::Debug::DebugManager::LogLevel::Verbose
);Logs are written to the configured folder. Nevo-base uses game.log.
Log Macros
Use the macros for normal game and engine diagnostics:
LOG_VERBOSE("Detailed system update trace");
LOG_INFO("Scene loaded");
LOG_ASSERT("Developer checkpoint reached");
LOG_WARNING("Texture missing, using fallback");
LOG_ERROR("Failed to load material");
LOG_CRITICAL("Fatal initialization failure");| Level | Use |
|---|---|
Verbose | High-frequency or detailed debugging. |
Info | Normal milestones. |
Assert | High-visibility developer checkpoints. |
Warning | Recoverable suspicious state. |
Error | Operation failed but the app can continue. |
Critical | Severe failure or crash-adjacent state. |
Crash Handling
The public debug headers include helpers for platform crash reporting. Nevo-base/src/main.cpp sets an unhandled exception filter on Windows and signal handlers on Linux.
Windows pattern:
#ifdef _WIN32
#include <Windows.h>
LONG WINAPI UnhandledExceptionHandler(EXCEPTION_POINTERS* exceptionInfo) {
DWORD code = exceptionInfo ? exceptionInfo->ExceptionRecord->ExceptionCode : 0;
Public::Debug::DebugManager::getInstance().UnhandledExceptionHandler(
"Unhandled exception: code " + std::to_string(code)
);
return EXCEPTION_EXECUTE_HANDLER;
}
#endifThen install it before engine initialization:
#ifdef _WIN32
SetUnhandledExceptionFilter(UnhandledExceptionHandler);
#endifRuntime Flags
Pass command-line flags into the engine flag manager:
auto& engine = Public::Engine::getInstance();
engine.GetFlagManager().passFlags(argc, argv);
if (ISFLAG("--flagManTest")) {
LOG_ASSERT("Flag manager test passed.");
}The helper macros are defined in EngineExports.hpp:
ISFLAG("--name")
FLAGVALUE("--name")FLAGVALUE returns std::optional<std::string>.
System Information and Crash Context
Public debug helpers include:
| Header | Purpose |
|---|---|
<debug/SystemInfoManager.hpp> | OS, GPU, CPU, and RAM details. |
<debug/PlatformCrashHandler.hpp> | Stacktrace, memory info, modules, threads, process snapshot. |
<debug/Dx12CrashDiagnostics.hpp> | DRED-style DX12 crash reports where available. |
<debug/CrashDumpProviders.hpp> | Register providers for scene state and other dump text. |
Use these when adding engine-level diagnostics or richer crash reports. Gameplay code usually only needs DebugManager and the log macros.
