Add logging functionality for installer process, capturing stdout, stderr, and error details to a timestamped log file in the downloads directory.
All checks were successful
farmcontrol/farmcontrol-ui/pipeline/head This commit looks good
All checks were successful
farmcontrol/farmcontrol-ui/pipeline/head This commit looks good
This commit is contained in:
parent
0a5563b2a7
commit
95cbff68a7
@ -176,6 +176,35 @@ const getMacAppPath = (app) => {
|
||||
|
||||
const quoteShellArg = (value) => `'${String(value).replaceAll("'", "'\\''")}'`
|
||||
|
||||
const writeInstallerLog = async (app, { installerPath, stdout, stderr, error }) => {
|
||||
const downloadsDir = app.getPath('downloads')
|
||||
const timestamp = new Date().toISOString().replaceAll(':', '-').replaceAll('.', '-')
|
||||
const logPath = path.join(
|
||||
downloadsDir,
|
||||
`farmcontrol-update-install-${timestamp}.log`
|
||||
)
|
||||
|
||||
const sections = [
|
||||
`Timestamp: ${new Date().toISOString()}`,
|
||||
`Installer: ${installerPath}`,
|
||||
`Status: ${error ? 'failed' : 'success'}`,
|
||||
'',
|
||||
'--- stdout ---',
|
||||
stdout || '(empty)',
|
||||
'',
|
||||
'--- stderr ---',
|
||||
stderr || '(empty)'
|
||||
]
|
||||
|
||||
if (error) {
|
||||
sections.push('', '--- error ---', error.stack || error.message || String(error))
|
||||
}
|
||||
|
||||
await fs.writeFile(logPath, `${sections.join('\n')}\n`, 'utf8')
|
||||
console.log('[app-update] installer log written to:', logPath)
|
||||
return logPath
|
||||
}
|
||||
|
||||
const getInstallErrorMessage = (error, output = '') => {
|
||||
const combined = `${output}\n${error?.message || ''}`.trim()
|
||||
|
||||
@ -244,6 +273,15 @@ const launchMacInstaller = (app, installerPath, webContents) => {
|
||||
if (stdout) console.log('[app-update] installer stdout:', stdout)
|
||||
if (stderr) console.error('[app-update] installer stderr:', stderr)
|
||||
|
||||
void writeInstallerLog(app, {
|
||||
installerPath,
|
||||
stdout,
|
||||
stderr,
|
||||
error
|
||||
}).catch((logError) => {
|
||||
console.error('[app-update] failed to write installer log:', logError)
|
||||
})
|
||||
|
||||
if (error) {
|
||||
console.error('[app-update] installer error:', error)
|
||||
const message = getInstallErrorMessage(error, output)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user