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