ui: logview logic in controller
* logfilter in applicationsettings * logview limit 500 entries
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user