avoid double logging in debug console (#6827)

Daniel Hammerschmidt committed Feb 27, 2025 at 19:23 UTC 9df033089641ff9f15a4bbf8ec050e00e0968873
1 file changed +4 -2
meshcentral.js
+4 -2
@@ -583,6 +583,8 @@ function CreateMeshCentralServer(config, args) {
583 // Launch MeshCentral as a child server and monitor it.
584 obj.launchChildServer = function (startArgs) {
585 const child_process = require('child_process');
586 + const isInspectorAttached = (()=> { try { return require('node:inspector').url() !== undefined; } catch (_) { return false; } }).call();
587 + const logFromChildProcess = isInspectorAttached ? () => {} : console.log.bind(console);
588 try { if (process.traceDeprecation === true) { startArgs.unshift('--trace-deprecation'); } } catch (ex) { }
589 try { if (process.traceProcessWarnings === true) { startArgs.unshift('--trace-warnings'); } } catch (ex) { }
590 if (startArgs[0] != "--disable-proto=delete") startArgs.unshift("--disable-proto=delete")
@@ -657,12 +659,12 @@ function CreateMeshCentralServer(config, args) {
659 else if (data.indexOf('Starting self upgrade to: ') >= 0) { obj.args.specificupdate = data.substring(26).split('\r')[0].split('\n')[0]; childProcess.xrestart = 3; }
660 var datastr = data;
661 while (datastr.endsWith('\r') || datastr.endsWith('\n')) { datastr = datastr.substring(0, datastr.length - 1); }
660 - console.log(datastr);
662 + logFromChildProcess(datastr);
663 });
664 childProcess.stderr.on('data', function (data) {
665 var datastr = data;
666 while (datastr.endsWith('\r') || datastr.endsWith('\n')) { datastr = datastr.substring(0, datastr.length - 1); }
665 - console.log('ERR: ' + datastr);
667 + logFromChildProcess('ERR: ' + datastr);
668 if (data.startsWith('le.challenges[tls-sni-01].loopback')) { return; } // Ignore this error output from GreenLock
669 if (data[data.length - 1] == '\n') { data = data.substring(0, data.length - 1); }
670 obj.logError(data);