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:
@@ -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