From 638eb78f0f8a38b55cf533728e6608960cdbb294 Mon Sep 17 00:00:00 2001 From: otavepto <153766569+otavepto@users.noreply.github.com> Date: Sat, 29 Jun 2024 06:49:53 +0300 Subject: [PATCH] use the new logger in all dll code base --- dll/base.cpp | 12 ++++++++---- dll/dll/common_includes.h | 19 +++++-------------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/dll/base.cpp b/dll/base.cpp index 69142077..76e8010d 100644 --- a/dll/base.cpp +++ b/dll/base.cpp @@ -18,12 +18,20 @@ #include "dll/base.h" #include "dll/settings_parser.h" +#ifndef EMU_RELEASE_BUILD +#include "dbg_log/dbg_log.hpp" +#endif + std::recursive_mutex global_mutex{}; // some arbitrary counter/time for reference const std::chrono::time_point startup_counter = std::chrono::high_resolution_clock::now(); const std::chrono::time_point startup_time = std::chrono::system_clock::now(); +#ifndef EMU_RELEASE_BUILD +dbg_log dbg_logger(get_full_program_path() + "STEAM_LOG.txt"); +#endif + #ifdef __WINDOWS__ @@ -102,10 +110,6 @@ bool set_env_variable(const std::string &name, const std::string &value) #endif -#ifndef EMU_RELEASE_BUILD -const std::string dbg_log_file = get_full_program_path() + "STEAM_LOG.txt"; -#endif - unsigned generate_account_id() { int a; diff --git a/dll/dll/common_includes.h b/dll/dll/common_includes.h index 0e9136ff..621f101d 100644 --- a/dll/dll/common_includes.h +++ b/dll/dll/common_includes.h @@ -163,6 +163,7 @@ static inline void reset_LastError() // PRINT_DEBUG definition #ifndef EMU_RELEASE_BUILD + #include "dbg_log/dbg_log.hpp" // we need this for printf specifiers for intptr_t such as PRIdPTR #include @@ -181,21 +182,11 @@ static inline void reset_LastError() #define PRINT_DEBUG_CLEANUP() (void)0 #endif - //#define PRINT_DEBUG(...) fprintf(stdout, __VA_ARGS__) - extern const std::string dbg_log_file; - extern const std::chrono::time_point startup_counter; + extern dbg_log dbg_logger; - #define PRINT_DEBUG(a, ...) do { \ - auto __prnt_dbg_ctr = std::chrono::high_resolution_clock::now(); \ - auto __prnt_dbg_duration = __prnt_dbg_ctr - startup_counter; \ - auto __prnt_dbg_micro = std::chrono::duration_cast>(__prnt_dbg_duration); \ - auto __prnt_dbg_ms = std::chrono::duration_cast>(__prnt_dbg_duration); \ - auto __prnt_dbg_f = fopen(dbg_log_file.c_str(), "a"); \ - if (!__prnt_dbg_f) break; \ - fprintf(__prnt_dbg_f, "[%llu ms, %lld us] [tid %lld] %s " a "\n", \ - __prnt_dbg_ms.count(), __prnt_dbg_micro.count(), PRINT_DEBUG_TID(), EMU_FUNC_NAME, ##__VA_ARGS__); \ - fclose(__prnt_dbg_f); \ - PRINT_DEBUG_CLEANUP(); \ + #define PRINT_DEBUG(a, ...) do { \ + dbg_logger.write("[tid %lld] %s " a, PRINT_DEBUG_TID(), EMU_FUNC_NAME, ##__VA_ARGS__); \ + PRINT_DEBUG_CLEANUP(); \ } while (0) #else // EMU_RELEASE_BUILD