From 04c8ab49d4ae42d5720fe1840663edd48e264367 Mon Sep 17 00:00:00 2001 From: angrybayblade Date: Wed, 13 Mar 2024 18:59:11 +0530 Subject: [PATCH] fix: add backend logging --- electron/main.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/electron/main.js b/electron/main.js index b0d8303bf..15d94f110 100644 --- a/electron/main.js +++ b/electron/main.js @@ -11,7 +11,7 @@ const { } = require('electron'); const { spawn, exec } = require('child_process'); const path = require('path'); -const url = require('url'); +const fs = require('fs'); const os = require('os'); const next = require('next'); const http = require('http'); @@ -168,6 +168,10 @@ const createMainWindow = () => { }; async function launchDaemon() { + function appendLog(data) { + fs.appendFileSync(`${OperateDirectory}/logs.txt`, data.trim() + "\n", { "encoding": "utf-8" }) + return data + } const check = new Promise(function (resolve, reject) { operateDaemon = spawn(OperateCmd, [ 'daemon', @@ -184,6 +188,10 @@ async function launchDaemon() { ) { resolve({ running: false, error: 'Port already in use' }); } + console.log(appendLog(data.toString().trim())); + }); + operateDaemon.stdout.on('data', (data) => { + console.log(appendLog(data.toString().trim())); }); }); return await check;