logs: add more log channels instead of GENERAL

This commit is contained in:
Nekotekina 2020-01-31 16:43:59 +03:00
parent d5f019c3d3
commit 1d0f359406
8 changed files with 57 additions and 48 deletions

View file

@ -15,6 +15,9 @@
DECLARE(cpu_thread::g_threads_created){0}; DECLARE(cpu_thread::g_threads_created){0};
DECLARE(cpu_thread::g_threads_deleted){0}; DECLARE(cpu_thread::g_threads_deleted){0};
LOG_CHANNEL(profiler);
LOG_CHANNEL(sys_log);
template <> template <>
void fmt_class_string<cpu_flag>::format(std::string& out, u64 arg) void fmt_class_string<cpu_flag>::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 else
{ {
LOG_FATAL(GENERAL, "Invalid Thread ID: 0x%08x", id); profiler.error("Invalid Thread ID: 0x%08x", id);
continue; continue;
} }
@ -211,7 +214,7 @@ struct cpu_prof
if (flush) if (flush)
{ {
LOG_SUCCESS(GENERAL, "Flushing profiling results..."); profiler.success("Flushing profiling results...");
// Print all results and cleanup // Print all results and cleanup
for (auto& [id, info] : threads) for (auto& [id, info] : threads)
@ -293,7 +296,7 @@ void cpu_thread::operator()()
if (c != 0) 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 // Register thread in g_cpu_array
if (!g_cpu_array_sema.try_inc(sizeof(g_cpu_array_bits) * 8)) 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(); Emu.Pause();
return; return;
} }
@ -362,8 +365,8 @@ void cpu_thread::operator()()
catch (const std::exception& e) catch (const std::exception& e)
{ {
Emu.Pause(); Emu.Pause();
LOG_FATAL(GENERAL, "%s thrown: %s", typeid(e).name(), e.what()); sys_log.fatal("%s thrown: %s", typeid(e).name(), e.what());
LOG_NOTICE(GENERAL, "\n%s", dump()); sys_log.notice("\n%s", dump());
break; break;
} }
@ -609,7 +612,7 @@ void cpu_thread::stop_all() noexcept
if (g_tls_current_cpu_thread) if (g_tls_current_cpu_thread)
{ {
// Report unsupported but unnecessary case // 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; return;
} }
else 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) while (g_cpu_array_sema)
{ {
@ -633,14 +636,14 @@ void cpu_thread::stop_all() noexcept
// Workaround for remaining threads (TODO) // Workaround for remaining threads (TODO)
std::this_thread::sleep_for(1300ms); 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 void cpu_thread::flush_profilers() noexcept
{ {
if (!g_fxo->get<cpu_profiler>()) if (!g_fxo->get<cpu_profiler>())
{ {
LOG_FATAL(GENERAL, "cpu_thread::flush_profilers() has been called incorrectly." HERE); profiler.fatal("cpu_thread::flush_profilers() has been called incorrectly." HERE);
return; return;
} }

View file

@ -1165,11 +1165,11 @@ void ppu_load_exec(const ppu_exec_object& elf)
applied = 0; applied = 0;
// Executable hash // Executable hash
sha1_context sha2; sha1_context sha2;
sha1_starts(&sha2); sha1_starts(&sha2);
u8 sha1_hash[20]; u8 sha1_hash[20];
for (const auto& prog : obj.progs) for (const auto& prog : obj.progs)
{ {
// Only hash the data, we are not loading it // 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); fmt::append(dump, "\n\tSPUNAME: '%s'", spu_name);
} }
} }
sha1_finish(&sha2, sha1_hash); sha1_finish(&sha2, sha1_hash);
// Format patch name // 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); LOG_NOTICE(LOADER, "SPU executable hash: %s (<- %u)%s", hash, applied, dump);
} }
// Static HLE patching // 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); 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; 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))) && (prio >= (g_ps3_process_info.debug_or_root() ? 0 : -512)))
{ {
primary_prio = prio; 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")) 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)." "\nYou should install the PS3 Firmware (Menu: File -> Install Firmware)."
"\nVisit https://rpcs3.net/ for Quickstart Guide and more information."); "\nVisit https://rpcs3.net/ for Quickstart Guide and more information.");
} }

View file

@ -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) if (g_cfg.core.ppu_decoder == ppu_decoder_type::llvm && Emu.GetStatus() != system_state::ready)
{ {
// TODO: support recompilers // 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; return false;
} }
if (!vm::try_access(addr, &value, sizeof(value), true)) 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; return false;
} }

View file

@ -1186,8 +1186,8 @@ void spu_recompiler_base::old_interpreter(spu_thread& spu, void* ls, u8* rip) tr
catch (const std::exception& e) catch (const std::exception& e)
{ {
Emu.Pause(); Emu.Pause();
LOG_FATAL(GENERAL, "%s thrown: %s", typeid(e).name(), e.what()); LOG_FATAL(SPU, "%s thrown: %s", typeid(e).name(), e.what());
LOG_NOTICE(GENERAL, "\n%s", spu.dump()); LOG_NOTICE(SPU, "\n%s", spu.dump());
} }
spu_program spu_recompiler_base::analyse(const be_t<u32>* ls, u32 entry_point) spu_program spu_recompiler_base::analyse(const be_t<u32>* ls, u32 entry_point)

View file

@ -234,7 +234,7 @@ public:
std::string GetCgParamRes(u32 /*offset*/) const std::string GetCgParamRes(u32 /*offset*/) const
{ {
// LOG_WARNING(GENERAL, "GetCgParamRes offset 0x%x", offset); // LOG_WARNING(RSX, "GetCgParamRes offset 0x%x", offset);
// TODO // TODO
return ""; return "";
} }

