From e2ea57ea58cd3944904ad20fde09c73be0b2e6db Mon Sep 17 00:00:00 2001 From: Shay Date: Thu, 1 Oct 2020 16:08:23 -0600 Subject: [PATCH] Replace printf logging with spdlog equivalent Preserve previous printfs in comments for now. Spdlog needs to be configured to be thread-safe. Few additional printfs to convert later. No changes have been made to GOAL's internal printing system --- game/kernel/kdgo.cpp | 14 +++++--- game/kernel/kmachine.cpp | 63 ++++++++++++++++++++++++------------ game/kernel/kscheme.cpp | 7 ++-- game/main.cpp | 13 +++++--- game/overlord/fake_iso.cpp | 19 +++++++---- game/overlord/iso.cpp | 10 ++++-- game/overlord/iso_api.cpp | 7 ++-- game/runtime.cpp | 33 +++++++++++++------ game/sce/deci2.cpp | 3 +- game/sce/iop.h | 1 + game/system/Deci2Server.h | 1 + game/system/SystemThread.cpp | 19 +++++++---- game/system/SystemThread.h | 1 + 13 files changed, 131 insertions(+), 60 deletions(-) diff --git a/game/kernel/kdgo.cpp b/game/kernel/kdgo.cpp index f57fbedf29..c1d5df7d94 100644 --- a/game/kernel/kdgo.cpp +++ b/game/kernel/kdgo.cpp @@ -16,6 +16,7 @@ #include "game/common/ramdisk_rpc_types.h" #include "game/common/loader_rpc_types.h" #include "game/common/play_rpc_types.h" +#include "third-party/spdlog/include/spdlog/spdlog.h" using namespace ee; @@ -175,9 +176,10 @@ void BeginLoadingDGO(const char* name, Ptr buffer1, Ptr buffer2, Ptr // file name strcpy(sMsg[msgID].name, name); - printf("[Begin Loading DGO RPC] %s, 0x%x, 0x%x, 0x%x\n", name, buffer1.offset, buffer2.offset, - currentHeap.offset); - + //printf("[Begin Loading DGO RPC] %s, 0x%x, 0x%x, 0x%x\n", name, buffer1.offset, buffer2.offset, + // currentHeap.offset); + spdlog::info("[Begin Loading DGO RPC] {}, 0x{}, 0x{}, 0x{}", name, buffer1.offset, buffer2.offset, + currentHeap.offset); // this RPC will return once we have loaded the first object file. // but we call async, so we don't block here. RpcCall(DGO_RPC_CHANNEL, DGO_RPC_LOAD_FNO, true, mess, sizeof(RPC_Dgo_Cmd), mess, @@ -299,7 +301,8 @@ void load_and_link_dgo(u64 name_gstr, u64 heap_info, u64 flag, u64 buffer_size) * This does not use the mutli-threaded linker and will block until the entire file is done.e */ void load_and_link_dgo_from_c(const char* name, Ptr heap, u32 linkFlag, s32 bufferSize) { - printf("[Load and Link DGO From C] %s\n", name); + //printf("[Load and Link DGO From C] %s\n", name); + spdlog::info("[Load and Link DGO From C] {}", name); u32 oldShowStall = sShowStallMsg; // remember where the heap top point is so we can clear temporary allocations @@ -348,7 +351,8 @@ void load_and_link_dgo_from_c(const char* name, Ptr heap, u32 linkFla char objName[64]; strcpy(objName, (dgoObj + 4).cast().c()); // name from dgo object header - printf("[link and exec] %s %d\n", objName, lastObjectLoaded); + //printf("[link and exec] %s %d\n", objName, lastObjectLoaded); + spdlog::info("[link and exec] {} {}", objName, lastObjectLoaded); link_and_exec(obj, objName, objSize, heap, linkFlag); // link now! // inform IOP we are done diff --git a/game/kernel/kmachine.cpp b/game/kernel/kmachine.cpp index ca569f702d..8e2bb63aad 100644 --- a/game/kernel/kmachine.cpp +++ b/game/kernel/kmachine.cpp @@ -25,6 +25,7 @@ #include "game/sce/libcdvd_ee.h" #include "game/sce/stubs.h" #include "common/symbols.h" +#include "third-party/spdlog/include/spdlog/spdlog.h" using namespace ee; /*! @@ -147,13 +148,16 @@ void InitParms(int argc, const char* const* argv) { * DONE, EXACT */ void InitCD() { - printf("Initializing CD drive\nThis may take a while ...\n"); + //printf("Initializing CD drive\nThis may take a while ...\n"); + spdlog::debug("Initializing CD drive\nThis may take a while...\n"); sceCdInit(SCECdINIT); sceCdMmode(SCECdDVD); while (sceCdDiskReady(0) == SCECdNotReady) { - printf("Drive not ready ... insert a disk!\n"); + //printf("Drive not ready ... insert a disk!\n"); + spdlog::debug("Drive not ready... insert a disk!\n"); } - printf("Disk type %d\n", sceCdGetDiskType()); + // printf("Disk type %d\n", sceCdGetDiskType()); + spdlog::debug("Disk type {}\n", sceCdGetDiskType()); } /*! @@ -171,22 +175,28 @@ void InitIOP() { if (!reboot) { // reboot with development IOP kernel - printf("Rebooting IOP...\n"); + //printf("Rebooting IOP...\n"); + spdlog::debug("Rebooting IOP..."); while (!sceSifRebootIop("host0:/usr/local/sce/iop/modules/ioprp221.img")) { - printf("Failed, retrying...\n"); + //printf("Failed, retrying...\n"); + spdlog::debug("Failed, retrying"); } while (!sceSifSyncIop()) { - printf("Syncing...\n"); + //printf("Syncing...\n"); + spdlog::debug("Syncing..."); } } else { // reboot with IOP kernel off of the disk // reboot with development IOP kernel - printf("Rebooting IOP...\n"); + //printf("Rebooting IOP...\n"); + spdlog::debug("Rebooting IOP..."); while (!sceSifRebootIop("cdrom0:\\DRIVERS\\IOPRP221.IMG;1")) { - printf("Failed, retrying...\n"); + //printf("Failed, retrying...\n"); + spdlog::debug("Failed, retrying"); } while (!sceSifSyncIop()) { - printf("Syncing...\n"); + //printf("Syncing...\n"); + spdlog::debug("Syncing..."); } } @@ -237,7 +247,8 @@ void InitIOP() { sceSifLoadModule("host0:/usr/home/src/989snd10/iop/989ERR.IRX", 0, nullptr); - printf("Initializing CD library\n"); + //printf("Initializing CD library\n"); + spdlog::debug("Initializing CD library..."); auto rv = sceSifLoadModule("host0:binee/overlord.irx", cmd + len + 1 - overlord_boot_command, overlord_boot_command); if (rv < 0) { @@ -269,7 +280,8 @@ void InitIOP() { MsgErr("loading 989snd.irx failed\n"); } - printf("Initializing CD library in ISO_CD mode\n"); + //printf("Initializing CD library in ISO_CD mode\n"); + spdlog::debug("Initializing CD library in ISO_CD mode..."); auto rv = sceSifLoadModule("cdrom0:\\\\DRIVERS\\\\OVERLORD.IRX;1", cmd + len + 1 - overlord_boot_command, overlord_boot_command); if (rv < 0) { @@ -280,7 +292,8 @@ void InitIOP() { if (rv < 0) { MsgErr("MC driver init failed %d\n", rv); } else { - printf("InitIOP OK\n"); + //printf("InitIOP OK\n"); + spdlog::debug("InitIOP OK"); } } @@ -301,8 +314,10 @@ int InitMachine() { // initialize the global heap u32 global_heap_size = GLOBAL_HEAP_END - HEAP_START; float size_mb = ((float)global_heap_size) / (float)(1 << 20); - printf("gkernel: global heap - 0x%x to 0x%x (size %.3f MB)\n", HEAP_START, GLOBAL_HEAP_END, - size_mb); + //printf("gkernel: global heap - 0x%x to 0x%x (size %.3f MB)\n", HEAP_START, GLOBAL_HEAP_END, + // size_mb); + spdlog::info("gkernel: global heap 0x{} to 0x{} (size {} MB)", HEAP_START, GLOBAL_HEAP_END, + size_mb); kinitheap(kglobalheap, Ptr(HEAP_START), global_heap_size); // initialize the debug heap, if appropriate @@ -311,8 +326,10 @@ int InitMachine() { kinitheap(kdebugheap, Ptr(DEBUG_HEAP_START), debug_heap_size); float debug_size_mb = ((float)debug_heap_size) / (float)(1 << 20); float gap_size_mb = ((float)DEBUG_HEAP_START - GLOBAL_HEAP_END) / (float)(1 << 20); - printf("gkernel: debug heap - 0x%x to 0x%x (size %.3f MB, gap %.3f MB)\n", DEBUG_HEAP_START, - debug_heap_end, debug_size_mb, gap_size_mb); + //printf("gkernel: debug heap - 0x%x to 0x%x (size %.3f MB, gap %.3f MB)\n", DEBUG_HEAP_START, + //debug_heap_end, debug_size_mb, gap_size_mb); + spdlog::info("gkernel: global heap 0x{} to 0x{} (size {} MB, gap {} MB)", DEBUG_HEAP_START, + debug_heap_end, debug_size_mb, gap_size_mb); } else { // if no debug, we make the kheapinfo structure NULL so GOAL knows not to use it. kdebugheap.offset = 0; @@ -337,9 +354,11 @@ int InitMachine() { InitGoalProto(); } - printf("InitSound\n"); + //printf("InitSound\n"); + spdlog::info("InitSound"); InitSound(); // do nothing! - printf("InitRPC\n"); + //printf("InitRPC\n"); + spdlog::info("InitRPC"); InitRPC(); // connect to IOP reset_output(); // reset output buffers clear_print(); @@ -349,9 +368,11 @@ int InitMachine() { return goal_status; } - printf("InitListenerConnect\n"); + spdlog::info("InitListenerConnect"); + //printf("InitListenerConnect\n"); InitListenerConnect(); - printf("InitCheckListener\n"); + spdlog::info("InitCheckListener"); + //printf("InitCheckListener\n"); InitCheckListener(); Msg(6, "kernel: machine started\n"); return 0; @@ -618,7 +639,7 @@ void InitMachineScheme() { new_pair(s7.offset + FIX_SYM_GLOBAL_HEAP, *((s7 + FIX_SYM_PAIR_TYPE).cast()), make_string_from_c("common"), kernel_packages->value); - printf("calling play!\n"); + spdlog::info("calling fake play~"); call_goal_function_by_name("play"); } } diff --git a/game/kernel/kscheme.cpp b/game/kernel/kscheme.cpp index e5b7fda32b..d51c0a8652 100644 --- a/game/kernel/kscheme.cpp +++ b/game/kernel/kscheme.cpp @@ -19,6 +19,7 @@ #include "common/symbols.h" #include "common/versions.h" #include "common/goal_constants.h" +#include "third-party/spdlog/include/spdlog/spdlog.h" //! Controls link mode when EnableMethodSet = 0, MasterDebug = 1, DiskBoot = 0. Will enable a //! warning message if EnableMethodSet = 1 @@ -1895,8 +1896,10 @@ s32 InitHeapAndSymbol() { (kernel_version >> 3) & 0xffff); return -1; } else { - printf("Got correct kernel version %d.%d\n", kernel_version >> 0x13, - (kernel_version >> 3) & 0xffff); + spdlog::info("Got correct kernel version {}.{}", kernel_version >> 0x13, + (kernel_version >> 3) & 0xffff); + //printf("Got correct kernel version %d.%d\n", kernel_version >> 0x13, + // (kernel_version >> 3) & 0xffff); } } diff --git a/game/main.cpp b/game/main.cpp index 909a1a9b1c..27fdbf4c3a 100644 --- a/game/main.cpp +++ b/game/main.cpp @@ -8,13 +8,18 @@ #include "third-party/spdlog/include/spdlog/spdlog.h" #include "third-party/spdlog/include/spdlog/sinks/basic_file_sink.h" + + int main(int argc, char** argv) { while (true) { - // run the runtime in a loop so we can reset the game and have it restart cleanly - printf("gk %d.%d\n", versions::GOAL_VERSION_MAJOR, versions::GOAL_VERSION_MINOR); - + spdlog::set_level(spdlog::level::debug); spdlog::info("spdlog initialized"); - spdlog::error("test error", 1); + spdlog::debug("This is a debug-only message"); + // run the runtime in a loop so we can reset the game and have it restart cleanly + //printf("gk %d.%d\n", versions::GOAL_VERSION_MAJOR, versions::GOAL_VERSION_MINOR); + spdlog::debug("gk {}.{} OK!\n", versions::GOAL_VERSION_MAJOR, versions::GOAL_VERSION_MINOR); + + if (exec_runtime(argc, argv) == 2) { return 0; } diff --git a/game/overlord/fake_iso.cpp b/game/overlord/fake_iso.cpp index 76284f2531..5f53ba766a 100644 --- a/game/overlord/fake_iso.cpp +++ b/game/overlord/fake_iso.cpp @@ -16,6 +16,7 @@ #include "isocommon.h" #include "overlord.h" #include "common/util/FileUtil.h" +#include "third-party/spdlog/include/spdlog/spdlog.h" using namespace iop; @@ -215,7 +216,8 @@ uint32_t FS_GetLength(FileRecord* fr) { * This is an ISO FS API Function */ LoadStackEntry* FS_Open(FileRecord* fr, int32_t offset) { - printf("[OVERLORD] FS Open %s\n", fr->name); // Added + //printf("[OVERLORD] FS Open %s\n", fr->name); // Added + spdlog::info("[OVERLORD] FS Open {}", fr->name); LoadStackEntry* selected = nullptr; // find first unused spot on load stack. for (uint32_t i = 0; i < MAX_OPEN_FILES; i++) { @@ -229,7 +231,8 @@ LoadStackEntry* FS_Open(FileRecord* fr, int32_t offset) { return selected; } } - printf("[OVERLORD ISO CD] Failed to FS_Open %s\n", fr->name); + //printf("[OVERLORD ISO CD] Failed to FS_Open %s\n", fr->name); + spdlog::warn("[OVERLORD] Failed to FS Open {}", fr->name); ExitIOP(); return nullptr; } @@ -240,7 +243,8 @@ LoadStackEntry* FS_Open(FileRecord* fr, int32_t offset) { * This is an ISO FS API Function */ LoadStackEntry* FS_OpenWad(FileRecord* fr, int32_t offset) { - printf("[OVERLORD] FS Open %s\n", fr->name); // Added + //printf("[OVERLORD] FS Open %s\n", fr->name); // Added + spdlog::info("[OVERLORD] FS_OpenWad {}", fr->name); LoadStackEntry* selected = nullptr; for (uint32_t i = 0; i < MAX_OPEN_FILES; i++) { if (!sLoadStack[i].fr) { @@ -250,7 +254,8 @@ LoadStackEntry* FS_OpenWad(FileRecord* fr, int32_t offset) { return selected; } } - printf("[OVERLORD ISO CD] Failed to FS_OpenWad %s\n", fr->name); + //printf("[OVERLORD ISO CD] Failed to FS_OpenWad %s\n", fr->name); + spdlog::warn("[OVERLORD] Failed to FS_OpenWad {}", fr->name); ExitIOP(); return nullptr; } @@ -260,7 +265,8 @@ LoadStackEntry* FS_OpenWad(FileRecord* fr, int32_t offset) { * This is an ISO FS API Function */ void FS_Close(LoadStackEntry* fd) { - printf("[OVERLORD] FS Close %s\n", fd->fr->name); + //printf("[OVERLORD] FS Close %s\n", fd->fr->name); + spdlog::info("[OVERLORD] FS_Close {}", fd->fr->name); // close the FD fd->fr = nullptr; @@ -279,7 +285,8 @@ uint32_t FS_BeginRead(LoadStackEntry* fd, void* buffer, int32_t len) { int32_t real_size = len; if (len < 0) { // not sure what this is about... - printf("[OVERLORD ISO CD] negative length warning!\n"); + //printf("[OVERLORD ISO CD] negative length warning!\n"); + spdlog::warn("[OVERLORD ISO CD] Negative length warning!"); real_size = len + 0x7ff; } diff --git a/game/overlord/iso.cpp b/game/overlord/iso.cpp index 17424022be..d38044e2f8 100644 --- a/game/overlord/iso.cpp +++ b/game/overlord/iso.cpp @@ -4,6 +4,7 @@ * This is a huge mess */ +#include "third-party/spdlog/include/spdlog/spdlog.h" #include #include #include @@ -17,6 +18,7 @@ #include "fake_iso.h" #include "game/common/dgo_rpc_types.h" + using namespace iop; u32 ISOThread(); @@ -492,9 +494,11 @@ u32 RunDGOStateMachine(IsoMessage* _cmd, IsoBufferHeader* buffer) { // if we are done with header if (cmd->bytes_processed == sizeof(DgoHeader)) { - printf("[Overlord DGO] Got DGO file header for %s with %d objects\n", - cmd->dgo_header.name, - cmd->dgo_header.object_count); // added + //printf("[Overlord DGO] Got DGO file header for %s with %d objects\n", + //cmd->dgo_header.name, + //cmd->dgo_header.object_count); // added + spdlog::info("[Overlord DGO] Got DGO file header for {} with {} objects", + cmd->dgo_header.name, cmd->dgo_header.object_count); cmd->bytes_processed = 0; cmd->objects_loaded = 0; if (cmd->dgo_header.object_count == 1) { diff --git a/game/overlord/iso_api.cpp b/game/overlord/iso_api.cpp index 1ff89e3296..48b5fe9d86 100644 --- a/game/overlord/iso_api.cpp +++ b/game/overlord/iso_api.cpp @@ -1,5 +1,6 @@ #include "iso_api.h" #include "game/sce/iop.h" +#include "third-party/spdlog/include/spdlog/spdlog.h" using namespace iop; @@ -7,7 +8,8 @@ using namespace iop; * Load a File to IOP memory (blocking) */ void LoadISOFileToIOP(FileRecord* file, void* addr, uint32_t length) { - printf("[OVERLORD] LoadISOFileToIOP %s, %d/%d bytes\n", file->name, length, file->size); + //printf("[OVERLORD] LoadISOFileToIOP %s, %d/%d bytes\n", file->name, length, file->size); + spdlog::info("[OVERLORD] LoadISOFileToIOP {}, {}/{} bytes", file->name, length, file->size); IsoCommandLoadSingle cmd; cmd.cmd_id = LOAD_TO_IOP_CMD_ID; cmd.messagebox_to_reply = 0; @@ -27,7 +29,8 @@ void LoadISOFileToIOP(FileRecord* file, void* addr, uint32_t length) { * Load a File to IOP memory (blocking) */ void LoadISOFileToEE(FileRecord* file, uint32_t addr, uint32_t length) { - printf("[OVERLORD] LoadISOFileToEE %s, %d/%d bytes\n", file->name, length, file->size); + //printf("[OVERLORD] LoadISOFileToEE %s, %d/%d bytes\n", file->name, length, file->size); + spdlog::info("[OVERLORD] LoadISOFileToEE {}, {}/{} bytes", file->name, length, file->size); IsoCommandLoadSingle cmd; cmd.cmd_id = LOAD_TO_EE_CMD_ID; cmd.messagebox_to_reply = 0; diff --git a/game/runtime.cpp b/game/runtime.cpp index a86cb0c134..524cde7a9f 100644 --- a/game/runtime.cpp +++ b/game/runtime.cpp @@ -68,7 +68,8 @@ void deci2_runner(SystemThreadInterface& iface) { iface.initialization_complete(); // in our own thread, wait for the EE to register the first protocol driver - printf("[DECI2] waiting for EE to register protos\n"); + //printf("[DECI2] waiting for EE to register protos\n"); + spdlog::debug("[DECI2] Waiting for EE to register protos"); server.wait_for_protos_ready(); // then allow the server to accept connections if (!server.init()) { @@ -76,11 +77,13 @@ void deci2_runner(SystemThreadInterface& iface) { } printf("[DECI2] waiting for listener...\n"); + //spdlog::debug("[DECI2] Waiting for listener..."); --> disabled temporarily, some weird race condition? bool saw_listener = false; while (!iface.get_want_exit()) { if (server.check_for_listener()) { if (!saw_listener) { printf("[DECI2] Connected!\n"); + spdlog::debug("[DECI2] Connected!"); } saw_listener = true; // we have a listener, run! @@ -117,19 +120,23 @@ void ee_runner(SystemThreadInterface& iface) { } if (g_ee_main_mem == (u8*)(-1)) { - printf(" Failed to initialize main memory! %s\n", strerror(errno)); + //printf(" Failed to initialize main memory! %s\n", strerror(errno)); + spdlog::debug("Failed to initialize main memory! {}", strerror(errno)); iface.initialization_complete(); return; } printf(" Main memory mapped at 0x%016llx\n", (u64)(g_ee_main_mem)); + //spdlog::debug("Main memory mapped at 0x00000") --- todo: printf conversion specification printf(" Main memory size 0x%x bytes (%.3f MB)\n", EE_MAIN_MEM_SIZE, (double)EE_MAIN_MEM_SIZE / (1 << 20)); - printf("[EE] Initialization complete!\n"); + //printf("[EE] Initialization complete!\n"); + spdlog::debug("[EE] Initialization complete!"); iface.initialization_complete(); - printf("[EE] Run!\n"); + //printf("[EE] Run!\n"); + spdlog::debug("[EE] Run!"); memset((void*)g_ee_main_mem, 0, EE_MAIN_MEM_SIZE); // prevent access to the first 1 MB of memory. @@ -151,7 +158,8 @@ void ee_runner(SystemThreadInterface& iface) { kprint_init_globals(); goal_main(g_argc, g_argv); - printf("[EE] Done!\n"); + //printf("[EE] Done!\n"); + spdlog::debug("[EE] Done!"); // // kill the IOP todo iop::LIBRARY_kill(); @@ -167,7 +175,8 @@ void ee_runner(SystemThreadInterface& iface) { */ void iop_runner(SystemThreadInterface& iface) { IOP iop; - printf("[IOP] Restart!\n"); + //printf("[IOP] Restart!\n"); + spdlog::debug("[IOP] Restart!"); iop.reset_allocator(); ee::LIBRARY_sceSif_register(&iop); iop::LIBRARY_register(&iop); @@ -190,12 +199,15 @@ void iop_runner(SystemThreadInterface& iface) { iface.initialization_complete(); - printf("[IOP] Wait for OVERLORD to be started...\n"); + //printf("[IOP] Wait for OVERLORD to be started...\n"); + spdlog::debug("[IOP] Wait for OVERLORD to start..."); iop.wait_for_overlord_start_cmd(); if (iop.status == IOP_OVERLORD_INIT) { - printf("[IOP] Run!\n"); + //printf("[IOP] Run!\n"); + spdlog::debug("[IOP] Run!"); } else { - printf("[IOP] shutdown!\n"); + //printf("[IOP] shutdown!\n"); + spdlog::debug("[IOP] Shutdown!"); return; } @@ -257,6 +269,7 @@ u32 exec_runtime(int argc, char** argv) { // join and exit tm.join(); - printf("GOAL Runtime Shutdown (code %d)\n", MasterExit); + //printf("GOAL Runtime Shutdown (code %d)\n", MasterExit); + spdlog::info("GOAL Runtime Shutdown (code {})", MasterExit); return MasterExit; } diff --git a/game/sce/deci2.cpp b/game/sce/deci2.cpp index 99b12cbcb3..e8b4f91a12 100644 --- a/game/sce/deci2.cpp +++ b/game/sce/deci2.cpp @@ -69,7 +69,8 @@ s32 sceDeci2Open(u16 protocol, void* opt, void (*handler)(s32 event, s32 param, drv.id = protocol_count + 1; drv.active = true; protocols[protocol_count++] = drv; - printf("[DECI2] Add new protocol driver %d for 0x%x\n", drv.id, drv.protocol); + //printf("[DECI2] Add new protocol driver %d for 0x%x\n", drv.id, drv.protocol); + spdlog::info("[DECI2] Add new protocol driver {} for 0x{}", drv.id, drv.protocol); server->unlock(); if (protocol_count == 1) { diff --git a/game/sce/iop.h b/game/sce/iop.h index f0ced35b3d..4638b799f3 100644 --- a/game/sce/iop.h +++ b/game/sce/iop.h @@ -4,6 +4,7 @@ #define JAK1_IOP_H #include "common/common_types.h" +#include "third-party/spdlog/include/spdlog/spdlog.h" #define SMEM_Low (0) #define SMEM_High (1) diff --git a/game/system/Deci2Server.h b/game/system/Deci2Server.h index 1bd164ffe6..7c888a188b 100644 --- a/game/system/Deci2Server.h +++ b/game/system/Deci2Server.h @@ -19,6 +19,7 @@ #include #include #include "game/system/deci_common.h" +#include "third-party/spdlog/include/spdlog/spdlog.h" class Deci2Server { public: diff --git a/game/system/SystemThread.cpp b/game/system/SystemThread.cpp index d449f7d405..3edda4cd9c 100644 --- a/game/system/SystemThread.cpp +++ b/game/system/SystemThread.cpp @@ -13,7 +13,8 @@ */ SystemThread& SystemThreadManager::create_thread(const std::string& name) { if (thread_count >= MAX_SYSTEM_THREADS) { - throw std::runtime_error("Out of System Threads! Please increase MAX_SYSTEM_THREADS"); + spdlog::critical("Out of System Threads! MAX_SYSTEM_THREADS is ", MAX_SYSTEM_THREADS); + throw std::runtime_error("Out of System Threads! Please increase MAX_SYSTEM_THREADS"); } auto& thread = threads[thread_count]; @@ -49,7 +50,8 @@ void SystemThreadManager::print_stats() { */ void SystemThreadManager::shutdown() { for (int i = 0; i < thread_count; i++) { - printf("# Stop %s\n", threads[i].name.c_str()); + //printf("# Stop %s\n", threads[i].name.c_str()); + spdlog::debug("# Stop {}", threads[i].name.c_str()); threads[i].stop(); } } @@ -59,7 +61,8 @@ void SystemThreadManager::shutdown() { */ void SystemThreadManager::join() { for (int i = 0; i < thread_count; i++) { - printf("# Join %s\n", threads[i].name.c_str()); + //printf("# Join %s\n", threads[i].name.c_str()); + spdlog::debug(" # Join {}", threads[i].name.c_str()); if (threads[i].running) { threads[i].join(); } @@ -73,7 +76,8 @@ void* bootstrap_thread_func(void* x) { SystemThread* thd = (SystemThread*)x; SystemThreadInterface iface(thd); thd->function(iface); - printf("[SYSTEM] Thread %s is returning\n", thd->name.c_str()); + //printf("[SYSTEM] Thread %s is returning\n", thd->name.c_str()); + spdlog::debug("[SYSTEM] Thread {} is returning", thd->name.c_str()); return nullptr; } @@ -81,7 +85,9 @@ void* bootstrap_thread_func(void* x) { * Start a thread and wait for its initialization */ void SystemThread::start(std::function f) { - printf("# Initialize %s...\n", name.c_str()); + //printf("# Initialize %s...\n", name.c_str()); + spdlog::debug("# Initialize {}...", name.c_str()); + function = f; thread = std::thread(bootstrap_thread_func, this); running = true; @@ -118,7 +124,8 @@ void SystemThreadInterface::initialization_complete() { std::unique_lock mlk(thread.initialization_mutex); thread.initialization_complete = true; thread.initialization_cv.notify_all(); - printf("# %s initialized\n", thread.name.c_str()); + //printf("# %s initialized\n", thread.name.c_str()); + spdlog::debug("# {} initialized", thread.name.c_str()); } /*! diff --git a/game/system/SystemThread.h b/game/system/SystemThread.h index a2ab512829..e6f9f6ebf0 100644 --- a/game/system/SystemThread.h +++ b/game/system/SystemThread.h @@ -14,6 +14,7 @@ #include #include #include +#include "third-party/spdlog/include/spdlog/spdlog.h" #include "Timer.h"