mirror-chatterino2/src/singletons/Logging.cpp

37 lines
866 B
C++
Raw Normal View History

2018-06-28 19:46:45 +02:00
#include "singletons/Logging.hpp"
2018-06-26 14:09:39 +02:00
#include "Application.hpp"
#include "debug/Log.hpp"
2018-06-28 19:46:45 +02:00
#include "singletons/Paths.hpp"
#include "singletons/Settings.hpp"
#include <QDir>
#include <QStandardPaths>
#include <unordered_map>
namespace chatterino {
2018-07-07 11:41:01 +02:00
void Logging::initialize(Application &app)
{
}
2018-06-28 19:51:07 +02:00
void Logging::addMessage(const QString &channelName, MessagePtr message)
{
2018-07-07 11:41:01 +02:00
if (!getSettings()->enableLogging) {
return;
}
2018-07-06 19:23:47 +02:00
auto it = this->loggingChannels_.find(channelName);
if (it == this->loggingChannels_.end()) {
auto channel = new LoggingChannel(channelName);
channel->addMessage(message);
2018-07-06 19:23:47 +02:00
this->loggingChannels_.emplace(channelName,
2018-07-07 11:41:01 +02:00
std::unique_ptr<LoggingChannel>(std::move(channel)));
} else {
it->second->addMessage(message);
}
}
} // namespace chatterino