Fix logging to file

Fixes #21411
This commit is contained in:
Henrik Rydgård committed 2026-03-11 14:14:58 +01:00
1 parent 5c066ce8a7
commit b7f257152d
3 files changed
+19 -3

No files matched your search

+4 -3
View File
@@ -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());
}
}
}
+14
View File
@@ -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")));
+1
View File
@@ -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 {