Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UX] Enable/disable logs game-by-game instead of globally #4214

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,9 @@
"showMetalOverlay": "Show Stats Overlay",
"start-in-tray": "Start Minimized",
"steamruntime": "Use Steam Runtime",
"verboseLogs": {
"description": "Enable verbose logs"
},
"winecrossoverbottle": "CrossOver Bottle",
"wineprefix": "WinePrefix folder",
"wineversion": "Wine Version"
Expand Down
3 changes: 2 additions & 1 deletion src/backend/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,8 @@ class GlobalConfigV0 extends GlobalConfig {
framelessWindow: false,
beforeLaunchScriptPath: '',
afterLaunchScriptPath: '',
disableUMU: false
disableUMU: false,
verboseLogs: false
}
// @ts-expect-error TODO: We need to settle on *one* place to define settings defaults
return settings
Expand Down
6 changes: 4 additions & 2 deletions src/backend/game_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ class GameConfigV0 extends GameConfig {
battlEyeRuntime,
beforeLaunchScriptPath,
afterLaunchScriptPath,
gamescope
gamescope,
verboseLogs
} = GlobalConfig.get().getSettings()

// initialize generic defaults
Expand Down Expand Up @@ -266,7 +267,8 @@ class GameConfigV0 extends GameConfig {
language: '', // we want to fallback to '' always here, fallback lang for games should be ''
beforeLaunchScriptPath,
afterLaunchScriptPath,
gamescope
gamescope,
verboseLogs
} as GameSettings

let gameSettings = {} as GameSettings
Expand Down
33 changes: 15 additions & 18 deletions src/backend/launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,6 @@ const launchEventCallback: (args: LaunchParams) => StatusPromise = async ({

initGamePlayLog(game)

if (logsDisabled) {
appendGamePlayLog(
game,
'IMPORTANT: Logs are disabled. Enable logs before reporting an issue.'
)
}

const isNative = gameManagerMap[runner].isNative(appName)

// check if isNative, if not, check if wine is valid
Expand Down Expand Up @@ -1695,23 +1688,27 @@ async function runScriptForGame(
env: scriptEnv
})

child.stdout.on('data', (data) => {
appendGamePlayLog(gameInfo, data.toString())
})
if (gameSettings.verboseLogs) {
child.stdout.on('data', (data) => {
appendGamePlayLog(gameInfo, data.toString())
})

child.stderr.on('data', (data) => {
appendGamePlayLog(gameInfo, data.toString())
})
}

child.stderr.on('data', (data) => {
appendGamePlayLog(gameInfo, data.toString())
child.on('error', (err: Error) => {
if (gameSettings.verboseLogs) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps errors should ignore this option? They're not exactly frequent after all

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My only concern with this is that users may see an error message and miss the IMPORTANT: Logs are disabled. Enable verbose logs before reporting an issue line and send it anyway without turning on logs (I know it's going to happen anyway, but I think not having anything apart from that line would reduce it the chances)

appendGamePlayLog(gameInfo, err.message)
if (err.stack) appendGamePlayLog(gameInfo, err.stack)
}
reject(err.message)
})

child.on('exit', () => {
resolve(true)
})

child.on('error', (err: Error) => {
appendGamePlayLog(gameInfo, err.message)
if (err.stack) appendGamePlayLog(gameInfo, err.stack)
reject(err.message)
})
})
}

Expand Down
10 changes: 8 additions & 2 deletions src/backend/storeManagers/gog/games.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ import {
logFileLocation,
logInfo,
LogPrefix,
logsDisabled,
logWarning
} from '../../logger/logger'
import { GOGUser } from './user'
Expand Down Expand Up @@ -688,6 +687,13 @@ export async function launch(
)
appendGamePlayLog(gameInfo, `Launch Command: ${fullCommand}\n\nGame Log:\n`)

if (!gameSettings.verboseLogs) {
appendGamePlayLog(
gameInfo,
'IMPORTANT: Logs are disabled. Enable verbose logs before reporting an issue.'
)
}

const userData: UserData | undefined = configStore.get_nodefault('userData')

sendGameStatusUpdate({ appName, runner: 'gog', status: 'playing' })
Expand Down Expand Up @@ -722,7 +728,7 @@ export async function launch(
wrappers,
logMessagePrefix: `Launching ${gameInfo.title}`,
onOutput: (output: string) => {
if (!logsDisabled) appendGamePlayLog(gameInfo, output)
if (gameSettings.verboseLogs) appendGamePlayLog(gameInfo, output)
}
})

