Added unify option to Log manager that basically disables the verbosity levels for those who wish that

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1202 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
John Peterson 2008-11-18 02:52:50 +00:00
parent a26865be88
commit 24cce4938f
3 changed files with 128 additions and 30 deletions

View File

@ -261,7 +261,9 @@ void LogManager::Log(LogTypes::LOG_TYPE _type, const char *_fmt, ...)
const char *eol = "\n";
if (Index > 0)
{
//sprintf(Msg2, "%i | %i %02i:%02i:%03i: %x %s (%s, %08x) : %s%s",
sprintf(Msg2, "%i %02i:%02i:%03i: %x %s (%s, %08x) : %s%s",
//v,
++count,
datetime.GetMinute(), datetime.GetSecond(), datetime.GetMillisecond(),
PowerPC::ppcState.DebugCount,
@ -271,11 +273,45 @@ void LogManager::Log(LogTypes::LOG_TYPE _type, const char *_fmt, ...)
}
// ==========================================================================================
// Level 0 verbosity logs will be written to all verbosity levels. Given that logging is enabled
// for that level. Level 1 verbosity will only be written to level 1, 2, 3 and so on.
/* Here we have two options
1. Verbosity mode where level 0 verbosity logs will be written to all verbosity
levels. Given that logging is enabled for that level. Level 1 verbosity will
only be written to level 1, 2, 3 and so on.
2. Unify mode where everything is written to the last message struct and the
last file */
// ---------------
// Check if we should do a unified write to a single file
if(m_LogSettings->bUnify)
{
// prepare the right id
int id = VERBOSITY_LEVELS*100 + type;
int ver = VERBOSITY_LEVELS;
// write to memory
m_Messages[ver][m_nextMessages[ver]].Set((LogTypes::LOG_TYPE)id, v, Msg2);
// ----------------------------------------------------------------------------------------
// Write to file
// ---------------
if (m_Log[id]->m_pFile && m_Log[id]->m_bLogToFile)
fprintf(m_Log[id]->m_pFile, "%s", Msg2);
if (m_Log[ver*100 + LogTypes::MASTER_LOG] && m_Log[ver*100 + LogTypes::MASTER_LOG]->m_pFile
&& m_LogSettings->bWriteMaster)
fprintf(m_Log[ver*100 + LogTypes::MASTER_LOG]->m_pFile, "%s", Msg2);
printf("%s", Msg2); // write to console screen
// this limits the memory space used for the memory logs to MAX_MESSAGES rows
m_nextMessages[ver]++;
if (m_nextMessages[ver] >= MAX_MESSAGES)
m_nextMessages[ver] = 0;
// ---------------
}
else // write to separate files and structs
{
int id;
for (int i = LogManager::VERBOSITY_LEVELS; i >= v ; i--)
for (int i = VERBOSITY_LEVELS; i >= v ; i--)
{
// prepare the right id
id = i*100 + type;
@ -284,12 +320,12 @@ void LogManager::Log(LogTypes::LOG_TYPE _type, const char *_fmt, ...)
m_Messages[i][m_nextMessages[i]].Set((LogTypes::LOG_TYPE)id, v, Msg2);
// ----------------------------------------------------------------------------------------
// write to file
// Write to file
// ---------------
if (m_Log[id]->m_pFile && m_Log[id]->m_bLogToFile)
fprintf(m_Log[id]->m_pFile, "%s", Msg2);
if (m_Log[i*100 + LogTypes::MASTER_LOG] && m_Log[i*100 + LogTypes::MASTER_LOG]->m_pFile
&& LogManager::m_LogSettings->bWriteMaster)
&& m_LogSettings->bWriteMaster)
fprintf(m_Log[i*100 + LogTypes::MASTER_LOG]->m_pFile, "%s", Msg2);
printf("%s", Msg2); // write to console screen
@ -300,6 +336,7 @@ void LogManager::Log(LogTypes::LOG_TYPE _type, const char *_fmt, ...)
m_nextMessages[i] = 0;
// ---------------
}
}
m_bDirty = true; // tell LogWindow that the log has been updated
}

View File

@ -53,6 +53,7 @@ struct CDebugger_LogSettings
int m_iVerbosity; // verbosity level 0 - 2
bool bResolve;
bool bWriteMaster;
bool bUnify;
// constructor
CDebugger_LogSettings();

View File

