Use mutexes in LogManager to make it threadsafe, as suggested by beistin's patch. Change some LogManager function names to be consistent with Dolphin's naming conventions.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7433 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
7a9a47376f
commit
021193b22f
|
@ -37,14 +37,12 @@ public:
|
||||||
void LetterSpace(int Width, int Height);
|
void LetterSpace(int Width, int Height);
|
||||||
void BufferWidthHeight(int BufferWidth, int BufferHeight, int ScreenWidth, int ScreenHeight, bool BufferFirst);
|
void BufferWidthHeight(int BufferWidth, int BufferHeight, int ScreenWidth, int ScreenHeight, bool BufferFirst);
|
||||||
void PixelSpace(int Left, int Top, int Width, int Height, bool);
|
void PixelSpace(int Left, int Top, int Width, int Height, bool);
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
COORD GetCoordinates(int BytesRead, int BufferWidth);
|
COORD GetCoordinates(int BytesRead, int BufferWidth);
|
||||||
#endif
|
#endif
|
||||||
void Log(LogTypes::LOG_LEVELS, const char *Text);
|
void Log(LogTypes::LOG_LEVELS, const char *Text);
|
||||||
void ClearScreen(bool Cursor = true);
|
void ClearScreen(bool Cursor = true);
|
||||||
|
|
||||||
const char *getName() const { return "Console"; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
HWND GetHwnd(void);
|
HWND GetHwnd(void);
|
||||||
|
|
|
@ -86,17 +86,20 @@ LogManager::LogManager()
|
||||||
m_fileLog = new FileLogListener(File::GetUserPath(F_MAINLOG_IDX).c_str());
|
m_fileLog = new FileLogListener(File::GetUserPath(F_MAINLOG_IDX).c_str());
|
||||||
m_consoleLog = new ConsoleListener();
|
m_consoleLog = new ConsoleListener();
|
||||||
|
|
||||||
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) {
|
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
|
||||||
m_Log[i]->setEnable(true);
|
{
|
||||||
m_Log[i]->addListener(m_fileLog);
|
m_Log[i]->SetEnable(true);
|
||||||
m_Log[i]->addListener(m_consoleLog);
|
m_Log[i]->AddListener(m_fileLog);
|
||||||
|
m_Log[i]->AddListener(m_consoleLog);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LogManager::~LogManager() {
|
LogManager::~LogManager()
|
||||||
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) {
|
{
|
||||||
m_logManager->removeListener((LogTypes::LOG_TYPE)i, m_fileLog);
|
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
|
||||||
m_logManager->removeListener((LogTypes::LOG_TYPE)i, m_consoleLog);
|
{
|
||||||
|
m_logManager->RemoveListener((LogTypes::LOG_TYPE)i, m_fileLog);
|
||||||
|
m_logManager->RemoveListener((LogTypes::LOG_TYPE)i, m_consoleLog);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
|
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
|
||||||
|
@ -107,32 +110,24 @@ LogManager::~LogManager() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type,
|
void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type,
|
||||||
const char *file, int line, const char *format,
|
const char *file, int line, const char *format, va_list args)
|
||||||
va_list args) {
|
{
|
||||||
|
|
||||||
char temp[MAX_MSGLEN];
|
char temp[MAX_MSGLEN];
|
||||||
char msg[MAX_MSGLEN * 2];
|
char msg[MAX_MSGLEN * 2];
|
||||||
LogContainer *log = m_Log[type];
|
LogContainer *log = m_Log[type];
|
||||||
|
|
||||||
if (! log->isEnable() || level > log->getLevel() || ! log->hasListeners())
|
if (!log->IsEnabled() || level > log->GetLevel() || ! log->HasListeners())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CharArrayFromFormatV(temp, MAX_MSGLEN, format, args);
|
CharArrayFromFormatV(temp, MAX_MSGLEN, format, args);
|
||||||
|
|
||||||
static const char level_to_char[7] = "-NEWID";
|
static const char level_to_char[7] = "-NEWID";
|
||||||
sprintf(msg, "%s %s:%u %c[%s]: %s\n",
|
sprintf(msg, "%s %s:%u %c[%s]: %s\n",
|
||||||
Common::Timer::GetTimeFormatted().c_str(),
|
Common::Timer::GetTimeFormatted().c_str(),
|
||||||
file, line, level_to_char[(int)level],
|
file, line, level_to_char[(int)level],
|
||||||
log->getShortName(), temp);
|
log->GetShortName(), temp);
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lk(logMutex);
|
log->Trigger(level, msg);
|
||||||
log->trigger(level, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void LogManager::removeListener(LogTypes::LOG_TYPE type, LogListener *listener)
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> lk(logMutex);
|
|
||||||
m_Log[type]->removeListener(listener);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogManager::Init()
|
void LogManager::Init()
|
||||||
|
@ -147,31 +142,33 @@ void LogManager::Shutdown()
|
||||||
}
|
}
|
||||||
|
|
||||||
LogContainer::LogContainer(const char* shortName, const char* fullName, bool enable)
|
LogContainer::LogContainer(const char* shortName, const char* fullName, bool enable)
|
||||||
: m_enable(enable) {
|
: m_enable(enable)
|
||||||
|
{
|
||||||
strncpy(m_fullName, fullName, 128);
|
strncpy(m_fullName, fullName, 128);
|
||||||
strncpy(m_shortName, shortName, 32);
|
strncpy(m_shortName, shortName, 32);
|
||||||
m_level = LogTypes::LWARNING;
|
m_level = LogTypes::LWARNING;
|
||||||
}
|
}
|
||||||
|
|
||||||
// LogContainer
|
// LogContainer
|
||||||
void LogContainer::addListener(LogListener *listener) {
|
void LogContainer::AddListener(LogListener *listener)
|
||||||
if (!isListener(listener))
|
{
|
||||||
listeners.push_back(listener);
|
std::lock_guard<std::mutex> lk(m_listeners_lock);
|
||||||
|
m_listeners.insert(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogContainer::removeListener(LogListener *listener) {
|
void LogContainer::RemoveListener(LogListener *listener)
|
||||||
std::vector<LogListener *>::iterator i = std::find(listeners.begin(), listeners.end(), listener);
|
{
|
||||||
if (listeners.end() != i)
|
std::lock_guard<std::mutex> lk(m_listeners_lock);
|
||||||
listeners.erase(i);
|
m_listeners.erase(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LogContainer::isListener(LogListener *listener) const {
|
void LogContainer::Trigger(LogTypes::LOG_LEVELS level, const char *msg)
|
||||||
return listeners.end() != std::find(listeners.begin(), listeners.end(), listener);
|
{
|
||||||
}
|
std::lock_guard<std::mutex> lk(m_listeners_lock);
|
||||||
|
|
||||||
void LogContainer::trigger(LogTypes::LOG_LEVELS level, const char *msg) {
|
std::set<LogListener*>::const_iterator i;
|
||||||
std::vector<LogListener *>::const_iterator i;
|
for (i = m_listeners.begin(); i != m_listeners.end(); ++i)
|
||||||
for (i = listeners.begin(); i != listeners.end(); ++i) {
|
{
|
||||||
(*i)->Log(level, msg);
|
(*i)->Log(level, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -179,13 +176,14 @@ void LogContainer::trigger(LogTypes::LOG_LEVELS level, const char *msg) {
|
||||||
FileLogListener::FileLogListener(const char *filename)
|
FileLogListener::FileLogListener(const char *filename)
|
||||||
{
|
{
|
||||||
m_logfile.open(filename, std::ios::app);
|
m_logfile.open(filename, std::ios::app);
|
||||||
setEnable(true);
|
SetEnable(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileLogListener::Log(LogTypes::LOG_LEVELS, const char *msg)
|
void FileLogListener::Log(LogTypes::LOG_LEVELS, const char *msg)
|
||||||
{
|
{
|
||||||
if (!m_enable || !isValid())
|
if (!IsEnabled() || !IsValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
std::lock_guard<std::mutex> lk(m_log_lock);
|
||||||
m_logfile << msg << std::flush;
|
m_logfile << msg << std::flush;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,80 +23,70 @@
|
||||||
#include "Thread.h"
|
#include "Thread.h"
|
||||||
#include "FileUtil.h"
|
#include "FileUtil.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <set>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#define MAX_MESSAGES 8000
|
#define MAX_MESSAGES 8000
|
||||||
#define MAX_MSGLEN 1024
|
#define MAX_MSGLEN 1024
|
||||||
|
|
||||||
|
|
||||||
// pure virtual interface (well, except the destructor which we just leave empty).
|
// pure virtual interface
|
||||||
class LogListener {
|
class LogListener
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~LogListener() {}
|
virtual ~LogListener() {}
|
||||||
|
|
||||||
virtual void Log(LogTypes::LOG_LEVELS, const char *msg) = 0;
|
virtual void Log(LogTypes::LOG_LEVELS, const char *msg) = 0;
|
||||||
virtual const char *getName() const = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class FileLogListener : public LogListener {
|
class FileLogListener : public LogListener
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
FileLogListener(const char *filename);
|
FileLogListener(const char *filename);
|
||||||
|
|
||||||
void Log(LogTypes::LOG_LEVELS, const char *msg);
|
void Log(LogTypes::LOG_LEVELS, const char *msg);
|
||||||
|
|
||||||
bool isValid() {
|
bool IsValid() { return (m_logfile != NULL); }
|
||||||
return (m_logfile != NULL);
|
bool IsEnabled() const { return m_enable; }
|
||||||
}
|
void SetEnable(bool enable) { m_enable = enable; }
|
||||||
|
|
||||||
bool isEnable() {
|
const char* GetName() const { return "file"; }
|
||||||
return m_enable;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setEnable(bool enable) {
|
|
||||||
m_enable = enable;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *getName() const { return "file"; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::mutex m_log_lock;
|
||||||
std::ofstream m_logfile;
|
std::ofstream m_logfile;
|
||||||
bool m_enable;
|
bool m_enable;
|
||||||
};
|
};
|
||||||
|
|
||||||
class LogContainer {
|
class LogContainer
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
LogContainer(const char* shortName, const char* fullName, bool enable = false);
|
LogContainer(const char* shortName, const char* fullName, bool enable = false);
|
||||||
|
|
||||||
const char *getShortName() const { return m_shortName; }
|
const char* GetShortName() const { return m_shortName; }
|
||||||
const char *getFullName() const { return m_fullName; }
|
const char* GetFullName() const { return m_fullName; }
|
||||||
|
|
||||||
bool isListener(LogListener *listener) const;
|
void AddListener(LogListener* listener);
|
||||||
void addListener(LogListener *listener);
|
void RemoveListener(LogListener* listener);
|
||||||
void removeListener(LogListener *listener);
|
|
||||||
|
|
||||||
void trigger(LogTypes::LOG_LEVELS, const char *msg);
|
void Trigger(LogTypes::LOG_LEVELS, const char *msg);
|
||||||
|
|
||||||
bool isEnable() const { return m_enable; }
|
bool IsEnabled() const { return m_enable; }
|
||||||
void setEnable(bool enable) {
|
void SetEnable(bool enable) { m_enable = enable; }
|
||||||
m_enable = enable;
|
|
||||||
}
|
|
||||||
|
|
||||||
LogTypes::LOG_LEVELS getLevel() const {
|
LogTypes::LOG_LEVELS GetLevel() const { return m_level; }
|
||||||
return m_level;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setLevel(LogTypes::LOG_LEVELS level) {
|
void SetLevel(LogTypes::LOG_LEVELS level) { m_level = level; }
|
||||||
m_level = level;
|
|
||||||
}
|
bool HasListeners() const { return !m_listeners.empty(); }
|
||||||
bool hasListeners() const { return listeners.size() > 0; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char m_fullName[128];
|
char m_fullName[128];
|
||||||
char m_shortName[32];
|
char m_shortName[32];
|
||||||
bool m_enable;
|
bool m_enable;
|
||||||
LogTypes::LOG_LEVELS m_level;
|
LogTypes::LOG_LEVELS m_level;
|
||||||
|
std::mutex m_listeners_lock;
|
||||||
std::vector<LogListener *> listeners;
|
std::set<LogListener*> m_listeners;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ConsoleListener;
|
class ConsoleListener;
|
||||||
|
@ -105,7 +95,6 @@ class LogManager : NonCopyable
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
LogContainer* m_Log[LogTypes::NUMBER_OF_LOGS];
|
LogContainer* m_Log[LogTypes::NUMBER_OF_LOGS];
|
||||||
std::mutex logMutex;
|
|
||||||
FileLogListener *m_fileLog;
|
FileLogListener *m_fileLog;
|
||||||
ConsoleListener *m_consoleLog;
|
ConsoleListener *m_consoleLog;
|
||||||
static LogManager *m_logManager; // Singleton. Ugh.
|
static LogManager *m_logManager; // Singleton. Ugh.
|
||||||
|
@ -119,49 +108,58 @@ public:
|
||||||
void Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type,
|
void Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type,
|
||||||
const char *file, int line, const char *fmt, va_list args);
|
const char *file, int line, const char *fmt, va_list args);
|
||||||
|
|
||||||
void setLogLevel(LogTypes::LOG_TYPE type, LogTypes::LOG_LEVELS level) {
|
void SetLogLevel(LogTypes::LOG_TYPE type, LogTypes::LOG_LEVELS level)
|
||||||
m_Log[type]->setLevel(level);
|
{
|
||||||
|
m_Log[type]->SetLevel(level);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setEnable(LogTypes::LOG_TYPE type, bool enable) {
|
void SetEnable(LogTypes::LOG_TYPE type, bool enable)
|
||||||
m_Log[type]->setEnable(enable);
|
{
|
||||||
|
m_Log[type]->SetEnable(enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isEnable(LogTypes::LOG_TYPE type) {
|
bool IsEnabled(LogTypes::LOG_TYPE type) const
|
||||||
return m_Log[type]->isEnable();
|
{
|
||||||
|
return m_Log[type]->IsEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *getShortName(LogTypes::LOG_TYPE type) const {
|
const char* GetShortName(LogTypes::LOG_TYPE type) const
|
||||||
return m_Log[type]->getShortName();
|
{
|
||||||
|
return m_Log[type]->GetShortName();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *getFullName(LogTypes::LOG_TYPE type) const {
|
const char* GetFullName(LogTypes::LOG_TYPE type) const
|
||||||
return m_Log[type]->getFullName();
|
{
|
||||||
|
return m_Log[type]->GetFullName();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isListener(LogTypes::LOG_TYPE type, LogListener *listener) const {
|
void AddListener(LogTypes::LOG_TYPE type, LogListener *listener)
|
||||||
return m_Log[type]->isListener(listener);
|
{
|
||||||
|
m_Log[type]->AddListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
void addListener(LogTypes::LOG_TYPE type, LogListener *listener) {
|
void RemoveListener(LogTypes::LOG_TYPE type, LogListener *listener)
|
||||||
m_Log[type]->addListener(listener);
|
{
|
||||||
|
m_Log[type]->RemoveListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeListener(LogTypes::LOG_TYPE type, LogListener *listener);
|
FileLogListener *GetFileListener() const
|
||||||
|
{
|
||||||
FileLogListener *getFileListener() {
|
|
||||||
return m_fileLog;
|
return m_fileLog;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConsoleListener *getConsoleListener() {
|
ConsoleListener *GetConsoleListener() const
|
||||||
|
{
|
||||||
return m_consoleLog;
|
return m_consoleLog;
|
||||||
}
|
}
|
||||||
|
|
||||||
static LogManager* GetInstance() {
|
static LogManager* GetInstance()
|
||||||
|
{
|
||||||
return m_logManager;
|
return m_logManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetInstance(LogManager *logManager) {
|
static void SetInstance(LogManager *logManager)
|
||||||
|
{
|
||||||
m_logManager = logManager;
|
m_logManager = logManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,8 +68,7 @@ public:
|
||||||
void Wait()
|
void Wait()
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lk(m_mutex);
|
std::unique_lock<std::mutex> lk(m_mutex);
|
||||||
if (!is_set)
|
m_condvar.wait(lk, IsSet(this));
|
||||||
m_condvar.wait(lk, IsSet(this));
|
|
||||||
is_set = false;
|
is_set = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -209,7 +209,7 @@ u32 CWII_IPC_HLE_Device_di::ExecuteCommand(u32 _BufferIn, u32 _BufferInSize, u32
|
||||||
u64 DVDAddress = (u64)Memory::Read_U32(_BufferIn + 0x08) << 2;
|
u64 DVDAddress = (u64)Memory::Read_U32(_BufferIn + 0x08) << 2;
|
||||||
|
|
||||||
// Don't do anything if the log is unselected
|
// Don't do anything if the log is unselected
|
||||||
if (LogManager::GetInstance()->isEnable(LogTypes::FILEMON))
|
if (LogManager::GetInstance()->IsEnabled(LogTypes::FILEMON))
|
||||||
{
|
{
|
||||||
const char *pFilename = m_pFileSystem->GetFileName(DVDAddress);
|
const char *pFilename = m_pFileSystem->GetFileName(DVDAddress);
|
||||||
if (pFilename != NULL)
|
if (pFilename != NULL)
|
||||||
|
|
|
@ -93,9 +93,11 @@ void ReadGC(std::string FileName)
|
||||||
void CheckFile(std::string File, u64 Size)
|
void CheckFile(std::string File, u64 Size)
|
||||||
{
|
{
|
||||||
// Don't do anything if the log is unselected
|
// Don't do anything if the log is unselected
|
||||||
if (!LogManager::GetInstance()->isEnable(LogTypes::FILEMON)) return;
|
if (!LogManager::GetInstance()->IsEnabled(LogTypes::FILEMON))
|
||||||
|
return;
|
||||||
// Do nothing if we found the same file again
|
// Do nothing if we found the same file again
|
||||||
if (CurrentFile == File) return;
|
if (CurrentFile == File)
|
||||||
|
return;
|
||||||
|
|
||||||
if (Size > 0) Size = (Size / 1000);
|
if (Size > 0) Size = (Size / 1000);
|
||||||
std::string Str = StringFromFormat("%s kB %s", ThousandSeparate(Size, 7).c_str(), File.c_str());
|
std::string Str = StringFromFormat("%s kB %s", ThousandSeparate(Size, 7).c_str(), File.c_str());
|
||||||
|
@ -119,7 +121,7 @@ void FindFilename(u64 offset)
|
||||||
// Don't do anything if a game is not running
|
// Don't do anything if a game is not running
|
||||||
if (Core::GetState() != Core::CORE_RUN) return;
|
if (Core::GetState() != Core::CORE_RUN) return;
|
||||||
// Or if the log is unselected
|
// Or if the log is unselected
|
||||||
if (!LogManager::GetInstance()->isEnable(LogTypes::FILEMON)) return;
|
if (!LogManager::GetInstance()->IsEnabled(LogTypes::FILEMON)) return;
|
||||||
if (!FileAccess) return;
|
if (!FileAccess) return;
|
||||||
|
|
||||||
if (!pFileSystem || ISOFile != SConfig::GetInstance().m_LastFilename)
|
if (!pFileSystem || ISOFile != SConfig::GetInstance().m_LastFilename)
|
||||||
|
|
|
@ -344,7 +344,7 @@ CFrame::CFrame(wxFrame* parent,
|
||||||
if (ShowLogWindow) SConfig::GetInstance().m_InterfaceLogWindow = true;
|
if (ShowLogWindow) SConfig::GetInstance().m_InterfaceLogWindow = true;
|
||||||
|
|
||||||
// Give it a console early to show potential messages from this onward
|
// Give it a console early to show potential messages from this onward
|
||||||
ConsoleListener *Console = LogManager::GetInstance()->getConsoleListener();
|
ConsoleListener *Console = LogManager::GetInstance()->GetConsoleListener();
|
||||||
if (SConfig::GetInstance().m_InterfaceConsole) Console->Open();
|
if (SConfig::GetInstance().m_InterfaceConsole) Console->Open();
|
||||||
|
|
||||||
// Start debugging mazimized
|
// Start debugging mazimized
|
||||||
|
|
|
@ -142,7 +142,7 @@ void CFrame::ToggleConsole(bool bShow)
|
||||||
// If the console doesn't exist, we create it
|
// If the console doesn't exist, we create it
|
||||||
if (!GetConsoleWindow())
|
if (!GetConsoleWindow())
|
||||||
{
|
{
|
||||||
ConsoleListener *Console = LogManager::GetInstance()->getConsoleListener();
|
ConsoleListener *Console = LogManager::GetInstance()->GetConsoleListener();
|
||||||
Console->Open();
|
Console->Open();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -747,7 +747,7 @@ void CFrame::ResizeConsole()
|
||||||
/*max out the width in the word wrap mode*/ 100;
|
/*max out the width in the word wrap mode*/ 100;
|
||||||
int WindowHeight = InternalHeight + MenuBar;
|
int WindowHeight = InternalHeight + MenuBar;
|
||||||
// Resize buffer
|
// Resize buffer
|
||||||
ConsoleListener* Console = LogManager::GetInstance()->getConsoleListener();
|
ConsoleListener* Console = LogManager::GetInstance()->GetConsoleListener();
|
||||||
Console->PixelSpace(0,0, InternalWidth, InternalHeight, false);
|
Console->PixelSpace(0,0, InternalWidth, InternalHeight, false);
|
||||||
// Move the window to hide the border
|
// Move the window to hide the border
|
||||||
MoveWindow(GetConsoleWindow(), -Border-wxBorder, -MenuBar-wxBorder,
|
MoveWindow(GetConsoleWindow(), -Border-wxBorder, -MenuBar-wxBorder,
|
||||||
|
|
|
@ -69,7 +69,7 @@ void LogConfigWindow::CreateGUIControls()
|
||||||
m_checks = new wxCheckListBox(this, wxID_ANY);
|
m_checks = new wxCheckListBox(this, wxID_ANY);
|
||||||
_connect_macro_(m_checks, LogConfigWindow::OnLogCheck, wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, this);
|
_connect_macro_(m_checks, LogConfigWindow::OnLogCheck, wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, this);
|
||||||
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++)
|
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++)
|
||||||
m_checks->Append(wxString::FromAscii(m_LogManager->getFullName((LogTypes::LOG_TYPE)i)));
|
m_checks->Append(wxString::FromAscii(m_LogManager->GetFullName((LogTypes::LOG_TYPE)i)));
|
||||||
|
|
||||||
// Sizers
|
// Sizers
|
||||||
wxStaticBoxSizer* sbOutputs = new wxStaticBoxSizer(wxVERTICAL, this, _("Logger Outputs"));
|
wxStaticBoxSizer* sbOutputs = new wxStaticBoxSizer(wxVERTICAL, this, _("Logger Outputs"));
|
||||||
|
@ -110,7 +110,7 @@ void LogConfigWindow::LoadSettings()
|
||||||
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
|
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
|
||||||
{
|
{
|
||||||
bool log_enabled;
|
bool log_enabled;
|
||||||
ini.Get("Logs", m_LogManager->getShortName((LogTypes::LOG_TYPE)i), &log_enabled, true);
|
ini.Get("Logs", m_LogManager->GetShortName((LogTypes::LOG_TYPE)i), &log_enabled, true);
|
||||||
if (log_enabled) enableAll = false;
|
if (log_enabled) enableAll = false;
|
||||||
m_checks->Check(i, log_enabled);
|
m_checks->Check(i, log_enabled);
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ void LogConfigWindow::SaveSettings()
|
||||||
ini.Set("Options", "WriteToConsole", m_writeConsole);
|
ini.Set("Options", "WriteToConsole", m_writeConsole);
|
||||||
ini.Set("Options", "WriteToWindow", m_writeWindow);
|
ini.Set("Options", "WriteToWindow", m_writeWindow);
|
||||||
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
|
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.Set("Logs", m_LogManager->GetShortName((LogTypes::LOG_TYPE)i), m_checks->IsChecked(i));
|
||||||
ini.Save(File::GetUserPath(F_LOGGERCONFIG_IDX));
|
ini.Save(File::GetUserPath(F_LOGGERCONFIG_IDX));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ void LogConfigWindow::OnVerbosityChange(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
int v = m_verbosity->GetSelection() + 1;
|
int v = m_verbosity->GetSelection() + 1;
|
||||||
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++)
|
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++)
|
||||||
m_LogManager->setLogLevel((LogTypes::LOG_TYPE)i, (LogTypes::LOG_LEVELS)v);
|
m_LogManager->SetLogLevel((LogTypes::LOG_TYPE)i, (LogTypes::LOG_LEVELS)v);
|
||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,9 +146,9 @@ void LogConfigWindow::OnWriteFileChecked(wxCommandEvent& event)
|
||||||
if (m_checks->IsChecked(i))
|
if (m_checks->IsChecked(i))
|
||||||
{
|
{
|
||||||
if (m_writeFile)
|
if (m_writeFile)
|
||||||
m_LogManager->addListener((LogTypes::LOG_TYPE)i, m_LogManager->getFileListener());
|
m_LogManager->AddListener((LogTypes::LOG_TYPE)i, m_LogManager->GetFileListener());
|
||||||
else
|
else
|
||||||
m_LogManager->removeListener((LogTypes::LOG_TYPE)i, m_LogManager->getFileListener());
|
m_LogManager->RemoveListener((LogTypes::LOG_TYPE)i, m_LogManager->GetFileListener());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -161,9 +161,9 @@ void LogConfigWindow::OnWriteConsoleChecked(wxCommandEvent& event)
|
||||||
if (m_checks->IsChecked(i))
|
if (m_checks->IsChecked(i))
|
||||||
{
|
{
|
||||||
if (m_writeConsole)
|
if (m_writeConsole)
|
||||||
m_LogManager->addListener((LogTypes::LOG_TYPE)i, m_LogManager->getConsoleListener());
|
m_LogManager->AddListener((LogTypes::LOG_TYPE)i, m_LogManager->GetConsoleListener());
|
||||||
else
|
else
|
||||||
m_LogManager->removeListener((LogTypes::LOG_TYPE)i, m_LogManager->getConsoleListener());
|
m_LogManager->RemoveListener((LogTypes::LOG_TYPE)i, m_LogManager->GetConsoleListener());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -176,9 +176,9 @@ void LogConfigWindow::OnWriteWindowChecked(wxCommandEvent& event)
|
||||||
if (m_checks->IsChecked(i))
|
if (m_checks->IsChecked(i))
|
||||||
{
|
{
|
||||||
if (m_writeWindow)
|
if (m_writeWindow)
|
||||||
m_LogManager->addListener((LogTypes::LOG_TYPE)i, (LogListener *)m_LogWindow);
|
m_LogManager->AddListener((LogTypes::LOG_TYPE)i, (LogListener *)m_LogWindow);
|
||||||
else
|
else
|
||||||
m_LogManager->removeListener((LogTypes::LOG_TYPE)i, (LogListener *)m_LogWindow);
|
m_LogManager->RemoveListener((LogTypes::LOG_TYPE)i, (LogListener *)m_LogWindow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -197,22 +197,22 @@ void LogConfigWindow::ToggleLog(int _logType, bool enable)
|
||||||
|
|
||||||
m_checks->Check(_logType, enable);
|
m_checks->Check(_logType, enable);
|
||||||
|
|
||||||
m_LogManager->setEnable(logType, enable);
|
m_LogManager->SetEnable(logType, enable);
|
||||||
|
|
||||||
if (enable)
|
if (enable)
|
||||||
{
|
{
|
||||||
if (m_writeWindow)
|
if (m_writeWindow)
|
||||||
m_LogManager->addListener(logType, (LogListener *)m_LogWindow);
|
m_LogManager->AddListener(logType, (LogListener *)m_LogWindow);
|
||||||
if (m_writeFile)
|
if (m_writeFile)
|
||||||
m_LogManager->addListener(logType, m_LogManager->getFileListener());
|
m_LogManager->AddListener(logType, m_LogManager->GetFileListener());
|
||||||
if (m_writeConsole)
|
if (m_writeConsole)
|
||||||
m_LogManager->addListener(logType, m_LogManager->getConsoleListener());
|
m_LogManager->AddListener(logType, m_LogManager->GetConsoleListener());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_LogManager->removeListener(logType, (LogListener *)m_LogWindow);
|
m_LogManager->RemoveListener(logType, (LogListener *)m_LogWindow);
|
||||||
m_LogManager->removeListener(logType, m_LogManager->getFileListener());
|
m_LogManager->RemoveListener(logType, m_LogManager->GetFileListener());
|
||||||
m_LogManager->removeListener(logType, m_LogManager->getConsoleListener());
|
m_LogManager->RemoveListener(logType, m_LogManager->GetConsoleListener());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,23 +87,23 @@ void CLogWindow::CreateGUIControls()
|
||||||
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
|
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
|
||||||
{
|
{
|
||||||
bool enable;
|
bool enable;
|
||||||
ini.Get("Logs", m_LogManager->getShortName((LogTypes::LOG_TYPE)i), &enable, true);
|
ini.Get("Logs", m_LogManager->GetShortName((LogTypes::LOG_TYPE)i), &enable, true);
|
||||||
|
|
||||||
if (m_writeWindow && enable)
|
if (m_writeWindow && enable)
|
||||||
m_LogManager->addListener((LogTypes::LOG_TYPE)i, this);
|
m_LogManager->AddListener((LogTypes::LOG_TYPE)i, this);
|
||||||
else
|
else
|
||||||
m_LogManager->removeListener((LogTypes::LOG_TYPE)i, this);
|
m_LogManager->RemoveListener((LogTypes::LOG_TYPE)i, this);
|
||||||
|
|
||||||
if (m_writeFile && enable)
|
if (m_writeFile && enable)
|
||||||
m_LogManager->addListener((LogTypes::LOG_TYPE)i, m_LogManager->getFileListener());
|
m_LogManager->AddListener((LogTypes::LOG_TYPE)i, m_LogManager->GetFileListener());
|
||||||
else
|
else
|
||||||
m_LogManager->removeListener((LogTypes::LOG_TYPE)i, m_LogManager->getFileListener());
|
m_LogManager->RemoveListener((LogTypes::LOG_TYPE)i, m_LogManager->GetFileListener());
|
||||||
|
|
||||||
if (m_writeConsole && enable)
|
if (m_writeConsole && enable)
|
||||||
m_LogManager->addListener((LogTypes::LOG_TYPE)i, m_LogManager->getConsoleListener());
|
m_LogManager->AddListener((LogTypes::LOG_TYPE)i, m_LogManager->GetConsoleListener());
|
||||||
else
|
else
|
||||||
m_LogManager->removeListener((LogTypes::LOG_TYPE)i, m_LogManager->getConsoleListener());
|
m_LogManager->RemoveListener((LogTypes::LOG_TYPE)i, m_LogManager->GetConsoleListener());
|
||||||
m_LogManager->setLogLevel((LogTypes::LOG_TYPE)i, (LogTypes::LOG_LEVELS)(verbosity));
|
m_LogManager->SetLogLevel((LogTypes::LOG_TYPE)i, (LogTypes::LOG_LEVELS)(verbosity));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Font
|
// Font
|
||||||
|
@ -159,7 +159,7 @@ CLogWindow::~CLogWindow()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
|
for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i)
|
||||||
{
|
{
|
||||||
m_LogManager->removeListener((LogTypes::LOG_TYPE)i, this);
|
m_LogManager->RemoveListener((LogTypes::LOG_TYPE)i, this);
|
||||||
}
|
}
|
||||||
m_LogTimer->Stop();
|
m_LogTimer->Stop();
|
||||||
delete m_LogTimer;
|
delete m_LogTimer;
|
||||||
|
@ -205,7 +205,7 @@ void CLogWindow::OnClear(wxCommandEvent& WXUNUSED (event))
|
||||||
msgQueue.pop();
|
msgQueue.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_LogManager->getConsoleListener()->ClearScreen();
|
m_LogManager->GetConsoleListener()->ClearScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CLogWindow::UnPopulateBottom()
|
void CLogWindow::UnPopulateBottom()
|
||||||
|
|
Loading…
Reference in New Issue