From 9b7eaf51171834002fa72212c14fe8dd6dce415d Mon Sep 17 00:00:00 2001 From: Megamouse Date: Sat, 7 Jan 2023 22:11:41 +0100 Subject: [PATCH] Improve error logging --- Utilities/bin_patch.cpp | 2 +- rpcs3/Emu/Cell/Modules/cellMusicSelectionContext.cpp | 2 +- rpcs3/Emu/IPC_config.cpp | 2 +- rpcs3/Emu/Io/camera_config.cpp | 2 +- rpcs3/Emu/Io/pad_config.cpp | 4 ++-- rpcs3/Emu/Io/recording_config.cpp | 2 +- rpcs3/Emu/NP/rpcn_config.cpp | 2 +- rpcs3/Emu/System.cpp | 4 ++-- rpcs3/Emu/vfs_config.cpp | 2 +- rpcs3/rpcs3qt/emu_settings.cpp | 5 ++++- rpcs3/rpcs3qt/patch_manager_dialog.cpp | 2 +- 11 files changed, 16 insertions(+), 13 deletions(-) diff --git a/Utilities/bin_patch.cpp b/Utilities/bin_patch.cpp index 9212165ef1..f44db2e578 100644 --- a/Utilities/bin_patch.cpp +++ b/Utilities/bin_patch.cpp @@ -1181,7 +1181,7 @@ void patch_engine::save_config(const patch_map& patches_map) if (!file.file || (file.file.write(out.c_str(), out.size()), !file.commit())) { - patch_log.error("Failed to create patch config file %s (%s)", path, fs::g_tls_error); + patch_log.error("Failed to create patch config file %s (error=%s)", path, fs::g_tls_error); } } diff --git a/rpcs3/Emu/Cell/Modules/cellMusicSelectionContext.cpp b/rpcs3/Emu/Cell/Modules/cellMusicSelectionContext.cpp index a40a6b2826..3f3b62b4d7 100644 --- a/rpcs3/Emu/Cell/Modules/cellMusicSelectionContext.cpp +++ b/rpcs3/Emu/Cell/Modules/cellMusicSelectionContext.cpp @@ -140,7 +140,7 @@ void music_selection_context::create_playlist(const std::string& new_hash) if (!file.file || (file.file.write(out.c_str(), out.size()), !file.commit())) { - cellMusicSelectionContext.error("Failed to create music playlist file %s (%s)", yaml_path, fs::g_tls_error); + cellMusicSelectionContext.error("Failed to create music playlist file %s (error=%s)", yaml_path, fs::g_tls_error); } } diff --git a/rpcs3/Emu/IPC_config.cpp b/rpcs3/Emu/IPC_config.cpp index c276645730..7eedad9246 100644 --- a/rpcs3/Emu/IPC_config.cpp +++ b/rpcs3/Emu/IPC_config.cpp @@ -36,7 +36,7 @@ void cfg_ipc::save() const if (!cfg_file.file || (cfg_file.file.write(to_string()), !cfg_file.commit())) { - IPC.error("Could not save config: %s", cfg_ipc::get_path()); + IPC.error("Could not save config: %s (error=%s)", cfg_ipc::get_path(), fs::g_tls_error); } } diff --git a/rpcs3/Emu/Io/camera_config.cpp b/rpcs3/Emu/Io/camera_config.cpp index 84b913890b..bcc19c5786 100644 --- a/rpcs3/Emu/Io/camera_config.cpp +++ b/rpcs3/Emu/Io/camera_config.cpp @@ -38,7 +38,7 @@ void cfg_camera::save() const if (!cfg_file.file || (cfg_file.file.write(to_string()), !cfg_file.commit())) { - camera_log.error("Failed to save camera config to '%s'", path); + camera_log.error("Failed to save camera config to '%s' (error=%s)", path, fs::g_tls_error); } } diff --git a/rpcs3/Emu/Io/pad_config.cpp b/rpcs3/Emu/Io/pad_config.cpp index c28679b984..b554a0277f 100644 --- a/rpcs3/Emu/Io/pad_config.cpp +++ b/rpcs3/Emu/Io/pad_config.cpp @@ -73,7 +73,7 @@ void cfg_input::save(const std::string& title_id, const std::string& profile) co if (!cfg_file.file || (cfg_file.file.write(to_string()), !cfg_file.commit())) { - input_log.error("Failed to save pad config to '%s'", cfg_name); + input_log.error("Failed to save pad config to '%s' (error=%s)", cfg_name, fs::g_tls_error); } } @@ -101,6 +101,6 @@ void cfg_profile::save() const if (!cfg_file.file || (cfg_file.file.write(to_string()), !cfg_file.commit())) { - input_log.error("Failed to save pad profile config to '%s'", path); + input_log.error("Failed to save pad profile config to '%s' (error=%s)", path, fs::g_tls_error); } } diff --git a/rpcs3/Emu/Io/recording_config.cpp b/rpcs3/Emu/Io/recording_config.cpp index 9b05ecbcab..5092c9c152 100644 --- a/rpcs3/Emu/Io/recording_config.cpp +++ b/rpcs3/Emu/Io/recording_config.cpp @@ -39,6 +39,6 @@ void cfg_recording::save() const if (!cfg_file.file || (cfg_file.file.write(to_string()), !cfg_file.commit())) { - cfg_log.error("Failed to save recording config to '%s'", path); + cfg_log.error("Failed to save recording config to '%s' (error=%s)", path, fs::g_tls_error); } } diff --git a/rpcs3/Emu/NP/rpcn_config.cpp b/rpcs3/Emu/NP/rpcn_config.cpp index 3cd068af43..fa623decb5 100644 --- a/rpcs3/Emu/NP/rpcn_config.cpp +++ b/rpcs3/Emu/NP/rpcn_config.cpp @@ -45,7 +45,7 @@ void cfg_rpcn::save() const if (!cfg_file.file || (cfg_file.file.write(to_string()), !cfg_file.commit())) { - rpcn_log.error("Could not save config: %s", cfg_rpcn::get_path()); + rpcn_log.error("Could not save config: %s (error=%s)", cfg_rpcn::get_path(), fs::g_tls_error); } } diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index f0a4a0f0a2..b1eac754eb 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -1541,7 +1541,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool add_only, bool // Do not update games.yml when TITLE_ID is empty if (!temp.file || temp.file.write(out.c_str(), out.size()), !temp.commit()) { - sys_log.error("Failed to save BDVD location of title '%s' (%s)", m_title_id, fs::g_tls_error); + sys_log.error("Failed to save BDVD location of title '%s' (error=%s)", m_title_id, fs::g_tls_error); } } } @@ -1597,7 +1597,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool add_only, bool if (!temp.file || temp.file.write(out.c_str(), out.size()), !temp.commit()) { - sys_log.error("Failed to save HG game location of title '%s' (%s)", m_title_id, fs::g_tls_error); + sys_log.error("Failed to save HG game location of title '%s' (error=%s)", m_title_id, fs::g_tls_error); } vfs::mount("/dev_hdd0/game/" + m_title_id, m_sfo_dir + '/'); diff --git a/rpcs3/Emu/vfs_config.cpp b/rpcs3/Emu/vfs_config.cpp index 54a0bf71e3..4ff5dd6659 100644 --- a/rpcs3/Emu/vfs_config.cpp +++ b/rpcs3/Emu/vfs_config.cpp @@ -111,7 +111,7 @@ void cfg_vfs::save() const if (!temp.file) { - vfs_log.error("Could not save config: \"%s\"", cfg_vfs::get_path()); + vfs_log.error("Could not save config: \"%s\" (error=%s)", cfg_vfs::get_path(), fs::g_tls_error); return; } diff --git a/rpcs3/rpcs3qt/emu_settings.cpp b/rpcs3/rpcs3qt/emu_settings.cpp index 471344f0fd..7e6beb2416 100644 --- a/rpcs3/rpcs3qt/emu_settings.cpp +++ b/rpcs3/rpcs3qt/emu_settings.cpp @@ -284,7 +284,10 @@ void emu_settings::SaveSettings() // Save config atomically fs::pending_file temp(config_name); temp.file.write(out.c_str(), out.size()); - temp.commit(); + if (!temp.commit()) + { + cfg_log.error("Could not save config to %s (error=%s)", config_name, fs::g_tls_error); + } // Check if the running config/title is the same as the edited config/title. if (config_name == g_cfg.name || m_title_id == Emu.GetTitleID()) diff --git a/rpcs3/rpcs3qt/patch_manager_dialog.cpp b/rpcs3/rpcs3qt/patch_manager_dialog.cpp index 929aa3f047..23ef326692 100644 --- a/rpcs3/rpcs3qt/patch_manager_dialog.cpp +++ b/rpcs3/rpcs3qt/patch_manager_dialog.cpp @@ -1034,7 +1034,7 @@ bool patch_manager_dialog::handle_json(const QByteArray& data) if (!patch_file.file || (patch_file.file.write(content), !patch_file.commit())) { - patch_log.error("Could not save new patches to %s (%s)", path, fs::g_tls_error); + patch_log.error("Could not save new patches to %s (error=%s)", path, fs::g_tls_error); return false; }