Added log path setting

This commit is contained in:
Farewell_
2025-01-12 22:57:31 +01:00
parent 6526b48191
commit 4e9fe1cb87
4 changed files with 9 additions and 6 deletions
+2 -1
View File
@@ -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.
# |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).
+4 -2
View File
@@ -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<i32> (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") {
+2 -2
View File
@@ -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<Logger *> (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
}
+1 -1
View File
@@ -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, ...);