1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-02 09:03:37 +00:00
GLideN64/src/Log.cpp

53 lines
1.1 KiB
C++
Raw Normal View History

#include <stdarg.h>
#include <stdio.h>
2017-03-03 10:41:18 +00:00
#include <stdlib.h>
2017-09-06 18:08:41 +00:00
#include <cwchar>
#include "Log.h"
#include "PluginAPI.h"
#include "wst.h"
2019-02-23 00:40:58 +00:00
#include <mutex>
std::mutex g_logMutex;
void LOG(u16 type, const char * format, ...) {
if (type > LOG_LEVEL)
return;
2019-02-23 00:40:58 +00:00
std::unique_lock<std::mutex> lock(g_logMutex);
wchar_t logPath[PLUGIN_PATH_SIZE + 16];
api().GetUserDataPath(logPath);
gln_wcscat(logPath, wst("/gliden64.log"));
2018-11-14 20:09:17 +00:00
#ifdef OS_WINDOWS
FILE *dumpFile = _wfopen(logPath, wst("a+"));
#else
2016-11-22 02:40:05 +00:00
constexpr size_t bufSize = PLUGIN_PATH_SIZE * 6;
char cbuf[bufSize];
wcstombs(cbuf, logPath, bufSize);
FILE *dumpFile = fopen(cbuf, "a+");
2018-11-14 20:09:17 +00:00
#endif //OS_WINDOWS
if (dumpFile == nullptr)
return;
va_list va;
va_start(va, format);
vfprintf(dumpFile, format, va);
fclose(dumpFile);
va_end(va);
}
2018-11-14 20:09:17 +00:00
#if defined(OS_WINDOWS) && !defined(MINGW)
#include "windows/GLideN64_windows.h"
void debugPrint(const char * format, ...) {
char text[256];
wchar_t wtext[256];
va_list va;
va_start(va, format);
vsprintf(text, format, va);
mbstowcs(wtext, text, 256);
OutputDebugString(wtext);
va_end(va);
}
#endif