Refactor logging system to use LOG_* macros
- Updated logging calls in main.cc, rom.cc, and test_manager.cc to utilize the new LOG_* macros for consistency and improved readability. - Removed deprecated util::logf function and replaced its usage with appropriate logging macros. - Enhanced logging in TestManager to provide more detailed information about ROM state and testing processes. - Cleaned up commented-out logf calls in room.cc to streamline the code. - Adjusted LogManager to support general logging through a new logf function for non-category specific messages.
This commit is contained in:
@@ -64,7 +64,8 @@ absl::Status CreateWindow(Window& window, int flags) {
|
||||
auto status = theme_manager.LoadTheme("YAZE Classic");
|
||||
if (!status.ok()) {
|
||||
// Theme system failed, stick with original ColorsYaze()
|
||||
util::logf("Theme system failed, using original ColorsYaze(): %s", status.message().data());
|
||||
LOG_WARN("Window", "Theme system failed, using original ColorsYaze(): %s",
|
||||
status.message().data());
|
||||
}
|
||||
|
||||
const int audio_frequency = 48000;
|
||||
|
||||
@@ -120,7 +120,7 @@ void EditorManager::RefreshWorkspacePresets() {
|
||||
}
|
||||
}
|
||||
} catch (const std::exception& e) {
|
||||
util::logf("Warning: Failed to load workspace presets: %s", e.what());
|
||||
LOG_WARN("EditorManager", "Failed to load workspace presets: %s", e.what());
|
||||
}
|
||||
|
||||
// Safely replace the vector
|
||||
@@ -128,7 +128,7 @@ void EditorManager::RefreshWorkspacePresets() {
|
||||
workspace_presets_loaded_ = true;
|
||||
|
||||
} catch (const std::exception& e) {
|
||||
util::logf("Error in RefreshWorkspacePresets: %s", e.what());
|
||||
LOG_ERROR("EditorManager", "Error in RefreshWorkspacePresets: %s", e.what());
|
||||
// Ensure we have a valid empty vector
|
||||
workspace_presets_ = std::vector<std::string>();
|
||||
workspace_presets_loaded_ =
|
||||
@@ -157,7 +157,7 @@ void EditorManager::SaveWorkspacePreset(const std::string& name) {
|
||||
ss << n << "\n";
|
||||
core::SaveFile("workspace_presets.txt", ss.str());
|
||||
} catch (const std::exception& e) {
|
||||
util::logf("Warning: Failed to save workspace presets: %s", e.what());
|
||||
LOG_WARN("EditorManager", "Failed to save workspace presets: %s", e.what());
|
||||
}
|
||||
}
|
||||
last_workspace_preset_ = name;
|
||||
@@ -853,9 +853,10 @@ absl::Status EditorManager::Update() {
|
||||
// Ensure TestManager always has the current ROM
|
||||
static Rom* last_test_rom = nullptr;
|
||||
if (last_test_rom != current_rom_) {
|
||||
util::logf(
|
||||
"EditorManager::Update - ROM changed, updating TestManager: %p -> %p",
|
||||
(void*)last_test_rom, (void*)current_rom_);
|
||||
LOG_INFO("EditorManager",
|
||||
"EditorManager::Update - ROM changed, updating TestManager: %p -> "
|
||||
"%p",
|
||||
(void*)last_test_rom, (void*)current_rom_);
|
||||
test::TestManager::Get().SetCurrentRom(current_rom_);
|
||||
last_test_rom = current_rom_;
|
||||
}
|
||||
@@ -1733,8 +1734,8 @@ absl::Status EditorManager::LoadRom() {
|
||||
for (auto& session : sessions_) {
|
||||
if (!session.rom.is_loaded()) {
|
||||
target_session = &session;
|
||||
util::logf("Found empty session to populate with ROM: %s",
|
||||
file_name.c_str());
|
||||
LOG_INFO("EditorManager", "Found empty session to populate with ROM: %s",
|
||||
file_name.c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1761,9 +1762,9 @@ absl::Status EditorManager::LoadRom() {
|
||||
|
||||
// Update test manager with current ROM for ROM-dependent tests (only when tests are enabled)
|
||||
#ifdef YAZE_ENABLE_TESTING
|
||||
util::logf("EditorManager: Setting ROM in TestManager - %p ('%s')",
|
||||
(void*)current_rom_,
|
||||
current_rom_ ? current_rom_->title().c_str() : "null");
|
||||
LOG_INFO("EditorManager", "Setting ROM in TestManager - %p ('%s')",
|
||||
(void*)current_rom_,
|
||||
current_rom_ ? current_rom_->title().c_str() : "null");
|
||||
test::TestManager::Get().SetCurrentRom(current_rom_);
|
||||
#endif
|
||||
|
||||
@@ -1804,7 +1805,7 @@ absl::Status EditorManager::LoadAssets() {
|
||||
auto end_time = std::chrono::steady_clock::now();
|
||||
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
end_time - start_time);
|
||||
util::logf("ROM assets loaded in %lld ms", duration.count());
|
||||
LOG_INFO("EditorManager", "ROM assets loaded in %lld ms", duration.count());
|
||||
|
||||
return absl::OkStatus();
|
||||
}
|
||||
@@ -1963,9 +1964,9 @@ absl::Status EditorManager::OpenProject() {
|
||||
|
||||
// Update test manager with current ROM for ROM-dependent tests (only when tests are enabled)
|
||||
#ifdef YAZE_ENABLE_TESTING
|
||||
util::logf("EditorManager: Setting ROM in TestManager - %p ('%s')",
|
||||
(void*)current_rom_,
|
||||
current_rom_ ? current_rom_->title().c_str() : "null");
|
||||
LOG_INFO("EditorManager", "Setting ROM in TestManager - %p ('%s')",
|
||||
(void*)current_rom_,
|
||||
current_rom_ ? current_rom_->title().c_str() : "null");
|
||||
test::TestManager::Get().SetCurrentRom(current_rom_);
|
||||
#endif
|
||||
|
||||
@@ -2225,8 +2226,8 @@ void EditorManager::RemoveSession(size_t index) {
|
||||
sessions_[index].custom_name = "[CLOSED SESSION]";
|
||||
sessions_[index].filepath = "";
|
||||
|
||||
util::logf("Marked session as closed: %s (index %zu)", session_name.c_str(),
|
||||
index);
|
||||
LOG_INFO("EditorManager", "Marked session as closed: %s (index %zu)",
|
||||
session_name.c_str(), index);
|
||||
toast_manager_.Show(
|
||||
absl::StrFormat("Session marked as closed: %s", session_name),
|
||||
editor::ToastType::kInfo);
|
||||
|
||||
@@ -180,6 +180,9 @@ void OverworldEditor::Initialize() {
|
||||
}
|
||||
|
||||
absl::Status OverworldEditor::Load() {
|
||||
gfx::ScopedTimer timer("OverworldEditor::Load");
|
||||
|
||||
LOG_INFO("OverworldEditor", "Loading overworld.");
|
||||
if (!rom_ || !rom_->is_loaded()) {
|
||||
return absl::FailedPreconditionError("ROM not loaded");
|
||||
}
|
||||
@@ -201,7 +204,7 @@ absl::Status OverworldEditor::Load() {
|
||||
// Force refresh of the current overworld map to show changes
|
||||
RefreshOverworldMap();
|
||||
|
||||
util::logf("Overworld editor refreshed after Tile16 changes");
|
||||
LOG_INFO("OverworldEditor", "Overworld editor refreshed after Tile16 changes");
|
||||
return absl::OkStatus();
|
||||
});
|
||||
|
||||
@@ -471,8 +474,8 @@ void OverworldEditor::DrawOverworldMapSettings() {
|
||||
auto asm_status = ApplyZSCustomOverworldASM(3);
|
||||
if (!asm_status.ok()) {
|
||||
// Show error but still set version marker
|
||||
util::logf("Failed to apply ZSCustomOverworld ASM: %s",
|
||||
asm_status.ToString().c_str());
|
||||
LOG_ERROR("OverworldEditor", "Failed to apply ZSCustomOverworld ASM: %s",
|
||||
asm_status.ToString().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -843,11 +846,11 @@ void OverworldEditor::DrawOverworldEdits() {
|
||||
// Validate tile16_blockset_ before calling GetTilemapData
|
||||
if (!tile16_blockset_.atlas.is_active() ||
|
||||
tile16_blockset_.atlas.vector().empty()) {
|
||||
util::logf(
|
||||
"Error: tile16_blockset_ is not properly initialized (active: %s, "
|
||||
"size: %zu)",
|
||||
tile16_blockset_.atlas.is_active() ? "true" : "false",
|
||||
tile16_blockset_.atlas.vector().size());
|
||||
LOG_ERROR("OverworldEditor",
|
||||
"Error: tile16_blockset_ is not properly initialized (active: %s, "
|
||||
"size: %zu)",
|
||||
tile16_blockset_.atlas.is_active() ? "true" : "false",
|
||||
tile16_blockset_.atlas.vector().size());
|
||||
return; // Skip drawing if blockset is invalid
|
||||
}
|
||||
|
||||
@@ -881,10 +884,10 @@ void OverworldEditor::RenderUpdatedMapBitmap(
|
||||
|
||||
// Bounds checking to prevent crashes
|
||||
if (current_map_ < 0 || current_map_ >= static_cast<int>(maps_bmp_.size())) {
|
||||
util::logf(
|
||||
"ERROR: RenderUpdatedMapBitmap - Invalid current_map_ %d "
|
||||
"(maps_bmp_.size()=%zu)",
|
||||
current_map_, maps_bmp_.size());
|
||||
LOG_ERROR("OverworldEditor",
|
||||
"ERROR: RenderUpdatedMapBitmap - Invalid current_map_ %d "
|
||||
"(maps_bmp_.size()=%zu)",
|
||||
current_map_, maps_bmp_.size());
|
||||
return; // Invalid map index, skip rendering
|
||||
}
|
||||
|
||||
@@ -904,11 +907,11 @@ void OverworldEditor::RenderUpdatedMapBitmap(
|
||||
|
||||
// Validate bitmap state before writing
|
||||
if (!current_bitmap.is_active() || current_bitmap.size() == 0) {
|
||||
util::logf(
|
||||
"ERROR: RenderUpdatedMapBitmap - Bitmap %d is not active or has no "
|
||||
"data (active=%s, size=%zu)",
|
||||
current_map_, current_bitmap.is_active() ? "true" : "false",
|
||||
current_bitmap.size());
|
||||
LOG_ERROR("OverworldEditor",
|
||||
"ERROR: RenderUpdatedMapBitmap - Bitmap %d is not active or has no "
|
||||
"data (active=%s, size=%zu)",
|
||||
current_map_, current_bitmap.is_active() ? "true" : "false",
|
||||
current_bitmap.size());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -920,10 +923,10 @@ void OverworldEditor::RenderUpdatedMapBitmap(
|
||||
// Bounds check for pixel index
|
||||
if (pixel_index < 0 ||
|
||||
pixel_index >= static_cast<int>(current_bitmap.size())) {
|
||||
util::logf(
|
||||
"ERROR: RenderUpdatedMapBitmap - pixel_index %d out of bounds "
|
||||
"(bitmap size=%zu)",
|
||||
pixel_index, current_bitmap.size());
|
||||
LOG_ERROR("OverworldEditor",
|
||||
"ERROR: RenderUpdatedMapBitmap - pixel_index %d out of bounds "
|
||||
"(bitmap size=%zu)",
|
||||
pixel_index, current_bitmap.size());
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -931,10 +934,10 @@ void OverworldEditor::RenderUpdatedMapBitmap(
|
||||
int tile_data_index = y * kTile16Size + x;
|
||||
if (tile_data_index < 0 ||
|
||||
tile_data_index >= static_cast<int>(tile_data.size())) {
|
||||
util::logf(
|
||||
"ERROR: RenderUpdatedMapBitmap - tile_data_index %d out of bounds "
|
||||
"(tile_data size=%zu)",
|
||||
tile_data_index, tile_data.size());
|
||||
LOG_ERROR("OverworldEditor",
|
||||
"ERROR: RenderUpdatedMapBitmap - tile_data_index %d out of bounds "
|
||||
"(tile_data size=%zu)",
|
||||
tile_data_index, tile_data.size());
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -949,6 +952,9 @@ void OverworldEditor::RenderUpdatedMapBitmap(
|
||||
}
|
||||
|
||||
void OverworldEditor::CheckForOverworldEdits() {
|
||||
LOG_DEBUG("OverworldEditor", "CheckForOverworldEdits: Frame %d",
|
||||
ImGui::GetFrameCount());
|
||||
|
||||
CheckForSelectRectangle();
|
||||
|
||||
// User has selected a tile they want to draw from the blockset
|
||||
@@ -962,7 +968,7 @@ void OverworldEditor::CheckForOverworldEdits() {
|
||||
if (ow_map_canvas_.select_rect_active()) {
|
||||
if (ImGui::IsMouseClicked(ImGuiMouseButton_Left) ||
|
||||
ImGui::IsMouseDragging(ImGuiMouseButton_Left)) {
|
||||
util::logf("CheckForOverworldEdits: About to apply rectangle selection");
|
||||
LOG_DEBUG("OverworldEditor", "CheckForOverworldEdits: About to apply rectangle selection");
|
||||
|
||||
auto& selected_world =
|
||||
(current_world_ == 0) ? overworld_.mutable_map_tiles()->light_world
|
||||
@@ -988,10 +994,10 @@ void OverworldEditor::CheckForOverworldEdits() {
|
||||
// Number of tiles per local map (since each tile is 16x16)
|
||||
constexpr int tiles_per_local_map = local_map_size / kTile16Size;
|
||||
|
||||
util::logf(
|
||||
"CheckForOverworldEdits: About to fill rectangle with "
|
||||
"current_tile16_=%d",
|
||||
current_tile16_);
|
||||
LOG_DEBUG("OverworldEditor",
|
||||
"CheckForOverworldEdits: About to fill rectangle with "
|
||||
"current_tile16_=%d",
|
||||
current_tile16_);
|
||||
|
||||
// Apply the selected tiles to each position in the rectangle
|
||||
// CRITICAL FIX: Use pre-computed tile16_ids_ instead of recalculating from selected_tiles_
|
||||
@@ -1038,12 +1044,12 @@ void OverworldEditor::CheckForOverworldEdits() {
|
||||
auto tile_data = gfx::GetTilemapData(tile16_blockset_, tile16_id);
|
||||
if (!tile_data.empty()) {
|
||||
RenderUpdatedMapBitmap(tile_position, tile_data);
|
||||
util::logf(
|
||||
"CheckForOverworldEdits: Updated bitmap at position (%d,%d) "
|
||||
"with tile16_id=%d",
|
||||
x, y, tile16_id);
|
||||
LOG_INFO("OverworldEditor",
|
||||
"CheckForOverworldEdits: Updated bitmap at position (%d,%d) "
|
||||
"with tile16_id=%d",
|
||||
x, y, tile16_id);
|
||||
} else {
|
||||
util::logf("ERROR: Failed to get tile data for tile16_id=%d",
|
||||
LOG_ERROR("OverworldEditor", "ERROR: Failed to get tile data for tile16_id=%d",
|
||||
tile16_id);
|
||||
}
|
||||
}
|
||||
@@ -1055,8 +1061,8 @@ void OverworldEditor::CheckForOverworldEdits() {
|
||||
// This is commented out for now, will come back to later.
|
||||
// ow_map_canvas_.mutable_selected_tiles()->clear();
|
||||
// ow_map_canvas_.mutable_points()->clear();
|
||||
util::logf(
|
||||
"CheckForOverworldEdits: Rectangle selection applied and cleared");
|
||||
LOG_INFO("OverworldEditor",
|
||||
"CheckForOverworldEdits: Rectangle selection applied and cleared");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1821,7 +1827,7 @@ absl::Status OverworldEditor::Save() {
|
||||
absl::Status OverworldEditor::LoadGraphics() {
|
||||
gfx::ScopedTimer timer("LoadGraphics");
|
||||
|
||||
util::logf("Loading overworld.");
|
||||
LOG_INFO("OverworldEditor", "Loading overworld.");
|
||||
// Load the Link to the Past overworld.
|
||||
{
|
||||
gfx::ScopedTimer load_timer("Overworld::Load");
|
||||
@@ -1829,7 +1835,7 @@ absl::Status OverworldEditor::LoadGraphics() {
|
||||
}
|
||||
palette_ = overworld_.current_area_palette();
|
||||
|
||||
util::logf("Loading overworld graphics (optimized).");
|
||||
LOG_INFO("OverworldEditor", "Loading overworld graphics (optimized).");
|
||||
|
||||
// Phase 1: Create bitmaps without textures for faster loading
|
||||
// This avoids blocking the main thread with GPU texture creation
|
||||
@@ -1840,7 +1846,7 @@ absl::Status OverworldEditor::LoadGraphics() {
|
||||
current_gfx_bmp_, palette_);
|
||||
}
|
||||
|
||||
util::logf("Loading overworld tileset (deferred textures).");
|
||||
LOG_INFO("OverworldEditor", "Loading overworld tileset (deferred textures).");
|
||||
{
|
||||
gfx::ScopedTimer tileset_timer("CreateBitmapWithoutTexture_Tileset");
|
||||
Renderer::Get().CreateBitmapWithoutTexture(
|
||||
@@ -1851,7 +1857,7 @@ absl::Status OverworldEditor::LoadGraphics() {
|
||||
|
||||
// Copy the tile16 data into individual tiles.
|
||||
auto tile16_blockset_data = overworld_.tile16_blockset_data();
|
||||
util::logf("Loading overworld tile16 graphics.");
|
||||
LOG_INFO("OverworldEditor", "Loading overworld tile16 graphics.");
|
||||
|
||||
{
|
||||
gfx::ScopedTimer tilemap_timer("CreateTilemap");
|
||||
@@ -1869,9 +1875,9 @@ absl::Status OverworldEditor::LoadGraphics() {
|
||||
constexpr int kSpecialWorldEssential =
|
||||
zelda3::kSpecialWorldMapIdStart + kEssentialMapsPerWorld;
|
||||
|
||||
util::logf(
|
||||
"Creating bitmaps for essential maps only (first %d maps per world)",
|
||||
kEssentialMapsPerWorld);
|
||||
LOG_INFO("OverworldEditor",
|
||||
"Creating bitmaps for essential maps only (first %d maps per world)",
|
||||
kEssentialMapsPerWorld);
|
||||
|
||||
std::vector<gfx::Bitmap*> maps_to_texture;
|
||||
maps_to_texture.reserve(kEssentialMapsPerWorld *
|
||||
@@ -2040,7 +2046,8 @@ void OverworldEditor::EnsureMapTexture(int map_index) {
|
||||
// Ensure the map is built first (on-demand loading)
|
||||
auto status = overworld_.EnsureMapBuilt(map_index);
|
||||
if (!status.ok()) {
|
||||
util::logf("Failed to build map %d: %s", map_index, status.message());
|
||||
LOG_ERROR("OverworldEditor", "Failed to build map %d: %s", map_index,
|
||||
status.message());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2055,7 +2062,8 @@ void OverworldEditor::EnsureMapTexture(int map_index) {
|
||||
overworld_.current_map_bitmap_data());
|
||||
bitmap.SetPalette(palette);
|
||||
} catch (const std::bad_alloc& e) {
|
||||
util::logf("Error allocating bitmap for map %d: %s", map_index, e.what());
|
||||
LOG_ERROR("OverworldEditor", "Error allocating bitmap for map %d: %s",
|
||||
map_index, e.what());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -2137,8 +2145,8 @@ void OverworldEditor::RefreshChildMapOnDemand(int map_index) {
|
||||
// Rebuild tileset only if graphics changed
|
||||
auto status = map->BuildTileset();
|
||||
if (!status.ok()) {
|
||||
util::logf("Failed to build tileset for map %d: %s", map_index,
|
||||
status.message().data());
|
||||
LOG_ERROR("OverworldEditor", "Failed to build tileset for map %d: %s",
|
||||
map_index, status.message().data());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2146,16 +2154,16 @@ void OverworldEditor::RefreshChildMapOnDemand(int map_index) {
|
||||
status = map->BuildTiles16Gfx(*overworld_.mutable_tiles16(),
|
||||
overworld_.tiles16().size());
|
||||
if (!status.ok()) {
|
||||
util::logf("Failed to build tiles16 graphics for map %d: %s", map_index,
|
||||
status.message().data());
|
||||
LOG_ERROR("OverworldEditor", "Failed to build tiles16 graphics for map %d: %s",
|
||||
map_index, status.message().data());
|
||||
return;
|
||||
}
|
||||
|
||||
// Rebuild bitmap
|
||||
status = map->BuildBitmap(overworld_.GetMapTiles(current_world_));
|
||||
if (!status.ok()) {
|
||||
util::logf("Failed to build bitmap for map %d: %s", map_index,
|
||||
status.message().data());
|
||||
LOG_ERROR("OverworldEditor", "Failed to build bitmap for map %d: %s",
|
||||
map_index, status.message().data());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2165,8 +2173,8 @@ void OverworldEditor::RefreshChildMapOnDemand(int map_index) {
|
||||
|
||||
// Validate surface synchronization to help debug crashes
|
||||
if (!maps_bmp_[map_index].ValidateDataSurfaceSync()) {
|
||||
util::logf("Warning: Surface synchronization issue detected for map %d",
|
||||
map_index);
|
||||
LOG_WARN("OverworldEditor", "Warning: Surface synchronization issue detected for map %d",
|
||||
map_index);
|
||||
}
|
||||
|
||||
// Update texture on main thread
|
||||
@@ -2216,12 +2224,12 @@ void OverworldEditor::RefreshMultiAreaMapsSafely(int map_index,
|
||||
return; // No siblings to coordinate
|
||||
}
|
||||
|
||||
util::logf(
|
||||
"RefreshMultiAreaMapsSafely: Processing %s area map %d (parent: %d)",
|
||||
(area_size == AreaSizeEnum::LargeArea) ? "large"
|
||||
: (area_size == AreaSizeEnum::WideArea) ? "wide"
|
||||
: "tall",
|
||||
map_index, map->parent());
|
||||
LOG_DEBUG("OverworldEditor",
|
||||
"RefreshMultiAreaMapsSafely: Processing %s area map %d (parent: %d)",
|
||||
(area_size == AreaSizeEnum::LargeArea) ? "large"
|
||||
: (area_size == AreaSizeEnum::WideArea) ? "wide"
|
||||
: "tall",
|
||||
map_index, map->parent());
|
||||
|
||||
// Determine all maps that are part of this multi-area structure
|
||||
std::vector<int> sibling_maps;
|
||||
@@ -2234,9 +2242,9 @@ void OverworldEditor::RefreshMultiAreaMapsSafely(int map_index,
|
||||
// Parent is top-left (quadrant 0), siblings are:
|
||||
// +1 (top-right, quadrant 1), +8 (bottom-left, quadrant 2), +9 (bottom-right, quadrant 3)
|
||||
sibling_maps = {parent_id, parent_id + 1, parent_id + 8, parent_id + 9};
|
||||
util::logf(
|
||||
"RefreshMultiAreaMapsSafely: Large area siblings: %d, %d, %d, %d",
|
||||
parent_id, parent_id + 1, parent_id + 8, parent_id + 9);
|
||||
LOG_DEBUG("OverworldEditor",
|
||||
"RefreshMultiAreaMapsSafely: Large area siblings: %d, %d, %d, %d",
|
||||
parent_id, parent_id + 1, parent_id + 8, parent_id + 9);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2244,8 +2252,9 @@ void OverworldEditor::RefreshMultiAreaMapsSafely(int map_index,
|
||||
// Wide Area: 2x1 grid (2 maps total, horizontally adjacent)
|
||||
// Parent is left, sibling is +1 (right)
|
||||
sibling_maps = {parent_id, parent_id + 1};
|
||||
util::logf("RefreshMultiAreaMapsSafely: Wide area siblings: %d, %d",
|
||||
parent_id, parent_id + 1);
|
||||
LOG_DEBUG("OverworldEditor",
|
||||
"RefreshMultiAreaMapsSafely: Wide area siblings: %d, %d",
|
||||
parent_id, parent_id + 1);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2253,14 +2262,16 @@ void OverworldEditor::RefreshMultiAreaMapsSafely(int map_index,
|
||||
// Tall Area: 1x2 grid (2 maps total, vertically adjacent)
|
||||
// Parent is top, sibling is +8 (bottom)
|
||||
sibling_maps = {parent_id, parent_id + 8};
|
||||
util::logf("RefreshMultiAreaMapsSafely: Tall area siblings: %d, %d",
|
||||
parent_id, parent_id + 8);
|
||||
LOG_DEBUG("OverworldEditor",
|
||||
"RefreshMultiAreaMapsSafely: Tall area siblings: %d, %d",
|
||||
parent_id, parent_id + 8);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
util::logf("RefreshMultiAreaMapsSafely: Unknown area size %d for map %d",
|
||||
static_cast<int>(area_size), map_index);
|
||||
LOG_WARN("OverworldEditor",
|
||||
"RefreshMultiAreaMapsSafely: Unknown area size %d for map %d",
|
||||
static_cast<int>(area_size), map_index);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2286,13 +2297,13 @@ void OverworldEditor::RefreshMultiAreaMapsSafely(int map_index,
|
||||
bool needs_refresh = maps_bmp_[sibling].modified();
|
||||
|
||||
if ((is_current_map || is_current_world) && needs_refresh) {
|
||||
util::logf(
|
||||
"RefreshMultiAreaMapsSafely: Refreshing %s area sibling map %d "
|
||||
"(parent: %d)",
|
||||
(area_size == AreaSizeEnum::LargeArea) ? "large"
|
||||
: (area_size == AreaSizeEnum::WideArea) ? "wide"
|
||||
: "tall",
|
||||
sibling, parent_id);
|
||||
LOG_DEBUG("OverworldEditor",
|
||||
"RefreshMultiAreaMapsSafely: Refreshing %s area sibling map %d "
|
||||
"(parent: %d)",
|
||||
(area_size == AreaSizeEnum::LargeArea) ? "large"
|
||||
: (area_size == AreaSizeEnum::WideArea) ? "wide"
|
||||
: "tall",
|
||||
sibling, parent_id);
|
||||
|
||||
// Direct refresh without calling RefreshChildMapOnDemand to avoid recursion
|
||||
auto* sibling_map = overworld_.mutable_overworld_map(sibling);
|
||||
@@ -2327,10 +2338,10 @@ void OverworldEditor::RefreshMultiAreaMapsSafely(int map_index,
|
||||
}
|
||||
|
||||
if (!status.ok()) {
|
||||
util::logf(
|
||||
"RefreshMultiAreaMapsSafely: Failed to refresh sibling map %d: "
|
||||
"%s",
|
||||
sibling, status.message().data());
|
||||
LOG_ERROR("OverworldEditor",
|
||||
"RefreshMultiAreaMapsSafely: Failed to refresh sibling map %d: "
|
||||
"%s",
|
||||
sibling, status.message().data());
|
||||
}
|
||||
}
|
||||
} else if (!is_current_map && !is_current_world) {
|
||||
@@ -2487,6 +2498,7 @@ void OverworldEditor::RefreshMapProperties() {
|
||||
}
|
||||
|
||||
absl::Status OverworldEditor::RefreshTile16Blockset() {
|
||||
LOG_DEBUG("OverworldEditor", "RefreshTile16Blockset called");
|
||||
if (current_blockset_ ==
|
||||
overworld_.overworld_map(current_map_)->area_graphics()) {
|
||||
return absl::OkStatus();
|
||||
@@ -3261,8 +3273,8 @@ void OverworldEditor::SetupOverworldCanvasContextMenu() {
|
||||
RefreshOverworldMap();
|
||||
auto status = RefreshTile16Blockset();
|
||||
if (!status.ok()) {
|
||||
util::logf("Failed to refresh tile16 blockset: %s",
|
||||
status.message().data());
|
||||
LOG_ERROR("OverworldEditor", "Failed to refresh tile16 blockset: %s",
|
||||
status.message().data());
|
||||
}
|
||||
};
|
||||
ow_map_canvas_.AddContextMenuItem(refresh_map_item);
|
||||
@@ -3581,7 +3593,8 @@ absl::Status OverworldEditor::ApplyZSCustomOverworldASM(int target_version) {
|
||||
"ROM is already version %d or higher", current_version));
|
||||
}
|
||||
|
||||
util::logf("Applying ZSCustomOverworld ASM v%d to ROM...", target_version);
|
||||
LOG_INFO("OverworldEditor", "Applying ZSCustomOverworld ASM v%d to ROM...",
|
||||
target_version);
|
||||
|
||||
// Initialize Asar wrapper
|
||||
auto asar_wrapper = std::make_unique<core::AsarWrapper>();
|
||||
@@ -3636,25 +3649,26 @@ absl::Status OverworldEditor::ApplyZSCustomOverworldASM(int target_version) {
|
||||
RETURN_IF_ERROR(UpdateROMVersionMarkers(target_version));
|
||||
|
||||
// Log symbols found during patching
|
||||
util::logf("ASM patch applied successfully. Found %zu symbols:",
|
||||
result.symbols.size());
|
||||
LOG_INFO("OverworldEditor", "ASM patch applied successfully. Found %zu symbols:",
|
||||
result.symbols.size());
|
||||
for (const auto& symbol : result.symbols) {
|
||||
util::logf(" %s @ $%06X", symbol.name.c_str(), symbol.address);
|
||||
LOG_INFO("OverworldEditor", " %s @ $%06X", symbol.name.c_str(),
|
||||
symbol.address);
|
||||
}
|
||||
|
||||
// Refresh overworld data to reflect changes
|
||||
RETURN_IF_ERROR(overworld_.Load(rom_));
|
||||
|
||||
util::logf("ZSCustomOverworld v%d successfully applied to ROM",
|
||||
target_version);
|
||||
LOG_INFO("OverworldEditor", "ZSCustomOverworld v%d successfully applied to ROM",
|
||||
target_version);
|
||||
return absl::OkStatus();
|
||||
|
||||
} catch (const std::exception& e) {
|
||||
// Restore original ROM data on any exception
|
||||
auto restore_result = rom_->LoadFromData(original_rom_data, false);
|
||||
if (!restore_result.ok()) {
|
||||
util::logf("Failed to restore ROM data: %s",
|
||||
restore_result.message().data());
|
||||
LOG_ERROR("OverworldEditor", "Failed to restore ROM data: %s",
|
||||
restore_result.message().data());
|
||||
}
|
||||
return absl::InternalError(
|
||||
absl::StrFormat("Exception during ASM application: %s", e.what()));
|
||||
@@ -3672,7 +3686,7 @@ absl::Status OverworldEditor::UpdateROMVersionMarkers(int target_version) {
|
||||
(*rom_)[zelda3::OverworldCustomAreaSpecificBGEnabled] = 0x01;
|
||||
(*rom_)[zelda3::OverworldCustomMainPaletteEnabled] = 0x01;
|
||||
|
||||
util::logf("Enabled v2+ features: Custom BG colors, Main palettes");
|
||||
LOG_INFO("OverworldEditor", "Enabled v2+ features: Custom BG colors, Main palettes");
|
||||
}
|
||||
|
||||
if (target_version >= 3) {
|
||||
@@ -3682,9 +3696,9 @@ absl::Status OverworldEditor::UpdateROMVersionMarkers(int target_version) {
|
||||
(*rom_)[zelda3::OverworldCustomTileGFXGroupEnabled] = 0x01;
|
||||
(*rom_)[zelda3::OverworldCustomMosaicEnabled] = 0x01;
|
||||
|
||||
util::logf(
|
||||
"Enabled v3+ features: Subscreen overlays, Animated GFX, Tile GFX "
|
||||
"groups, Mosaic");
|
||||
LOG_INFO("OverworldEditor",
|
||||
"Enabled v3+ features: Subscreen overlays, Animated GFX, Tile GFX "
|
||||
"groups, Mosaic");
|
||||
|
||||
// Initialize area size data for v3 (set all areas to small by default)
|
||||
for (int i = 0; i < 0xA0; i++) {
|
||||
@@ -3706,10 +3720,11 @@ absl::Status OverworldEditor::UpdateROMVersionMarkers(int target_version) {
|
||||
}
|
||||
}
|
||||
|
||||
util::logf("Initialized area size data for %zu areas", large_areas.size());
|
||||
LOG_INFO("OverworldEditor", "Initialized area size data for %zu areas",
|
||||
large_areas.size());
|
||||
}
|
||||
|
||||
util::logf("ROM version markers updated to v%d", target_version);
|
||||
LOG_INFO("OverworldEditor", "ROM version markers updated to v%d", target_version);
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
|
||||
@@ -54,15 +54,17 @@ int main(int argc, char **argv) {
|
||||
yaze::util::FlagParser parser(yaze::util::global_flag_registry());
|
||||
RETURN_IF_EXCEPTION(parser.Parse(argc, argv));
|
||||
|
||||
// Set up logging and debug flags (using custom flag system)
|
||||
if (!FLAGS_log_file->Get().empty()) {
|
||||
yaze::util::SetLogFile(FLAGS_log_file->Get());
|
||||
}
|
||||
|
||||
// Enable debugging if requested
|
||||
// Set up logging
|
||||
yaze::util::LogLevel log_level = FLAGS_debug->Get()
|
||||
? yaze::util::LogLevel::YAZE_DEBUG
|
||||
: yaze::util::LogLevel::INFO;
|
||||
yaze::util::LogManager::instance().configure(log_level, FLAGS_log_file->Get(),
|
||||
{});
|
||||
|
||||
// Enable console logging via feature flag if debug is enabled.
|
||||
if (FLAGS_debug->Get()) {
|
||||
yaze::core::FeatureFlags::get().kLogToConsole = true;
|
||||
yaze::util::logf("🚀 YAZE started in debug mode");
|
||||
LOG_INFO("Main", "🚀 YAZE started in debug mode");
|
||||
}
|
||||
|
||||
std::string rom_filename = "";
|
||||
|
||||
@@ -674,7 +674,7 @@ absl::Status Rom::WriteByte(int addr, uint8_t value) {
|
||||
value, addr));
|
||||
}
|
||||
rom_data_[addr] = value;
|
||||
util::logf("WriteByte: %#06X: %s", addr, util::HexByte(value).data());
|
||||
LOG_DEBUG("Rom", "WriteByte: %#06X: %s", addr, util::HexByte(value).data());
|
||||
dirty_ = true;
|
||||
return absl::OkStatus();
|
||||
}
|
||||
@@ -687,7 +687,7 @@ absl::Status Rom::WriteWord(int addr, uint16_t value) {
|
||||
}
|
||||
rom_data_[addr] = (uint8_t)(value & 0xFF);
|
||||
rom_data_[addr + 1] = (uint8_t)((value >> 8) & 0xFF);
|
||||
util::logf("WriteWord: %#06X: %s", addr, util::HexWord(value).data());
|
||||
LOG_DEBUG("Rom", "WriteWord: %#06X: %s", addr, util::HexWord(value).data());
|
||||
dirty_ = true;
|
||||
return absl::OkStatus();
|
||||
}
|
||||
@@ -700,7 +700,7 @@ absl::Status Rom::WriteShort(int addr, uint16_t value) {
|
||||
}
|
||||
rom_data_[addr] = (uint8_t)(value & 0xFF);
|
||||
rom_data_[addr + 1] = (uint8_t)((value >> 8) & 0xFF);
|
||||
util::logf("WriteShort: %#06X: %s", addr, util::HexWord(value).data());
|
||||
LOG_DEBUG("Rom", "WriteShort: %#06X: %s", addr, util::HexWord(value).data());
|
||||
dirty_ = true;
|
||||
return absl::OkStatus();
|
||||
}
|
||||
@@ -714,7 +714,7 @@ absl::Status Rom::WriteLong(uint32_t addr, uint32_t value) {
|
||||
rom_data_[addr] = (uint8_t)(value & 0xFF);
|
||||
rom_data_[addr + 1] = (uint8_t)((value >> 8) & 0xFF);
|
||||
rom_data_[addr + 2] = (uint8_t)((value >> 16) & 0xFF);
|
||||
util::logf("WriteLong: %#06X: %s", addr, util::HexLong(value).data());
|
||||
LOG_DEBUG("Rom", "WriteLong: %#06X: %s", addr, util::HexLong(value).data());
|
||||
dirty_ = true;
|
||||
return absl::OkStatus();
|
||||
}
|
||||
@@ -728,7 +728,8 @@ absl::Status Rom::WriteVector(int addr, std::vector<uint8_t> data) {
|
||||
for (int i = 0; i < static_cast<int>(data.size()); i++) {
|
||||
rom_data_[addr + i] = data[i];
|
||||
}
|
||||
util::logf("WriteVector: %#06X: %s", addr, util::HexByte(data[0]).data());
|
||||
LOG_DEBUG("Rom", "WriteVector: %#06X: %s", addr,
|
||||
util::HexByte(data[0]).data());
|
||||
dirty_ = true;
|
||||
return absl::OkStatus();
|
||||
}
|
||||
@@ -738,9 +739,10 @@ absl::Status Rom::WriteColor(uint32_t address, const gfx::SnesColor &color) {
|
||||
(color.snes() & 0x7C00);
|
||||
|
||||
// Write the 16-bit color value to the ROM at the specified address
|
||||
util::logf("WriteColor: %#06X: %s", address, util::HexWord(bgr).data());
|
||||
LOG_DEBUG("Rom", "WriteColor: %#06X: %s", address, util::HexWord(bgr).data());
|
||||
auto st = WriteShort(address, bgr);
|
||||
if (st.ok()) dirty_ = true;
|
||||
if (st.ok())
|
||||
dirty_ = true;
|
||||
return st;
|
||||
}
|
||||
|
||||
|
||||
@@ -129,9 +129,8 @@ void TestManager::InitializeUITesting() {
|
||||
if (!ui_test_engine_) {
|
||||
// Check if ImGui context is ready
|
||||
if (ImGui::GetCurrentContext() == nullptr) {
|
||||
util::logf(
|
||||
"[TestManager] Warning: ImGui context not ready, deferring test "
|
||||
"engine initialization");
|
||||
LOG_WARN("TestManager",
|
||||
"ImGui context not ready, deferring test engine initialization");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -144,7 +143,7 @@ void TestManager::InitializeUITesting() {
|
||||
|
||||
// Start the test engine
|
||||
ImGuiTestEngine_Start(ui_test_engine_, ImGui::GetCurrentContext());
|
||||
util::logf("[TestManager] ImGuiTestEngine initialized successfully");
|
||||
LOG_INFO("TestManager", "ImGuiTestEngine initialized successfully");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -364,8 +363,9 @@ void TestManager::DrawTestDashboard(bool* show_dashboard) {
|
||||
frame_counter++;
|
||||
if (frame_counter % 60 == 0) { // Check every 60 frames
|
||||
// Log ROM status periodically for debugging
|
||||
util::logf("TestManager ROM status check - Frame %d: ROM %p, loaded: %s",
|
||||
frame_counter, (void*)current_rom_, has_rom ? "true" : "false");
|
||||
LOG_INFO("TestManager",
|
||||
"TestManager ROM status check - Frame %d: ROM %p, loaded: %s",
|
||||
frame_counter, (void*)current_rom_, has_rom ? "true" : "false");
|
||||
}
|
||||
|
||||
if (ImGui::BeginTable("ROM_Status_Table", 2, ImGuiTableFlags_BordersInner)) {
|
||||
@@ -448,16 +448,18 @@ void TestManager::DrawTestDashboard(bool* show_dashboard) {
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Debug ROM State")) {
|
||||
util::logf("=== ROM DEBUG INFO ===");
|
||||
util::logf("current_rom_ pointer: %p", (void*)current_rom_);
|
||||
LOG_INFO("TestManager", "=== ROM DEBUG INFO ===");
|
||||
LOG_INFO("TestManager", "current_rom_ pointer: %p", (void*)current_rom_);
|
||||
if (current_rom_) {
|
||||
util::logf("ROM title: '%s'", current_rom_->title().c_str());
|
||||
util::logf("ROM size: %zu", current_rom_->size());
|
||||
util::logf("ROM is_loaded(): %s",
|
||||
current_rom_->is_loaded() ? "true" : "false");
|
||||
util::logf("ROM data pointer: %p", (void*)current_rom_->data());
|
||||
LOG_INFO("TestManager", "ROM title: '%s'",
|
||||
current_rom_->title().c_str());
|
||||
LOG_INFO("TestManager", "ROM size: %zu", current_rom_->size());
|
||||
LOG_INFO("TestManager", "ROM is_loaded(): %s",
|
||||
current_rom_->is_loaded() ? "true" : "false");
|
||||
LOG_INFO("TestManager", "ROM data pointer: %p",
|
||||
(void*)current_rom_->data());
|
||||
}
|
||||
util::logf("======================");
|
||||
LOG_INFO("TestManager", "======================");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -529,8 +531,8 @@ void TestManager::DrawTestDashboard(bool* show_dashboard) {
|
||||
bool nfd_mode = core::FeatureFlags::get().kUseNativeFileDialog;
|
||||
if (ImGui::MenuItem("Use NFD File Dialog", nullptr, &nfd_mode)) {
|
||||
core::FeatureFlags::get().kUseNativeFileDialog = nfd_mode;
|
||||
util::logf("Global file dialog mode changed to: %s",
|
||||
nfd_mode ? "NFD" : "Bespoke");
|
||||
LOG_INFO("TestManager", "Global file dialog mode changed to: %s",
|
||||
nfd_mode ? "NFD" : "Bespoke");
|
||||
}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
@@ -858,7 +860,7 @@ void TestManager::DrawTestDashboard(bool* show_dashboard) {
|
||||
|
||||
if (ImGui::Button("Run All Google Tests")) {
|
||||
// Run Google tests - this would integrate with gtest
|
||||
util::logf("Running Google Tests...");
|
||||
LOG_INFO("TestManager", "Running Google Tests...");
|
||||
}
|
||||
|
||||
ImGui::SameLine();
|
||||
@@ -977,7 +979,7 @@ void TestManager::DrawTestDashboard(bool* show_dashboard) {
|
||||
bool nfd_mode = core::FeatureFlags::get().kUseNativeFileDialog;
|
||||
if (ImGui::RadioButton("NFD (Native File Dialog)", nfd_mode)) {
|
||||
core::FeatureFlags::get().kUseNativeFileDialog = true;
|
||||
util::logf("Global file dialog mode set to: NFD");
|
||||
LOG_INFO("TestManager", "Global file dialog mode set to: NFD");
|
||||
}
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::SetTooltip(
|
||||
@@ -986,7 +988,7 @@ void TestManager::DrawTestDashboard(bool* show_dashboard) {
|
||||
|
||||
if (ImGui::RadioButton("Bespoke Implementation", !nfd_mode)) {
|
||||
core::FeatureFlags::get().kUseNativeFileDialog = false;
|
||||
util::logf("Global file dialog mode set to: Bespoke");
|
||||
LOG_INFO("TestManager", "Global file dialog mode set to: Bespoke");
|
||||
}
|
||||
if (ImGui::IsItemHovered()) {
|
||||
ImGui::SetTooltip(
|
||||
@@ -1003,17 +1005,19 @@ void TestManager::DrawTestDashboard(bool* show_dashboard) {
|
||||
|
||||
if (ImGui::Button("Test Current File Dialog")) {
|
||||
// Test the current file dialog implementation
|
||||
util::logf("Testing global file dialog mode: %s",
|
||||
core::FeatureFlags::get().kUseNativeFileDialog
|
||||
? "NFD"
|
||||
: "Bespoke");
|
||||
LOG_INFO("TestManager", "Testing global file dialog mode: %s",
|
||||
core::FeatureFlags::get().kUseNativeFileDialog
|
||||
? "NFD"
|
||||
: "Bespoke");
|
||||
|
||||
// Actually test the file dialog
|
||||
auto result = core::FileDialogWrapper::ShowOpenFileDialog();
|
||||
if (!result.empty()) {
|
||||
util::logf("File dialog test successful: %s", result.c_str());
|
||||
LOG_INFO("TestManager", "File dialog test successful: %s",
|
||||
result.c_str());
|
||||
} else {
|
||||
util::logf("File dialog test: No file selected or dialog canceled");
|
||||
LOG_INFO("TestManager",
|
||||
"File dialog test: No file selected or dialog canceled");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1021,9 +1025,10 @@ void TestManager::DrawTestDashboard(bool* show_dashboard) {
|
||||
if (ImGui::Button("Test NFD Directly")) {
|
||||
auto result = core::FileDialogWrapper::ShowOpenFileDialogNFD();
|
||||
if (!result.empty()) {
|
||||
util::logf("NFD test successful: %s", result.c_str());
|
||||
LOG_INFO("TestManager", "NFD test successful: %s", result.c_str());
|
||||
} else {
|
||||
util::logf(
|
||||
LOG_INFO(
|
||||
"TestManager",
|
||||
"NFD test: No file selected, canceled, or error occurred");
|
||||
}
|
||||
}
|
||||
@@ -1032,9 +1037,11 @@ void TestManager::DrawTestDashboard(bool* show_dashboard) {
|
||||
if (ImGui::Button("Test Bespoke Directly")) {
|
||||
auto result = core::FileDialogWrapper::ShowOpenFileDialogBespoke();
|
||||
if (!result.empty()) {
|
||||
util::logf("Bespoke test successful: %s", result.c_str());
|
||||
LOG_INFO("TestManager", "Bespoke test successful: %s",
|
||||
result.c_str());
|
||||
} else {
|
||||
util::logf("Bespoke test: No file selected or not implemented");
|
||||
LOG_INFO("TestManager",
|
||||
"Bespoke test: No file selected or not implemented");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1118,12 +1125,12 @@ void TestManager::DrawTestDashboard(bool* show_dashboard) {
|
||||
if (enabled) {
|
||||
if (ImGui::Button("Disable")) {
|
||||
DisableTest(test_name);
|
||||
util::logf("Disabled test: %s", test_name.c_str());
|
||||
LOG_INFO("TestManager", "Disabled test: %s", test_name.c_str());
|
||||
}
|
||||
} else {
|
||||
if (ImGui::Button("Enable")) {
|
||||
EnableTest(test_name);
|
||||
util::logf("Enabled test: %s", test_name.c_str());
|
||||
LOG_INFO("TestManager", "Enabled test: %s", test_name.c_str());
|
||||
}
|
||||
}
|
||||
ImGui::PopID();
|
||||
@@ -1143,7 +1150,7 @@ void TestManager::DrawTestDashboard(bool* show_dashboard) {
|
||||
DisableTest(test_name);
|
||||
}
|
||||
}
|
||||
util::logf("Enabled only safe tests");
|
||||
LOG_INFO("TestManager", "Enabled only safe tests");
|
||||
}
|
||||
ImGui::SameLine();
|
||||
|
||||
@@ -1151,7 +1158,7 @@ void TestManager::DrawTestDashboard(bool* show_dashboard) {
|
||||
for (const auto& [test_name, description] : known_tests) {
|
||||
EnableTest(test_name);
|
||||
}
|
||||
util::logf("Enabled all tests (including dangerous ones)");
|
||||
LOG_INFO("TestManager", "Enabled all tests (including dangerous ones)");
|
||||
}
|
||||
ImGui::SameLine();
|
||||
|
||||
@@ -1159,7 +1166,7 @@ void TestManager::DrawTestDashboard(bool* show_dashboard) {
|
||||
for (const auto& [test_name, description] : known_tests) {
|
||||
DisableTest(test_name);
|
||||
}
|
||||
util::logf("Disabled all tests");
|
||||
LOG_INFO("TestManager", "Disabled all tests");
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
@@ -1181,15 +1188,14 @@ void TestManager::DrawTestDashboard(bool* show_dashboard) {
|
||||
|
||||
if (ImGui::Button("Quick Test NFD")) {
|
||||
auto result = core::FileDialogWrapper::ShowOpenFileDialogNFD();
|
||||
util::logf("NFD test result: %s",
|
||||
result.empty() ? "Failed/Canceled" : result.c_str());
|
||||
LOG_INFO("TestManager", "NFD test result: %s",
|
||||
result.empty() ? "Failed/Canceled" : result.c_str());
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Quick Test Bespoke")) {
|
||||
auto result = core::FileDialogWrapper::ShowOpenFileDialogBespoke();
|
||||
util::logf("Bespoke test result: %s", result.empty()
|
||||
? "Failed/Not Implemented"
|
||||
: result.c_str());
|
||||
LOG_INFO("TestManager", "Bespoke test result: %s",
|
||||
result.empty() ? "Failed/Not Implemented" : result.c_str());
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
@@ -1229,8 +1235,9 @@ void TestManager::DrawTestDashboard(bool* show_dashboard) {
|
||||
ImVec2(200, 0))) {
|
||||
// TODO: This would need access to EditorManager to create a new session
|
||||
// For now, just show a message
|
||||
util::logf("User requested to open test ROM in new session: %s",
|
||||
test_rom_path_for_session_.c_str());
|
||||
LOG_INFO("TestManager",
|
||||
"User requested to open test ROM in new session: %s",
|
||||
test_rom_path_for_session_.c_str());
|
||||
show_test_session_dialog_ = false;
|
||||
}
|
||||
|
||||
@@ -1253,32 +1260,38 @@ void TestManager::DrawTestDashboard(bool* show_dashboard) {
|
||||
}
|
||||
|
||||
void TestManager::RefreshCurrentRom() {
|
||||
util::logf("=== TestManager ROM Refresh ===");
|
||||
LOG_INFO("TestManager", "=== TestManager ROM Refresh ===");
|
||||
|
||||
// Log current TestManager ROM state for debugging
|
||||
if (current_rom_) {
|
||||
util::logf("TestManager ROM pointer: %p", (void*)current_rom_);
|
||||
util::logf("ROM is_loaded(): %s",
|
||||
current_rom_->is_loaded() ? "true" : "false");
|
||||
LOG_INFO("TestManager", "TestManager ROM pointer: %p", (void*)current_rom_);
|
||||
LOG_INFO("TestManager", "ROM is_loaded(): %s",
|
||||
current_rom_->is_loaded() ? "true" : "false");
|
||||
if (current_rom_->is_loaded()) {
|
||||
util::logf("ROM title: '%s'", current_rom_->title().c_str());
|
||||
util::logf("ROM size: %.2f MB", current_rom_->size() / 1048576.0f);
|
||||
util::logf("ROM dirty: %s", current_rom_->dirty() ? "true" : "false");
|
||||
LOG_INFO("TestManager", "ROM title: '%s'",
|
||||
current_rom_->title().c_str());
|
||||
LOG_INFO("TestManager", "ROM size: %.2f MB",
|
||||
current_rom_->size() / 1048576.0f);
|
||||
LOG_INFO("TestManager", "ROM dirty: %s",
|
||||
current_rom_->dirty() ? "true" : "false");
|
||||
}
|
||||
} else {
|
||||
util::logf("TestManager ROM pointer is null");
|
||||
util::logf("Note: ROM should be set by EditorManager when ROM is loaded");
|
||||
LOG_INFO("TestManager", "TestManager ROM pointer is null");
|
||||
LOG_INFO(
|
||||
"TestManager",
|
||||
"Note: ROM should be set by EditorManager when ROM is loaded");
|
||||
}
|
||||
util::logf("===============================");
|
||||
LOG_INFO("TestManager", "===============================");
|
||||
}
|
||||
|
||||
absl::Status TestManager::CreateTestRomCopy(Rom* source_rom,
|
||||
std::unique_ptr<Rom>& test_rom) {
|
||||
absl::Status TestManager::CreateTestRomCopy(
|
||||
Rom* source_rom, std::unique_ptr<Rom>& test_rom) {
|
||||
if (!source_rom || !source_rom->is_loaded()) {
|
||||
return absl::FailedPreconditionError("Source ROM not loaded");
|
||||
}
|
||||
|
||||
util::logf("Creating test ROM copy from: %s", source_rom->title().c_str());
|
||||
LOG_INFO("TestManager", "Creating test ROM copy from: %s",
|
||||
source_rom->title().c_str());
|
||||
|
||||
// Create a new ROM instance
|
||||
test_rom = std::make_unique<Rom>();
|
||||
@@ -1290,12 +1303,13 @@ absl::Status TestManager::CreateTestRomCopy(Rom* source_rom,
|
||||
return load_status;
|
||||
}
|
||||
|
||||
util::logf("Test ROM copy created successfully (size: %.2f MB)",
|
||||
test_rom->size() / 1048576.0f);
|
||||
LOG_INFO("TestManager", "Test ROM copy created successfully (size: %.2f MB)",
|
||||
test_rom->size() / 1048576.0f);
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
std::string TestManager::GenerateTestRomFilename(const std::string& base_name) {
|
||||
std::string TestManager::GenerateTestRomFilename(
|
||||
const std::string& base_name) {
|
||||
// Generate filename with timestamp
|
||||
auto now = std::chrono::system_clock::now();
|
||||
auto time_t = std::chrono::system_clock::to_time_t(now);
|
||||
@@ -1337,13 +1351,13 @@ absl::Status TestManager::TestRomWithCopy(
|
||||
std::unique_ptr<Rom> test_rom;
|
||||
RETURN_IF_ERROR(CreateTestRomCopy(source_rom, test_rom));
|
||||
|
||||
util::logf("Executing test function on ROM copy");
|
||||
LOG_INFO("TestManager", "Executing test function on ROM copy");
|
||||
|
||||
// Run the test function on the copy
|
||||
auto test_result = test_function(test_rom.get());
|
||||
|
||||
util::logf("Test function completed with status: %s",
|
||||
test_result.ToString().c_str());
|
||||
LOG_INFO("TestManager", "Test function completed with status: %s",
|
||||
test_result.ToString().c_str());
|
||||
|
||||
return test_result;
|
||||
}
|
||||
@@ -1351,7 +1365,8 @@ absl::Status TestManager::TestRomWithCopy(
|
||||
absl::Status TestManager::LoadRomForTesting(const std::string& filename) {
|
||||
// This would load a ROM specifically for testing purposes
|
||||
// For now, just log the request
|
||||
util::logf("Request to load ROM for testing: %s", filename.c_str());
|
||||
LOG_INFO("TestManager", "Request to load ROM for testing: %s",
|
||||
filename.c_str());
|
||||
return absl::UnimplementedError(
|
||||
"ROM loading for testing not yet implemented");
|
||||
}
|
||||
@@ -1397,8 +1412,8 @@ absl::Status TestManager::TestRomSaveLoad(Rom* rom) {
|
||||
|
||||
// Use TestRomWithCopy to avoid affecting the original ROM
|
||||
return TestRomWithCopy(rom, [this](Rom* test_rom) -> absl::Status {
|
||||
util::logf("Testing ROM save/load operations on copy: %s",
|
||||
test_rom->title().c_str());
|
||||
LOG_INFO("TestManager", "Testing ROM save/load operations on copy: %s",
|
||||
test_rom->title().c_str());
|
||||
|
||||
// Perform test modifications on the copy
|
||||
// Test save operations
|
||||
@@ -1412,7 +1427,8 @@ absl::Status TestManager::TestRomSaveLoad(Rom* rom) {
|
||||
return save_status;
|
||||
}
|
||||
|
||||
util::logf("Test ROM saved successfully to: %s", settings.filename.c_str());
|
||||
LOG_INFO("TestManager", "Test ROM saved successfully to: %s",
|
||||
settings.filename.c_str());
|
||||
|
||||
// Offer to open test ROM in new session
|
||||
OfferTestSessionCreation(settings.filename);
|
||||
@@ -1428,8 +1444,8 @@ absl::Status TestManager::TestRomDataIntegrity(Rom* rom) {
|
||||
|
||||
// Use TestRomWithCopy for integrity testing (read-only but uses copy for safety)
|
||||
return TestRomWithCopy(rom, [](Rom* test_rom) -> absl::Status {
|
||||
util::logf("Testing ROM data integrity on copy: %s",
|
||||
test_rom->title().c_str());
|
||||
LOG_INFO("TestManager", "Testing ROM data integrity on copy: %s",
|
||||
test_rom->title().c_str());
|
||||
|
||||
// Perform data integrity checks on the copy
|
||||
// This validates ROM structure, checksums, etc. without affecting original
|
||||
@@ -1446,7 +1462,8 @@ absl::Status TestManager::TestRomDataIntegrity(Rom* rom) {
|
||||
return header_status.status();
|
||||
}
|
||||
|
||||
util::logf("ROM integrity check passed for: %s", test_rom->title().c_str());
|
||||
LOG_INFO("TestManager", "ROM integrity check passed for: %s",
|
||||
test_rom->title().c_str());
|
||||
return absl::OkStatus();
|
||||
});
|
||||
}
|
||||
@@ -1753,22 +1770,25 @@ void TestManager::CaptureFailureContext(const std::string& test_id) {
|
||||
|
||||
#if defined(YAZE_WITH_GRPC)
|
||||
if (screenshot_artifact.ok()) {
|
||||
util::logf("[TestManager] Captured failure context for test %s: %s",
|
||||
test_id.c_str(), failure_context.c_str());
|
||||
util::logf("[TestManager] Failure screenshot stored at %s (%lld bytes)",
|
||||
screenshot_artifact->file_path.c_str(),
|
||||
static_cast<long long>(screenshot_artifact->file_size_bytes));
|
||||
LOG_INFO("TestManager",
|
||||
"Captured failure context for test %s: %s", test_id.c_str(),
|
||||
failure_context.c_str());
|
||||
LOG_INFO("TestManager",
|
||||
"Failure screenshot stored at %s (%lld bytes)",
|
||||
screenshot_artifact->file_path.c_str(),
|
||||
static_cast<long long>(screenshot_artifact->file_size_bytes));
|
||||
} else {
|
||||
util::logf("[TestManager] Failed to capture screenshot for test %s: %s",
|
||||
test_id.c_str(),
|
||||
screenshot_artifact.status().ToString().c_str());
|
||||
LOG_WARN("TestManager",
|
||||
"Failed to capture screenshot for test %s: %s", test_id.c_str(),
|
||||
screenshot_artifact.status().ToString().c_str());
|
||||
}
|
||||
#else
|
||||
util::logf(
|
||||
"[TestManager] Screenshot capture unavailable (YAZE_WITH_GRPC=OFF) for test %s",
|
||||
LOG_INFO(
|
||||
"TestManager",
|
||||
"Screenshot capture unavailable (YAZE_WITH_GRPC=OFF) for test %s",
|
||||
test_id.c_str());
|
||||
#endif
|
||||
util::logf("[TestManager] Widget state: %s", widget_state.c_str());
|
||||
LOG_INFO("TestManager", "Widget state: %s", widget_state.c_str());
|
||||
}
|
||||
|
||||
} // namespace test
|
||||
|
||||
@@ -213,10 +213,10 @@ class TestManager {
|
||||
|
||||
// ROM-dependent testing
|
||||
void SetCurrentRom(Rom* rom) {
|
||||
util::logf("TestManager::SetCurrentRom called with ROM: %p", (void*)rom);
|
||||
LOG_INFO("TestManager", "SetCurrentRom called with ROM: %p", (void*)rom);
|
||||
if (rom) {
|
||||
util::logf("ROM title: '%s', loaded: %s", rom->title().c_str(),
|
||||
rom->is_loaded() ? "true" : "false");
|
||||
LOG_INFO("TestManager", "ROM title: '%s', loaded: %s",
|
||||
rom->title().c_str(), rom->is_loaded() ? "true" : "false");
|
||||
}
|
||||
current_rom_ = rom;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ RoomSize CalculateRoomSize(Rom *rom, int room_id) {
|
||||
room_size.room_size = 0;
|
||||
|
||||
auto room_size_address = 0xF8000 + (room_id * 3);
|
||||
// util::logf("Room #%#03X Addresss: %#06X", room_id, room_size_address);
|
||||
|
||||
// Reading bytes for long address construction
|
||||
uint8_t low = rom->data()[room_size_address];
|
||||
@@ -45,12 +44,10 @@ RoomSize CalculateRoomSize(Rom *rom, int room_id) {
|
||||
|
||||
// Constructing the long address
|
||||
int long_address = (bank << 16) | (high << 8) | low;
|
||||
// util::logf("%#06X", long_address);
|
||||
room_size.room_size_pointer = long_address;
|
||||
|
||||
if (long_address == 0x0A8000) {
|
||||
// Blank room disregard in size calculation
|
||||
// util::logf("Size of Room #%#03X: 0 bytes", room_id);
|
||||
room_size.room_size = 0;
|
||||
} else {
|
||||
// use the long address to calculate the size of the room
|
||||
@@ -58,7 +55,6 @@ RoomSize CalculateRoomSize(Rom *rom, int room_id) {
|
||||
// and subtract the two to get the size of the room
|
||||
|
||||
int next_room_address = 0xF8000 + ((room_id + 1) * 3);
|
||||
// util::logf("Next Room Address: %#06X", next_room_address);
|
||||
|
||||
// Reading bytes for long address construction
|
||||
uint8_t next_low = rom->data()[next_room_address];
|
||||
@@ -67,12 +63,10 @@ RoomSize CalculateRoomSize(Rom *rom, int room_id) {
|
||||
|
||||
// Constructing the long address
|
||||
int next_long_address = (next_bank << 16) | (next_high << 8) | next_low;
|
||||
// util::logf("%#06X", next_long_address);
|
||||
|
||||
// Calculate the size of the room
|
||||
int actual_room_size = next_long_address - long_address;
|
||||
room_size.room_size = actual_room_size;
|
||||
// util::logf("Size of Room #%#03X: %d bytes", room_id, actual_room_size);
|
||||
}
|
||||
|
||||
return room_size;
|
||||
@@ -522,7 +516,6 @@ void Room::LoadObjects() {
|
||||
|
||||
// Enhanced bounds checking for object pointer
|
||||
if (object_pointer < 0 || object_pointer >= (int)rom_->size()) {
|
||||
// util::logf("Object pointer out of range for room %d: %#06x", room_id_, object_pointer);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -530,7 +523,6 @@ void Room::LoadObjects() {
|
||||
|
||||
// Enhanced bounds checking for room address
|
||||
if (room_address < 0 || room_address + 2 >= (int)rom_->size()) {
|
||||
// util::logf("Room address out of range for room %d: %#06x", room_id_, room_address);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -541,7 +533,6 @@ void Room::LoadObjects() {
|
||||
|
||||
// Enhanced bounds checking for objects location
|
||||
if (objects_location < 0 || objects_location >= (int)rom_->size()) {
|
||||
// util::logf("Objects location out of range for room %d: %#06x", room_id_, objects_location);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -912,16 +903,11 @@ void Room::LoadRoomLayout() {
|
||||
auto status = layout_.LoadLayout(room_id_);
|
||||
if (!status.ok()) {
|
||||
// Log error but don't fail - some rooms might not have layout data
|
||||
// util::logf("Failed to load room layout for room %d: %s",
|
||||
// room_id_, status.message().data());
|
||||
return;
|
||||
}
|
||||
|
||||
// Store the layout ID for compatibility with existing code
|
||||
layout = static_cast<uint8_t>(room_id_ & 0xFF);
|
||||
|
||||
// util::logf("Loaded room layout for room %d with %zu objects",
|
||||
// room_id_, layout_.GetObjects().size());
|
||||
}
|
||||
|
||||
void Room::LoadDoors() {
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "absl/strings/str_cat.h"
|
||||
@@ -18,45 +19,6 @@
|
||||
namespace yaze {
|
||||
namespace util {
|
||||
|
||||
// Static variables for library state
|
||||
static std::string g_log_file_path = "";
|
||||
|
||||
|
||||
// Set custom log file path
|
||||
inline void SetLogFile(const std::string& filepath) {
|
||||
g_log_file_path = filepath;
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
static void logf(const absl::FormatSpec<Args...> &format, const Args &...args) {
|
||||
std::string message = absl::StrFormat(format, args...);
|
||||
auto timestamp = std::chrono::system_clock::now();
|
||||
|
||||
std::time_t now_tt = std::chrono::system_clock::to_time_t(timestamp);
|
||||
std::tm tm = *std::localtime(&now_tt);
|
||||
message = absl::StrCat("[", tm.tm_hour, ":", tm.tm_min, ":", tm.tm_sec, "] ",
|
||||
message, "\n");
|
||||
|
||||
if (core::FeatureFlags::get().kLogToConsole) {
|
||||
std::cout << message;
|
||||
}
|
||||
|
||||
// Use the configurable log file path
|
||||
static std::ofstream fout;
|
||||
static std::string last_log_path = "";
|
||||
|
||||
// Reopen file if path changed
|
||||
if (g_log_file_path != last_log_path) {
|
||||
fout.close();
|
||||
fout.open(g_log_file_path, std::ios::out | std::ios::trunc);
|
||||
last_log_path = g_log_file_path;
|
||||
}
|
||||
|
||||
fout << message;
|
||||
fout.flush(); // Ensure immediate write for debugging
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @enum LogLevel
|
||||
* @brief Defines the severity levels for log messages.
|
||||
@@ -114,9 +76,6 @@ class LogManager {
|
||||
std::string log_file_path_;
|
||||
};
|
||||
|
||||
// logf mapping
|
||||
#define logf LOG_INFO
|
||||
|
||||
// --- Public Logging Macros ---
|
||||
// These macros provide a convenient and efficient API for logging.
|
||||
// The `do-while(0)` loop ensures they behave like a single statement.
|
||||
@@ -140,6 +99,16 @@ class LogManager {
|
||||
#define LOG_FATAL(category, format, ...) \
|
||||
LOG(yaze::util::LogLevel::FATAL, category, format, ##__VA_ARGS__)
|
||||
|
||||
template <typename... Args>
|
||||
inline void logf(const absl::FormatSpec<Args...>& format, Args&&... args) {
|
||||
LogManager::instance().log(LogLevel::INFO, "General",
|
||||
absl::StrFormat(format, std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
inline void logf(absl::string_view message) {
|
||||
LogManager::instance().log(LogLevel::INFO, "General", message);
|
||||
}
|
||||
|
||||
} // namespace util
|
||||
} // namespace yaze
|
||||
|
||||
|
||||
Reference in New Issue
Block a user