feat: Enhance Logging and Test Suite Integration
- Integrated logging functionality across various components, replacing standard output with structured logging for improved traceability. - Added z3ed AI Agent test suites for enhanced testing capabilities, including connectivity and command parsing tests. - Updated the Settings Editor to allow configuration of logging behavior, including log levels and file output options. - Enhanced the Test Dashboard with tabbed views for better organization of test results, including GUI automation tests.
This commit is contained in:
@@ -1041,7 +1041,7 @@ void AgentChatWidget::Draw() {
|
||||
RenderZ3EDCommandPanel();
|
||||
RenderMultimodalPanel();
|
||||
RenderCollaborationPanel();
|
||||
RenderRomSyncPanel(); // Always visible now
|
||||
RenderRomSyncPanel();
|
||||
RenderProposalManagerPanel();
|
||||
|
||||
ImGui::PopStyleVar(2);
|
||||
@@ -1799,11 +1799,6 @@ void AgentChatWidget::RenderZ3EDCommandPanel() {
|
||||
}
|
||||
|
||||
void AgentChatWidget::RenderRomSyncPanel() {
|
||||
if (!ImGui::CollapsingHeader(ICON_MD_SYNC " ROM Synchronization",
|
||||
ImGuiTreeNodeFlags_DefaultOpen)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, ImVec4(0.18f, 0.14f, 0.12f, 1.0f));
|
||||
ImGui::BeginChild("RomSync", ImVec2(0, 200), true);
|
||||
|
||||
|
||||
@@ -42,6 +42,9 @@
|
||||
#ifdef YAZE_ENABLE_GTEST
|
||||
#include "app/test/unit_test_suite.h"
|
||||
#endif
|
||||
#ifdef YAZE_WITH_GRPC
|
||||
#include "app/test/z3ed_test_suite.h"
|
||||
#endif
|
||||
#include "app/editor/system/settings_editor.h"
|
||||
#include "app/editor/system/toast_manager.h"
|
||||
#include "app/emu/emulator.h"
|
||||
@@ -203,6 +206,11 @@ void EditorManager::InitializeTestSuites() {
|
||||
test_manager.RegisterTestSuite(std::make_unique<test::UnitTestSuite>());
|
||||
#endif
|
||||
|
||||
// Register z3ed AI Agent test suites (requires gRPC)
|
||||
#ifdef YAZE_WITH_GRPC
|
||||
test::RegisterZ3edTestSuites();
|
||||
#endif
|
||||
|
||||
// Update resource monitoring to track Arena state
|
||||
test_manager.UpdateResourceStats();
|
||||
}
|
||||
@@ -1072,17 +1080,124 @@ void EditorManager::BuildModernMenu() {
|
||||
#endif
|
||||
|
||||
// Debug Menu - comprehensive development tools
|
||||
menu_builder_.BeginMenu("Debug")
|
||||
menu_builder_.BeginMenu("Debug");
|
||||
|
||||
#ifdef YAZE_ENABLE_TESTING
|
||||
// Testing and Validation section
|
||||
menu_builder_
|
||||
.Item("Test Dashboard", ICON_MD_SCIENCE,
|
||||
[this]() { show_test_dashboard_ = true; }, "Ctrl+T")
|
||||
.Item("Run All Tests", ICON_MD_PLAY_ARROW,
|
||||
[this]() { [[maybe_unused]] auto status = test::TestManager::Get().RunAllTests(); })
|
||||
.Item("Run Unit Tests", ICON_MD_INTEGRATION_INSTRUCTIONS,
|
||||
[this]() { [[maybe_unused]] auto status = test::TestManager::Get().RunTestsByCategory(test::TestCategory::kUnit); })
|
||||
.Item("Run Integration Tests", ICON_MD_MEMORY,
|
||||
[this]() { [[maybe_unused]] auto status = test::TestManager::Get().RunTestsByCategory(test::TestCategory::kIntegration); })
|
||||
.Item("Run UI Tests", ICON_MD_VISIBILITY,
|
||||
[this]() { [[maybe_unused]] auto status = test::TestManager::Get().RunTestsByCategory(test::TestCategory::kUI); })
|
||||
.Item("Run Performance Tests", ICON_MD_SPEED,
|
||||
[this]() { [[maybe_unused]] auto status = test::TestManager::Get().RunTestsByCategory(test::TestCategory::kPerformance); })
|
||||
.Item("Run Memory Tests", ICON_MD_STORAGE,
|
||||
[this]() { [[maybe_unused]] auto status = test::TestManager::Get().RunTestsByCategory(test::TestCategory::kMemory); })
|
||||
.Item("Clear Test Results", ICON_MD_CLEAR_ALL,
|
||||
[this]() { test::TestManager::Get().ClearResults(); })
|
||||
.Separator();
|
||||
#endif
|
||||
|
||||
// ROM and ASM Management
|
||||
menu_builder_
|
||||
.BeginSubMenu("ROM Analysis", ICON_MD_STORAGE)
|
||||
.Item("ROM Information", ICON_MD_INFO,
|
||||
[this]() { popup_manager_->Show("ROM Information"); },
|
||||
nullptr,
|
||||
[this]() { return current_rom_ && current_rom_->is_loaded(); })
|
||||
#ifdef YAZE_ENABLE_TESTING
|
||||
.Item("Data Integrity Check", ICON_MD_ANALYTICS,
|
||||
[this]() {
|
||||
if (current_rom_) {
|
||||
[[maybe_unused]] auto status = test::TestManager::Get().RunTestSuite("RomIntegrity");
|
||||
toast_manager_.Show("Running ROM integrity tests...", ToastType::kInfo);
|
||||
}
|
||||
},
|
||||
nullptr,
|
||||
[this]() { return current_rom_ && current_rom_->is_loaded(); })
|
||||
.Item("Test Save/Load", ICON_MD_SAVE_ALT,
|
||||
[this]() {
|
||||
if (current_rom_) {
|
||||
[[maybe_unused]] auto status = test::TestManager::Get().RunTestSuite("RomSaveLoad");
|
||||
toast_manager_.Show("Running ROM save/load tests...", ToastType::kInfo);
|
||||
}
|
||||
},
|
||||
nullptr,
|
||||
[this]() { return current_rom_ && current_rom_->is_loaded(); })
|
||||
#endif
|
||||
.EndMenu()
|
||||
.BeginSubMenu("ZSCustomOverworld", ICON_MD_CODE)
|
||||
.Item("Check ROM Version", ICON_MD_INFO,
|
||||
[this]() {
|
||||
if (current_rom_) {
|
||||
uint8_t version = (*current_rom_)[zelda3::OverworldCustomASMHasBeenApplied];
|
||||
std::string version_str = (version == 0xFF) ? "Vanilla" : absl::StrFormat("v%d", version);
|
||||
toast_manager_.Show(absl::StrFormat("ROM: %s | ZSCustomOverworld: %s",
|
||||
current_rom_->title().c_str(), version_str.c_str()),
|
||||
ToastType::kInfo, 5.0f);
|
||||
}
|
||||
},
|
||||
nullptr,
|
||||
[this]() { return current_rom_ && current_rom_->is_loaded(); })
|
||||
.Item("Upgrade ROM", ICON_MD_UPGRADE,
|
||||
[this]() {
|
||||
if (current_rom_) {
|
||||
toast_manager_.Show("Use Overworld Editor to upgrade ROM version",
|
||||
ToastType::kInfo, 4.0f);
|
||||
}
|
||||
},
|
||||
nullptr,
|
||||
[this]() { return current_rom_ && current_rom_->is_loaded(); })
|
||||
.Item("Toggle Custom Loading", ICON_MD_SETTINGS,
|
||||
[this]() {
|
||||
auto& flags = core::FeatureFlags::get();
|
||||
flags.overworld.kLoadCustomOverworld = !flags.overworld.kLoadCustomOverworld;
|
||||
toast_manager_.Show(absl::StrFormat("Custom Overworld Loading: %s",
|
||||
flags.overworld.kLoadCustomOverworld ? "Enabled" : "Disabled"),
|
||||
ToastType::kInfo);
|
||||
})
|
||||
.EndMenu()
|
||||
.BeginSubMenu("Asar Integration", ICON_MD_BUILD)
|
||||
.Item("Asar Status", ICON_MD_INFO,
|
||||
[this]() { popup_manager_->Show("Asar Integration"); })
|
||||
.Item("Toggle ASM Patch", ICON_MD_CODE,
|
||||
[this]() {
|
||||
if (current_rom_) {
|
||||
auto& flags = core::FeatureFlags::get();
|
||||
flags.overworld.kApplyZSCustomOverworldASM = !flags.overworld.kApplyZSCustomOverworldASM;
|
||||
toast_manager_.Show(absl::StrFormat("ZSCustomOverworld ASM Application: %s",
|
||||
flags.overworld.kApplyZSCustomOverworldASM ? "Enabled" : "Disabled"),
|
||||
ToastType::kInfo);
|
||||
}
|
||||
},
|
||||
nullptr,
|
||||
[this]() { return current_rom_ && current_rom_->is_loaded(); })
|
||||
.Item("Load ASM File", ICON_MD_FOLDER_OPEN,
|
||||
[this]() {
|
||||
toast_manager_.Show("ASM file loading not yet implemented",
|
||||
ToastType::kWarning);
|
||||
})
|
||||
.EndMenu()
|
||||
.Separator()
|
||||
// Development Tools
|
||||
.Item("Memory Editor", ICON_MD_MEMORY,
|
||||
[this]() { show_memory_editor_ = true; })
|
||||
.Item("Assembly Editor", ICON_MD_CODE,
|
||||
[this]() { show_asm_editor_ = true; })
|
||||
.Item("Feature Flags", ICON_MD_FLAG,
|
||||
[this]() { popup_manager_->Show("Feature Flags"); })
|
||||
.Separator()
|
||||
.Item("Performance Dashboard", ICON_MD_SPEED,
|
||||
[this]() { show_performance_dashboard_ = true; })
|
||||
#ifdef YAZE_ENABLE_TESTING
|
||||
.Item("Test Dashboard", ICON_MD_SCIENCE,
|
||||
[this]() { show_test_dashboard_ = true; }, "Ctrl+T")
|
||||
#ifdef YAZE_WITH_GRPC
|
||||
.Item("Agent Proposals", ICON_MD_PREVIEW,
|
||||
[this]() { proposal_drawer_.Toggle(); })
|
||||
#endif
|
||||
.Separator()
|
||||
.Item("ImGui Demo", ICON_MD_HELP,
|
||||
|
||||
@@ -8,6 +8,10 @@
|
||||
#include "app/gui/icons.h"
|
||||
#include "app/gui/theme_manager.h"
|
||||
#include "imgui/imgui.h"
|
||||
#include "util/log.h"
|
||||
|
||||
#include <set>
|
||||
#include <filesystem>
|
||||
|
||||
namespace yaze {
|
||||
namespace editor {
|
||||
@@ -263,6 +267,166 @@ void SettingsEditor::DrawAIAgentSettings() {
|
||||
static bool multimodal = true;
|
||||
Checkbox("Enable Vision/Multimodal", &multimodal);
|
||||
}
|
||||
|
||||
// z3ed CLI logging settings
|
||||
if (CollapsingHeader(ICON_MD_TERMINAL " CLI Logging", ImGuiTreeNodeFlags_DefaultOpen)) {
|
||||
Text("Configure z3ed command-line logging behavior");
|
||||
Spacing();
|
||||
|
||||
// Declare all static variables first
|
||||
static int log_level = 1; // 0=Debug, 1=Info, 2=Warning, 3=Error, 4=Fatal
|
||||
static bool log_to_file = false;
|
||||
static char log_file_path[512] = "";
|
||||
static bool log_ai_requests = true;
|
||||
static bool log_rom_operations = true;
|
||||
static bool log_gui_automation = true;
|
||||
static bool log_proposals = true;
|
||||
|
||||
// Log level selection
|
||||
const char* log_levels[] = { "Debug (Verbose)", "Info (Normal)", "Warning (Quiet)", "Error (Critical)", "Fatal Only" };
|
||||
if (Combo("Log Level", &log_level, log_levels, IM_ARRAYSIZE(log_levels))) {
|
||||
// Apply log level immediately using existing LogManager
|
||||
util::LogLevel level;
|
||||
switch (log_level) {
|
||||
case 0: level = util::LogLevel::YAZE_DEBUG; break;
|
||||
case 1: level = util::LogLevel::INFO; break;
|
||||
case 2: level = util::LogLevel::WARNING; break;
|
||||
case 3: level = util::LogLevel::ERROR; break;
|
||||
case 4: level = util::LogLevel::FATAL; break;
|
||||
default: level = util::LogLevel::INFO; break;
|
||||
}
|
||||
|
||||
// Get current categories
|
||||
std::set<std::string> categories;
|
||||
if (log_ai_requests) categories.insert("AI");
|
||||
if (log_rom_operations) categories.insert("ROM");
|
||||
if (log_gui_automation) categories.insert("GUI");
|
||||
if (log_proposals) categories.insert("Proposals");
|
||||
|
||||
// Reconfigure with new level
|
||||
util::LogManager::instance().configure(level, std::string(log_file_path), categories);
|
||||
Text("✓ Log level applied");
|
||||
}
|
||||
TextDisabled("Controls verbosity of YAZE and z3ed output");
|
||||
|
||||
Spacing();
|
||||
|
||||
// Logging targets
|
||||
|
||||
if (Checkbox("Log to File", &log_to_file)) {
|
||||
if (log_to_file) {
|
||||
// Set default path if empty
|
||||
if (strlen(log_file_path) == 0) {
|
||||
const char* home = std::getenv("HOME");
|
||||
if (home) {
|
||||
snprintf(log_file_path, sizeof(log_file_path), "%s/.yaze/logs/yaze.log", home);
|
||||
}
|
||||
}
|
||||
|
||||
// Enable file logging
|
||||
std::set<std::string> categories;
|
||||
util::LogLevel level = static_cast<util::LogLevel>(log_level);
|
||||
util::LogManager::instance().configure(level, std::string(log_file_path), categories);
|
||||
} else {
|
||||
// Disable file logging
|
||||
std::set<std::string> categories;
|
||||
util::LogLevel level = static_cast<util::LogLevel>(log_level);
|
||||
util::LogManager::instance().configure(level, "", categories);
|
||||
}
|
||||
}
|
||||
|
||||
if (log_to_file) {
|
||||
Indent();
|
||||
if (InputText("Log File", log_file_path, IM_ARRAYSIZE(log_file_path))) {
|
||||
// Update log file path
|
||||
std::set<std::string> categories;
|
||||
util::LogLevel level = static_cast<util::LogLevel>(log_level);
|
||||
util::LogManager::instance().configure(level, std::string(log_file_path), categories);
|
||||
}
|
||||
|
||||
TextDisabled("Log file path (supports ~ for home directory)");
|
||||
Unindent();
|
||||
}
|
||||
|
||||
Spacing();
|
||||
|
||||
// Log filtering
|
||||
Text(ICON_MD_FILTER_ALT " Category Filtering");
|
||||
Separator();
|
||||
TextDisabled("Enable/disable specific log categories");
|
||||
Spacing();
|
||||
|
||||
bool categories_changed = false;
|
||||
|
||||
categories_changed |= Checkbox("AI API Requests", &log_ai_requests);
|
||||
categories_changed |= Checkbox("ROM Operations", &log_rom_operations);
|
||||
categories_changed |= Checkbox("GUI Automation", &log_gui_automation);
|
||||
categories_changed |= Checkbox("Proposal Generation", &log_proposals);
|
||||
|
||||
if (categories_changed) {
|
||||
// Rebuild category set
|
||||
std::set<std::string> categories;
|
||||
if (log_ai_requests) categories.insert("AI");
|
||||
if (log_rom_operations) categories.insert("ROM");
|
||||
if (log_gui_automation) categories.insert("GUI");
|
||||
if (log_proposals) categories.insert("Proposals");
|
||||
|
||||
// Reconfigure LogManager
|
||||
util::LogLevel level = static_cast<util::LogLevel>(log_level);
|
||||
util::LogManager::instance().configure(level, log_to_file ? std::string(log_file_path) : "", categories);
|
||||
}
|
||||
|
||||
Spacing();
|
||||
|
||||
// Quick actions
|
||||
if (Button(ICON_MD_DELETE " Clear Logs")) {
|
||||
if (log_to_file && strlen(log_file_path) > 0) {
|
||||
std::filesystem::path path(log_file_path);
|
||||
if (std::filesystem::exists(path)) {
|
||||
std::filesystem::remove(path);
|
||||
LOG_INFO("Settings", "Log file cleared: %s", log_file_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
SameLine();
|
||||
if (Button(ICON_MD_FOLDER_OPEN " Open Log Directory")) {
|
||||
if (log_to_file && strlen(log_file_path) > 0) {
|
||||
std::filesystem::path path(log_file_path);
|
||||
std::filesystem::path dir = path.parent_path();
|
||||
|
||||
// Platform-specific command to open directory
|
||||
#ifdef _WIN32
|
||||
std::string cmd = "explorer " + dir.string();
|
||||
#elif __APPLE__
|
||||
std::string cmd = "open " + dir.string();
|
||||
#else
|
||||
std::string cmd = "xdg-open " + dir.string();
|
||||
#endif
|
||||
system(cmd.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
Spacing();
|
||||
Separator();
|
||||
|
||||
// Log test buttons
|
||||
Text(ICON_MD_BUG_REPORT " Test Logging");
|
||||
if (Button("Test Debug")) {
|
||||
LOG_DEBUG("Settings", "This is a debug message");
|
||||
}
|
||||
SameLine();
|
||||
if (Button("Test Info")) {
|
||||
LOG_INFO("Settings", "This is an info message");
|
||||
}
|
||||
SameLine();
|
||||
if (Button("Test Warning")) {
|
||||
LOG_WARN("Settings", "This is a warning message");
|
||||
}
|
||||
SameLine();
|
||||
if (Button("Test Error")) {
|
||||
LOG_ERROR("Settings", "This is an error message");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace editor
|
||||
|
||||
Reference in New Issue
Block a user