2
0

Log.cpp 729 B

1234567891011121314151617181920212223242526272829303132333435
  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. va_end(list);
  15. strcat_s(buffer, "\n");
  16. // Log to the output window
  17. OutputDebugStringA(buffer);
  18. }
  19. void FatalError [[noreturn]] (const char *inFMT, ...)
  20. {
  21. // Format the message
  22. va_list list;
  23. va_start(list, inFMT);
  24. char buffer[1024];
  25. vsnprintf(buffer, sizeof(buffer), inFMT, list);
  26. Trace("Fatal Error: %s", buffer);
  27. MessageBoxA(nullptr, buffer, "Fatal Error", MB_OK);
  28. exit(1);
  29. }