mirror of
https://github.com/libretro/ppsspp.git
synced 2025-01-29 12:52:34 +00:00
More cleanup
This commit is contained in:
parent
1ccca2ef33
commit
a5d77f940a
@ -233,7 +233,11 @@ void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const
|
||||
msgPos[neededBytes + 1] = '\0';
|
||||
}
|
||||
|
||||
Trigger(level, msg);
|
||||
std::lock_guard<std::mutex> listeners_lock(listeners_lock_);
|
||||
std::set<LogListener*>::const_iterator i;
|
||||
for (i = listeners_.begin(); i != listeners_.end(); ++i) {
|
||||
(*i)->Log(level, msg);
|
||||
}
|
||||
}
|
||||
|
||||
bool LogManager::IsEnabled(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type) {
|
||||
@ -264,24 +268,13 @@ LogChannel::LogChannel(const char* shortName)
|
||||
|
||||
// LogContainer
|
||||
void LogManager::AddListener(LogListener *listener) {
|
||||
std::lock_guard<std::mutex> lk(m_listeners_lock);
|
||||
m_listeners.insert(listener);
|
||||
m_hasListeners = true;
|
||||
std::lock_guard<std::mutex> lk(listeners_lock_);
|
||||
listeners_.insert(listener);
|
||||
}
|
||||
|
||||
void LogManager::RemoveListener(LogListener *listener) {
|
||||
std::lock_guard<std::mutex> lk(m_listeners_lock);
|
||||
m_listeners.erase(listener);
|
||||
m_hasListeners = !m_listeners.empty();
|
||||
}
|
||||
|
||||
void LogManager::Trigger(LogTypes::LOG_LEVELS level, const char *msg) {
|
||||
std::lock_guard<std::mutex> lk(m_listeners_lock);
|
||||
|
||||
std::set<LogListener*>::const_iterator i;
|
||||
for (i = m_listeners.begin(); i != m_listeners.end(); ++i) {
|
||||
(*i)->Log(level, msg);
|
||||
}
|
||||
std::lock_guard<std::mutex> lk(listeners_lock_);
|
||||
listeners_.erase(listener);
|
||||
}
|
||||
|
||||
FileLogListener::FileLogListener(const char *filename) {
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include <set>
|
||||
#include <mutex>
|
||||
|
||||
#include "file/ini_file.h"
|
||||
#include "Log.h"
|
||||
#include "StringUtils.h"
|
||||
@ -171,8 +172,6 @@ public:
|
||||
void LoadConfig(IniFile::Section *section, bool debugDefaults);
|
||||
|
||||
private:
|
||||
void Trigger(LogTypes::LOG_LEVELS, const char *msg);
|
||||
|
||||
LogChannel* log_[LogTypes::NUMBER_OF_LOGS];
|
||||
FileLogListener *fileLog_;
|
||||
ConsoleListener *consoleLog_;
|
||||
@ -181,9 +180,8 @@ private:
|
||||
static LogManager *logManager_; // Singleton. Ugh.
|
||||
std::mutex log_lock_;
|
||||
|
||||
std::mutex m_listeners_lock;
|
||||
std::set<LogListener*> m_listeners;
|
||||
bool m_hasListeners;
|
||||
std::mutex listeners_lock_;
|
||||
std::set<LogListener*> listeners_;
|
||||
|
||||
LogManager();
|
||||
~LogManager();
|
||||
|
Loading…
x
Reference in New Issue
Block a user