2016-02-01 08:56:25 +00:00
|
|
|
#include "trace.h"
|
|
|
|
#include "Config.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>
|
|
|
|
#include <Common/LogClass.h>
|
|
|
|
#include <Settings/Settings.h>
|
|
|
|
|
|
|
|
#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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
static AndroidLogger * g_AndroidLogger = NULL;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static CTraceFileLog * g_LogFile = NULL;
|
|
|
|
|
|
|
|
void SetupTrace(void)
|
|
|
|
{
|
|
|
|
if (g_LogFile != NULL)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef ANDROID
|
|
|
|
if (g_AndroidLogger == NULL)
|
|
|
|
{
|
|
|
|
g_AndroidLogger = new AndroidLogger();
|
|
|
|
}
|
|
|
|
TraceAddModule(g_AndroidLogger);
|
|
|
|
|
|
|
|
TraceSetMaxModule(MaxTraceModuleGlide64, TraceVerbose);
|
|
|
|
#else
|
|
|
|
#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
|
|
|
|
#endif
|
|
|
|
|
|
|
|
TraceSetModuleName(TraceMD5, "MD5");
|
|
|
|
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-02-01 08:56:25 +00:00
|
|
|
|
|
|
|
char log_dir[260];
|
|
|
|
memset(log_dir, 0, sizeof(log_dir));
|
2016-02-22 06:11:13 +00:00
|
|
|
if (Set_log_dir != 0)
|
|
|
|
{
|
|
|
|
GetSystemSettingSz(Set_log_dir, log_dir, sizeof(log_dir));
|
|
|
|
}
|
2016-02-01 08:56:25 +00:00
|
|
|
|
|
|
|
if (strlen(log_dir) == 0)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
CPath LogFilePath(log_dir);
|
|
|
|
if (!LogFilePath.DirectoryExists())
|
|
|
|
{
|
|
|
|
LogFilePath.DirectoryCreate();
|
|
|
|
}
|
|
|
|
LogFilePath.SetNameExtension("Glide64.log");
|
|
|
|
g_LogFile = new CTraceFileLog(LogFilePath, GetSystemSetting(Set_log_flush) != 0, Log_New, 500);
|
|
|
|
TraceAddModule(g_LogFile);
|
|
|
|
}
|