2013-04-18 03:43:35 +00:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
2009-08-31 23:09:50 +00:00
|
|
|
|
2014-02-22 22:36:30 +00: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 19:28:27 +00:00
|
|
|
|
2014-09-08 01:06:58 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "Common/FileUtil.h"
|
|
|
|
#include "Common/IniFile.h"
|
2014-06-05 23:29:54 +00:00
|
|
|
#include "Common/Logging/ConsoleListener.h"
|
|
|
|
#include "Common/Logging/LogManager.h"
|
2014-02-22 22:36:30 +00:00
|
|
|
#include "DolphinWX/Frame.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "DolphinWX/LogWindow.h"
|
|
|
|
#include "DolphinWX/WxUtils.h"
|
|
|
|
#include "DolphinWX/Debugger/DebuggerUIUtil.h"
|
|
|
|
|
2009-09-01 02:41:48 +00:00
|
|
|
// Milliseconds between msgQueue flushes to wxTextCtrl
|
2009-08-31 23:09:50 +00:00
|
|
|
#define UPDATETIME 200
|
|
|
|
|
2010-07-22 02:05:28 +00:00
|
|
|
CLogWindow::CLogWindow(CFrame *parent, wxWindowID id, const wxPoint& pos,
|
2013-04-08 05:16:50 +00:00
|
|
|
const wxSize& size, long style, const wxString& name)
|
2010-07-22 02:05:28 +00:00
|
|
|
: wxPanel(parent, id, pos, size, style, name)
|
2010-07-27 22:12:19 +00:00
|
|
|
, x(0), y(0), winpos(0)
|
2015-03-01 01:25:50 +00:00
|
|
|
, Parent(parent), m_LogAccess(true)
|
2014-03-09 20:14:26 +00:00
|
|
|
, m_Log(nullptr), m_cmdline(nullptr), m_FontChoice(nullptr)
|
2011-01-20 06:05:52 +00:00
|
|
|
{
|
2014-11-09 00:26:20 +00:00
|
|
|
Bind(wxEVT_CLOSE_WINDOW, &CLogWindow::OnClose, this);
|
2014-11-14 05:46:42 +00:00
|
|
|
Bind(wxEVT_TIMER, &CLogWindow::OnLogTimer, this);
|
|
|
|
|
2009-09-02 12:09:51 +00:00
|
|
|
m_LogManager = LogManager::GetInstance();
|
2009-08-31 23:09:50 +00:00
|
|
|
|
|
|
|
CreateGUIControls();
|
|
|
|
|
2015-03-01 01:25:50 +00:00
|
|
|
m_LogTimer.SetOwner(this);
|
|
|
|
m_LogTimer.Start(UPDATETIME);
|
2009-08-31 23:09:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CLogWindow::CreateGUIControls()
|
|
|
|
{
|
2011-03-03 22:47:48 +00:00
|
|
|
IniFile ini;
|
|
|
|
ini.Load(File::GetUserPath(F_LOGGERCONFIG_IDX));
|
|
|
|
|
2014-06-16 05:12:43 +00:00
|
|
|
IniFile::Section* options = ini.GetOrCreateSection("Options");
|
|
|
|
IniFile::Section* log_window = ini.GetOrCreateSection("LogWindow");
|
|
|
|
log_window->Get("x", &x, Parent->GetSize().GetX() / 2);
|
|
|
|
log_window->Get("y", &y, Parent->GetSize().GetY());
|
|
|
|
log_window->Get("pos", &winpos, wxAUI_DOCK_RIGHT);
|
2011-03-03 22:47:48 +00:00
|
|
|
|
|
|
|
// Set up log listeners
|
|
|
|
int verbosity;
|
2014-06-16 05:12:43 +00:00
|
|
|
options->Get("Verbosity", &verbosity, 0);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2013-04-08 05:16:50 +00: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.
|
2014-06-16 05:12:43 +00:00
|
|
|
options->Get("WriteToFile", &m_writeFile, false);
|
|
|
|
options->Get("WriteToWindow", &m_writeWindow, true);
|
2014-02-23 06:33:03 +00:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
if (IsDebuggerPresent())
|
|
|
|
{
|
2014-06-16 05:12:43 +00:00
|
|
|
options->Get("WriteToDebugger", &m_writeDebugger, true);
|
2014-02-23 06:33:03 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
m_writeDebugger = false;
|
|
|
|
}
|
2013-04-08 05:16:50 +00:00
|
|
|
|
2014-06-16 05:12:43 +00:00
|
|
|
IniFile::Section* logs = ini.GetOrCreateSection("Logs");
|
2011-03-03 22:47:48 +00:00
|
|
|
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
|
|
|
|
{
|
|
|
|
bool enable;
|
2014-09-03 23:48:54 +00:00
|
|
|
logs->Get(m_LogManager->GetShortName((LogTypes::LOG_TYPE)i), &enable, false);
|
2011-03-03 22:47:48 +00:00
|
|
|
|
|
|
|
if (m_writeWindow && enable)
|
2011-04-01 07:43:02 +00:00
|
|
|
m_LogManager->AddListener((LogTypes::LOG_TYPE)i, this);
|
2011-03-03 22:47:48 +00:00
|
|
|
else
|
2011-04-01 07:43:02 +00:00
|
|
|
m_LogManager->RemoveListener((LogTypes::LOG_TYPE)i, this);
|
2011-03-03 22:47:48 +00:00
|
|
|
|
|
|
|
if (m_writeFile && enable)
|
2011-04-01 07:43:02 +00:00
|
|
|
m_LogManager->AddListener((LogTypes::LOG_TYPE)i, m_LogManager->GetFileListener());
|
2011-03-03 22:47:48 +00:00
|
|
|
else
|
2011-04-01 07:43:02 +00:00
|
|
|
m_LogManager->RemoveListener((LogTypes::LOG_TYPE)i, m_LogManager->GetFileListener());
|
2011-03-03 22:47:48 +00:00
|
|
|
|
2014-02-23 06:33:03 +00: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 07:43:02 +00:00
|
|
|
m_LogManager->SetLogLevel((LogTypes::LOG_TYPE)i, (LogTypes::LOG_LEVELS)(verbosity));
|
2011-03-03 22:47:48 +00:00
|
|
|
}
|
|
|
|
|
2009-09-02 12:09:51 +00:00
|
|
|
// Font
|
2014-11-09 00:26:20 +00:00
|
|
|
m_FontChoice = new wxChoice(this, wxID_ANY);
|
|
|
|
m_FontChoice->Bind(wxEVT_CHOICE, &CLogWindow::OnFontChange, this);
|
2011-01-05 04:35:46 +00:00
|
|
|
m_FontChoice->Append(_("Default font"));
|
|
|
|
m_FontChoice->Append(_("Monospaced font"));
|
|
|
|
m_FontChoice->Append(_("Selected font"));
|
2011-03-03 22:47:48 +00:00
|
|
|
|
2010-07-27 22:12:19 +00:00
|
|
|
DefaultFont = GetFont();
|
2014-05-17 17:17:28 +00:00
|
|
|
MonoSpaceFont.SetNativeFontInfoUserDesc("lucida console windows-1252");
|
2010-08-03 03:20:44 +00:00
|
|
|
LogFont.push_back(DefaultFont);
|
|
|
|
LogFont.push_back(MonoSpaceFont);
|
|
|
|
LogFont.push_back(DebuggerFont);
|
2009-09-02 12:09:51 +00:00
|
|
|
|
2011-03-03 22:47:48 +00:00
|
|
|
int font;
|
2014-06-16 05:12:43 +00:00
|
|
|
options->Get("Font", &font, 0);
|
2011-03-03 22:47:48 +00:00
|
|
|
m_FontChoice->SetSelection(font);
|
|
|
|
|
|
|
|
// Word wrap
|
|
|
|
bool wrap_lines;
|
2014-06-16 05:12:43 +00:00
|
|
|
options->Get("WrapLines", &wrap_lines, false);
|
2014-11-09 00:26:20 +00:00
|
|
|
m_WrapLine = new wxCheckBox(this, wxID_ANY, _("Word Wrap"));
|
|
|
|
m_WrapLine->Bind(wxEVT_CHECKBOX, &CLogWindow::OnWrapLineCheck, this);
|
2011-03-03 22:47:48 +00:00
|
|
|
m_WrapLine->SetValue(wrap_lines);
|
|
|
|
|
|
|
|
// Log viewer
|
2014-11-09 00:26:20 +00:00
|
|
|
m_Log = CreateTextCtrl(this, wxID_ANY, wxTE_RICH | wxTE_MULTILINE | wxTE_READONLY |
|
2011-03-03 22:47:48 +00:00
|
|
|
(wrap_lines ? wxTE_WORDWRAP : wxTE_DONTWRAP));
|
2009-08-31 23:09:50 +00:00
|
|
|
|
2011-03-03 22:47:48 +00:00
|
|
|
// submit row
|
2014-11-09 00:26:20 +00:00
|
|
|
m_cmdline = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize,
|
2011-03-03 22:47:48 +00:00
|
|
|
wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB);
|
2009-08-31 23:09:50 +00:00
|
|
|
|
2014-11-09 00:26:20 +00:00
|
|
|
// Clear log button
|
|
|
|
m_clear_log_btn = new wxButton(this, wxID_ANY, _("Clear"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
|
|
|
|
m_clear_log_btn->Bind(wxEVT_BUTTON, &CLogWindow::OnClear, this);
|
|
|
|
|
2009-09-01 07:32:07 +00:00
|
|
|
// Sizers
|
2014-11-09 00:26:20 +00:00
|
|
|
wxBoxSizer* sTop = new wxBoxSizer(wxHORIZONTAL);
|
|
|
|
sTop->Add(m_clear_log_btn);
|
2011-02-18 12:34:24 +00:00
|
|
|
sTop->Add(m_FontChoice, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, 3);
|
|
|
|
sTop->Add(m_WrapLine, 0, wxALIGN_CENTER_VERTICAL);
|
2009-09-01 07:32:07 +00:00
|
|
|
|
2011-02-18 12:34:24 +00:00
|
|
|
sBottom = new wxBoxSizer(wxVERTICAL);
|
2011-03-03 22:47:48 +00:00
|
|
|
PopulateBottom();
|
2010-07-27 22:12:19 +00:00
|
|
|
|
2014-11-09 00:26:20 +00:00
|
|
|
wxBoxSizer* sMain = new wxBoxSizer(wxVERTICAL);
|
2011-02-18 12:34:24 +00:00
|
|
|
sMain->Add(sTop, 0, wxEXPAND);
|
|
|
|
sMain->Add(sBottom, 1, wxEXPAND);
|
|
|
|
SetSizer(sMain);
|
2009-08-31 23:09:50 +00:00
|
|
|
|
|
|
|
m_cmdline->SetFocus();
|
|
|
|
}
|
|
|
|
|
|
|
|
CLogWindow::~CLogWindow()
|
|
|
|
{
|
2010-12-14 17:52:01 +00:00
|
|
|
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
|
2009-08-31 23:09:50 +00:00
|
|
|
{
|
2011-04-01 07:43:02 +00:00
|
|
|
m_LogManager->RemoveListener((LogTypes::LOG_TYPE)i, this);
|
2009-08-31 23:09:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CLogWindow::OnClose(wxCloseEvent& event)
|
|
|
|
{
|
2010-03-18 14:34:37 +00:00
|
|
|
SaveSettings();
|
2009-08-31 23:09:50 +00:00
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CLogWindow::SaveSettings()
|
|
|
|
{
|
|
|
|
IniFile ini;
|
2010-07-31 14:14:01 +00:00
|
|
|
ini.Load(File::GetUserPath(F_LOGGERCONFIG_IDX));
|
|
|
|
|
2010-07-27 22:12:19 +00:00
|
|
|
if (!Parent->g_pCodeWindow)
|
|
|
|
{
|
2014-06-16 05:12:43 +00:00
|
|
|
IniFile::Section* log_window = ini.GetOrCreateSection("LogWindow");
|
|
|
|
log_window->Set("x", x);
|
|
|
|
log_window->Set("y", y);
|
|
|
|
log_window->Set("pos", winpos);
|
2010-07-27 22:12:19 +00:00
|
|
|
}
|
2014-06-16 05:12:43 +00:00
|
|
|
|
|
|
|
IniFile::Section* options = ini.GetOrCreateSection("Options");
|
|
|
|
options->Set("Font", m_FontChoice->GetSelection());
|
|
|
|
options->Set("WrapLines", m_WrapLine->IsChecked());
|
|
|
|
|
2010-02-02 21:56:29 +00:00
|
|
|
ini.Save(File::GetUserPath(F_LOGGERCONFIG_IDX));
|
2009-08-31 23:09:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CLogWindow::OnClear(wxCommandEvent& WXUNUSED (event))
|
|
|
|
{
|
2009-09-02 12:09:51 +00:00
|
|
|
m_Log->Clear();
|
2009-08-31 23:09:50 +00:00
|
|
|
|
2014-02-23 06:33:03 +00:00
|
|
|
{
|
2011-03-05 06:11:26 +00:00
|
|
|
std::lock_guard<std::mutex> lk(m_LogSection);
|
2014-03-16 23:56:57 +00:00
|
|
|
while (!msgQueue.empty())
|
2009-08-31 23:09:50 +00:00
|
|
|
msgQueue.pop();
|
2014-02-23 06:33:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_LogManager->GetConsoleListener()->ClearScreen();
|
2009-08-31 23:09:50 +00:00
|
|
|
}
|
|
|
|
|
2011-03-03 22:47:48 +00:00
|
|
|
void CLogWindow::UnPopulateBottom()
|
2009-09-02 12:09:51 +00:00
|
|
|
{
|
2011-02-18 12:34:24 +00:00
|
|
|
sBottom->Detach(m_Log);
|
|
|
|
sBottom->Detach(m_cmdline);
|
2009-09-02 12:09:51 +00:00
|
|
|
}
|
2011-02-18 12:34:24 +00:00
|
|
|
|
2011-03-03 22:47:48 +00:00
|
|
|
void CLogWindow::PopulateBottom()
|
2009-09-02 12:09:51 +00:00
|
|
|
{
|
2011-02-18 12:34:24 +00:00
|
|
|
sBottom->Add(m_Log, 1, wxEXPAND | wxSHRINK);
|
|
|
|
sBottom->Add(m_cmdline, 0, wxEXPAND);
|
|
|
|
Layout();
|
2009-09-02 12:09:51 +00:00
|
|
|
}
|
|
|
|
|
2009-09-07 21:37:27 +00:00
|
|
|
wxTextCtrl* CLogWindow::CreateTextCtrl(wxPanel* parent, wxWindowID id, long Style)
|
2009-09-02 12:09:51 +00:00
|
|
|
{
|
2010-07-27 22:12:19 +00:00
|
|
|
wxTextCtrl* TC = new wxTextCtrl(parent, id, wxEmptyString, wxDefaultPosition, wxDefaultSize, Style);
|
2010-12-12 05:38:37 +00:00
|
|
|
#ifdef __APPLE__
|
2010-12-05 15:59:11 +00:00
|
|
|
TC->SetBackgroundColour(*wxLIGHT_GREY);
|
2010-12-12 05:38:37 +00:00
|
|
|
#else
|
|
|
|
TC->SetBackgroundColour(*wxBLACK);
|
|
|
|
#endif
|
2013-03-01 09:11:08 +00:00
|
|
|
if (m_FontChoice && m_FontChoice->GetSelection() < (int)LogFont.size() && m_FontChoice->GetSelection() >= 0)
|
2011-03-03 22:47:48 +00:00
|
|
|
TC->SetDefaultStyle(wxTextAttr(wxNullColour, wxNullColour, LogFont[m_FontChoice->GetSelection()]));
|
|
|
|
|
2009-09-02 12:09:51 +00:00
|
|
|
return TC;
|
|
|
|
}
|
|
|
|
|
2011-02-18 12:34:24 +00: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-19 04:43:51 +00:00
|
|
|
{
|
2010-08-03 03:20:44 +00:00
|
|
|
#ifdef __WXGTK__
|
2011-03-03 22:47:48 +00:00
|
|
|
// Clear the old word wrap state and set the new
|
2011-02-18 12:34:24 +00:00
|
|
|
m_Log->SetWindowStyleFlag(m_Log->GetWindowStyleFlag() ^ (wxTE_WORDWRAP | wxTE_DONTWRAP));
|
2010-08-03 03:20:44 +00:00
|
|
|
#else
|
2011-02-19 04:43:51 +00:00
|
|
|
wxString Text;
|
2011-02-18 12:34:24 +00:00
|
|
|
// Unfortunately wrapping styles can only be changed dynamically with wxGTK
|
2014-02-17 04:51:41 +00: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 12:34:24 +00:00
|
|
|
// Prevent m_Log access while it's being destroyed
|
|
|
|
m_LogAccess = false;
|
2011-03-03 22:47:48 +00:00
|
|
|
UnPopulateBottom();
|
2011-02-18 12:34:24 +00:00
|
|
|
Text = m_Log->GetValue();
|
|
|
|
m_Log->Destroy();
|
2011-03-03 22:47:48 +00:00
|
|
|
if (event.IsChecked())
|
2014-11-09 00:26:20 +00:00
|
|
|
m_Log = CreateTextCtrl(this, wxID_ANY, wxTE_RICH | wxTE_MULTILINE | wxTE_READONLY | wxTE_WORDWRAP);
|
2011-02-18 12:34:24 +00:00
|
|
|
else
|
2014-11-09 00:26:20 +00:00
|
|
|
m_Log = CreateTextCtrl(this, wxID_ANY, wxTE_RICH | wxTE_MULTILINE | wxTE_READONLY | wxTE_DONTWRAP);
|
2011-02-18 12:34:24 +00:00
|
|
|
m_Log->SetDefaultStyle(wxTextAttr(*wxWHITE));
|
|
|
|
m_Log->AppendText(Text);
|
2011-03-03 22:47:48 +00:00
|
|
|
PopulateBottom();
|
2011-02-18 12:34:24 +00:00
|
|
|
m_LogAccess = true;
|
2010-08-03 03:20:44 +00:00
|
|
|
#endif
|
2011-03-03 22:47:48 +00:00
|
|
|
SaveSettings();
|
2009-08-31 23:09:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CLogWindow::OnLogTimer(wxTimerEvent& WXUNUSED(event))
|
|
|
|
{
|
2015-03-01 01:25:50 +00:00
|
|
|
if (!m_LogAccess)
|
2014-03-16 23:56:57 +00:00
|
|
|
return;
|
2009-09-02 12:09:51 +00:00
|
|
|
|
2009-08-31 23:09:50 +00:00
|
|
|
UpdateLog();
|
2014-03-16 23:56:57 +00:00
|
|
|
|
2010-08-03 03:20:44 +00:00
|
|
|
// Scroll to the last line
|
2014-02-12 15:00:34 +00:00
|
|
|
if (!msgQueue.empty())
|
2009-09-03 20:00:09 +00:00
|
|
|
{
|
|
|
|
m_Log->ScrollLines(1);
|
|
|
|
m_Log->ShowPosition( m_Log->GetLastPosition() );
|
|
|
|
}
|
2009-08-31 23:09:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CLogWindow::UpdateLog()
|
|
|
|
{
|
2015-03-01 01:25:50 +00:00
|
|
|
if (!m_LogAccess || !m_Log || msgQueue.empty())
|
2014-03-16 23:56:57 +00:00
|
|
|
return;
|
2009-09-02 12:09:51 +00:00
|
|
|
|
2015-03-01 01:25:50 +00:00
|
|
|
m_LogTimer.Stop();
|
2009-08-31 23:09:50 +00:00
|
|
|
|
2014-03-16 23:56:57 +00:00
|
|
|
std::lock_guard<std::mutex> lk(m_LogSection);
|
|
|
|
while (!msgQueue.empty())
|
2011-03-05 06:11:26 +00:00
|
|
|
{
|
2014-03-16 23:56:57 +00:00
|
|
|
switch (msgQueue.front().first)
|
|
|
|
{
|
2014-08-22 00:11:52 +00:00
|
|
|
case LogTypes::LOG_LEVELS::LERROR:
|
2014-03-16 23:56:57 +00:00
|
|
|
m_Log->SetDefaultStyle(wxTextAttr(*wxRED));
|
|
|
|
break;
|
|
|
|
|
2014-08-22 00:11:52 +00:00
|
|
|
case LogTypes::LOG_LEVELS::LWARNING:
|
2014-05-17 17:17:28 +00:00
|
|
|
m_Log->SetDefaultStyle(wxTextAttr(*wxYELLOW));
|
2014-03-16 23:56:57 +00:00
|
|
|
break;
|
|
|
|
|
2014-08-22 00:11:52 +00:00
|
|
|
case LogTypes::LOG_LEVELS::LNOTICE:
|
2014-03-16 23:56:57 +00:00
|
|
|
m_Log->SetDefaultStyle(wxTextAttr(*wxGREEN));
|
|
|
|
break;
|
|
|
|
|
2014-08-22 00:11:52 +00:00
|
|
|
case LogTypes::LOG_LEVELS::LINFO:
|
2014-03-16 23:56:57 +00:00
|
|
|
m_Log->SetDefaultStyle(wxTextAttr(*wxCYAN));
|
|
|
|
break;
|
|
|
|
|
2014-08-22 00:11:52 +00:00
|
|
|
case LogTypes::LOG_LEVELS::LDEBUG:
|
2014-03-16 23:56:57 +00:00
|
|
|
m_Log->SetDefaultStyle(wxTextAttr(*wxLIGHT_GREY));
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
m_Log->SetDefaultStyle(wxTextAttr(*wxWHITE));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (msgQueue.front().second.size())
|
2010-07-27 22:12:19 +00:00
|
|
|
{
|
2014-03-16 23:56:57 +00: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 22:12:19 +00:00
|
|
|
}
|
2010-08-03 03:20:44 +00:00
|
|
|
|
2014-03-16 23:56:57 +00:00
|
|
|
msgQueue.pop();
|
|
|
|
}
|
|
|
|
|
2015-03-01 01:25:50 +00:00
|
|
|
m_LogTimer.Start();
|
2009-08-31 23:09:50 +00:00
|
|
|
}
|
|
|
|
|
2010-12-14 17:52:01 +00:00
|
|
|
void CLogWindow::Log(LogTypes::LOG_LEVELS level, const char *text)
|
2009-08-31 23:09:50 +00:00
|
|
|
{
|
2011-03-05 06:11:26 +00:00
|
|
|
std::lock_guard<std::mutex> lk(m_LogSection);
|
|
|
|
|
2009-11-14 17:08:32 +00:00
|
|
|
if (msgQueue.size() >= 100)
|
|
|
|
msgQueue.pop();
|
2013-03-03 02:38:40 +00:00
|
|
|
|
|
|
|
msgQueue.push(std::make_pair(u8(level), StrToWxStr(text)));
|
2009-08-31 23:09:50 +00:00
|
|
|
}
|