2018-01-28 14:23:55 +01:00
|
|
|
#pragma once
|
|
|
|
|
2018-07-07 11:41:01 +02:00
|
|
|
#include "common/Singleton.hpp"
|
2023-01-15 12:47:22 +01:00
|
|
|
#include "util/QStringHash.hpp"
|
|
|
|
#include "util/ThreadGuard.hpp"
|
2018-01-28 14:23:55 +01:00
|
|
|
|
2022-12-31 15:41:01 +01:00
|
|
|
#include <QString>
|
|
|
|
|
|
|
|
#include <map>
|
2018-01-28 14:23:55 +01:00
|
|
|
#include <memory>
|
2023-01-15 12:47:22 +01:00
|
|
|
#include <unordered_set>
|
2018-01-28 14:23:55 +01:00
|
|
|
|
|
|
|
namespace chatterino {
|
2018-06-26 16:37:59 +02:00
|
|
|
|
2018-06-28 19:51:07 +02:00
|
|
|
class Paths;
|
2022-12-31 15:41:01 +01:00
|
|
|
struct Message;
|
|
|
|
using MessagePtr = std::shared_ptr<const Message>;
|
|
|
|
class LoggingChannel;
|
2018-01-28 14:23:55 +01:00
|
|
|
|
2018-07-07 11:41:01 +02:00
|
|
|
class Logging : public Singleton
|
2018-01-28 14:23:55 +01:00
|
|
|
{
|
2018-06-28 19:51:07 +02:00
|
|
|
Paths *pathManager = nullptr;
|
2018-01-28 14:23:55 +01:00
|
|
|
|
|
|
|
public:
|
2018-06-28 19:51:07 +02:00
|
|
|
Logging() = default;
|
2018-04-28 15:20:18 +02:00
|
|
|
|
2018-08-02 14:23:27 +02:00
|
|
|
virtual void initialize(Settings &settings, Paths &paths) override;
|
2018-01-28 14:23:55 +01:00
|
|
|
|
2022-07-02 11:42:28 +02:00
|
|
|
void addMessage(const QString &channelName, MessagePtr message,
|
|
|
|
const QString &platformName);
|
2018-01-28 14:23:55 +01:00
|
|
|
|
|
|
|
private:
|
2022-07-02 11:42:28 +02:00
|
|
|
using PlatformName = QString;
|
|
|
|
using ChannelName = QString;
|
|
|
|
std::map<PlatformName,
|
|
|
|
std::map<ChannelName, std::unique_ptr<LoggingChannel>>>
|
|
|
|
loggingChannels_;
|
2023-01-15 12:47:22 +01:00
|
|
|
|
|
|
|
// Keeps the value of the `loggedChannels` settings
|
|
|
|
std::unordered_set<ChannelName> onlyLogListedChannels;
|
|
|
|
ThreadGuard threadGuard;
|
2018-01-28 14:23:55 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace chatterino
|