mirror-chatterino2/src/singletons/Logging.cpp
pajlada 032f290767
Sort and force grouping of includes (#4172)
This change enforces strict include grouping using IncludeCategories

In addition to adding this to the .clang-format file and applying it in the tests/src and src directories, I also did the following small changes:

    In ChatterSet.hpp, I changed lrucache to a <>include
    In Irc2.hpp, I change common/SignalVector.hpp to a "project-include"
    In AttachedWindow.cpp, NativeMessaging.cpp, WindowsHelper.hpp, BaseWindow.cpp, and StreamerMode.cpp, I disabled clang-format for the windows-includes
    In WindowDescriptors.hpp, I added the missing vector include. It was previously not needed because the include was handled by another file that was previously included first.
    clang-format minimum version has been bumped, so Ubuntu version used in the check-formatting job has been bumped to 22.04 (which is the latest LTS)
2022-11-27 19:32:53 +01:00

54 lines
1.4 KiB
C++

#include "singletons/Logging.hpp"
#include "Application.hpp"
#include "singletons/helper/LoggingChannel.hpp"
#include "singletons/Paths.hpp"
#include "singletons/Settings.hpp"
#include <QDir>
#include <QStandardPaths>
#include <memory>
#include <unordered_map>
#include <utility>
namespace chatterino {
void Logging::initialize(Settings &settings, Paths &paths)
{
}
void Logging::addMessage(const QString &channelName, MessagePtr message,
const QString &platformName)
{
if (!getSettings()->enableLogging)
{
return;
}
auto platIt = this->loggingChannels_.find(platformName);
if (platIt == this->loggingChannels_.end())
{
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));
}
else
{
chanIt->second->addMessage(message);
}
}
} // namespace chatterino