mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
4c782ce90c
* Add checkbox for custom logging and table with channels to log on Logs page * Add checkbox to enable and disable logging per channel * Return from addMessage before logging if custom logging enabled and channel does not have logging enabled * Use clang-format to fix formatting * Add CHANGELOG.md entry * Resolve PR comments * Remove toggle for channels so any channel listed will be logged * Move Only log channels listed below checkbox to just above table * Fix formatting * Re-order changelog * ChannelLog constructor: Copy & move instead of const ref & copy * ChannelLog::createEmpty: Curly brace initialize instead of repeating name * ChannelLog toString & createEmpty: nodiscard * Use COUNT paradigm in model column * Remove ChanneLoggingModel source file comments * Use Column::Channel in getRowFromItem * Rename `getItemFromRow` parameter and mark it as unused * Curly brace initialize ChannelLog * private & friend class the model * Filter out channels to log using a set instead of iterating over a vector every time a message comes in * Rename `ChannelLog::channel` member to `ChannelLog::channelName` Also made it private * mini comment on ChannelLog Co-authored-by: Felanbird <41973452+Felanbird@users.noreply.github.com> Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
45 lines
987 B
C++
45 lines
987 B
C++
#pragma once
|
|
|
|
#include "common/Singleton.hpp"
|
|
#include "util/QStringHash.hpp"
|
|
#include "util/ThreadGuard.hpp"
|
|
|
|
#include <QString>
|
|
|
|
#include <map>
|
|
#include <memory>
|
|
#include <unordered_set>
|
|
|
|
namespace chatterino {
|
|
|
|
class Paths;
|
|
struct Message;
|
|
using MessagePtr = std::shared_ptr<const Message>;
|
|
class LoggingChannel;
|
|
|
|
class Logging : public Singleton
|
|
{
|
|
Paths *pathManager = nullptr;
|
|
|
|
public:
|
|
Logging() = default;
|
|
|
|
virtual void initialize(Settings &settings, Paths &paths) override;
|
|
|
|
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
|