From 69f0518bd87a97525a6acaaaadebbe8660decbcf Mon Sep 17 00:00:00 2001 From: dinglili Date: Wed, 17 Jul 2024 14:08:33 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=8F=92=E4=BB=B6=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E5=92=8C=E8=BD=AF=E4=BB=B6=E5=8C=85=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E8=AE=B0=E5=BD=95=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../issue/electron-main/deployMainService.ts | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/vs/platform/issue/electron-main/deployMainService.ts b/src/vs/platform/issue/electron-main/deployMainService.ts index 0db3738c..38952eee 100644 --- a/src/vs/platform/issue/electron-main/deployMainService.ts +++ b/src/vs/platform/issue/electron-main/deployMainService.ts @@ -115,6 +115,8 @@ export class DeployMainService implements IDeployMainService { startInstallDepWatch = 0; logger: ILogger; + loggerExt: ILogger; + loggerSoft: ILogger; constructor( private userEnv: IProcessEnvironment, @@ -128,6 +130,8 @@ export class DeployMainService implements IDeployMainService { this.updateConfigDir = installUtils.installConfigDirPre() + "/" + installUtils.getDateDir(); this.reset(); this.logger = this.loggerMainService.createLogger(URI.file(this.installConfig + "/log/instguide.log")); + this.loggerExt = this.loggerMainService.createLogger(URI.file(this.installConfig + "/log/extinstdetail.log")); + this.loggerSoft = this.loggerMainService.createLogger(URI.file(this.installConfig + "/log/softinstdetail.log")); this.removeListeners(); this.registerListeners(); } @@ -208,7 +212,6 @@ export class DeployMainService implements IDeployMainService { if (!fs.existsSync(logFile0)) { fs.mkdirSync(this.installConfig + "/log", { recursive: true }); } - let installCommand = ""; try { const installItem = this.extDownloadPath + msg.downloadDone; @@ -232,8 +235,8 @@ export class DeployMainService implements IDeployMainService { } } else if (msg.type === 'installPkg') { - const extlogFile = this.installConfig + '/log/extInstall.log'; - this.backupLogFile(extlogFile) + // const extlogFile = this.installConfig + '/log/extInstall.log'; + // this.backupLogFile(extlogFile) const extlogFile0 = this.installConfig + '/log/extInstall.1.log'; fs.writeFileSync(extlogFile0, ''); @@ -284,11 +287,11 @@ export class DeployMainService implements IDeployMainService { this.lastLogPosition = 0; this.lastExtLogPosition = 0; - const logFile = this.installConfig + '/log/install.log'; + // const logFile = this.installConfig + '/log/install.log'; const resultFile = this.installConfig + '/resultFile'; const installFile = this.installConfig + '/install.sh'; const logFile0 = this.installConfig + '/log/install.1.log'; - this.backupLogFile(logFile); + // this.backupLogFile(logFile); try { fs.writeFileSync(resultFile, ''); @@ -714,8 +717,9 @@ export class DeployMainService implements IDeployMainService { data: updatedContent }; - this.logger.debug(`install pkg输出信息更新:${updatedContent}`); - + // this.logger.debug(`install pkg输出信息更新:${updatedContent}`); + if (updatedContent.length > 0) + fs.appendFileSync(this.installConfig + "/log/soft.log", updatedContent); if (this.DeployWindow) this.DeployWindow.webContents.send("kylinide.installWizard.msg", installMsg); } @@ -972,11 +976,13 @@ export class DeployMainService implements IDeployMainService { try { const pkexecCommand = `pkexec sudo bash ${scriptPath}`; this.logger.info(`执行命令 ${pkexecCommand}`); + this.loggerSoft.info(`执行命令 ${pkexecCommand}`); this.installProcessId = spawn(pkexecCommand, { shell: true, stdio: 'inherit' }); this.installProcessId.on('exit', (code, signal) => { this.flagPkexec++; this.logger.info(`执行命令 ${pkexecCommand} 结束,退出码:${code}`); + this.loggerSoft.info(`执行命令 ${pkexecCommand} 结束,退出码:${code}`); if (code == 127) { //授权失败,结束安装。 if (this.DeployWindow) { @@ -987,6 +993,7 @@ export class DeployMainService implements IDeployMainService { }); } catch (error) { this.logger.error(`执行脚本时出错: ${error.message}`); + this.loggerSoft.error(`执行脚本时出错: ${error.message}`); // return false; } } @@ -1031,11 +1038,15 @@ export class DeployMainService implements IDeployMainService { const extlogFile = this.installConfig + '/log/extInstall.1.log'; let ret: { stdout: string, stderr: string } = await this.spawnCommand(installCommand) as { stdout: string; stderr: string; }; - if (ret.stdout) + if (ret.stdout) { fs.appendFileSync(extlogFile, ret.stdout); + this.loggerExt.info(ret.stdout); + } + // if (ret.stderr) // fs.appendFileSync(extlogFile, ret.stderr); this.logger.info(`执行命令成功 ${installCommand}`); + this.loggerExt.info(`执行命令成功 ${installCommand}`); const installMsg = { type: "extInstalled", @@ -1053,6 +1064,8 @@ export class DeployMainService implements IDeployMainService { fs.appendFileSync(extlogFile, '\n'); fs.appendFileSync(extlogFile, error.message); fs.appendFileSync(extlogFile, '\n'); + this.loggerExt.info(`执行命令失败 ${installCommand}`); + this.loggerExt.info(error.message); const installMsg = { type: "extInstalledFail", extFileName: msg.downloadDone,