diff --git a/Utilities/Log.cpp b/Utilities/Log.cpp index f4e0cdbdd2..180f77bff3 100644 --- a/Utilities/Log.cpp +++ b/Utilities/Log.cpp @@ -210,6 +210,20 @@ void LogManager::log(LogMessage msg) #endif } +void LogManager::addListener(std::shared_ptr listener) +{ + for (auto& channel : mChannels) + { + channel.addListener(listener); + } +} +void LogManager::removeListener(std::shared_ptr listener) +{ + for (auto& channel : mChannels) + { + channel.removeListener(listener); + } +} LogManager& LogManager::getInstance() { diff --git a/Utilities/Log.h b/Utilities/Log.h index bf98355690..d34e664be9 100644 --- a/Utilities/Log.h +++ b/Utilities/Log.h @@ -113,6 +113,8 @@ namespace Log static LogManager& getInstance(); LogChannel& getChannel(LogType type); void log(LogMessage msg); + void addListener(std::shared_ptr listener); + void removeListener(std::shared_ptr listener); #ifdef BUFFERED_LOGGING void consumeLog(); #endif diff --git a/rpcs3/Gui/ConLogFrame.cpp b/rpcs3/Gui/ConLogFrame.cpp index 273d673a02..3e5a7056a8 100644 --- a/rpcs3/Gui/ConLogFrame.cpp +++ b/rpcs3/Gui/ConLogFrame.cpp @@ -139,14 +139,7 @@ LogFrame::LogFrame(wxWindow* parent) m_tabs.AddPage(m_log, "Log"); m_tabs.AddPage(m_tty, "TTY"); - Log::LogManager::getInstance().getChannel(Log::GENERAL).addListener(listener); - Log::LogManager::getInstance().getChannel(Log::LOADER).addListener(listener); - Log::LogManager::getInstance().getChannel(Log::MEMORY).addListener(listener); - Log::LogManager::getInstance().getChannel(Log::RSX).addListener(listener); - Log::LogManager::getInstance().getChannel(Log::HLE).addListener(listener); - Log::LogManager::getInstance().getChannel(Log::PPU).addListener(listener); - Log::LogManager::getInstance().getChannel(Log::SPU).addListener(listener); - Log::LogManager::getInstance().getChannel(Log::TTY).addListener(listener); + Log::LogManager::getInstance().addListener(listener); wxBoxSizer* s_main = new wxBoxSizer(wxVERTICAL); s_main->Add(&m_tabs, 1, wxEXPAND); @@ -158,14 +151,7 @@ LogFrame::LogFrame(wxWindow* parent) LogFrame::~LogFrame() { - Log::LogManager::getInstance().getChannel(Log::GENERAL).removeListener(listener); - Log::LogManager::getInstance().getChannel(Log::LOADER).removeListener(listener); - Log::LogManager::getInstance().getChannel(Log::MEMORY).removeListener(listener); - Log::LogManager::getInstance().getChannel(Log::RSX).removeListener(listener); - Log::LogManager::getInstance().getChannel(Log::HLE).removeListener(listener); - Log::LogManager::getInstance().getChannel(Log::PPU).removeListener(listener); - Log::LogManager::getInstance().getChannel(Log::SPU).removeListener(listener); - Log::LogManager::getInstance().getChannel(Log::TTY).removeListener(listener); + Log::LogManager::getInstance().removeListener(listener); } bool LogFrame::Close(bool force)