diff --git a/rpcs3/Emu/CPU/CPUThread.cpp b/rpcs3/Emu/CPU/CPUThread.cpp index ce53d8e21f..15daac9da5 100644 --- a/rpcs3/Emu/CPU/CPUThread.cpp +++ b/rpcs3/Emu/CPU/CPUThread.cpp @@ -15,6 +15,9 @@ DECLARE(cpu_thread::g_threads_created){0}; DECLARE(cpu_thread::g_threads_deleted){0}; +LOG_CHANNEL(profiler); +LOG_CHANNEL(sys_log); + template <> void fmt_class_string::format(std::string& out, u64 arg) { @@ -115,7 +118,7 @@ struct cpu_prof } } - LOG_NOTICE(GENERAL, "Thread [0x%08x]: %u samples (%.4f%% idle):%s", id, samples, 100. * idle / samples, results); + profiler.notice("Thread [0x%08x]: %u samples (%.4f%% idle):%s", id, samples, 100. * idle / samples, results); } }; @@ -149,7 +152,7 @@ struct cpu_prof } else { - LOG_FATAL(GENERAL, "Invalid Thread ID: 0x%08x", id); + profiler.error("Invalid Thread ID: 0x%08x", id); continue; } @@ -211,7 +214,7 @@ struct cpu_prof if (flush) { - LOG_SUCCESS(GENERAL, "Flushing profiling results..."); + profiler.success("Flushing profiling results..."); // Print all results and cleanup for (auto& [id, info] : threads) @@ -293,7 +296,7 @@ void cpu_thread::operator()() if (c != 0) { - LOG_FATAL(GENERAL,"could not disable denormals"); + sys_log.fatal("Could not disable denormals."); } } @@ -310,7 +313,7 @@ void cpu_thread::operator()() // Register thread in g_cpu_array if (!g_cpu_array_sema.try_inc(sizeof(g_cpu_array_bits) * 8)) { - LOG_FATAL(GENERAL, "Too many threads"); + sys_log.fatal("Too many threads."); Emu.Pause(); return; } @@ -362,8 +365,8 @@ void cpu_thread::operator()() catch (const std::exception& e) { Emu.Pause(); - LOG_FATAL(GENERAL, "%s thrown: %s", typeid(e).name(), e.what()); - LOG_NOTICE(GENERAL, "\n%s", dump()); + sys_log.fatal("%s thrown: %s", typeid(e).name(), e.what()); + sys_log.notice("\n%s", dump()); break; } @@ -609,7 +612,7 @@ void cpu_thread::stop_all() noexcept if (g_tls_current_cpu_thread) { // Report unsupported but unnecessary case - LOG_FATAL(GENERAL, "cpu_thread::stop_all() has been called from a CPU thread."); + sys_log.fatal("cpu_thread::stop_all() has been called from a CPU thread."); return; } else @@ -623,7 +626,7 @@ void cpu_thread::stop_all() noexcept }); } - LOG_NOTICE(GENERAL, "All CPU threads have been signaled."); + sys_log.notice("All CPU threads have been signaled."); while (g_cpu_array_sema) { @@ -633,14 +636,14 @@ void cpu_thread::stop_all() noexcept // Workaround for remaining threads (TODO) std::this_thread::sleep_for(1300ms); - LOG_NOTICE(GENERAL, "All CPU threads have been stopped."); + sys_log.notice("All CPU threads have been stopped."); } void cpu_thread::flush_profilers() noexcept { if (!g_fxo->get()) { - LOG_FATAL(GENERAL, "cpu_thread::flush_profilers() has been called incorrectly." HERE); + profiler.fatal("cpu_thread::flush_profilers() has been called incorrectly." HERE); return; } diff --git a/rpcs3/Emu/Cell/PPUModule.cpp b/rpcs3/Emu/Cell/PPUModule.cpp index 32d8ed84d4..59e2f7597f 100644 --- a/rpcs3/Emu/Cell/PPUModule.cpp +++ b/rpcs3/Emu/Cell/PPUModule.cpp @@ -1165,11 +1165,11 @@ void ppu_load_exec(const ppu_exec_object& elf) applied = 0; - // Executable hash + // Executable hash sha1_context sha2; sha1_starts(&sha2); u8 sha1_hash[20]; - + for (const auto& prog : obj.progs) { // Only hash the data, we are not loading it @@ -1193,7 +1193,7 @@ void ppu_load_exec(const ppu_exec_object& elf) fmt::append(dump, "\n\tSPUNAME: '%s'", spu_name); } } - + sha1_finish(&sha2, sha1_hash); // Format patch name @@ -1219,7 +1219,7 @@ void ppu_load_exec(const ppu_exec_object& elf) } LOG_NOTICE(LOADER, "SPU executable hash: %s (<- %u)%s", hash, applied, dump); - + } // Static HLE patching @@ -1254,7 +1254,7 @@ void ppu_load_exec(const ppu_exec_object& elf) } } - LOG_NOTICE(LOADER, "SELF header information found: ctrl_flags1=0x%x, authid=0x%llx", + LOG_NOTICE(LOADER, "SELF header information found: ctrl_flags1=0x%x, authid=0x%llx", g_ps3_process_info.ctrl_flags1, g_ps3_process_info.self_info.app_info.authid); } @@ -1305,7 +1305,7 @@ void ppu_load_exec(const ppu_exec_object& elf) { sdk_version = info.sdk_version; - if (s32 prio = info.primary_prio; prio < 3072 + if (s32 prio = info.primary_prio; prio < 3072 && (prio >= (g_ps3_process_info.debug_or_root() ? 0 : -512))) { primary_prio = prio; @@ -1404,7 +1404,7 @@ void ppu_load_exec(const ppu_exec_object& elf) if (!fs::is_dir(lle_dir) || !fs::is_file(lle_dir + "libsysmodule.sprx")) { - LOG_ERROR(GENERAL, "PS3 firmware is not installed or the installed firmware is invalid." + LOG_ERROR(LOADER, "PS3 firmware is not installed or the installed firmware is invalid." "\nYou should install the PS3 Firmware (Menu: File -> Install Firmware)." "\nVisit https://rpcs3.net/ for Quickstart Guide and more information."); } diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index f5ab6b62e6..191f0f0510 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -404,13 +404,13 @@ extern bool ppu_patch(u32 addr, u32 value) if (g_cfg.core.ppu_decoder == ppu_decoder_type::llvm && Emu.GetStatus() != system_state::ready) { // TODO: support recompilers - LOG_FATAL(GENERAL, "Patch failed at 0x%x: LLVM recompiler is used.", addr); + LOG_FATAL(PPU, "Patch failed at 0x%x: LLVM recompiler is used.", addr); return false; } if (!vm::try_access(addr, &value, sizeof(value), true)) { - LOG_FATAL(GENERAL, "Patch failed at 0x%x: invalid memory address.", addr); + LOG_FATAL(PPU, "Patch failed at 0x%x: invalid memory address.", addr); return false; } diff --git a/rpcs3/Emu/Cell/SPURecompiler.cpp b/rpcs3/Emu/Cell/SPURecompiler.cpp index 34764bab61..ec0a46f0d6 100644 --- a/rpcs3/Emu/Cell/SPURecompiler.cpp +++ b/rpcs3/Emu/Cell/SPURecompiler.cpp @@ -1186,8 +1186,8 @@ void spu_recompiler_base::old_interpreter(spu_thread& spu, void* ls, u8* rip) tr catch (const std::exception& e) { Emu.Pause(); - LOG_FATAL(GENERAL, "%s thrown: %s", typeid(e).name(), e.what()); - LOG_NOTICE(GENERAL, "\n%s", spu.dump()); + LOG_FATAL(SPU, "%s thrown: %s", typeid(e).name(), e.what()); + LOG_NOTICE(SPU, "\n%s", spu.dump()); } spu_program spu_recompiler_base::analyse(const be_t* ls, u32 entry_point) diff --git a/rpcs3/Emu/RSX/CgBinaryProgram.h b/rpcs3/Emu/RSX/CgBinaryProgram.h index 3f26a6fcff..30b41b1200 100644 --- a/rpcs3/Emu/RSX/CgBinaryProgram.h +++ b/rpcs3/Emu/RSX/CgBinaryProgram.h @@ -234,7 +234,7 @@ public: std::string GetCgParamRes(u32 /*offset*/) const { - // LOG_WARNING(GENERAL, "GetCgParamRes offset 0x%x", offset); + // LOG_WARNING(RSX, "GetCgParamRes offset 0x%x", offset); // TODO return ""; } diff --git a/rpcs3/Emu/RSX/GL/GLPresent.cpp b/rpcs3/Emu/RSX/GL/GLPresent.cpp index abdfdd7b36..0944142a8d 100644 --- a/rpcs3/Emu/RSX/GL/GLPresent.cpp +++ b/rpcs3/Emu/RSX/GL/GLPresent.cpp @@ -1,6 +1,8 @@ #include "stdafx.h" #include "GLGSRender.h" +LOG_CHANNEL(screenshot); + GLuint GLGSRender::get_present_source(gl::present_surface_info* info, const rsx::avconf* avconfig) { GLuint image = GL_NONE; @@ -184,7 +186,7 @@ void GLGSRender::flip(const rsx::display_flip_info_t& info) glGetTextureImageEXT(image_to_flip, GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_BYTE, sshot_frame.data()); if (GLenum err; (err = glGetError()) != GL_NO_ERROR) - LOG_ERROR(GENERAL, "[Screenshot] Failed to capture image: 0x%x", err); + screenshot.error("Failed to capture image: 0x%x", err); else m_frame->take_screenshot(std::move(sshot_frame), buffer_width, buffer_height); } diff --git a/rpcs3/Emu/RSX/Overlays/overlays.cpp b/rpcs3/Emu/RSX/Overlays/overlays.cpp index 11ac0486c1..383994dde0 100644 --- a/rpcs3/Emu/RSX/Overlays/overlays.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlays.cpp @@ -2,6 +2,8 @@ #include "overlays.h" #include "../GSRender.h" +LOG_CHANNEL(overlays); + static auto s_ascii_lowering_map = []() { std::unordered_map _map; @@ -81,7 +83,7 @@ std::string utf8_to_ascii8(const std::string& utf8_string) if ((index + extra_bytes) > end) { // Malformed string, abort - LOG_ERROR(GENERAL, "Failed to decode supossedly malformed utf8 string '%s'", utf8_string); + overlays.error("Failed to decode supossedly malformed utf8 string '%s'", utf8_string); break; } diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index aa50dc67ff..556ccb3331 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -48,6 +48,8 @@ #include "Emu/RSX/VK/VulkanAPI.h" #endif +LOG_CHANNEL(sys_log); + stx::manual_fixed_typemap g_fixed_typemap; cfg_root g_cfg; @@ -314,7 +316,7 @@ void Emulator::Init() if (!g_tty) { - LOG_FATAL(GENERAL, "Failed to create TTY log: %s (%s)", tty_path, fs::g_tls_error); + sys_log.fatal("Failed to create TTY log: %s (%s)", tty_path, fs::g_tls_error); } } @@ -335,7 +337,7 @@ void Emulator::Init() } else { - LOG_FATAL(GENERAL, "Failed to access global config: %s (%s)", cfg_path, fs::g_tls_error); + sys_log.fatal("Failed to access global config: %s (%s)", cfg_path, fs::g_tls_error); } // Create directories (can be disabled if necessary) @@ -348,7 +350,7 @@ void Emulator::Init() { if (!fs::create_path(path)) { - LOG_FATAL(GENERAL, "Failed to create path: %s (%s)", path, fs::g_tls_error); + sys_log.fatal("Failed to create path: %s (%s)", path, fs::g_tls_error); } }; @@ -373,7 +375,7 @@ void Emulator::Init() { if (fs::g_tls_error != fs::error::exist) { - LOG_FATAL(GENERAL, "Failed to create file: %shome/%s/localusername (%s)", dev_hdd0, m_usr, fs::g_tls_error); + sys_log.fatal("Failed to create file: %shome/%s/localusername (%s)", dev_hdd0, m_usr, fs::g_tls_error); } } @@ -396,23 +398,23 @@ void Emulator::Init() // Finalize interrupted saving if (!fs::rename(pending, save_path + desired, false)) { - LOG_FATAL(GENERAL, "Failed to fix save data: %s (%s)", pending, fs::g_tls_error); + sys_log.fatal("Failed to fix save data: %s (%s)", pending, fs::g_tls_error); continue; } else { - LOG_SUCCESS(GENERAL, "Fixed save data: %s", desired); + sys_log.success("Fixed save data: %s", desired); } } // Remove pending backup data if (!fs::remove_all(save_path + entry.name)) { - LOG_FATAL(GENERAL, "Failed to remove save data backup: %s%s (%s)", save_path, entry.name, fs::g_tls_error); + sys_log.fatal("Failed to remove save data backup: %s%s (%s)", save_path, entry.name, fs::g_tls_error); } else { - LOG_SUCCESS(GENERAL, "Removed save data backup: %s%s", save_path, entry.name); + sys_log.success("Removed save data backup: %s%s", save_path, entry.name); } } } @@ -649,7 +651,7 @@ void Emulator::LimitCacheSize() const std::string cache_location = Emulator::GetHdd1Dir() + "/caches"; if (!fs::is_dir(cache_location)) { - LOG_WARNING(GENERAL, "Cache does not exist (%s)", cache_location); + sys_log.warning("Cache does not exist (%s)", cache_location); return; } @@ -659,22 +661,22 @@ void Emulator::LimitCacheSize() if (max_size == 0) // Everything must go, so no need to do checks { fs::remove_all(cache_location, false); - LOG_SUCCESS(GENERAL, "Cleared disk cache"); + sys_log.success("Cleared disk cache"); return; } if (size <= max_size) { - LOG_TRACE(GENERAL, "Cache size below limit: %llu/%llu", size, max_size); + sys_log.trace("Cache size below limit: %llu/%llu", size, max_size); return; } - LOG_SUCCESS(GENERAL, "Cleaning disk cache..."); + sys_log.success("Cleaning disk cache..."); std::vector file_list{}; fs::dir cache_dir{}; if (!cache_dir.open(cache_location)) { - LOG_ERROR(GENERAL, "Could not open cache directory"); + sys_log.error("Could not open cache directory"); return; } @@ -715,7 +717,7 @@ void Emulator::LimitCacheSize() break; } - LOG_SUCCESS(GENERAL, "Cleaned disk cache, removed %.2f MB", size / 1024.0 / 1024.0); + sys_log.success("Cleaned disk cache, removed %.2f MB", size / 1024.0 / 1024.0); } bool Emulator::BootGame(const std::string& path, const std::string& title_id, bool direct, bool add_only, bool force_global_config) @@ -783,7 +785,7 @@ bool Emulator::BootGame(const std::string& path, const std::string& title_id, bo bool Emulator::InstallPkg(const std::string& path) { - LOG_SUCCESS(GENERAL, "Installing package: %s", path); + sys_log.success("Installing package: %s", path); atomic_t progress(0.); int int_progress = 0; @@ -806,7 +808,7 @@ bool Emulator::InstallPkg(const std::string& path) if (static_cast(pval) > int_progress) { int_progress = static_cast(pval); - LOG_SUCCESS(GENERAL, "... %u%%", int_progress); + sys_log.success("... %u%%", int_progress); } } } @@ -1047,7 +1049,7 @@ void Emulator::Load(const std::string& title_id, bool add_only, bool force_globa if (g_use_rtm && !utils::has_mpx()) { - LOG_WARNING(GENERAL, "TSX forced by User"); + sys_log.warning("TSX forced by User"); } // Load patches from different locations @@ -1688,7 +1690,7 @@ bool Emulator::Pause() // Update pause start time if (m_pause_start_time.exchange(start)) { - LOG_ERROR(GENERAL, "Emulator::Pause() error: concurrent access"); + sys_log.error("Emulator::Pause() error: concurrent access"); } auto on_select = [](u32, cpu_thread& cpu) @@ -1757,7 +1759,7 @@ void Emulator::Resume() if (!time) { - LOG_ERROR(GENERAL, "Emulator::Resume() error: concurrent access"); + sys_log.error("Emulator::Resume() error: concurrent access"); } auto on_select = [](u32, cpu_thread& cpu) @@ -1792,7 +1794,7 @@ void Emulator::Stop(bool restart) const bool full_stop = !restart && !m_force_boot; const bool do_exit = full_stop && g_cfg.misc.autoexit; - LOG_NOTICE(GENERAL, "Stopping emulator..."); + sys_log.notice("Stopping emulator..."); GetCallbacks().on_stop(); @@ -1801,7 +1803,7 @@ void Emulator::Stop(bool restart) lv2_obj::cleanup(); idm::clear(); - LOG_NOTICE(GENERAL, "Objects cleared..."); + sys_log.notice("Objects cleared..."); vm::close(); @@ -1873,7 +1875,7 @@ s32 error_code::error_report(const fmt_type_info* sup, u64 arg, const fmt_type_i { if (pair.second > 3) { - LOG_ERROR(GENERAL, "Stat: %s [x%u]", pair.first, pair.second); + sys_log.error("Stat: %s [x%u]", pair.first, pair.second); } } @@ -1882,7 +1884,7 @@ s32 error_code::error_report(const fmt_type_info* sup, u64 arg, const fmt_type_i } } - logs::channel* channel = &logs::GENERAL; + logs::channel* channel = &sys_log; const char* func = "Unknown function"; if (auto thread = get_current_cpu_thread())