2016-02-01 08:56:25 +00:00
|
|
|
#include "trace.h"
|
|
|
|
#include "Config.h"
|
2017-01-23 21:34:08 +00:00
|
|
|
#include "settings.h"
|
2016-02-05 23:53:58 +00:00
|
|
|
|
|
|
|
#include <string.h>
|
2016-02-01 08:56:25 +00:00
|
|
|
#include <Common/Trace.h>
|
|
|
|
#include <Common/path.h>
|
2021-04-14 05:34:15 +00:00
|
|
|
#include <Common/Log.h>
|
2017-01-23 21:11:51 +00:00
|
|
|
|
2016-02-01 08:56:25 +00:00
|
|
|
#ifdef ANDROID
|
|
|
|
#include <android/log.h>
|
|
|
|
|
|
|
|
class AndroidLogger : public CTraceModule
|
|
|
|
{
|
|
|
|
void Write(uint32_t module, uint8_t severity, const char * file, int line, const char * function, const char * Message)
|
|
|
|
{
|
|
|
|
switch (severity)
|
|
|
|
{
|
|
|
|
case TraceError: __android_log_print(ANDROID_LOG_ERROR, TraceModule(module), "%s: %s", function, Message); break;
|
|
|
|
case TraceWarning: __android_log_print(ANDROID_LOG_WARN, TraceModule(module), "%s: %s", function, Message); break;
|
|
|
|
case TraceNotice: __android_log_print(ANDROID_LOG_INFO, TraceModule(module), "%s: %s", function, Message); break;
|
|
|
|
case TraceInfo: __android_log_print(ANDROID_LOG_INFO, TraceModule(module), "%s: %s", function, Message); break;
|
|
|
|
case TraceDebug: __android_log_print(ANDROID_LOG_DEBUG, TraceModule(module), "%s: %s", function, Message); break;
|
|
|
|
case TraceVerbose: __android_log_print(ANDROID_LOG_VERBOSE, TraceModule(module), "%s: %s", function, Message); break;
|
|
|
|
default: __android_log_print(ANDROID_LOG_UNKNOWN, TraceModule(module), "%s: %s", function, Message); break;
|
|
|
|
}
|
|
|
|
}
|
2016-12-23 20:51:52 +00:00
|
|
|
|
|
|
|
void FlushTrace(void)
|
|
|
|
{
|
|
|
|
}
|
2016-02-01 08:56:25 +00:00
|
|
|
};
|
2021-04-12 11:35:39 +00:00
|
|
|
static AndroidLogger * g_AndroidLogger = nullptr;
|
2016-02-01 08:56:25 +00:00
|
|
|
#endif
|
|
|
|
|
2021-04-12 11:35:39 +00:00
|
|
|
static CTraceFileLog * g_LogFile = nullptr;
|
2016-02-01 08:56:25 +00:00
|
|
|
|
|
|
|
void SetupTrace(void)
|
|
|
|
{
|
2021-04-12 11:35:39 +00:00
|
|
|
if (g_LogFile != nullptr)
|
2016-02-01 08:56:25 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef ANDROID
|
2021-04-12 11:35:39 +00:00
|
|
|
if (g_AndroidLogger == nullptr)
|
2016-02-01 08:56:25 +00:00
|
|
|
{
|
|
|
|
g_AndroidLogger = new AndroidLogger();
|
|
|
|
}
|
|
|
|
TraceAddModule(g_AndroidLogger);
|
2016-03-10 18:29:41 +00:00
|
|
|
#endif
|
2016-02-01 08:56:25 +00:00
|
|
|
#ifdef _DEBUG
|
2016-02-04 10:22:19 +00:00
|
|
|
TraceSetMaxModule(MaxTraceModuleGlide64, TraceInfo);
|
2016-02-01 08:56:25 +00:00
|
|
|
#else
|
|
|
|
TraceSetMaxModule(MaxTraceModuleGlide64, TraceError);
|
|
|
|
#endif
|
2016-03-10 18:29:41 +00:00
|
|
|
|
2016-02-01 08:56:25 +00:00
|
|
|
TraceSetModuleName(TraceMD5, "MD5");
|
2016-04-17 19:34:47 +00:00
|
|
|
TraceSetModuleName(TraceThread, "Thread");
|
|
|
|
TraceSetModuleName(TracePath, "Path");
|
2016-02-01 08:56:25 +00:00
|
|
|
TraceSetModuleName(TraceSettings, "Settings");
|
|
|
|
TraceSetModuleName(TraceUnknown, "Unknown");
|
2016-02-04 10:22:19 +00:00
|
|
|
TraceSetModuleName(TraceGlide64, "Glide64");
|
2016-02-01 08:56:25 +00:00
|
|
|
TraceSetModuleName(TraceInterface, "Interface");
|
2016-02-04 10:22:19 +00:00
|
|
|
TraceSetModuleName(TraceResolution, "Resolution");
|
|
|
|
TraceSetModuleName(TraceGlitch, "Glitch");
|
2016-02-11 09:58:42 +00:00
|
|
|
TraceSetModuleName(TraceRDP, "RDP");
|
|
|
|
TraceSetModuleName(TraceTLUT, "TLUT");
|
2016-02-24 10:55:42 +00:00
|
|
|
TraceSetModuleName(TracePNG, "PNG");
|
2016-03-10 18:29:41 +00:00
|
|
|
TraceSetModuleName(TraceOGLWrapper, "OGL Wrapper");
|
2017-04-18 12:03:49 +00:00
|
|
|
TraceSetModuleName(TraceRDPCommands, "RDP Command");
|
|
|
|
}
|
2016-02-01 08:56:25 +00:00
|
|
|
|
2017-04-18 12:03:49 +00:00
|
|
|
void StartTrace(void)
|
|
|
|
{
|
2021-04-12 11:35:39 +00:00
|
|
|
const char * log_dir = g_settings ? g_settings->log_dir() : nullptr;
|
|
|
|
if (log_dir == nullptr || log_dir[0] == '\0')
|
2016-02-01 08:56:25 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-05-01 02:46:06 +00:00
|
|
|
CPath LogFilePath(log_dir, "Glide64.log");
|
2016-02-01 08:56:25 +00:00
|
|
|
if (!LogFilePath.DirectoryExists())
|
|
|
|
{
|
|
|
|
LogFilePath.DirectoryCreate();
|
|
|
|
}
|
2017-01-23 21:34:08 +00:00
|
|
|
g_LogFile = new CTraceFileLog(LogFilePath, g_settings->FlushLogs(), CLog::Log_New, 500);
|
2016-02-01 08:56:25 +00:00
|
|
|
TraceAddModule(g_LogFile);
|
2018-11-24 02:47:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void StopTrace(void)
|
|
|
|
{
|
|
|
|
if (g_LogFile)
|
|
|
|
{
|
|
|
|
TraceRemoveModule(g_LogFile);
|
|
|
|
delete g_LogFile;
|
2021-04-12 11:35:39 +00:00
|
|
|
g_LogFile = nullptr;
|
2018-11-24 02:47:37 +00:00
|
|
|
}
|
|
|
|
}
|