mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 05:47:56 -07:00
More log fixing: Write to Window checkbox added, fix some log levels again, clean some code.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2701 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
aa7fe1edee
commit
866e393426
@ -3,7 +3,8 @@
|
||||
|
||||
LogManager *LogManager::m_logManager = NULL;
|
||||
|
||||
LogManager::LogManager() {
|
||||
LogManager::LogManager()\
|
||||
: logMutex(1) {
|
||||
// create log files
|
||||
m_Log[LogTypes::MASTER_LOG] = new LogContainer("*", "Master Log");
|
||||
m_Log[LogTypes::BOOT] = new LogContainer("BOOT", "Boot");
|
||||
@ -42,7 +43,6 @@ LogManager::LogManager() {
|
||||
m_Log[LogTypes::WII_IPC_WIIMOTE] = new LogContainer("WII_IPC_WIIMOTE","WII IPC WIIMOTE");
|
||||
m_Log[LogTypes::ACTIONREPLAY] = new LogContainer("ActionReplay", "ActionReplay");
|
||||
|
||||
logMutex = new Common::CriticalSection(1);
|
||||
m_fileLog = new FileLogListener(MAIN_LOG_FILE);
|
||||
m_consoleLog = new ConsoleListener();
|
||||
|
||||
@ -54,8 +54,7 @@ LogManager::LogManager() {
|
||||
}
|
||||
|
||||
LogManager::~LogManager() {
|
||||
delete [] &m_Log;
|
||||
delete logMutex;
|
||||
delete [] &m_Log; // iffy :P
|
||||
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) {
|
||||
m_logManager->removeListener((LogTypes::LOG_TYPE)i, m_fileLog);
|
||||
m_logManager->removeListener((LogTypes::LOG_TYPE)i, m_consoleLog);
|
||||
@ -78,23 +77,23 @@ void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type,
|
||||
va_start(args, format);
|
||||
CharArrayFromFormatV(temp, MAX_MSGLEN, format, args);
|
||||
va_end(args);
|
||||
sprintf(msg, "%s: %i %s %s\n",
|
||||
|
||||
static const char level_to_char[7] = "-NEWID";
|
||||
sprintf(msg, "%s %c: %s %s\n",
|
||||
Common::Timer::GetTimeFormatted().c_str(),
|
||||
// PowerPC::ppcState.DebugCount,
|
||||
(int)level,
|
||||
level_to_char[(int)level],
|
||||
log->getShortName(),
|
||||
temp);
|
||||
|
||||
logMutex->Enter();
|
||||
logMutex.Enter();
|
||||
log->trigger(level, msg);
|
||||
logMutex->Leave();
|
||||
|
||||
logMutex.Leave();
|
||||
}
|
||||
|
||||
void LogManager::removeListener(LogTypes::LOG_TYPE type, LogListener *listener) {
|
||||
logMutex->Enter();
|
||||
logMutex.Enter();
|
||||
m_Log[type]->removeListener(listener);
|
||||
logMutex->Leave();
|
||||
logMutex.Leave();
|
||||
}
|
||||
|
||||
LogContainer::LogContainer(const char* shortName, const char* fullName, bool enable)
|
||||
@ -106,17 +105,7 @@ LogContainer::LogContainer(const char* shortName, const char* fullName, bool ena
|
||||
|
||||
// LogContainer
|
||||
void LogContainer::addListener(LogListener *listener) {
|
||||
bool exists = false;
|
||||
|
||||
std::vector<LogListener *>::iterator i;
|
||||
for(i = listeners.begin(); i != listeners.end(); i++) {
|
||||
if ((*i) == listener) {
|
||||
exists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (! exists)
|
||||
if (!isListener(listener))
|
||||
listeners.push_back(listener);
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ class LogManager
|
||||
{
|
||||
private:
|
||||
LogContainer* m_Log[LogTypes::NUMBER_OF_LOGS];
|
||||
Common::CriticalSection* logMutex;
|
||||
Common::CriticalSection logMutex;
|
||||
FileLogListener *m_fileLog;
|
||||
ConsoleListener *m_consoleLog;
|
||||
static LogManager *m_logManager; // Singleton. Ugh.
|
||||
|
@ -208,7 +208,5 @@ std::string Timer::GetTimeFormatted()
|
||||
|
||||
return std::string(formattedTime);
|
||||
}
|
||||
/////////////////////////////////////
|
||||
|
||||
|
||||
} // end of namespace Common
|
||||
|
@ -988,7 +988,7 @@ void CWII_IPC_HLE_WiiMote::SendCommandToACL(u8 _Ident, u8 _Code, u8 _CommandLeng
|
||||
|
||||
memcpy(&DataFrame[Offset], _pCommandData, _CommandLength);
|
||||
|
||||
WARN_LOG(WII_IPC_WIIMOTE, " SendCommandToACL (answer)");
|
||||
INFO_LOG(WII_IPC_WIIMOTE, " SendCommandToACL (answer)");
|
||||
DEBUG_LOG(WII_IPC_WIIMOTE, " Ident: 0x%02x", _Ident);
|
||||
DEBUG_LOG(WII_IPC_WIIMOTE, " Code: 0x%02x", _Code);
|
||||
|
||||
|
@ -37,6 +37,7 @@ BEGIN_EVENT_TABLE(CLogWindow, wxDialog)
|
||||
EVT_RADIOBOX(IDM_VERBOSITY, CLogWindow::OnOptionsCheck)
|
||||
EVT_CHECKBOX(IDM_WRITEFILE, CLogWindow::OnOptionsCheck)
|
||||
EVT_CHECKBOX(IDM_WRITECONSOLE, CLogWindow::OnOptionsCheck)
|
||||
EVT_CHECKBOX(IDM_WRITEWINDOW, CLogWindow::OnOptionsCheck)
|
||||
EVT_CHECKLISTBOX(IDM_LOGCHECKS, CLogWindow::OnLogCheck)
|
||||
EVT_TIMER(IDTM_UPDATELOG, CLogWindow::OnLogTimer)
|
||||
END_EVENT_TABLE()
|
||||
@ -79,6 +80,9 @@ void CLogWindow::CreateGUIControls()
|
||||
m_writeConsoleCB = new wxCheckBox(this, IDM_WRITECONSOLE, wxT("Write to Console"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
sbLeftOptions->Add(m_writeConsoleCB);
|
||||
|
||||
m_writeWindowCB = new wxCheckBox(this, IDM_WRITEWINDOW, wxT("Write to window ->"), wxDefaultPosition, wxDefaultSize, 0);
|
||||
sbLeftOptions->Add(m_writeWindowCB);
|
||||
|
||||
sLeft->Add(sbLeftOptions, 0, wxEXPAND);
|
||||
|
||||
wxBoxSizer* sLogCtrl = new wxBoxSizer(wxHORIZONTAL);
|
||||
@ -145,6 +149,7 @@ void CLogWindow::SaveSettings()
|
||||
ini.Set("Options", "Verbosity", m_verbosity->GetSelection() + 1);
|
||||
ini.Set("Options", "WriteToFile", m_writeFile);
|
||||
ini.Set("Options", "WriteToConsole", m_writeConsole);
|
||||
ini.Set("Options", "WriteToWindow", m_writeWindow);
|
||||
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
|
||||
ini.Set("Logs", m_logManager->getShortName((LogTypes::LOG_TYPE)i), m_checks->IsChecked(i));
|
||||
ini.Save(LOGGER_CONFIG_FILE);
|
||||
@ -166,12 +171,14 @@ void CLogWindow::LoadSettings()
|
||||
m_writeFileCB->SetValue(m_writeFile);
|
||||
ini.Get("Options", "WriteToConsole", &m_writeConsole, true);
|
||||
m_writeConsoleCB->SetValue(m_writeConsole);
|
||||
ini.Get("Options", "WriteToWindow", &m_writeWindow, true);
|
||||
m_writeWindowCB->SetValue(m_writeWindow);
|
||||
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
|
||||
{
|
||||
bool enable;
|
||||
ini.Get("Logs", m_logManager->getShortName((LogTypes::LOG_TYPE)i), &enable, true);
|
||||
|
||||
if (enable)
|
||||
if (m_writeWindow && enable)
|
||||
m_logManager->addListener((LogTypes::LOG_TYPE)i, this);
|
||||
else
|
||||
m_logManager->removeListener((LogTypes::LOG_TYPE)i, this);
|
||||
@ -294,6 +301,20 @@ void CLogWindow::OnOptionsCheck(wxCommandEvent& event)
|
||||
}
|
||||
break;
|
||||
|
||||
case IDM_WRITEWINDOW:
|
||||
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
|
||||
{
|
||||
m_writeFile = event.IsChecked();
|
||||
if (m_checks->IsChecked(i))
|
||||
{
|
||||
if (m_writeFile)
|
||||
m_logManager->addListener((LogTypes::LOG_TYPE)i, this);
|
||||
else
|
||||
m_logManager->removeListener((LogTypes::LOG_TYPE)i, this);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case IDM_WRITECONSOLE:
|
||||
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
|
||||
{
|
||||
@ -350,8 +371,6 @@ void CLogWindow::NotifyUpdate()
|
||||
|
||||
void CLogWindow::UpdateLog()
|
||||
{
|
||||
if (!msgQueue.size())
|
||||
return;
|
||||
m_logTimer->Stop();
|
||||
wxString collected_text;
|
||||
// rough estimate.
|
||||
@ -393,16 +412,14 @@ void CLogWindow::UpdateLog()
|
||||
collected_text.Append(msgQueue.front().second);
|
||||
msgQueue.pop();
|
||||
}
|
||||
if (collected_text.size())
|
||||
if (collected_text.size()) {
|
||||
m_log->AppendText(collected_text);
|
||||
}
|
||||
m_logTimer->Start(UPDATETIME);
|
||||
}
|
||||
|
||||
void CLogWindow::Log(LogTypes::LOG_LEVELS level, const char *text)
|
||||
{
|
||||
if (level > NOTICE_LEVEL)
|
||||
return;
|
||||
|
||||
if (msgQueue.size() >= 100)
|
||||
msgQueue.pop();
|
||||
msgQueue.push(std::pair<u8, wxString>((u8)level, wxString::FromAscii(text)));
|
||||
|
@ -31,6 +31,7 @@ enum
|
||||
IDM_TOGGLEALL,
|
||||
IDM_WRITEFILE,
|
||||
IDM_WRITECONSOLE,
|
||||
IDM_WRITEWINDOW,
|
||||
IDTM_UPDATELOG,
|
||||
IDM_VERBOSITY,
|
||||
IDM_SUBMITCMD
|
||||
@ -53,9 +54,9 @@ public:
|
||||
void Log(LogTypes::LOG_LEVELS, const char *text);
|
||||
|
||||
private:
|
||||
wxTextCtrl* m_log, * m_cmdline;
|
||||
bool m_writeFile, m_writeConsole;
|
||||
wxCheckBox* m_writeFileCB, * m_writeConsoleCB;
|
||||
wxTextCtrl *m_log, *m_cmdline;
|
||||
bool m_writeFile, m_writeConsole, m_writeWindow;
|
||||
wxCheckBox *m_writeFileCB, *m_writeConsoleCB, *m_writeWindowCB;
|
||||
wxTimer *m_logTimer;
|
||||
wxCheckListBox* m_checks;
|
||||
wxRadioBox *m_verbosity;
|
||||
|
Loading…
Reference in New Issue
Block a user