diff --git a/Common/Log/LogManager.cpp b/Common/Log/LogManager.cpp index dd9836100f..3c1a4b3bb6 100644 --- a/Common/Log/LogManager.cpp +++ b/Common/Log/LogManager.cpp @@ -199,13 +199,14 @@ void LogManager::SetFileLogPath(const Path &filename) { fclose(fp_); } - if (!filename.empty() && (outputs_ & LogOutput::File)) { - logFilename_ = Path(filename); + logFilename_ = Path(filename); + + if (outputs_ & LogOutput::File) { File::CreateFullPath(logFilename_.NavigateUp()); fp_ = File::OpenCFile(logFilename_, "at"); logFileOpenFailed_ = fp_ == nullptr; if (logFileOpenFailed_) { - printf("Failed to open log file %s\n", filename.c_str()); + printf("Failed to open log file %s\n", logFilename_.c_str()); } } } diff --git a/UI/DeveloperToolsScreen.cpp b/UI/DeveloperToolsScreen.cpp index ebfa18baba..8bba489edc 100644 --- a/UI/DeveloperToolsScreen.cpp +++ b/UI/DeveloperToolsScreen.cpp @@ -166,6 +166,20 @@ void DeveloperToolsScreen::CreateGeneralTab(UI::LinearLayout *list) { screenManager()->push(new LogConfigScreen()); }); list->Add(new CheckBox(&g_Config.bEnableFileLogging, dev->T("Log to file")))->SetEnabledPtr(&g_Config.bEnableLogging); + if (System_GetPropertyInt(SYSPROP_DEVICE_TYPE) == DEVICE_TYPE_DESKTOP) { + list->Add(new Choice(dev->T("Show log file in folder")))->OnClick.Add([](UI::EventParams &e) { + Path logFilePath = g_logManager.GetLogFilePath(); + if (logFilePath.empty()) { + ERROR_LOG(Log::System, "No log file path configured."); + return; + } + if (File::Exists(logFilePath)) { + System_ShowFileInFolder(logFilePath); + } else { + System_LaunchUrl(LaunchUrlType::LOCAL_FILE, logFilePath.NavigateUp().ToString()); + } + }); + } list->Add(new CheckBox(&g_Config.bLogFrameDrops, dev->T("Log Dropped Frame Statistics"))); if (GetGPUBackend() == GPUBackend::VULKAN) { list->Add(new CheckBox(&g_Config.bGpuLogProfiler, dev->T("GPU log profiler"))); diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index f324b2511e..cf2b0974da 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -650,6 +650,7 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch } if (fileToLog) { + // Start logging immediately. g_logManager.EnableOutput(LogOutput::File); g_logManager.SetFileLogPath(Path(fileToLog)); } else {