2021-01-22 18:01:39 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <hex.hpp>
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <string_view>
|
|
|
|
#include <utility>
|
|
|
|
#include <vector>
|
|
|
|
|
2021-09-08 15:18:24 +02:00
|
|
|
namespace hex::pl {
|
2021-01-22 18:01:39 +01:00
|
|
|
|
|
|
|
class LogConsole {
|
|
|
|
public:
|
|
|
|
enum Level {
|
|
|
|
Debug,
|
|
|
|
Info,
|
|
|
|
Warning,
|
|
|
|
Error
|
|
|
|
};
|
|
|
|
|
|
|
|
const auto& getLog() { return this->m_consoleLog; }
|
|
|
|
|
|
|
|
using EvaluateError = std::string;
|
|
|
|
|
2021-09-08 15:18:24 +02:00
|
|
|
void log(Level level, const std::string &message) {
|
2021-01-22 18:01:39 +01:00
|
|
|
switch (level) {
|
|
|
|
default:
|
2021-09-08 15:18:24 +02:00
|
|
|
case Level::Debug: this->m_consoleLog.emplace_back(level, "[-] " + message); break;
|
|
|
|
case Level::Info: this->m_consoleLog.emplace_back(level, "[i] " + message); break;
|
|
|
|
case Level::Warning: this->m_consoleLog.emplace_back(level, "[*] " + message); break;
|
|
|
|
case Level::Error: this->m_consoleLog.emplace_back(level, "[!] " + message); break;
|
2021-01-22 18:01:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-08 15:18:24 +02:00
|
|
|
[[noreturn]] void abortEvaluation(const std::string &message) {
|
2021-01-22 18:01:39 +01:00
|
|
|
throw EvaluateError(message);
|
|
|
|
}
|
|
|
|
|
|
|
|
void clear() {
|
|
|
|
this->m_consoleLog.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<std::pair<Level, std::string>> m_consoleLog;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|