LogDefault.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include "LogDefault.h"
  2. #include "../../Include/RmlUi/Core/StringUtilities.h"
  3. #ifdef RMLUI_PLATFORM_WIN32_NATIVE
  4. #include <windows.h>
  5. #else
  6. #include <stdio.h>
  7. #endif
  8. namespace Rml {
  9. #if defined RMLUI_PLATFORM_WIN32_NATIVE
  10. bool LogDefault::LogMessage(Log::Type type, const String& message)
  11. {
  12. #if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP)
  13. if (type == Log::LT_ASSERT)
  14. {
  15. String message_user = CreateString("%s\nWould you like to interrupt execution?", message.c_str());
  16. // Return TRUE if the user presses NO (continue execution)
  17. return (IDNO == MessageBoxA(nullptr, message_user.c_str(), "Assertion Failure", MB_YESNO | MB_ICONSTOP | MB_DEFBUTTON2 | MB_TASKMODAL));
  18. }
  19. else
  20. #endif
  21. {
  22. OutputDebugStringA(message.c_str());
  23. OutputDebugStringA("\r\n");
  24. }
  25. return true;
  26. }
  27. #else
  28. bool LogDefault::LogMessage(Log::Type /*type*/, const String& message)
  29. {
  30. #ifdef RMLUI_PLATFORM_EMSCRIPTEN
  31. puts(message.c_str());
  32. #else
  33. fprintf(stderr, "%s\n", message.c_str());
  34. #endif
  35. return true;
  36. }
  37. #endif
  38. } // namespace Rml