From b4a4dfea8b8822e0cbab1e70d2b8d4009a9619bd Mon Sep 17 00:00:00 2001
From: Roman Azarenko <roman.azarenko@iopsys.eu>
Date: Thu, 23 Jun 2022 10:47:20 +0200
Subject: [PATCH] quickjs: remove console.log calls in async-mqtt.js

console.log outputs to stdout. This breaks CLI tools, which use stdout for outputting response JSON data.

QuickJS doesn't support console.warn/console.error. Printing to stderr can be achieved with `std.err.puts()` or
`std.err.printf()`.

Alternatively, this kind of output should be put behind a verbose/debug flag.
---
 src/configurations/quickjs/async-mqtt.js | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/configurations/quickjs/async-mqtt.js b/src/configurations/quickjs/async-mqtt.js
index 7c4a54a..cbdfa9f 100644
--- a/src/configurations/quickjs/async-mqtt.js
+++ b/src/configurations/quickjs/async-mqtt.js
@@ -18,13 +18,10 @@ class AsyncClient {
     protobuf.Root.prototype.fetch = function (filename, callback) {
       os.setTimeout(function () {
         const data = std.loadFile(filename);
-        if (data === null) {
-          console.log("failed to load file: " + filename);
+        if (data === null)
           callback(new Error("failed to load file: " + filename));
-        } else {
-          //console.log(`data loaded for ${filename}`)
+        else
           callback(null, data);
-        }
       }, 0);
     };
   }
@@ -82,7 +79,6 @@ class AsyncClient {
       // there is no erro handling in paho mqtt
       this.client.onConnectionLost = function (responseObject) {
         callback(responseObject);
-        console.log("USP Disconnected: ", responseObject.errorMessage);
       };
     }
   }
-- 
GitLab