From 0f10ea93123e13f62cab622349909a37cda91cac Mon Sep 17 00:00:00 2001 From: Grimbakor Date: Tue, 4 Feb 2025 00:05:55 +0000 Subject: Add logging frontend errors to decky logging (#53) --- src/index.tsx | 102 ++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 56 insertions(+), 46 deletions(-) (limited to 'src/index.tsx') diff --git a/src/index.tsx b/src/index.tsx index 61dc8a5..74c43f1 100755 --- a/src/index.tsx +++ b/src/index.tsx @@ -28,6 +28,8 @@ const listInstalledGames = callable< { status: string; games: { appid: string; name: string }[] } >("list_installed_games"); +const logError = callable<[string], void>("log_error"); + function FGModInstallerSection() { const [installing, setInstalling] = useState(false); const [uninstalling, setUninstalling] = useState(false); @@ -45,14 +47,16 @@ function FGModInstallerSection() { useEffect(() => { const checkPath = async () => { - const result = await checkFGModPath(); - setPathExists(result.exists); + try { + const result = await checkFGModPath(); + setPathExists(result.exists); + } catch (e) { + logError('useEffect -> checkPath' + String(e)); + console.error(e); + } }; - checkPath(); // Initial check - const intervalId = setInterval(checkPath, 3000); // Check every 3 seconds - return () => clearInterval(intervalId); // Cleanup interval on component unmount }, []); @@ -77,82 +81,92 @@ function FGModInstallerSection() { }, [uninstallResult]); const handleInstallClick = async () => { - setInstalling(true); - const result = await runInstallFGMod(); - setInstalling(false); - setInstallResult(result); + try { + setInstalling(true); + const result = await runInstallFGMod(); + setInstalling(false); + setInstallResult(result); + } catch (e) { + logError('handleInstallClick: ' + String(e)); + console.error(e) + } }; const handleUninstallClick = async () => { - setUninstalling(true); - const result = await runUninstallFGMod(); - setUninstalling(false); - setUninstallResult(result); + try { + setUninstalling(true); + const result = await runUninstallFGMod(); + setUninstalling(false); + setUninstallResult(result); + } catch (e) { + logError('handleUninstallClick' + String(e)); + console.error(e) + } }; return ( - {pathExists !== null && ( + {pathExists !== null ? (
{pathExists ? "Mod Is Installed" : "Mod Not Installed"}
- )} - {pathExists === false && ( + ) : null} + {pathExists === false ? ( {installing ? "Installing..." : "Install FG Mod"} - )} - {pathExists === true && ( + ) : null} + {pathExists === true ? ( {uninstalling ? "Uninstalling..." : "Uninstall FG Mod"} - )} - {installResult && ( + ) : null} + {installResult ? (
Status:{" "} {installResult.status === "success" ? "Success" : "Error"}
- {installResult.output && ( + {installResult.output ? ( <> Output:
{installResult.output}
- )} - {installResult.message && ( + ) : null} + {installResult.message ? ( <> Error: {installResult.message} - )} + ) : null}
- )} - {uninstallResult && ( + ) : null} + {uninstallResult ? (
Status:{" "} {uninstallResult.status === "success" ? "Success" : "Error"}
- {uninstallResult.output && ( + {uninstallResult.output ? ( <> Output:
{uninstallResult.output}
- )} - {uninstallResult.message && ( + ) : null} + {uninstallResult.message ? ( <> Error: {uninstallResult.message} - )} + ) : null}
- )} + ) : null}
Once installed, patch a games below to replace DLSS upscale and frame gen options with FSR 3 equivalents. * NON STEAM GAMES, GAMES WITH LAUNCHERS, AND DX11 OR BELOW NOT SUPPORTED. @@ -179,12 +193,15 @@ function InstalledGamesSection() { })) .sort((a, b) => a.name.toLowerCase().localeCompare(b.name.toLowerCase())); setGames(sortedGames); + } else { + logError('fetchGames: ' + JSON.stringify(response)); + console.error('fetchGames: ' + JSON.stringify(response)); } } catch (error) { - console.error("Error fetching games:", error); + logError("Error fetching games:" + String(error)); + console.error("Error fetching games:", String(error)); } }; - fetchGames(); }, []); @@ -195,6 +212,7 @@ function InstalledGamesSection() { await SteamClient.Apps.SetAppLaunchOptions(selectedGame.appid, '~/fgmod/fgmod %COMMAND%'); setResult(`Launch options set successfully for ${selectedGame.name}. You can now select DLSS in the game's menu to use FSR Upscaling and FrameGen equivalents.`); } catch (error) { + logError('handlePatchClick: ' + String(error)); setResult(error instanceof Error ? `Error setting launch options: ${error.message}` : 'Error setting launch options'); } }; @@ -206,6 +224,7 @@ function InstalledGamesSection() { await SteamClient.Apps.SetAppLaunchOptions(selectedGame.appid, '~/fgmod/fgmod-uninstaller.sh %COMMAND%'); setResult(`DLSS mods will uninstall on next launch of ${selectedGame.name}. The game is now unpatched.`); } catch (error) { + logError('handleUnpatchClick: ' + String(error)); setResult(error instanceof Error ? `Error clearing launch options: ${error.message}` : 'Error clearing launch options'); } }; @@ -229,7 +248,7 @@ function InstalledGamesSection() { /> - {selectedGame && ( + {selectedGame ? ( <>
@@ -253,9 +272,9 @@ function InstalledGamesSection() { - )} + ) : null} - {result && ( + {result ? (
- )} + ) : null} ); } @@ -279,7 +298,6 @@ export default definePlugin(() => ({ <> - ), icon: , @@ -287,11 +305,3 @@ export default definePlugin(() => ({ console.log("Framegen Plugin unmounted"); }, })); - -function MainContent() { - return ( - <> - {} - - ); -} -- cgit v1.2.3