1
0
mirror of synced 2024-12-04 20:17:57 +01:00
ImHex/plugins/libimhex/include/hex/pattern_language/log_console.hpp
WerWolv e74c0f5cf5 sys: Tons of long overdue cleanup
- std::string -> const std::string& where needed
- Added a FileIO abstraction class
- Fixed recent files not updating
- Removed localization file from global include
- Renamed lang to pattern_language/pl
- Renamed EventFileDropped to RequestFileOpen
2021-09-08 15:18:24 +02:00

47 lines
1.2 KiB
C++

#pragma once
#include <hex.hpp>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
namespace hex::pl {
class LogConsole {
public:
enum Level {
Debug,
Info,
Warning,
Error
};
const auto& getLog() { return this->m_consoleLog; }
using EvaluateError = std::string;
void log(Level level, const std::string &message) {
switch (level) {
default:
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;
}
}
[[noreturn]] void abortEvaluation(const std::string &message) {
throw EvaluateError(message);
}
void clear() {
this->m_consoleLog.clear();
}
private:
std::vector<std::pair<Level, std::string>> m_consoleLog;
};
}