2
0

Log.cpp 791 B

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