@ -62,6 +62,7 @@ CLogWindow::CLogWindow(wxWindow* parent)
wxStaticBoxSizer * m_optionsSizer = new wxStaticBoxSizer(wxVERTICAL, this, wxT("Settings"));
m_options = new wxCheckListBox(this, IDM_OPTIONS, wxDefaultPosition, wxDefaultSize,
0, NULL, wxNO_BORDER);
m_options->Append(wxT("Unify"));
m_options->Append(wxT("Resolve symbols"));
m_options->Append(wxT("Write master"));
m_options->Append(wxT("Show unique"));
@ -143,12 +144,21 @@ void CLogWindow::Load(IniFile& _IniFile)
LogManager::m_LogSettings->m_iVerbosity = v;
// load options
_IniFile.Get("LogWindow", "Unify", &LogManager::m_LogSettings->bUnify, false);
_IniFile.Get("LogWindow", "ResolveSymbols", &LogManager::m_LogSettings->bResolve, false);
_IniFile.Get("LogWindow", "WriteMaster", &LogManager::m_LogSettings->bWriteMaster, false);
_IniFile.Get("LogWindow", "OnlyUnique", &bOnlyUnique, false);
m_options->Check(0, LogManager::m_LogSettings->bResolve);
m_options->Check(1, LogManager::m_LogSettings->bWriteMaster);
m_options->Check(2, bOnlyUnique);
m_options->Check(0, LogManager::m_LogSettings->bUnify);
m_options->Check(1, LogManager::m_LogSettings->bResolve);
m_options->Check(2, LogManager::m_LogSettings->bWriteMaster);
m_options->Check(3, bOnlyUnique);
if(LogManager::m_LogSettings->bUnify)
{
m_RadioBox[0]->SetSelection(LogManager::VERBOSITY_LEVELS);
LogManager::m_LogSettings->m_iVerbosity = LogManager::VERBOSITY_LEVELS;
m_RadioBox[0]->Disable();
}
}
void CLogWindow::OnSubmit(wxCommandEvent& event)
@ -248,12 +258,42 @@ void CLogWindow::OnOptionsCheck(wxCommandEvent& event)
{
IniFile ini;
ini.Load(DEBUGGER_CONFIG_FILE);
LogManager::m_LogSettings->bResolve = m_options->IsChecked(0);
LogManager::m_LogSettings->bWriteMaster = m_options->IsChecked(1);
bOnlyUnique = m_options->IsChecked(2);
ini.Set("LogWindow", "ResolveSymbols", m_options->IsChecked(0));
ini.Set("LogWindow", "WriteMaster", m_options->IsChecked(1));
ini.Set("LogWindow", "OnlyUnique", m_options->IsChecked(2));
// Unified case
if(m_options->IsChecked(0) && Core::GetState() != Core::CORE_UNINITIALIZED)
{
m_RadioBox[0]->SetSelection(LogManager::VERBOSITY_LEVELS);
LogManager::m_LogSettings->m_iVerbosity = LogManager::VERBOSITY_LEVELS;
m_RadioBox[0]->Disable();
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++)
{
for (int j = 0; j <= LogManager::VERBOSITY_LEVELS; j++)
{
// update groups to enabled or disabled
bool Enabled = m_checks->IsChecked(i); // get all from the current i
LogManager::m_Log[i + 100*j]->m_bEnable = Enabled;
LogManager::m_Log[i + 100*j]->m_bShowInLog = Enabled;
// update all verbosity levels to this level's Enabled
ini.Set("LogManager", LogManager::m_Log[i + 100*j]->m_szShortName, Enabled);
}
}
}
else
{
m_RadioBox[0]->Enable(true);
}
LogManager::m_LogSettings->bUnify = m_options->IsChecked(0);
LogManager::m_LogSettings->bResolve = m_options->IsChecked(1);
LogManager::m_LogSettings->bWriteMaster = m_options->IsChecked(2);
bOnlyUnique = m_options->IsChecked(3);
ini.Set("LogWindow", "Unify", m_options->IsChecked(0));
ini.Set("LogWindow", "ResolveSymbols", m_options->IsChecked(1));
ini.Set("LogWindow", "WriteMaster", m_options->IsChecked(2));
ini.Set("LogWindow", "OnlyUnique", m_options->IsChecked(3));
ini.Save(DEBUGGER_CONFIG_FILE);
if (Core::GetState() != Core::CORE_UNINITIALIZED) UpdateLog();
}
@ -271,8 +311,27 @@ void CLogWindow::OnLogCheck(wxCommandEvent& event)
IniFile ini;
ini.Load(DEBUGGER_CONFIG_FILE);
int v = LogManager::m_LogSettings->m_iVerbosity;
int v = LogManager::m_LogSettings->m_iVerbosity; // current radio button
int uni = LogManager::m_LogSettings->bUnify;
// Unified case
if(uni)
{
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++)
{
for (int j = 0; j <= LogManager::VERBOSITY_LEVELS; j++)
{
// update groups to enabled or disabled
bool Enabled = m_checks->IsChecked(i); // get all from the current i
LogManager::m_Log[i + 100*j]->m_bEnable = Enabled;
LogManager::m_Log[i + 100*j]->m_bShowInLog = Enabled;
ini.Set("LogManager", LogManager::m_Log[i + 100*v]->m_szShortName, Enabled);
}
}
}
else
{
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++)
{
// update groups to enabled or disabled
@ -282,6 +341,7 @@ void CLogWindow::OnLogCheck(wxCommandEvent& event)
ini.Set("LogManager", LogManager::m_Log[i + 100*v]->m_szShortName, Enabled);
}
}
ini.Save(DEBUGGER_CONFIG_FILE);