2013-04-17 21:43:35 -06:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
2009-08-31 17:09:50 -06:00
|
|
|
|
2014-02-22 15:36:30 -07:00
|
|
|
#include <cstddef>
|
|
|
|
#include <mutex>
|
|
|
|
#include <queue>
|
|
|
|
#include <utility>
|
|
|
|
#include <vector>
|
|
|
|
#include <wx/anybutton.h>
|
|
|
|
#include <wx/button.h>
|
|
|
|
#include <wx/chartype.h>
|
|
|
|
#include <wx/checkbox.h>
|
|
|
|
#include <wx/choice.h>
|
|
|
|
#include <wx/colour.h>
|
|
|
|
#include <wx/defs.h>
|
|
|
|
#include <wx/event.h>
|
|
|
|
#include <wx/font.h>
|
|
|
|
#include <wx/gdicmn.h>
|
|
|
|
#include <wx/panel.h>
|
|
|
|
#include <wx/sizer.h>
|
|
|
|
#include <wx/string.h>
|
|
|
|
#include <wx/textctrl.h>
|
|
|
|
#include <wx/timer.h>
|
|
|
|
#include <wx/translation.h>
|
|
|
|
#include <wx/validate.h>
|
|
|
|
#include <wx/window.h>
|
|
|
|
#include <wx/windowid.h>
|
|
|
|
#include <wx/aui/framemanager.h>
|
2010-01-19 12:28:27 -07:00
|
|
|
|
2014-02-22 15:36:30 -07:00
|
|
|
#include "Common/Common.h"
|
2014-02-22 23:33:03 -07:00
|
|
|
#include "Common/ConsoleListener.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "Common/FileUtil.h"
|
|
|
|
#include "Common/IniFile.h"
|
2014-02-22 15:36:30 -07:00
|
|
|
#include "Common/LogManager.h"
|
|
|
|
#include "DolphinWX/Frame.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "DolphinWX/LogWindow.h"
|
|
|
|
#include "DolphinWX/WxUtils.h"
|
|
|
|
#include "DolphinWX/Debugger/DebuggerUIUtil.h"
|
|
|
|
|
2009-08-31 20:41:48 -06:00
|
|
|
// Milliseconds between msgQueue flushes to wxTextCtrl
|
2009-08-31 17:09:50 -06:00
|
|
|
#define UPDATETIME 200
|
|
|
|
|
2009-09-07 15:37:27 -06:00
|
|
|
BEGIN_EVENT_TABLE(CLogWindow, wxPanel)
|
2009-08-31 17:09:50 -06:00
|
|
|
EVT_CLOSE(CLogWindow::OnClose)
|
|
|
|
EVT_BUTTON(IDM_CLEARLOG, CLogWindow::OnClear)
|
2011-02-18 05:34:24 -07:00
|
|
|
EVT_CHOICE(IDM_FONT, CLogWindow::OnFontChange)
|
|
|
|
EVT_CHECKBOX(IDM_WRAPLINE, CLogWindow::OnWrapLineCheck)
|
2009-08-31 17:09:50 -06:00
|
|
|
EVT_TIMER(IDTM_UPDATELOG, CLogWindow::OnLogTimer)
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
2010-07-21 20:05:28 -06:00
|
|
|
CLogWindow::CLogWindow(CFrame *parent, wxWindowID id, const wxPoint& pos,
|
2013-04-07 23:16:50 -06:00
|
|
|
const wxSize& size, long style, const wxString& name)
|
2010-07-21 20:05:28 -06:00
|
|
|
: wxPanel(parent, id, pos, size, style, name)
|
2010-07-27 16:12:19 -06:00
|
|
|
, x(0), y(0), winpos(0)
|
2011-12-30 21:51:17 -07:00
|
|
|
, Parent(parent), m_ignoreLogTimer(false), m_LogAccess(true)
|
2014-03-09 14:14:26 -06:00
|
|
|
, m_Log(nullptr), m_cmdline(nullptr), m_FontChoice(nullptr)
|
2011-01-19 23:05:52 -07:00
|
|
|
{
|
2009-09-02 06:09:51 -06:00
|
|
|
m_LogManager = LogManager::GetInstance();
|
2009-08-31 17:09:50 -06:00
|
|
|
|
|
|
|
CreateGUIControls();
|
|
|
|
|
2010-08-02 21:20:44 -06:00
|
|
|
m_LogTimer = new wxTimer(this, IDTM_UPDATELOG);
|
|
|
|
m_LogTimer->Start(UPDATETIME);
|
2009-08-31 17:09:50 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void CLogWindow::CreateGUIControls()
|
|
|
|
{
|
2011-03-03 15:47:48 -07:00
|
|
|
IniFile ini;
|
|
|
|
ini.Load(File::GetUserPath(F_LOGGERCONFIG_IDX));
|
|
|
|
|
|
|
|
ini.Get("LogWindow", "x", &x, Parent->GetSize().GetX() / 2);
|
|
|
|
ini.Get("LogWindow", "y", &y, Parent->GetSize().GetY());
|
|
|
|
ini.Get("LogWindow", "pos", &winpos, wxAUI_DOCK_RIGHT);
|
|
|
|
|
|
|
|
// Set up log listeners
|
|
|
|
int verbosity;
|
|
|
|
ini.Get("Options", "Verbosity", &verbosity, 0);
|
2013-10-28 23:23:17 -06:00
|
|
|
|
2013-04-07 23:16:50 -06:00
|
|
|
// Ensure the verbosity level is valid
|
|
|
|
if (verbosity < 1)
|
|
|
|
verbosity = 1;
|
|
|
|
if (verbosity > MAX_LOGLEVEL)
|
|
|
|
verbosity = MAX_LOGLEVEL;
|
|
|
|
|
|
|
|
// Get the logger output settings from the config ini file.
|
2011-03-03 15:47:48 -07:00
|
|
|
ini.Get("Options", "WriteToFile", &m_writeFile, false);
|
|
|
|
ini.Get("Options", "WriteToWindow", &m_writeWindow, true);
|
2014-02-22 23:33:03 -07:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
if (IsDebuggerPresent())
|
|
|
|
{
|
|
|
|
ini.Get("Options", "WriteToDebugger", &m_writeDebugger, true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
m_writeDebugger = false;
|
|
|
|
}
|
2013-04-07 23:16:50 -06:00
|
|
|
|
2011-03-03 15:47:48 -07:00
|
|
|
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
|
|
|
|
{
|
|
|
|
bool enable;
|
2011-04-01 01:43:02 -06:00
|
|
|
ini.Get("Logs", m_LogManager->GetShortName((LogTypes::LOG_TYPE)i), &enable, true);
|
2011-03-03 15:47:48 -07:00
|
|
|
|
|
|
|
if (m_writeWindow && enable)
|
2011-04-01 01:43:02 -06:00
|
|
|
m_LogManager->AddListener((LogTypes::LOG_TYPE)i, this);
|
2011-03-03 15:47:48 -07:00
|
|
|
else
|
2011-04-01 01:43:02 -06:00
|
|
|
m_LogManager->RemoveListener((LogTypes::LOG_TYPE)i, this);
|
2011-03-03 15:47:48 -07:00
|
|
|
|
|
|
|
if (m_writeFile && enable)
|
2011-04-01 01:43:02 -06:00
|
|
|
m_LogManager->AddListener((LogTypes::LOG_TYPE)i, m_LogManager->GetFileListener());
|
2011-03-03 15:47:48 -07:00
|
|
|
else
|
2011-04-01 01:43:02 -06:00
|
|
|
m_LogManager->RemoveListener((LogTypes::LOG_TYPE)i, m_LogManager->GetFileListener());
|
2011-03-03 15:47:48 -07:00
|
|
|
|
2014-02-22 23:33:03 -07:00
|
|
|
if (m_writeDebugger && enable)
|
|
|
|
m_LogManager->AddListener((LogTypes::LOG_TYPE)i, m_LogManager->GetDebuggerListener());
|
|
|
|
else
|
|
|
|
m_LogManager->RemoveListener((LogTypes::LOG_TYPE)i, m_LogManager->GetDebuggerListener());
|
|
|
|
|
2011-04-01 01:43:02 -06:00
|
|
|
m_LogManager->SetLogLevel((LogTypes::LOG_TYPE)i, (LogTypes::LOG_LEVELS)(verbosity));
|
2011-03-03 15:47:48 -07:00
|
|
|
}
|
|
|
|
|
2009-09-02 06:09:51 -06:00
|
|
|
// Font
|
2014-03-05 21:02:34 -07:00
|
|
|
m_FontChoice = new wxChoice(this, IDM_FONT);
|
2011-01-04 21:35:46 -07:00
|
|
|
m_FontChoice->Append(_("Default font"));
|
|
|
|
m_FontChoice->Append(_("Monospaced font"));
|
|
|
|
m_FontChoice->Append(_("Selected font"));
|
2011-03-03 15:47:48 -07:00
|
|
|
|
2010-07-27 16:12:19 -06:00
|
|
|
DefaultFont = GetFont();
|
2011-01-06 06:57:46 -07:00
|
|
|
MonoSpaceFont.SetNativeFontInfoUserDesc(_T("lucida console windows-1252"));
|
2010-08-02 21:20:44 -06:00
|
|
|
LogFont.push_back(DefaultFont);
|
|
|
|
LogFont.push_back(MonoSpaceFont);
|
|
|
|
LogFont.push_back(DebuggerFont);
|
2009-09-02 06:09:51 -06:00
|
|
|
|
2011-03-03 15:47:48 -07:00
|
|
|
int font;
|
|
|
|
ini.Get("Options", "Font", &font, 0);
|
|
|
|
m_FontChoice->SetSelection(font);
|
|
|
|
|
|
|
|
// Word wrap
|
|
|
|
bool wrap_lines;
|
|
|
|
ini.Get("Options", "WrapLines", &wrap_lines, false);
|
2011-02-18 21:43:51 -07:00
|
|
|
m_WrapLine = new wxCheckBox(this, IDM_WRAPLINE, _("Word Wrap"));
|
2011-03-03 15:47:48 -07:00
|
|
|
m_WrapLine->SetValue(wrap_lines);
|
|
|
|
|
|
|
|
// Log viewer
|
|
|
|
m_Log = CreateTextCtrl(this, IDM_LOG, wxTE_RICH | wxTE_MULTILINE | wxTE_READONLY |
|
|
|
|
(wrap_lines ? wxTE_WORDWRAP : wxTE_DONTWRAP));
|
2009-08-31 17:09:50 -06:00
|
|
|
|
2011-03-03 15:47:48 -07:00
|
|
|
// submit row
|
2009-08-31 17:09:50 -06:00
|
|
|
m_cmdline = new wxTextCtrl(this, IDM_SUBMITCMD, wxEmptyString, wxDefaultPosition, wxDefaultSize,
|
2011-03-03 15:47:48 -07:00
|
|
|
wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB);
|
2009-08-31 17:09:50 -06:00
|
|
|
|
2009-09-01 01:32:07 -06:00
|
|
|
// Sizers
|
2011-02-18 05:34:24 -07:00
|
|
|
wxBoxSizer *sTop = new wxBoxSizer(wxHORIZONTAL);
|
2014-03-05 21:02:34 -07:00
|
|
|
sTop->Add(new wxButton(this, IDM_CLEARLOG, _("Clear"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT));
|
2011-02-18 05:34:24 -07:00
|
|
|
sTop->Add(m_FontChoice, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 3);
|
|
|
|
sTop->Add(m_WrapLine, 0, wxALIGN_CENTER_VERTICAL);
|
2009-09-01 01:32:07 -06:00
|
|
|
|
2011-02-18 05:34:24 -07:00
|
|
|
sBottom = new wxBoxSizer(wxVERTICAL);
|
2011-03-03 15:47:48 -07:00
|
|
|
PopulateBottom();
|
2010-07-27 16:12:19 -06:00
|
|
|
|
2011-02-18 05:34:24 -07:00
|
|
|
wxBoxSizer *sMain = new wxBoxSizer(wxVERTICAL);
|
|
|
|
sMain->Add(sTop, 0, wxEXPAND);
|
|
|
|
sMain->Add(sBottom, 1, wxEXPAND);
|
|
|
|
SetSizer(sMain);
|
2009-08-31 17:09:50 -06:00
|
|
|
|
|
|
|
m_cmdline->SetFocus();
|
|
|
|
}
|
|
|
|
|
|
|
|
CLogWindow::~CLogWindow()
|
|
|
|
{
|
2010-12-14 10:52:01 -07:00
|
|
|
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
|
2009-08-31 17:09:50 -06:00
|
|
|
{
|
2011-04-01 01:43:02 -06:00
|
|
|
m_LogManager->RemoveListener((LogTypes::LOG_TYPE)i, this);
|
2009-08-31 17:09:50 -06:00
|
|
|
}
|
2009-09-02 06:09:51 -06:00
|
|
|
m_LogTimer->Stop();
|
|
|
|
delete m_LogTimer;
|
2009-08-31 17:09:50 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void CLogWindow::OnClose(wxCloseEvent& event)
|
|
|
|
{
|
2010-03-18 08:34:37 -06:00
|
|
|
SaveSettings();
|
2009-08-31 17:09:50 -06:00
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CLogWindow::SaveSettings()
|
|
|
|
{
|
|
|
|
IniFile ini;
|
2010-07-31 08:14:01 -06:00
|
|
|
ini.Load(File::GetUserPath(F_LOGGERCONFIG_IDX));
|
|
|
|
|
2010-07-27 16:12:19 -06:00
|
|
|
if (!Parent->g_pCodeWindow)
|
|
|
|
{
|
2011-01-06 06:57:46 -07:00
|
|
|
ini.Set("LogWindow", "x", x);
|
|
|
|
ini.Set("LogWindow", "y", y);
|
|
|
|
ini.Set("LogWindow", "pos", winpos);
|
2010-07-27 16:12:19 -06:00
|
|
|
}
|
2010-06-03 12:05:08 -06:00
|
|
|
ini.Set("Options", "Font", m_FontChoice->GetSelection());
|
2011-03-03 15:47:48 -07:00
|
|
|
ini.Set("Options", "WrapLines", m_WrapLine->IsChecked());
|
2010-02-02 14:56:29 -07:00
|
|
|
ini.Save(File::GetUserPath(F_LOGGERCONFIG_IDX));
|
2009-08-31 17:09:50 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void CLogWindow::OnClear(wxCommandEvent& WXUNUSED (event))
|
|
|
|
{
|
2009-09-02 06:09:51 -06:00
|
|
|
m_Log->Clear();
|
2009-08-31 17:09:50 -06:00
|
|
|
|
2014-02-22 23:33:03 -07:00
|
|
|
{
|
2011-03-04 23:11:26 -07:00
|
|
|
std::lock_guard<std::mutex> lk(m_LogSection);
|
2014-03-16 17:56:57 -06:00
|
|
|
while (!msgQueue.empty())
|
2009-08-31 17:09:50 -06:00
|
|
|
msgQueue.pop();
|
2014-02-22 23:33:03 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
m_LogManager->GetConsoleListener()->ClearScreen();
|
2009-08-31 17:09:50 -06:00
|
|
|
}
|
|
|
|
|
2011-03-03 15:47:48 -07:00
|
|
|
void CLogWindow::UnPopulateBottom()
|
2009-09-02 06:09:51 -06:00
|
|
|
{
|
2011-02-18 05:34:24 -07:00
|
|
|
sBottom->Detach(m_Log);
|
|
|
|
sBottom->Detach(m_cmdline);
|
2009-09-02 06:09:51 -06:00
|
|
|
}
|
2011-02-18 05:34:24 -07:00
|
|
|
|
2011-03-03 15:47:48 -07:00
|
|
|
void CLogWindow::PopulateBottom()
|
2009-09-02 06:09:51 -06:00
|
|
|
{
|
2011-02-18 05:34:24 -07:00
|
|
|
sBottom->Add(m_Log, 1, wxEXPAND | wxSHRINK);
|
|
|
|
sBottom->Add(m_cmdline, 0, wxEXPAND);
|
|
|
|
Layout();
|
2009-09-02 06:09:51 -06:00
|
|
|
}
|
|
|
|
|
2009-09-07 15:37:27 -06:00
|
|
|
wxTextCtrl* CLogWindow::CreateTextCtrl(wxPanel* parent, wxWindowID id, long Style)
|
2009-09-02 06:09:51 -06:00
|
|
|
{
|
2010-07-27 16:12:19 -06:00
|
|
|
wxTextCtrl* TC = new wxTextCtrl(parent, id, wxEmptyString, wxDefaultPosition, wxDefaultSize, Style);
|
2010-12-11 22:38:37 -07:00
|
|
|
#ifdef __APPLE__
|
2010-12-05 08:59:11 -07:00
|
|
|
TC->SetBackgroundColour(*wxLIGHT_GREY);
|
2010-12-11 22:38:37 -07:00
|
|
|
#else
|
|
|
|
TC->SetBackgroundColour(*wxBLACK);
|
|
|
|
#endif
|
2013-03-01 02:11:08 -07:00
|
|
|
if (m_FontChoice && m_FontChoice->GetSelection() < (int)LogFont.size() && m_FontChoice->GetSelection() >= 0)
|
2011-03-03 15:47:48 -07:00
|
|
|
TC->SetDefaultStyle(wxTextAttr(wxNullColour, wxNullColour, LogFont[m_FontChoice->GetSelection()]));
|
|
|
|
|
2009-09-02 06:09:51 -06:00
|
|
|
return TC;
|
|
|
|
}
|
|
|
|
|
2011-02-18 05:34:24 -07:00
|
|
|
void CLogWindow::OnFontChange(wxCommandEvent& event)
|
|
|
|
{
|
|
|
|
// Update selected font
|
|
|
|
LogFont[LogFont.size()-1] = DebuggerFont;
|
|
|
|
m_Log->SetStyle(0, m_Log->GetLastPosition(),
|
|
|
|
wxTextAttr(wxNullColour, wxNullColour, LogFont[event.GetSelection()]));
|
|
|
|
m_Log->SetDefaultStyle(wxTextAttr(wxNullColour, wxNullColour, LogFont[event.GetSelection()]));
|
|
|
|
|
|
|
|
SaveSettings();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CLogWindow::OnWrapLineCheck(wxCommandEvent& event)
|
2011-02-18 21:43:51 -07:00
|
|
|
{
|
2010-08-02 21:20:44 -06:00
|
|
|
#ifdef __WXGTK__
|
2011-03-03 15:47:48 -07:00
|
|
|
// Clear the old word wrap state and set the new
|
2011-02-18 05:34:24 -07:00
|
|
|
m_Log->SetWindowStyleFlag(m_Log->GetWindowStyleFlag() ^ (wxTE_WORDWRAP | wxTE_DONTWRAP));
|
2010-08-02 21:20:44 -06:00
|
|
|
#else
|
2011-02-18 21:43:51 -07:00
|
|
|
wxString Text;
|
2011-02-18 05:34:24 -07:00
|
|
|
// Unfortunately wrapping styles can only be changed dynamically with wxGTK
|
2014-02-16 21:51:41 -07:00
|
|
|
// Notice: To retain the colors when changing word wrapping we need to
|
|
|
|
// loop through every letter with GetStyle and then reapply them letter by letter
|
2011-02-18 05:34:24 -07:00
|
|
|
// Prevent m_Log access while it's being destroyed
|
|
|
|
m_LogAccess = false;
|
2011-03-03 15:47:48 -07:00
|
|
|
UnPopulateBottom();
|
2011-02-18 05:34:24 -07:00
|
|
|
Text = m_Log->GetValue();
|
|
|
|
m_Log->Destroy();
|
2011-03-03 15:47:48 -07:00
|
|
|
if (event.IsChecked())
|
2014-02-16 21:51:41 -07:00
|
|
|
m_Log = CreateTextCtrl(this, IDM_LOG, wxTE_RICH | wxTE_MULTILINE | wxTE_READONLY | wxTE_WORDWRAP);
|
2011-02-18 05:34:24 -07:00
|
|
|
else
|
2014-02-16 21:51:41 -07:00
|
|
|
m_Log = CreateTextCtrl(this, IDM_LOG, wxTE_RICH | wxTE_MULTILINE | wxTE_READONLY | wxTE_DONTWRAP);
|
2011-02-18 05:34:24 -07:00
|
|
|
m_Log->SetDefaultStyle(wxTextAttr(*wxWHITE));
|
|
|
|
m_Log->AppendText(Text);
|
2011-03-03 15:47:48 -07:00
|
|
|
PopulateBottom();
|
2011-02-18 05:34:24 -07:00
|
|
|
m_LogAccess = true;
|
2010-08-02 21:20:44 -06:00
|
|
|
#endif
|
2011-03-03 15:47:48 -07:00
|
|
|
SaveSettings();
|
2009-08-31 17:09:50 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void CLogWindow::OnLogTimer(wxTimerEvent& WXUNUSED(event))
|
|
|
|
{
|
2014-03-16 17:56:57 -06:00
|
|
|
if (!m_LogAccess || m_ignoreLogTimer)
|
|
|
|
return;
|
2009-09-02 06:09:51 -06:00
|
|
|
|
2009-08-31 17:09:50 -06:00
|
|
|
UpdateLog();
|
2014-03-16 17:56:57 -06:00
|
|
|
|
2010-08-02 21:20:44 -06:00
|
|
|
// Scroll to the last line
|
2014-02-12 08:00:34 -07:00
|
|
|
if (!msgQueue.empty())
|
2009-09-03 14:00:09 -06:00
|
|
|
{
|
|
|
|
m_Log->ScrollLines(1);
|
|
|
|
m_Log->ShowPosition( m_Log->GetLastPosition() );
|
|
|
|
}
|
2009-08-31 17:09:50 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void CLogWindow::UpdateLog()
|
|
|
|
{
|
2014-03-16 17:56:57 -06:00
|
|
|
if (!m_LogAccess || !m_Log)
|
|
|
|
return;
|
2009-09-02 06:09:51 -06:00
|
|
|
|
2011-12-30 21:51:17 -07:00
|
|
|
// m_LogTimer->Stop();
|
|
|
|
// instead of stopping the timer, let's simply ignore its calls during UpdateLog,
|
|
|
|
// because repeatedly stopping and starting a timer churns memory (and potentially leaks it).
|
|
|
|
m_ignoreLogTimer = true;
|
2009-08-31 17:09:50 -06:00
|
|
|
|
2014-03-16 17:56:57 -06:00
|
|
|
std::lock_guard<std::mutex> lk(m_LogSection);
|
|
|
|
while (!msgQueue.empty())
|
2011-03-04 23:11:26 -07:00
|
|
|
{
|
2014-03-16 17:56:57 -06:00
|
|
|
switch (msgQueue.front().first)
|
|
|
|
{
|
|
|
|
case ERROR_LEVEL:
|
|
|
|
m_Log->SetDefaultStyle(wxTextAttr(*wxRED));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WARNING_LEVEL:
|
|
|
|
m_Log->SetDefaultStyle(wxTextAttr(wxColour(255, 255, 0))); // YELLOW
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NOTICE_LEVEL:
|
|
|
|
m_Log->SetDefaultStyle(wxTextAttr(*wxGREEN));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case INFO_LEVEL:
|
|
|
|
m_Log->SetDefaultStyle(wxTextAttr(*wxCYAN));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DEBUG_LEVEL:
|
|
|
|
m_Log->SetDefaultStyle(wxTextAttr(*wxLIGHT_GREY));
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
m_Log->SetDefaultStyle(wxTextAttr(*wxWHITE));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (msgQueue.front().second.size())
|
2010-07-27 16:12:19 -06:00
|
|
|
{
|
2014-03-16 17:56:57 -06:00
|
|
|
int i = m_Log->GetLastPosition();
|
|
|
|
m_Log->AppendText(msgQueue.front().second);
|
|
|
|
// White timestamp
|
|
|
|
m_Log->SetStyle(i, i + 9, wxTextAttr(*wxWHITE));
|
2010-07-27 16:12:19 -06:00
|
|
|
}
|
2010-08-02 21:20:44 -06:00
|
|
|
|
2014-03-16 17:56:57 -06:00
|
|
|
msgQueue.pop();
|
|
|
|
}
|
|
|
|
|
2011-12-30 21:51:17 -07:00
|
|
|
m_ignoreLogTimer = false;
|
2009-08-31 17:09:50 -06:00
|
|
|
}
|
|
|
|
|
2010-12-14 10:52:01 -07:00
|
|
|
void CLogWindow::Log(LogTypes::LOG_LEVELS level, const char *text)
|
2009-08-31 17:09:50 -06:00
|
|
|
{
|
2011-03-04 23:11:26 -07:00
|
|
|
std::lock_guard<std::mutex> lk(m_LogSection);
|
|
|
|
|
2009-11-14 10:08:32 -07:00
|
|
|
if (msgQueue.size() >= 100)
|
|
|
|
msgQueue.pop();
|
2013-03-02 19:38:40 -07:00
|
|
|
|
|
|
|
msgQueue.push(std::make_pair(u8(level), StrToWxStr(text)));
|
2009-08-31 17:09:50 -06:00
|
|
|
}
|