Add a switch to Windows to save to a log file.

This commit is contained in:
Unknown W. Brackets 2012-12-22 09:49:29 -08:00
parent d745bddc23
commit 7fb65a5997
4 changed files with 40 additions and 8 deletions

View File

@ -100,7 +100,7 @@
#define LOGGER_CONFIG "Logger.ini"
// Files in the directory returned by GetUserPath(D_LOGS_IDX)
#define MAIN_LOG "dolphin.log"
#define MAIN_LOG "ppsspp.log"
// Sys files
#define TOTALDB "totaldb.dsy"

View File

@ -68,6 +68,8 @@ LogManager::LogManager()
m_fileLog = new FileLogListener(File::GetUserPath(F_MAINLOG_IDX).c_str());
m_consoleLog = new ConsoleListener();
m_debuggerLog = new DebuggerLogListener();
#else
m_fileLog = NULL;
#endif
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
@ -88,8 +90,9 @@ LogManager::~LogManager()
{
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
{
if (m_fileLog != NULL)
m_logManager->RemoveListener((LogTypes::LOG_TYPE)i, m_fileLog);
#if !defined(ANDROID) && !defined(IOS) && !defined(BLACKBERRY)
m_logManager->RemoveListener((LogTypes::LOG_TYPE)i, m_fileLog);
m_logManager->RemoveListener((LogTypes::LOG_TYPE)i, m_consoleLog);
m_logManager->RemoveListener((LogTypes::LOG_TYPE)i, m_debuggerLog);
#endif
@ -97,12 +100,30 @@ LogManager::~LogManager()
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
delete m_Log[i];
if (m_fileLog != NULL)
delete m_fileLog;
#if !defined(ANDROID) && !defined(IOS) && !defined(BLACKBERRY)
delete m_fileLog;
delete m_consoleLog;
#endif
}
void LogManager::ChangeFileLog(const char *filename)
{
if (m_fileLog != NULL)
{
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
m_logManager->RemoveListener((LogTypes::LOG_TYPE)i, m_fileLog);
delete m_fileLog;
}
if (filename != NULL)
{
m_fileLog = new FileLogListener(filename);
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
m_Log[i]->AddListener(m_fileLog);
}
}
void LogManager::SaveConfig(IniFile::Section *section)
{
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++)

View File

@ -179,6 +179,8 @@ public:
static void Init();
static void Shutdown();
void ChangeFileLog(const char *filename);
void SaveConfig(IniFile::Section *section);
void LoadConfig(IniFile::Section *section);
};

View File

@ -52,6 +52,7 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
Common::EnableCrashingOnCrashes();
const char *fileToStart = NULL;
const char *fileToLog = NULL;
bool showLog = false;
bool autoRun = true;
@ -59,14 +60,14 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
VFSRegister("", new DirectoryAssetReader("assets/"));
VFSRegister("", new DirectoryAssetReader(""));
for (int i = 1; i < __argc; i++)
for (int i = 1; i < __argc; ++i)
{
if (__targv[i][0] == '\0')
if (__argv[i][0] == '\0')
continue;
if (__targv[i][0] == '-')
if (__argv[i][0] == '-')
{
switch (__targv[i][1])
switch (__argv[i][1])
{
case 'j':
g_Config.iCpuCore = CPU_JIT;
@ -80,11 +81,17 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
case 's':
autoRun = false;
break;
case '-':
if (!strcmp(__argv[i], "--log") && i < __argc - 1)
fileToLog = __argv[++i];
if (!strncmp(__argv[i], "--log=", strlen("--log=")) && strlen(__argv[i]) > strlen("--log="))
fileToLog = __argv[i] + strlen("--log=");
break;
}
}
else if (fileToStart == NULL)
{
fileToStart = __targv[i];
fileToStart = __argv[i];
if (!File::Exists(fileToStart))
{
fprintf(stderr, "File not found: %s\n", fileToStart);
@ -127,6 +134,8 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
MainWindow::UpdateMenus();
LogManager::Init();
if (fileToLog != NULL)
LogManager::GetInstance()->ChangeFileLog(fileToLog);
bool hidden = false;
#ifndef _DEBUG
hidden = true;