View file

@ -1,6 +1,8 @@
#include "stdafx.h" #include "stdafx.h"
#include "GLGSRender.h" #include "GLGSRender.h"
LOG_CHANNEL(screenshot);
GLuint GLGSRender::get_present_source(gl::present_surface_info* info, const rsx::avconf* avconfig) GLuint GLGSRender::get_present_source(gl::present_surface_info* info, const rsx::avconf* avconfig)
{ {
GLuint image = GL_NONE; 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()); glGetTextureImageEXT(image_to_flip, GL_TEXTURE_2D, 0, GL_BGRA, GL_UNSIGNED_BYTE, sshot_frame.data());
if (GLenum err; (err = glGetError()) != GL_NO_ERROR) 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 else
m_frame->take_screenshot(std::move(sshot_frame), buffer_width, buffer_height); m_frame->take_screenshot(std::move(sshot_frame), buffer_width, buffer_height);
} }

View file

@ -2,6 +2,8 @@
#include "overlays.h" #include "overlays.h"
#include "../GSRender.h" #include "../GSRender.h"
LOG_CHANNEL(overlays);
static auto s_ascii_lowering_map = []() static auto s_ascii_lowering_map = []()
{ {
std::unordered_map<u32, u8> _map; std::unordered_map<u32, u8> _map;
@ -81,7 +83,7 @@ std::string utf8_to_ascii8(const std::string& utf8_string)
if ((index + extra_bytes) > end) if ((index + extra_bytes) > end)
{ {
// Malformed string, abort // 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; break;
} }

View file

@ -48,6 +48,8 @@
#include "Emu/RSX/VK/VulkanAPI.h" #include "Emu/RSX/VK/VulkanAPI.h"
#endif #endif
LOG_CHANNEL(sys_log);
stx::manual_fixed_typemap<void> g_fixed_typemap; stx::manual_fixed_typemap<void> g_fixed_typemap;
cfg_root g_cfg; cfg_root g_cfg;
@ -314,7 +316,7 @@ void Emulator::Init()
if (!g_tty) 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 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) // Create directories (can be disabled if necessary)
@ -348,7 +350,7 @@ void Emulator::Init()
{ {
if (!fs::create_path(path)) 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) 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 // Finalize interrupted saving
if (!fs::rename(pending, save_path + desired, false)) 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; continue;
} }
else else
{ {
LOG_SUCCESS(GENERAL, "Fixed save data: %s", desired); sys_log.success("Fixed save data: %s", desired);
} }
} }
// Remove pending backup data // Remove pending backup data
if (!fs::remove_all(save_path + entry.name)) 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 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"; const std::string cache_location = Emulator::GetHdd1Dir() + "/caches";
if (!fs::is_dir(cache_location)) 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; return;
} }
@ -659,22 +661,22 @@ void Emulator::LimitCacheSize()
if (max_size == 0) // Everything must go, so no need to do checks if (max_size == 0) // Everything must go, so no need to do checks
{ {
fs::remove_all(cache_location, false); fs::remove_all(cache_location, false);
LOG_SUCCESS(GENERAL, "Cleared disk cache"); sys_log.success("Cleared disk cache");
return; return;
} }
if (size <= max_size) 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; return;
} }
LOG_SUCCESS(GENERAL, "Cleaning disk cache..."); sys_log.success("Cleaning disk cache...");
std::vector<fs::dir_entry> file_list{}; std::vector<fs::dir_entry> file_list{};
fs::dir cache_dir{}; fs::dir cache_dir{};
if (!cache_dir.open(cache_location)) if (!cache_dir.open(cache_location))
{ {
LOG_ERROR(GENERAL, "Could not open cache directory"); sys_log.error("Could not open cache directory");
return; return;
} }
@ -715,7 +717,7 @@ void Emulator::LimitCacheSize()
break; 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) 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) bool Emulator::InstallPkg(const std::string& path)
{ {
LOG_SUCCESS(GENERAL, "Installing package: %s", path); sys_log.success("Installing package: %s", path);
atomic_t<double> progress(0.); atomic_t<double> progress(0.);
int int_progress = 0; int int_progress = 0;
@ -806,7 +808,7 @@ bool Emulator::InstallPkg(const std::string& path)
if (static_cast<int>(pval) > int_progress) if (static_cast<int>(pval) > int_progress)
{ {
int_progress = static_cast<int>(pval); int_progress = static_cast<int>(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()) 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 // Load patches from different locations
@ -1688,7 +1690,7 @@ bool Emulator::Pause()
// Update pause start time // Update pause start time
if (m_pause_start_time.exchange(start)) 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) auto on_select = [](u32, cpu_thread& cpu)
@ -1757,7 +1759,7 @@ void Emulator::Resume()
if (!time) 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) 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 full_stop = !restart && !m_force_boot;
const bool do_exit = full_stop && g_cfg.misc.autoexit; const bool do_exit = full_stop && g_cfg.misc.autoexit;
LOG_NOTICE(GENERAL, "Stopping emulator..."); sys_log.notice("Stopping emulator...");
GetCallbacks().on_stop(); GetCallbacks().on_stop();
@ -1801,7 +1803,7 @@ void Emulator::Stop(bool restart)
lv2_obj::cleanup(); lv2_obj::cleanup();
idm::clear(); idm::clear();
LOG_NOTICE(GENERAL, "Objects cleared..."); sys_log.notice("Objects cleared...");
vm::close(); 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) 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"; const char* func = "Unknown function";
if (auto thread = get_current_cpu_thread()) if (auto thread = get_current_cpu_thread())