mirror-chatterino2/src/singletons/Logging.hpp
pajlada 65b1ed312c
refactor: Logging (chat logger) (#5058)
It's no longer a singleton

It's now a unique_ptr that dies together with the Application

* Add getChatLogger to EmptyApplication

* unrelated change: Access Application::instance statically

* fix logging init order

* Add changelog entry
2023-12-31 12:51:40 +00:00

39 lines
839 B
C++

#pragma once
#include "util/QStringHash.hpp"
#include "util/ThreadGuard.hpp"
#include <QString>
#include <map>
#include <memory>
#include <unordered_set>
namespace chatterino {
class Settings;
struct Message;
using MessagePtr = std::shared_ptr<const Message>;
class LoggingChannel;
class Logging
{
public:
Logging(Settings &settings);
void addMessage(const QString &channelName, MessagePtr message,
const QString &platformName);
private:
using PlatformName = QString;
using ChannelName = QString;
std::map<PlatformName,
std::map<ChannelName, std::unique_ptr<LoggingChannel>>>
loggingChannels_;
// Keeps the value of the `loggedChannels` settings
std::unordered_set<ChannelName> onlyLogListedChannels;
ThreadGuard threadGuard;
};
} // namespace chatterino