1
0

log.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include "api.h"
  2. #include <api/syscb/callbacks/consolecb.h>
  3. #include <time.h>
  4. #include <strsafe.h>
  5. void Log(const wchar_t *format, ...)
  6. {
  7. wchar_t buffer[2048] = {0}; // hope it's big enough :)
  8. va_list args;
  9. va_start (args, format);
  10. StringCbVPrintf(buffer, sizeof(buffer), format, args);
  11. WASABI_API_SYSCB->syscb_issueCallback(SysCallback::CONSOLE, ConsoleCallback::DEBUGMESSAGE, 0, reinterpret_cast<intptr_t>(buffer));
  12. va_end(args);
  13. }
  14. const wchar_t *MakeDateString(__time64_t convertTime)
  15. {
  16. static wchar_t dest[2048];
  17. SYSTEMTIME sysTime;
  18. tm *newtime = _localtime64(&convertTime);
  19. if (newtime)
  20. {
  21. sysTime.wYear = (WORD)(newtime->tm_year + 1900);
  22. sysTime.wMonth = (WORD)(newtime->tm_mon + 1);
  23. sysTime.wDayOfWeek = (WORD)newtime->tm_wday;
  24. sysTime.wDay = (WORD)newtime->tm_mday;
  25. sysTime.wHour = (WORD)newtime->tm_hour;
  26. sysTime.wMinute = (WORD)newtime->tm_min;
  27. sysTime.wSecond = (WORD)newtime->tm_sec;
  28. sysTime.wMilliseconds = 0;
  29. GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &sysTime, NULL, dest, 2048);
  30. //wcsftime(expire_time, 63, L"%b %d, %Y", _localtime64(&convertTime));
  31. }
  32. else
  33. dest[0] = 0;
  34. return dest;
  35. }