Skip to content

Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit

Open a game's launch and Wine logs from the Prefixes view

Logan0f05b2b7eac3
diff --git a/app/Sources/NotProtonApp/Model/PrefixTools.swift b/app/Sources/NotProtonApp/Model/PrefixTools.swift
index d522c13..7969955 100644
--- a/app/Sources/NotProtonApp/Model/PrefixTools.swift
+++ b/app/Sources/NotProtonApp/Model/PrefixTools.swift
@@ -19,6 +19,26 @@ enum WineTool: String, CaseIterable, Sendable {
}
}
+// The logs compat_run.sh writes for a game.
+enum PrefixLog: CaseIterable, Sendable {
+ case launch
+ case wine
+
+ var label: String {
+ switch self {
+ case .launch: String(localized: "Launch Log")
+ case .wine: String(localized: "Wine Log")
+ }
+ }
+
+ func url(for prefix: WinePrefix, launchers: URL = SupportPaths.launchers) -> URL {
+ switch self {
+ case .launch: prefix.root.appending(path: "notproton-run.log")
+ case .wine: launchers.appending(path: prefix.appID).appending(path: "notproton-wine.log")
+ }
+ }
+}
+
// What compat_run.sh writes to notproton-build when a tool first runs a prefix.
struct PrefixBuildRecord: Sendable, Equatable {
let build: String
@@ -246,6 +266,14 @@ enum PrefixTools {
)
}
+ static func hasLog(_ log: PrefixLog, for prefix: WinePrefix) -> Bool {
+ FileManager.default.fileExists(atPath: log.url(for: prefix).path(percentEncoded: false))
+ }
+
+ static func open(_ log: PrefixLog, for prefix: WinePrefix) {
+ NSWorkspace.shared.open(log.url(for: prefix))
+ }
+
static func reveal(at url: URL) {
NSWorkspace.shared.selectFile(
url.path(percentEncoded: false),
diff --git a/app/Sources/NotProtonApp/PrefixesModel.swift b/app/Sources/NotProtonApp/PrefixesModel.swift
index 271eabc..f53ae7c 100644
--- a/app/Sources/NotProtonApp/PrefixesModel.swift
+++ b/app/Sources/NotProtonApp/PrefixesModel.swift
@@ -145,6 +145,14 @@ final class PrefixesModel {
PrefixTools.reveal(prefix)
}
+ func hasLog(_ log: PrefixLog, for prefix: WinePrefix) -> Bool {
+ PrefixTools.hasLog(log, for: prefix)
+ }
+
+ func open(_ log: PrefixLog, for prefix: WinePrefix) {
+ PrefixTools.open(log, for: prefix)
+ }
+
func delete(_ targets: [WinePrefix]) async {
await eachInTurn(targets, { try PrefixTools.delete($0) }) { deleted in
if deleted.count == 1 {
diff --git a/app/Sources/NotProtonApp/Resources/Localization/Localizable.xcstrings b/app/Sources/NotProtonApp/Resources/Localization/Localizable.xcstrings
index caa1262..a1c0785 100644
--- a/app/Sources/NotProtonApp/Resources/Localization/Localizable.xcstrings
+++ b/app/Sources/NotProtonApp/Resources/Localization/Localizable.xcstrings
@@ -1875,6 +1875,16 @@
}
}
},
+ "Launch Log" : {
+ "localizations" : {
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "启动日志"
+ }
+ }
+ }
+ },
"Library" : {
"localizations" : {
"zh-Hans" : {
@@ -2258,6 +2268,16 @@
}
}
},
+ "Open Log" : {
+ "localizations" : {
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "打开日志"
+ }
+ }
+ }
+ },
"Open System Settings" : {
"localizations" : {
"zh-Hans" : {
@@ -3841,6 +3861,16 @@
}
}
},
+ "Wine Log" : {
+ "localizations" : {
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Wine 日志"
+ }
+ }
+ }
+ },
"You will not lose saves by using this tool." : {
"localizations" : {
"zh-Hans" : {
diff --git a/app/Sources/NotProtonApp/Views/PrefixesView.swift b/app/Sources/NotProtonApp/Views/PrefixesView.swift
index de6dee8..6ee9614 100644
--- a/app/Sources/NotProtonApp/Views/PrefixesView.swift
+++ b/app/Sources/NotProtonApp/Views/PrefixesView.swift
@@ -321,6 +321,12 @@ struct PrefixesView: View {
toolButtons(for: prefix)
Divider()
Button("Reveal in Finder") { model.reveal(prefix) }
+ Menu("Open Log") {
+ ForEach(PrefixLog.allCases, id: \.self) { log in
+ Button(log.label) { model.open(log, for: prefix) }
+ .disabled(!model.hasLog(log, for: prefix))
+ }
+ }
}
if !targets.isEmpty {
Divider()
diff --git a/app/Tests/NotProtonAppTests/PrefixToolsTests.swift b/app/Tests/NotProtonAppTests/PrefixToolsTests.swift
index 7a1f7a9..8c9d2dd 100644
--- a/app/Tests/NotProtonAppTests/PrefixToolsTests.swift
+++ b/app/Tests/NotProtonAppTests/PrefixToolsTests.swift
@@ -27,6 +27,21 @@ struct PrefixToolsTests {
)
}
+ @Test("Log paths match where compat_run.sh writes them")
+ func logPathsMatchRunScript() throws {
+ let source = try Self.compatSource()
+ #expect(source.contains(#"log="$STEAM_COMPAT_DATA_PATH/notproton-run.log""#))
+ #expect(source.contains(#"loader_root="$HOME/Library/Application Support/notproton/launchers/$app_id""#))
+ #expect(source.contains(#"wine_log="$loader_root/notproton-wine.log""#))
+
+ let prefix = samplePrefix()
+ let launchers = URL(filePath: "/tmp/launchers")
+ #expect(PrefixLog.launch.url(for: prefix, launchers: launchers) == prefix.root.appending(path: "notproton-run.log"))
+ #expect(PrefixLog.wine.url(for: prefix, launchers: launchers).path(percentEncoded: false)
+ == "/tmp/launchers/1574480/notproton-wine.log")
+ #expect(SupportPaths.launchers.path(percentEncoded: false).hasSuffix("Application Support/notproton/launchers"))
+ }
+
@Test("The runner variables are the ones RUN_SCRIPT exports")
func matchesRunScript() throws {
// A tool under a stale copy of the runner layout writes registry keys the game side then