diff --git a/dist/config.toml b/dist/config.toml index 484baaa..f647985 100644 --- a/dist/config.toml +++ b/dist/config.toml @@ -80,4 +80,5 @@ enabled = false # Replace assets from the game using a layered file log_level = "INFO" # Log level, Can be either "NONE", "ERROR", "WARN", "INFO", "DEBUG" and "HOOKS" # | Keep this as low as possible (Info is usually more than enough) as more logging will slow down your game log_to_file = false # Log to file, set this to true to save the logs from your last session to TaikoArcadeLoader.log - # |Again, if you do not have a use for this (debugging mods or whatnot), turn it off. \ No newline at end of file + # |Again, if you do not have a use for this (debugging mods or whatnot), turn it off. +log_path = "logs.log" # Log file path (Can be both relative and absolute). \ No newline at end of file diff --git a/src/dllmain.cpp b/src/dllmain.cpp index 1852129..c3056bd 100644 --- a/src/dllmain.cpp +++ b/src/dllmain.cpp @@ -34,6 +34,7 @@ bool acceptInvalidCards = false; std::string logLevelStr = "INFO"; bool logToFile = true; +std::string logPath = "TaikoArcadeLoader.log"; HWND hGameWnd; FAST_HOOK (i32, ShowMouse, PROC_ADDRESS ("user32.dll", "ShowCursor"), bool) { return originalShowMouse.stdcall (true); } @@ -148,7 +149,7 @@ DllMain (HMODULE module, const DWORD reason, LPVOID reserved) { // Init logger for loading config auto start = std::chrono::high_resolution_clock::now(); - InitializeLogger (GetLogLevel (logLevelStr), logToFile); + InitializeLogger (GetLogLevel (logLevelStr), logToFile, logPath); patches::Timer::Init (); // #ifdef ASYNC_IO @@ -198,11 +199,12 @@ DllMain (HMODULE module, const DWORD reason, LPVOID reserved) { if (const auto logging = openConfigSection (config, "logging")) { logLevelStr = readConfigString (logging, "log_level", logLevelStr); logToFile = readConfigBool (logging, "log_to_file", logToFile); + logPath = readConfigString (logging, "log_path", logPath); } } // Update the logger with the level read from config file. - InitializeLogger (GetLogLevel (logLevelStr), logToFile); + InitializeLogger (GetLogLevel (logLevelStr), logToFile, logPath); LogMessage (LogLevel::INFO, "Application started."); if (version == "auto") { diff --git a/src/logger.cpp b/src/logger.cpp index e0d451e..b024a44 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -12,7 +12,7 @@ tm *timeInfo; SYSTEMTIME systemTime; void -InitializeLogger (const LogLevel level, const bool logToFile) { +InitializeLogger (const LogLevel level, const bool logToFile, const std::string& logPath) { if (loggerInstance == nullptr) { loggerInstance = static_cast (malloc (sizeof (Logger))); if (consoleHandle == nullptr) consoleHandle = GetStdHandle (STD_OUTPUT_HANDLE); @@ -21,7 +21,7 @@ InitializeLogger (const LogLevel level, const bool logToFile) { loggerInstance->logLevel = level; if (logToFile) { - loggerInstance->logFile = fopen ("TaikoArcadeLoader.log", "w"); // Open in write mode + loggerInstance->logFile = fopen (logPath.c_str (), "w"); // Open in write mode if (!loggerInstance->logFile) LogMessage (LogLevel::WARN, std::string ("Failed to open TaikoArcadeLoader.log for writing.")); } else loggerInstance->logFile = nullptr; // No file logging } diff --git a/src/logger.h b/src/logger.h index c1b7073..d8f5f19 100644 --- a/src/logger.h +++ b/src/logger.h @@ -30,7 +30,7 @@ typedef struct { } Logger; /* Initializes a global Logger instance. */ -void InitializeLogger (LogLevel level, bool logToFile); +void InitializeLogger (LogLevel level, bool logToFile, const std::string& logPath); void LogMessageHandler (const char *function, const char *codeFile, int codeLine, LogLevel messageLevel, const char *format, ...); void LogMessageHandler (const char *function, const char *codeFile, int codeLine, LogLevel messageLevel, const wchar_t *format, ...);