ui: logview logic in controller

* logfilter in applicationsettings
* logview limit 500 entries
This commit is contained in:
Andreas Stallinger
2016-11-25 15:16:07 +01:00
parent 3a61a98e4b
commit f53f6dae98
17 changed files with 258 additions and 37 deletions
+10
View File
@@ -53,6 +53,16 @@ void LogManager::removeLoggersByType(const std::string& type)
m_logManagerImplementation.removeLoggersByType(type);
}
Logger* LogManager::getLogger(std::shared_ptr<Logger> logger)
{
return m_logManagerImplementation.getLogger(logger);
}
Logger* LogManager::getLoggerByType(const std::string& type)
{
return m_logManagerImplementation.getLoggerByType(type);
}
void LogManager::clearLoggers()
{
m_logManagerImplementation.clearLoggers();
+2
View File
@@ -22,6 +22,8 @@ public:
void removeLoggersByType(const std::string& type);
void clearLoggers();
int getLoggerCount() const;
Logger* getLoggerByType(const std::string& type);
Logger* getLogger(std::shared_ptr<Logger> logger);
void logInfo(
const std::string& message,
@@ -49,6 +49,31 @@ void LogManagerImplementation::removeLoggersByType(const std::string& type)
}
}
Logger* LogManagerImplementation::getLogger(std::shared_ptr<Logger> logger)
{
std::lock_guard<std::mutex> lockGuard(m_loggerMutex);
std::vector<std::shared_ptr<Logger>>::iterator it = std::find(m_loggers.begin(), m_loggers.end(), logger);
if (it != m_loggers.end())
{
return (*it).get();
}
return nullptr;
}
Logger* LogManagerImplementation::getLoggerByType(const std::string& type)
{
std::lock_guard<std::mutex> lockGuard(m_loggerMutex);
for (unsigned int i = 0; i < m_loggers.size(); i++)
{
if (m_loggers[i]->getType() == type)
{
return m_loggers[i].get();
}
}
return nullptr;
}
void LogManagerImplementation::clearLoggers()
{
m_loggers.clear();
@@ -26,6 +26,8 @@ public:
void removeLoggersByType(const std::string& type);
void clearLoggers();
int getLoggerCount() const;
Logger* getLogger(std::shared_ptr<Logger> logger);
Logger* getLoggerByType(const std::string& type);
void logInfo(
const std::string& message,
@@ -54,4 +56,4 @@ private:
mutable std::mutex m_loggerMutex;
};
#endif // LOG_MANAGER_IMPLEMENTATION_H
#endif // LOG_MANAGER_IMPLEMENTATION_H
@@ -0,0 +1,24 @@
#ifndef MESSAGE_LOG_FILTER_CHANGED_H
#define MESSAGE_LOG_FILTER_CHANGED_H
#include "utility/messaging/Message.h"
#include "utility/logging/Logger.h"
class MessageLogFilterChanged
: public Message<MessageLogFilterChanged>
{
public:
MessageLogFilterChanged(const Logger::LogLevelMask filter)
: logFilter(filter)
{
}
static const std::string getStaticType()
{
return "MessageLogFilterChanged";
}
const Logger::LogLevelMask logFilter;
};
#endif // MESSAGE_LOG_FILTER_CHANGED_H