Expand Down
12 changes: 9 additions & 3 deletions src/backend/storeManagers/legendary/games.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ import {
logError,
logFileLocation,
logInfo,
LogPrefix,
logsDisabled
LogPrefix
} from '../../logger/logger'
import {
prepareLaunch,
Expand Down Expand Up @@ -953,6 +952,13 @@ export async function launch(
)
appendGamePlayLog(gameInfo, `Launch Command: ${fullCommand}\n\nGame Log:\n`)

if (!gameSettings.verboseLogs) {
appendGamePlayLog(
gameInfo,
'IMPORTANT: Logs are disabled. Enable verbose logs before reporting an issue.'
)
}

sendGameStatusUpdate({ appName, runner: 'legendary', status: 'playing' })

const { error } = await runLegendaryCommand(command, {
Expand All @@ -961,7 +967,7 @@ export async function launch(
wrappers: wrappers,
logMessagePrefix: `Launching ${gameInfo.title}`,
onOutput: (output) => {
if (!logsDisabled) appendGamePlayLog(gameInfo, output)
if (gameSettings.verboseLogs) appendGamePlayLog(gameInfo, output)
}
})

Expand Down
12 changes: 9 additions & 3 deletions src/backend/storeManagers/nile/games.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ import {
logDebug,
logError,
logFileLocation,
logInfo,
logsDisabled
logInfo
} from 'backend/logger/logger'
import { isLinux, isWindows } from 'backend/constants'
import { GameConfig } from 'backend/game_config'
Expand Down Expand Up @@ -418,6 +417,13 @@ export async function launch(
)
appendGamePlayLog(gameInfo, `Launch Command: ${fullCommand}\n\nGame Log:\n`)

if (!gameSettings.verboseLogs) {
appendGamePlayLog(
gameInfo,
'IMPORTANT: Logs are disabled. Enable verbose logs before reporting an issue.'
)
}

sendGameStatusUpdate({ appName, runner: 'nile', status: 'playing' })

const { error } = await runNileCommand(commandParts, {
Expand All @@ -426,7 +432,7 @@ export async function launch(
wrappers,
logMessagePrefix: `Launching ${gameInfo.title}`,
onOutput(output) {
if (!logsDisabled) appendGamePlayLog(gameInfo, output)
if (gameSettings.verboseLogs) appendGamePlayLog(gameInfo, output)
}
})

Expand Down
3 changes: 1 addition & 2 deletions src/backend/storeManagers/storeManagerCommon/games.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
lastPlayLogFileLocation,
logInfo,
LogPrefix,
logsDisabled,
logWarning
} from '../../logger/logger'
import { basename, dirname } from 'path'
Expand Down Expand Up @@ -264,7 +263,7 @@ export async function launchGame(
logFile: lastPlayLogFileLocation(appName),
logMessagePrefix: LogPrefix.Backend,
onOutput: (output) => {
if (!logsDisabled) appendGamePlayLog(gameInfo, output)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably should add that

  if (!gameSettings.verboseLogs) {
    appendGamePlayLog(
      gameInfo,
      'IMPORTANT: Logs are disabled. Enable verbose logs before reporting an issue.'
    )
  }

here as well ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm looks like we have some issues with how we log things with sideloaded games, for native games the logs are just broken (we log the wrong thing in the wrong file and no system info / config)

I'm trying to fix that, but feel that should be its own PR to limit the scope of this one

if (gameSettings.verboseLogs) appendGamePlayLog(gameInfo, output)
}
}
})
Expand Down
12 changes: 8 additions & 4 deletions src/backend/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,9 @@ export async function checkWineBeforeLaunch(
`Wine version ${gameSettings.wineVersion.name} is not valid, trying another one.`,
LogPrefix.Backend
)
}

if (gameSettings.verboseLogs) {
appendGamePlayLog(
gameInfo,
`Wine version ${gameSettings.wineVersion.name} is not valid, trying another one.\n`
Expand All @@ -989,10 +991,12 @@ export async function checkWineBeforeLaunch(

if (response === 0) {
logInfo(`Changing wine version to ${defaultwine.name}`)
appendGamePlayLog(
gameInfo,
`Changing wine version to ${defaultwine.name}\n`
)
if (gameSettings.verboseLogs) {
appendGamePlayLog(
gameInfo,
`Changing wine version to ${defaultwine.name}\n`
)
}
gameSettings.wineVersion = defaultwine
GameConfig.get(gameInfo.app_name).setSetting('wineVersion', defaultwine)
return true
Expand Down
2 changes: 2 additions & 0 deletions src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export interface AppSettings extends GameSettings {
startInTray: boolean
allowInstallationBrokenAnticheat: boolean
disableUMU: boolean
verboseLogs: boolean
}

export type LibraryTopSectionOptions =
Expand Down Expand Up @@ -203,6 +204,7 @@ export interface GameSettings {
beforeLaunchScriptPath: string
afterLaunchScriptPath: string
disableUMU: boolean
verboseLogs: boolean
}

export type Status =
Expand Down
30 changes: 30 additions & 0 deletions src/frontend/screens/Settings/components/VerboseLogs.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React, { useContext } from 'react'
import { useTranslation } from 'react-i18next'
import { ToggleSwitch } from 'frontend/components/UI'
import useSetting from 'frontend/hooks/useSetting'
import SettingsContext from '../SettingsContext'

const VerboseLogs = () => {
const { t } = useTranslation()

const { isDefault } = useContext(SettingsContext)

const [verboseLogs, setVerboseLogs] = useSetting('verboseLogs', false)

if (isDefault) {
return <></>
}

return (
<div className="toggleRow">
<ToggleSwitch
htmlId="verboseLogs"
value={verboseLogs}
handleChange={() => setVerboseLogs(!verboseLogs)}
title={t('setting.verboseLogs.description', 'Enable verbose logs')}
/>
</div>
)
}

export default VerboseLogs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import FooterInfo from '../FooterInfo'
import { Tabs, Tab } from '@mui/material'
import { GameInfo } from 'common/types'
import DisableUMU from '../../components/DisableUMU'
import VerboseLogs from '../../components/VerboseLogs'

const windowsPlatforms = ['Win32', 'Windows', 'windows']
function getStartingTab(platform: string, gameInfo?: GameInfo | null): string {
Expand Down Expand Up @@ -215,6 +216,7 @@ export default function GamesSettings() {
<OfflineMode />
</>
)}
<VerboseLogs />
<DisableUMU />
<AlternativeExe />
<LauncherArgs />
Expand Down
Loading