arduino-ide/electron-app/arduino-ide-backend-main.js
Akos Kitta ec28623a97
fix: forward backend logging to electron (#2236)
Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
2023-09-26 09:45:03 +02:00

18 lines
555 B
JavaScript

// @ts-check
'use strict';
// `true` if the this (backend main) process has been forked.
if (process.send) {
const util = require('util');
for (const name of ['log', 'trace', 'debug', 'info', 'warn', 'error']) {
console[name] = function () {
// eslint-disable-next-line prefer-rest-params
const args = Object.values(arguments);
const message = util.format(...args);
process.send?.({ severity: name, message }); // send the log message to the parent process (electron main)
};
}
}
require('./src-gen/backend/main');