Compare commits

..

2 Commits

Author SHA1 Message Date
blankie 4db64d4da6
Fix string check 2023-03-07 18:02:57 +07:00
blankie a6572fb085
Add buttons to add test logcat entries 2023-03-07 18:02:18 +07:00
4 changed files with 45 additions and 5 deletions

View File

@ -43,7 +43,7 @@ void event_loop(ImFont* monospace_font, Config& active_config, LogcatThread& log
check_for_logcat_items(logcat_thread, active_config, logcat_entries, filtered_logcat_entry_offsets);
#ifndef NDEBUG
debug_window(logcat_thread);
debug_window(logcat_thread, active_config, logcat_entries, filtered_logcat_entry_offsets);
#endif
if (show_settings_window) {

View File

@ -136,9 +136,9 @@ bool StringFilter::_match_regex(const LogcatEntry& entry) const {
matched = this->_regex->match(str ? str->data() : "", 1, pmatch, eflags);
if (this->exact_match) {
matched = matched && pmatch[0].rm_so == 0 && str
matched = matched && pmatch[0].rm_so == 0 && (str
? static_cast<size_t>(pmatch[0].rm_eo) == str->size()
: pmatch[0].rm_so == 0;
: pmatch[0].rm_eo == 0);
}
return matched;
}

View File

@ -2,10 +2,14 @@
#include "../myimconfig.h"
#include "../log.h"
#include "../config.h"
#include "../filters.h"
#include "../logcat_entry.h"
#include "../logcat_thread.h"
#include "debug.h"
void debug_window(LogcatThread& logcat_thread) {
void debug_window(LogcatThread& logcat_thread, const Config& active_config,
std::vector<LogcatEntry>& logcat_entries, std::vector<size_t>& filtered_logcat_entry_offsets) {
static bool show_demo_window = false;
static size_t add_log_entry_presses = 1;
static bool log_entry_every_second = false;
@ -49,5 +53,36 @@ void debug_window(LogcatThread& logcat_thread) {
}
}
ImGui::Separator();
auto add_logcat_entry = [&](LogcatEntry logcat_entry) {
logcat_entries.push_back(std::move(logcat_entry));
if (matches(logcat_entries.back(), active_config.filters, active_config.exclusions)) {
filtered_logcat_entry_offsets.push_back(logcat_entries.size() - 1);
}
};
if (ImGui::Button("Add test entry (w/ user)")) {
add_logcat_entry({
.buffer = Buffer::Main,
.time = time(nullptr),
.user = "blankie",
.pid = 69,
.tid = 420,
.priority = Priority::Error,
.tag = "blanket, inc.",
.message = "Failed to make blanket",
});
}
if (ImGui::Button("Add test entry (w/o user)")) {
add_logcat_entry({
.buffer = Buffer::Crash,
.time = time(nullptr),
.pid = 420,
.tid = 69,
.priority = Priority::Fatal,
.tag = "blanket, inc.",
.message = "Failed to invent blankets",
});
}
ImGui::End();
}

View File

@ -1,5 +1,10 @@
#pragma once
#include <vector>
struct Config; // forward declaration from ../config.h
struct LogcatEntry; // forward declaration from ../logcat_entry.h
class LogcatThread; // forward declaration from ../logcat_thread.h
void debug_window(LogcatThread& logcat_thread);
void debug_window(LogcatThread& logcat_thread, const Config& active_config,
std::vector<LogcatEntry>& logcat_entries, std::vector<size_t>& filtered_logcat_entry_offsets);