Skip to content

Commit

Permalink
fix for double log
Browse files Browse the repository at this point in the history
  • Loading branch information
SturdyStubs committed Oct 12, 2024
1 parent e63f90d commit fa51bdd
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions games/carbon/wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit fa51bdd

Please sign in to comment.