From 3c0bd821c8609f17ce87709ce004167cbf241133 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Sat, 1 Feb 2020 10:43:43 +0300 Subject: [PATCH] Give log channels fancier names Improve LOG_CHANNEL macro to accept custom name. --- Utilities/Config.cpp | 2 +- Utilities/JIT.cpp | 2 +- Utilities/Log.h | 14 +++++++++++++- Utilities/Thread.cpp | 2 +- rpcs3/Crypto/unedat.cpp | 2 +- rpcs3/Crypto/unpkg.cpp | 2 +- rpcs3/Crypto/unself.h | 2 +- rpcs3/Emu/CPU/CPUThread.cpp | 2 +- rpcs3/Emu/Io/Skylander.cpp | 2 +- rpcs3/Emu/Memory/vm.cpp | 2 +- rpcs3/Emu/System.cpp | 2 +- rpcs3/Input/basic_keyboard_handler.cpp | 2 +- rpcs3/Input/basic_mouse_handler.cpp | 2 +- rpcs3/Input/evdev_joystick_handler.cpp | 2 +- rpcs3/Input/keyboard_pad_handler.cpp | 2 +- rpcs3/Input/mm_joystick_handler.cpp | 2 +- rpcs3/Input/pad_thread.cpp | 2 +- rpcs3/Loader/PSF.cpp | 2 +- rpcs3/Loader/TAR.cpp | 2 +- rpcs3/Loader/TROPUSR.cpp | 2 +- rpcs3/rpcs3qt/cg_disasm_window.cpp | 2 +- rpcs3/rpcs3qt/emu_settings.cpp | 2 +- rpcs3/rpcs3qt/game_list_frame.cpp | 4 ++-- rpcs3/rpcs3qt/gui_application.cpp | 2 +- rpcs3/rpcs3qt/gui_settings.cpp | 2 +- rpcs3/rpcs3qt/main_window.cpp | 2 +- rpcs3/rpcs3qt/memory_string_searcher.cpp | 2 +- rpcs3/rpcs3qt/pad_settings_dialog.cpp | 2 +- rpcs3/rpcs3qt/save_manager_dialog.cpp | 2 +- rpcs3/rpcs3qt/settings_dialog.cpp | 2 +- rpcs3/rpcs3qt/trophy_manager_dialog.cpp | 2 +- rpcs3/rpcs3qt/user_account.cpp | 2 +- rpcs3/rpcs3qt/user_manager_dialog.cpp | 2 +- 33 files changed, 46 insertions(+), 34 deletions(-) diff --git a/Utilities/Config.cpp b/Utilities/Config.cpp index d31fb628ec..882fdafe7c 100644 --- a/Utilities/Config.cpp +++ b/Utilities/Config.cpp @@ -6,7 +6,7 @@ #include #include -LOG_CHANNEL(cfg_log); +LOG_CHANNEL(cfg_log, "CFG"); namespace cfg { diff --git a/Utilities/JIT.cpp b/Utilities/JIT.cpp index 5c4c483498..9f7ad7f0d4 100644 --- a/Utilities/JIT.cpp +++ b/Utilities/JIT.cpp @@ -14,7 +14,7 @@ #define CAN_OVERCOMMIT #endif -LOG_CHANNEL(jit_log); +LOG_CHANNEL(jit_log, "JIT"); static u8* get_jit_memory() { diff --git a/Utilities/Log.h b/Utilities/Log.h index d822e6119c..f97426ddde 100644 --- a/Utilities/Log.h +++ b/Utilities/Log.h @@ -101,9 +101,21 @@ namespace logs // Get all registered log channels std::vector get_channels(); + + // Helper: no additional name specified + constexpr const char* make_channel_name(const char* name) + { + return name; + } + + // Helper: special channel name specified + constexpr const char* make_channel_name(const char*, const char* name, ...) + { + return name; + } } -#define LOG_CHANNEL(ch) inline ::logs::channel ch(#ch) +#define LOG_CHANNEL(ch, ...) inline ::logs::channel ch(::logs::make_channel_name(#ch, ##__VA_ARGS__)) // Legacy: diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index 6d47390f51..1e18a4ddad 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -46,7 +46,7 @@ #include "Log.h" LOG_CHANNEL(sig_log); -LOG_CHANNEL(vm_log); +LOG_CHANNEL(vm_log, "VM"); thread_local u64 g_tls_fault_all = 0; thread_local u64 g_tls_fault_rsx = 0; diff --git a/rpcs3/Crypto/unedat.cpp b/rpcs3/Crypto/unedat.cpp index 4103154b92..3edb7bff52 100644 --- a/rpcs3/Crypto/unedat.cpp +++ b/rpcs3/Crypto/unedat.cpp @@ -4,7 +4,7 @@ #include -LOG_CHANNEL(edat_log); +LOG_CHANNEL(edat_log, "EDAT"); void generate_key(int crypto_mode, int version, unsigned char *key_final, unsigned char *iv_final, unsigned char *key, unsigned char *iv) { diff --git a/rpcs3/Crypto/unpkg.cpp b/rpcs3/Crypto/unpkg.cpp index e61d7a2f5b..55236b6468 100644 --- a/rpcs3/Crypto/unpkg.cpp +++ b/rpcs3/Crypto/unpkg.cpp @@ -8,7 +8,7 @@ #include "Emu/VFS.h" #include "unpkg.h" -LOG_CHANNEL(pkg_log); +LOG_CHANNEL(pkg_log, "PKG"); bool pkg_install(const std::string& path, atomic_t& sync) { diff --git a/rpcs3/Crypto/unself.h b/rpcs3/Crypto/unself.h index 5c19873cfa..ef5d3c893b 100644 --- a/rpcs3/Crypto/unself.h +++ b/rpcs3/Crypto/unself.h @@ -7,7 +7,7 @@ #include "Utilities/File.h" #include "Utilities/Log.h" -LOG_CHANNEL(self_log); +LOG_CHANNEL(self_log, "SELF"); struct AppInfo { diff --git a/rpcs3/Emu/CPU/CPUThread.cpp b/rpcs3/Emu/CPU/CPUThread.cpp index 15daac9da5..87a96ca50f 100644 --- a/rpcs3/Emu/CPU/CPUThread.cpp +++ b/rpcs3/Emu/CPU/CPUThread.cpp @@ -16,7 +16,7 @@ DECLARE(cpu_thread::g_threads_created){0}; DECLARE(cpu_thread::g_threads_deleted){0}; LOG_CHANNEL(profiler); -LOG_CHANNEL(sys_log); +LOG_CHANNEL(sys_log, "SYS"); template <> void fmt_class_string::format(std::string& out, u64 arg) diff --git a/rpcs3/Emu/Io/Skylander.cpp b/rpcs3/Emu/Io/Skylander.cpp index 060112f5ab..6b18d22976 100644 --- a/rpcs3/Emu/Io/Skylander.cpp +++ b/rpcs3/Emu/Io/Skylander.cpp @@ -2,7 +2,7 @@ #include "Skylander.h" #include "Emu/Cell/lv2/sys_usbd.h" -LOG_CHANNEL(skylander_log); +LOG_CHANNEL(skylander_log, "skylander"); sky_portal g_skylander; diff --git a/rpcs3/Emu/Memory/vm.cpp b/rpcs3/Emu/Memory/vm.cpp index 8ffb787f64..60c0a36746 100644 --- a/rpcs3/Emu/Memory/vm.cpp +++ b/rpcs3/Emu/Memory/vm.cpp @@ -17,7 +17,7 @@ #include #include -LOG_CHANNEL(vm_log); +LOG_CHANNEL(vm_log, "VM"); namespace vm { diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 9106b22fa9..cf6394e92a 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -48,7 +48,7 @@ #include "Emu/RSX/VK/VulkanAPI.h" #endif -LOG_CHANNEL(sys_log); +LOG_CHANNEL(sys_log, "SYS"); stx::manual_fixed_typemap g_fixed_typemap; diff --git a/rpcs3/Input/basic_keyboard_handler.cpp b/rpcs3/Input/basic_keyboard_handler.cpp index 8596326231..5fe6a2b2ad 100644 --- a/rpcs3/Input/basic_keyboard_handler.cpp +++ b/rpcs3/Input/basic_keyboard_handler.cpp @@ -9,7 +9,7 @@ #include "windows.h" #endif -LOG_CHANNEL(input_log); +LOG_CHANNEL(input_log, "Input"); void basic_keyboard_handler::Init(const u32 max_connect) { diff --git a/rpcs3/Input/basic_mouse_handler.cpp b/rpcs3/Input/basic_mouse_handler.cpp index af4aa8eeec..7bce34beb4 100644 --- a/rpcs3/Input/basic_mouse_handler.cpp +++ b/rpcs3/Input/basic_mouse_handler.cpp @@ -3,7 +3,7 @@ #include #include -LOG_CHANNEL(input_log); +LOG_CHANNEL(input_log, "Input"); void basic_mouse_handler::Init(const u32 max_connect) { diff --git a/rpcs3/Input/evdev_joystick_handler.cpp b/rpcs3/Input/evdev_joystick_handler.cpp index bf4ebf1836..c3926cb9c8 100644 --- a/rpcs3/Input/evdev_joystick_handler.cpp +++ b/rpcs3/Input/evdev_joystick_handler.cpp @@ -17,7 +17,7 @@ #include #include -LOG_CHANNEL(evdev_log); +LOG_CHANNEL(evdev_log, "evdev"); evdev_joystick_handler::evdev_joystick_handler() : PadHandlerBase(pad_handler::evdev) { diff --git a/rpcs3/Input/keyboard_pad_handler.cpp b/rpcs3/Input/keyboard_pad_handler.cpp index 44c632263e..5eff3e5fc2 100644 --- a/rpcs3/Input/keyboard_pad_handler.cpp +++ b/rpcs3/Input/keyboard_pad_handler.cpp @@ -3,7 +3,7 @@ #include #include -LOG_CHANNEL(input_log); +LOG_CHANNEL(input_log, "Input"); inline std::string sstr(const QString& _in) { return _in.toStdString(); } constexpr auto qstr = QString::fromStdString; diff --git a/rpcs3/Input/mm_joystick_handler.cpp b/rpcs3/Input/mm_joystick_handler.cpp index 1bb5df4360..6efba98c84 100644 --- a/rpcs3/Input/mm_joystick_handler.cpp +++ b/rpcs3/Input/mm_joystick_handler.cpp @@ -1,7 +1,7 @@ #ifdef _WIN32 #include "mm_joystick_handler.h" -LOG_CHANNEL(input_log); +LOG_CHANNEL(input_log, "Input"); mm_joystick_handler::mm_joystick_handler() : PadHandlerBase(pad_handler::mm) { diff --git a/rpcs3/Input/pad_thread.cpp b/rpcs3/Input/pad_thread.cpp index aa44a4f5cb..b1096b7444 100644 --- a/rpcs3/Input/pad_thread.cpp +++ b/rpcs3/Input/pad_thread.cpp @@ -10,7 +10,7 @@ #include "keyboard_pad_handler.h" #include "Emu/Io/Null/NullPadHandler.h" -LOG_CHANNEL(input_log); +LOG_CHANNEL(input_log, "Input"); namespace pad { diff --git a/rpcs3/Loader/PSF.cpp b/rpcs3/Loader/PSF.cpp index 5e718e714c..859c5d6eb6 100644 --- a/rpcs3/Loader/PSF.cpp +++ b/rpcs3/Loader/PSF.cpp @@ -1,7 +1,7 @@ #include "stdafx.h" #include "PSF.h" -LOG_CHANNEL(psf_log); +LOG_CHANNEL(psf_log, "PSF"); template<> void fmt_class_string::format(std::string& out, u64 arg) diff --git a/rpcs3/Loader/TAR.cpp b/rpcs3/Loader/TAR.cpp index 113a629f6f..23358c8208 100644 --- a/rpcs3/Loader/TAR.cpp +++ b/rpcs3/Loader/TAR.cpp @@ -5,7 +5,7 @@ #include #include -LOG_CHANNEL(tar_log); +LOG_CHANNEL(tar_log, "TAR"); tar_object::tar_object(const fs::file& file, size_t offset) : m_file(file) diff --git a/rpcs3/Loader/TROPUSR.cpp b/rpcs3/Loader/TROPUSR.cpp index c5862b164c..f739b57e5d 100644 --- a/rpcs3/Loader/TROPUSR.cpp +++ b/rpcs3/Loader/TROPUSR.cpp @@ -5,7 +5,7 @@ #include "Emu/System.h" #include "TROPUSR.h" -LOG_CHANNEL(trp_log); +LOG_CHANNEL(trp_log, "Trophy"); bool TROPUSRLoader::Load(const std::string& filepath, const std::string& configpath) { diff --git a/rpcs3/rpcs3qt/cg_disasm_window.cpp b/rpcs3/rpcs3qt/cg_disasm_window.cpp index 4ea07807b8..3494bf6c32 100644 --- a/rpcs3/rpcs3qt/cg_disasm_window.cpp +++ b/rpcs3/rpcs3qt/cg_disasm_window.cpp @@ -16,7 +16,7 @@ #include "Emu/RSX/CgBinaryProgram.h" -LOG_CHANNEL(gui_log); +LOG_CHANNEL(gui_log, "GUI"); constexpr auto qstr = QString::fromStdString; inline std::string sstr(const QString& _in) { return _in.toStdString(); } diff --git a/rpcs3/rpcs3qt/emu_settings.cpp b/rpcs3/rpcs3qt/emu_settings.cpp index ce54fc3728..63db4ce9a1 100644 --- a/rpcs3/rpcs3qt/emu_settings.cpp +++ b/rpcs3/rpcs3qt/emu_settings.cpp @@ -19,7 +19,7 @@ #include "3rdparty/OpenAL/include/alext.h" -LOG_CHANNEL(cfg_log); +LOG_CHANNEL(cfg_log, "CFG"); extern std::string g_cfg_defaults; //! Default settings grabbed from Utilities/Config.h diff --git a/rpcs3/rpcs3qt/game_list_frame.cpp b/rpcs3/rpcs3qt/game_list_frame.cpp index f38745fc11..f5349a3e0e 100644 --- a/rpcs3/rpcs3qt/game_list_frame.cpp +++ b/rpcs3/rpcs3qt/game_list_frame.cpp @@ -29,8 +29,8 @@ #include #include -LOG_CHANNEL(game_list_log); -LOG_CHANNEL(sys_log); +LOG_CHANNEL(game_list_log, "GameList"); +LOG_CHANNEL(sys_log, "SYS"); inline std::string sstr(const QString& _in) { return _in.toStdString(); } diff --git a/rpcs3/rpcs3qt/gui_application.cpp b/rpcs3/rpcs3qt/gui_application.cpp index d69dcc53cf..c3782868f4 100644 --- a/rpcs3/rpcs3qt/gui_application.cpp +++ b/rpcs3/rpcs3qt/gui_application.cpp @@ -18,7 +18,7 @@ #include -LOG_CHANNEL(gui_log); +LOG_CHANNEL(gui_log, "GUI"); gui_application::gui_application(int& argc, char** argv) : QApplication(argc, argv) { diff --git a/rpcs3/rpcs3qt/gui_settings.cpp b/rpcs3/rpcs3qt/gui_settings.cpp index c9233ef55c..89dc839cd9 100644 --- a/rpcs3/rpcs3qt/gui_settings.cpp +++ b/rpcs3/rpcs3qt/gui_settings.cpp @@ -6,7 +6,7 @@ #include #include -LOG_CHANNEL(cfg_log); +LOG_CHANNEL(cfg_log, "CFG"); inline std::string sstr(const QString& _in) { return _in.toStdString(); } diff --git a/rpcs3/rpcs3qt/main_window.cpp b/rpcs3/rpcs3qt/main_window.cpp index eaec900cd2..64e8d95a3d 100644 --- a/rpcs3/rpcs3qt/main_window.cpp +++ b/rpcs3/rpcs3qt/main_window.cpp @@ -55,7 +55,7 @@ #include "ui_main_window.h" -LOG_CHANNEL(gui_log); +LOG_CHANNEL(gui_log, "GUI"); inline std::string sstr(const QString& _in) { return _in.toStdString(); } diff --git a/rpcs3/rpcs3qt/memory_string_searcher.cpp b/rpcs3/rpcs3qt/memory_string_searcher.cpp index 7b0959dbad..945db15a94 100644 --- a/rpcs3/rpcs3qt/memory_string_searcher.cpp +++ b/rpcs3/rpcs3qt/memory_string_searcher.cpp @@ -2,7 +2,7 @@ #include -LOG_CHANNEL(gui_log); +LOG_CHANNEL(gui_log, "GUI"); memory_string_searcher::memory_string_searcher(QWidget* parent) : QDialog(parent) diff --git a/rpcs3/rpcs3qt/pad_settings_dialog.cpp b/rpcs3/rpcs3qt/pad_settings_dialog.cpp index 2ac9cbe762..cbb20f092e 100644 --- a/rpcs3/rpcs3qt/pad_settings_dialog.cpp +++ b/rpcs3/rpcs3qt/pad_settings_dialog.cpp @@ -24,7 +24,7 @@ #include "Input/evdev_joystick_handler.h" #endif -LOG_CHANNEL(cfg_log); +LOG_CHANNEL(cfg_log, "CFG"); inline std::string sstr(const QString& _in) { return _in.toStdString(); } constexpr auto qstr = QString::fromStdString; diff --git a/rpcs3/rpcs3qt/save_manager_dialog.cpp b/rpcs3/rpcs3qt/save_manager_dialog.cpp index b778068f83..d01a16883a 100644 --- a/rpcs3/rpcs3qt/save_manager_dialog.cpp +++ b/rpcs3/rpcs3qt/save_manager_dialog.cpp @@ -22,7 +22,7 @@ #include #include -LOG_CHANNEL(gui_log); +LOG_CHANNEL(gui_log, "GUI"); namespace { diff --git a/rpcs3/rpcs3qt/settings_dialog.cpp b/rpcs3/rpcs3qt/settings_dialog.cpp index 0decc1cfd0..e5d4457207 100644 --- a/rpcs3/rpcs3qt/settings_dialog.cpp +++ b/rpcs3/rpcs3qt/settings_dialog.cpp @@ -32,7 +32,7 @@ #include "_discord_utils.h" #endif -LOG_CHANNEL(cfg_log); +LOG_CHANNEL(cfg_log, "CFG"); inline std::string sstr(const QString& _in) { return _in.toStdString(); } inline std::string sstr(const QVariant& _in) { return sstr(_in.toString()); } diff --git a/rpcs3/rpcs3qt/trophy_manager_dialog.cpp b/rpcs3/rpcs3qt/trophy_manager_dialog.cpp index c71e74cefe..56322102c8 100644 --- a/rpcs3/rpcs3qt/trophy_manager_dialog.cpp +++ b/rpcs3/rpcs3qt/trophy_manager_dialog.cpp @@ -35,7 +35,7 @@ #include #include -LOG_CHANNEL(gui_log); +LOG_CHANNEL(gui_log, "GUI"); namespace { diff --git a/rpcs3/rpcs3qt/user_account.cpp b/rpcs3/rpcs3qt/user_account.cpp index 962247f871..8b19d3a526 100644 --- a/rpcs3/rpcs3qt/user_account.cpp +++ b/rpcs3/rpcs3qt/user_account.cpp @@ -1,6 +1,6 @@ #include "user_account.h" -LOG_CHANNEL(gui_log); +LOG_CHANNEL(gui_log, "GUI"); UserAccount::UserAccount(const std::string& user_id) { diff --git a/rpcs3/rpcs3qt/user_manager_dialog.cpp b/rpcs3/rpcs3qt/user_manager_dialog.cpp index 9c3bd9707b..ffcc15309d 100644 --- a/rpcs3/rpcs3qt/user_manager_dialog.cpp +++ b/rpcs3/rpcs3qt/user_manager_dialog.cpp @@ -15,7 +15,7 @@ #include #include -LOG_CHANNEL(gui_log); +LOG_CHANNEL(gui_log, "GUI"); namespace {