mirror-chatterino2/src/singletons/Logging.cpp

54 lines
1.4 KiB
C++
Raw Normal View History

2018-06-28 19:46:45 +02:00
#include "singletons/Logging.hpp"
2018-06-26 14:09:39 +02:00
#include "Application.hpp"
#include "singletons/helper/LoggingChannel.hpp"
2018-06-28 19:46:45 +02:00
#include "singletons/Paths.hpp"
#include "singletons/Settings.hpp"
#include <QDir>
#include <QStandardPaths>
#include <memory>
#include <unordered_map>
#include <utility>
namespace chatterino {
2018-08-02 14:23:27 +02:00
void Logging::initialize(Settings &settings, Paths &paths)
{
}
void Logging::addMessage(const QString &channelName, MessagePtr message,
const QString &platformName)
{
2018-10-21 13:43:02 +02:00
if (!getSettings()->enableLogging)
{
return;
}
auto platIt = this->loggingChannels_.find(platformName);
if (platIt == this->loggingChannels_.end())
2018-10-21 13:43:02 +02:00
{
auto channel = new LoggingChannel(channelName, platformName);
channel->addMessage(message);
auto map = std::map<QString, std::unique_ptr<LoggingChannel>>();
this->loggingChannels_[platformName] = std::move(map);
auto &ref = this->loggingChannels_.at(platformName);
ref.emplace(channelName, std::move(channel));
return;
}
auto chanIt = platIt->second.find(channelName);
if (chanIt == platIt->second.end())
{
auto channel = new LoggingChannel(channelName, platformName);
channel->addMessage(message);
platIt->second.emplace(channelName, std::move(channel));
2018-10-21 13:43:02 +02:00
}
else
{
chanIt->second->addMessage(message);
}
}
} // namespace chatterino