Log.cpp 714 B

12345678910111213141516171819202122232425262728293031323334
  1. // SPDX-FileCopyrightText: 2021 Jorrit Rouwe
  2. // SPDX-License-Identifier: MIT
  3. #include <TestFramework.h>
  4. #include <Utils/Log.h>
  5. #include <cstdarg>
  6. // Trace to TTY
  7. void TraceImpl(const char *inFMT, ...)
  8. {
  9. // Format the message
  10. va_list list;
  11. va_start(list, inFMT);
  12. char buffer[1024];
  13. vsnprintf(buffer, sizeof(buffer), inFMT, list);
  14. strcat_s(buffer, "\n");
  15. // Log to the output window
  16. OutputDebugStringA(buffer);
  17. }
  18. void FatalError [[noreturn]] (const char *inFMT, ...)
  19. {
  20. // Format the message
  21. va_list list;
  22. va_start(list, inFMT);
  23. char buffer[1024];
  24. vsnprintf(buffer, sizeof(buffer), inFMT, list);
  25. Trace("Fatal Error: %s", buffer);
  26. MessageBoxA(nullptr, buffer, "Fatal Error", MB_OK);
  27. exit(1);
  28. }