mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-28 07:47:03 -05:00
fix: Logs in log view not being filtered correctly
This commit is contained in:
@@ -26,17 +26,18 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
|
||||
static bool shouldDisplay(std::string_view messageLevel, int currLevel) {
|
||||
if (currLevel == 0)
|
||||
return true;
|
||||
else if (currLevel == 1 && messageLevel.contains("INFO"))
|
||||
return true;
|
||||
else if (currLevel == 2 && messageLevel.contains("WARN"))
|
||||
return true;
|
||||
else if (currLevel == 3 && messageLevel.contains("ERROR"))
|
||||
return true;
|
||||
else if (currLevel == 4 && messageLevel.contains("FATAL"))
|
||||
return true;
|
||||
return false;
|
||||
if (messageLevel.contains("[DEBUG]"))
|
||||
return currLevel <= 0;
|
||||
else if (messageLevel.contains("[INFO]"))
|
||||
return currLevel <= 1;
|
||||
else if (messageLevel.contains("[WARN]"))
|
||||
return currLevel <= 2;
|
||||
else if (messageLevel.contains("[ERROR]"))
|
||||
return currLevel <= 3;
|
||||
else if (messageLevel.contains("[FATAL]"))
|
||||
return currLevel <= 4;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void ViewLogs::drawContent() {
|
||||
@@ -50,28 +51,18 @@ namespace hex::plugin::builtin {
|
||||
ImGui::TableHeadersRow();
|
||||
|
||||
const auto &logs = log::impl::getLogEntries();
|
||||
ImGuiListClipper clipper;
|
||||
clipper.Begin(logs.size());
|
||||
|
||||
while (clipper.Step()) {
|
||||
auto end = 0;
|
||||
for (size_t i = clipper.DisplayStart; i < std::min<size_t>(clipper.DisplayEnd + end, logs.size()); i++) {
|
||||
const auto &log = logs[logs.size() - 1 - i];
|
||||
|
||||
if (!shouldDisplay(log.level, m_logLevel)) {
|
||||
end++;
|
||||
clipper.ItemsCount--;
|
||||
continue;
|
||||
}
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextUnformatted(log.project.c_str());
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, getColor(log.level).Value);
|
||||
ImGui::TextUnformatted(log.message.c_str());
|
||||
ImGui::PopStyleColor();
|
||||
for (const auto &log : logs | std::views::reverse) {
|
||||
if (!shouldDisplay(log.level, m_logLevel)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextUnformatted(log.project.c_str());
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, getColor(log.level).Value);
|
||||
ImGui::TextUnformatted(log.message.c_str());
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
|
||||
ImGui::EndTable();
|
||||
|
||||
Reference in New Issue
Block a user