From fe25460997df4d7e02b78a1570240f3743fccaec Mon Sep 17 00:00:00 2001 From: Cass Date: Tue, 31 Aug 2021 21:03:39 +0100 Subject: [PATCH 1/2] Replace "ALL" log flag with individually disabling every log. https://github.com/danielyxie/bitburner/issues/1116 --- src/Netscript/WorkerScript.ts | 2 +- src/NetscriptFunctions.js | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Netscript/WorkerScript.ts b/src/Netscript/WorkerScript.ts index 6129f0712..9500f70d6 100644 --- a/src/Netscript/WorkerScript.ts +++ b/src/Netscript/WorkerScript.ts @@ -187,7 +187,7 @@ export class WorkerScript { } shouldLog(fn: string): boolean { - return (this.disableLogs.ALL == null && this.disableLogs[fn] == null); + return (this.disableLogs[fn] == null); } log(func: string, txt: string): void { diff --git a/src/NetscriptFunctions.js b/src/NetscriptFunctions.js index 91217fc61..ddec5b753 100644 --- a/src/NetscriptFunctions.js +++ b/src/NetscriptFunctions.js @@ -940,11 +940,18 @@ function NetscriptFunctions(workerScript) { workerScript.scriptRef.clearLog(); }, disableLog: function(fn) { - if (possibleLogs[fn]===undefined) { + if (fn = "ALL") { + for (fn in possibleLogs) { + workerScript.disableLogs[fn] = true; + + } + workerScript.log("disableLog", `Disabled logging for all functions`); + } else if (possibleLogs[fn] === undefined) { throw makeRuntimeErrorMsg("disableLog", `Invalid argument: ${fn}.`); + } else { + workerScript.disableLogs[fn] = true; + workerScript.log("disableLog", `Disabled logging for ${fn}`); } - workerScript.disableLogs[fn] = true; - workerScript.log("disableLog", `Disabled logging for ${fn}`); }, enableLog: function(fn) { if (possibleLogs[fn]===undefined) { @@ -4541,7 +4548,7 @@ function NetscriptFunctions(workerScript) { return functionNames; } - const possibleLogs = Object.fromEntries(["ALL", ...getFunctionNames(functions)].map(a => [a, true])) + const possibleLogs = Object.fromEntries([...getFunctionNames(functions)].map(a => [a, true])) return functions; } // End NetscriptFunction() From 294640d27e64d0817f3ed264821b946b34d3712f Mon Sep 17 00:00:00 2001 From: Cass Date: Tue, 31 Aug 2021 21:04:40 +0100 Subject: [PATCH 2/2] Quick Tidy --- src/NetscriptFunctions.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/NetscriptFunctions.js b/src/NetscriptFunctions.js index ddec5b753..6f85f7c18 100644 --- a/src/NetscriptFunctions.js +++ b/src/NetscriptFunctions.js @@ -943,7 +943,6 @@ function NetscriptFunctions(workerScript) { if (fn = "ALL") { for (fn in possibleLogs) { workerScript.disableLogs[fn] = true; - } workerScript.log("disableLog", `Disabled logging for all functions`); } else if (possibleLogs[fn] === undefined) {