2018-06-28 19:46:45 +02:00
|
|
|
#include "singletons/Logging.hpp"
|
2018-04-27 22:11:19 +02:00
|
|
|
|
2018-06-26 14:09:39 +02:00
|
|
|
#include "Application.hpp"
|
2018-06-28 19:46:45 +02:00
|
|
|
#include "singletons/Paths.hpp"
|
|
|
|
#include "singletons/Settings.hpp"
|
2022-07-02 11:42:28 +02:00
|
|
|
#include "singletons/helper/LoggingChannel.hpp"
|
2018-01-28 14:23:55 +01:00
|
|
|
|
|
|
|
#include <QDir>
|
|
|
|
#include <QStandardPaths>
|
|
|
|
|
2022-07-02 11:42:28 +02:00
|
|
|
#include <memory>
|
2018-01-28 14:23:55 +01:00
|
|
|
#include <unordered_map>
|
2022-07-02 11:42:28 +02:00
|
|
|
#include <utility>
|
2018-01-28 14:23:55 +01:00
|
|
|
|
|
|
|
namespace chatterino {
|
|
|
|
|
2018-08-02 14:23:27 +02:00
|
|
|
void Logging::initialize(Settings &settings, Paths &paths)
|
2018-01-28 14:23:55 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-07-02 11:42:28 +02:00
|
|
|
void Logging::addMessage(const QString &channelName, MessagePtr message,
|
|
|
|
const QString &platformName)
|
2018-01-28 14:23:55 +01:00
|
|
|
{
|
2018-10-21 13:43:02 +02:00
|
|
|
if (!getSettings()->enableLogging)
|
|
|
|
{
|
2018-01-28 14:23:55 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-07-02 11:42:28 +02:00
|
|
|
auto platIt = this->loggingChannels_.find(platformName);
|
|
|
|
if (platIt == this->loggingChannels_.end())
|
2018-10-21 13:43:02 +02:00
|
|
|
{
|
2022-07-02 11:42:28 +02:00
|
|
|
auto channel = new LoggingChannel(channelName, platformName);
|
2018-01-28 14:23:55 +01:00
|
|
|
channel->addMessage(message);
|
2022-07-02 11:42:28 +02:00
|
|
|
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
|
|
|
|
{
|
2022-07-02 11:42:28 +02:00
|
|
|
chanIt->second->addMessage(message);
|
2018-01-28 14:23:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace chatterino
|