Add logging to experimental IRC (#2996)
Co-authored-by: xHeaveny <69117321+xHeaveny@users.noreply.github.com> Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -3,11 +3,14 @@
|
||||
#include "Application.hpp"
|
||||
#include "singletons/Paths.hpp"
|
||||
#include "singletons/Settings.hpp"
|
||||
#include "singletons/helper/LoggingChannel.hpp"
|
||||
|
||||
#include <QDir>
|
||||
#include <QStandardPaths>
|
||||
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
@@ -15,24 +18,35 @@ void Logging::initialize(Settings &settings, Paths &paths)
|
||||
{
|
||||
}
|
||||
|
||||
void Logging::addMessage(const QString &channelName, MessagePtr message)
|
||||
void Logging::addMessage(const QString &channelName, MessagePtr message,
|
||||
const QString &platformName)
|
||||
{
|
||||
if (!getSettings()->enableLogging)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto it = this->loggingChannels_.find(channelName);
|
||||
if (it == this->loggingChannels_.end())
|
||||
auto platIt = this->loggingChannels_.find(platformName);
|
||||
if (platIt == this->loggingChannels_.end())
|
||||
{
|
||||
auto channel = new LoggingChannel(channelName);
|
||||
auto channel = new LoggingChannel(channelName, platformName);
|
||||
channel->addMessage(message);
|
||||
this->loggingChannels_.emplace(
|
||||
channelName, std::unique_ptr<LoggingChannel>(std::move(channel)));
|
||||
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));
|
||||
}
|
||||
else
|
||||
{
|
||||
it->second->addMessage(message);
|
||||
chanIt->second->addMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user