From fa51bdd28d6d64e22d2b186d8717a924c876ee27 Mon Sep 17 00:00:00 2001 From: Matt Larsen Date: Sat, 12 Oct 2024 14:19:52 +0200 Subject: [PATCH] fix for double log --- games/carbon/wrapper.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/games/carbon/wrapper.js b/games/carbon/wrapper.js index 1a213f3..92f74ed 100644 --- a/games/carbon/wrapper.js +++ b/games/carbon/wrapper.js @@ -2,9 +2,12 @@ var startupCmd = ""; const fs = require("fs"); -fs.writeFile("latest.log", "", (err) => { - if (err) console.log("Callback error in appendFile:" + err); -}); + +if (process.env.LOG_FILE !== "false") { // Check if LOG_FILE is not set to false + fs.writeFile("latest.log", "", (err) => { + if (err) console.log("Callback error in appendFile:" + err); + }); +} var args = process.argv.splice(process.execArgv.length + 2); for (var i = 0; i < args.length; i++) { @@ -124,9 +127,11 @@ var poll = function () { if (json !== undefined) { if (json.Message !== undefined && json.Message.length > 0) { console.log(json.Message); - fs.appendFile("latest.log", "\n" + json.Message, (err) => { - if (err) console.log("Callback error in appendFile:" + err); - }); + if (process.env.LOG_FILE !== "false") { // Only log if LOG_FILE is not false + fs.appendFile("latest.log", "\n" + json.Message, (err) => { + if (err) console.log("Callback error in appendFile:" + err); + }); + } } } else { console.log("Error: Invalid JSON received");