2018-06-26 14:09:39 +02:00
|
|
|
#include "singletons/LoggingManager.hpp"
|
2018-04-27 22:11:19 +02:00
|
|
|
|
2018-06-26 14:09:39 +02:00
|
|
|
#include "Application.hpp"
|
|
|
|
#include "debug/Log.hpp"
|
|
|
|
#include "singletons/PathManager.hpp"
|
|
|
|
#include "singletons/SettingsManager.hpp"
|
2018-01-28 14:23:55 +01:00
|
|
|
|
|
|
|
#include <QDir>
|
|
|
|
#include <QStandardPaths>
|
|
|
|
|
|
|
|
#include <unordered_map>
|
|
|
|
|
|
|
|
namespace chatterino {
|
|
|
|
|
2018-04-27 22:11:19 +02:00
|
|
|
void LoggingManager::initialize()
|
2018-01-28 14:23:55 +01:00
|
|
|
{
|
2018-04-27 22:11:19 +02:00
|
|
|
this->pathManager = getApp()->paths;
|
2018-01-28 14:23:55 +01:00
|
|
|
}
|
|
|
|
|
2018-06-28 19:38:57 +02:00
|
|
|
void LoggingManager::addMessage(const QString &channelName, MessagePtr message)
|
2018-01-28 14:23:55 +01:00
|
|
|
{
|
2018-04-27 22:11:19 +02:00
|
|
|
auto app = getApp();
|
2018-01-28 14:23:55 +01:00
|
|
|
|
2018-04-27 22:11:19 +02:00
|
|
|
if (!app->settings->enableLogging) {
|
2018-01-28 14:23:55 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto it = this->loggingChannels.find(channelName);
|
|
|
|
if (it == this->loggingChannels.end()) {
|
2018-06-06 20:30:11 +02:00
|
|
|
auto channel = new LoggingChannel(channelName);
|
2018-01-28 14:23:55 +01:00
|
|
|
channel->addMessage(message);
|
2018-01-28 15:28:02 +01:00
|
|
|
this->loggingChannels.emplace(channelName,
|
|
|
|
std::unique_ptr<LoggingChannel>(std::move(channel)));
|
2018-01-28 14:23:55 +01:00
|
|
|
} else {
|
|
|
|
it->second->addMessage(message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace chatterino
|