2017-09-11 11:57:21 +00:00
|
|
|
#include "trace.h"
|
|
|
|
#include <Settings/Settings.h>
|
2016-06-05 01:33:35 +00:00
|
|
|
#include <Common/path.h>
|
|
|
|
#include <Common/LogClass.h>
|
2017-09-11 22:37:32 +00:00
|
|
|
#include "AudioSettings.h"
|
2016-06-05 01:33:35 +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-06-05 01:33:35 +00:00
|
|
|
};
|
|
|
|
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);
|
|
|
|
#endif
|
|
|
|
#ifdef _DEBUG
|
|
|
|
TraceSetMaxModule(MaxTraceModulePluginAudio, TraceInfo);
|
|
|
|
#else
|
|
|
|
TraceSetMaxModule(MaxTraceModulePluginAudio, TraceError);
|
|
|
|
#endif
|
|
|
|
TraceSetModuleName(TraceAudioInitShutdown, "AudioInitShutdown");
|
|
|
|
TraceSetModuleName(TraceAudioInterface, "AudioInterface");
|
2017-09-11 22:16:45 +00:00
|
|
|
TraceSetModuleName(TraceAudioDriver, "AudioDriver");
|
|
|
|
}
|
|
|
|
|
|
|
|
void StartTrace(void)
|
|
|
|
{
|
2017-09-14 08:07:12 +00:00
|
|
|
const char * log_dir = g_settings ? g_settings->log_dir() : NULL;
|
|
|
|
if (log_dir == NULL || log_dir[0] == '\0')
|
2016-06-05 01:33:35 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-09-11 22:16:45 +00:00
|
|
|
CPath LogFilePath(log_dir, "Project64-audio.log");
|
2016-06-05 01:33:35 +00:00
|
|
|
if (!LogFilePath.DirectoryExists())
|
|
|
|
{
|
|
|
|
LogFilePath.DirectoryCreate();
|
|
|
|
}
|
2017-09-14 08:07:12 +00:00
|
|
|
g_LogFile = new CTraceFileLog(LogFilePath, g_settings->FlushLogs(), CLog::Log_New, 500);
|
2016-06-05 01:33:35 +00:00
|
|
|
TraceAddModule(g_LogFile);
|
2018-11-24 02:41:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void StopTrace(void)
|
|
|
|
{
|
|
|
|
if (g_LogFile)
|
|
|
|
{
|
|
|
|
TraceRemoveModule(g_LogFile);
|
|
|
|
delete g_LogFile;
|
|
|
|
g_LogFile = NULL;
|
|
|
|
}
|
|
|
|
}
|