mirror-chatterino2/src/singletons/LoggingManager.cpp

40 lines
947 B
C++
Raw Normal View History

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