Open akshaygarg834 opened 7 years ago
You can use IPC to send a message to the main process to log messages to it, e.g. via:
Background window
const electron = require('electron');
const ipcRenderer = electron.ipcRenderer;
let log = function(message) {
ipcRenderer.send('worker-message', message);
};
log('Hello world');
Main process
ipcMain.on('worker-message', (e, message) => console.log(message));
You could also pipe it to the developer tools console of the main window via:
Main process
ipcMain.on('worker-message', function(e, message) {
mainWindow.webContents.send('worker-message', message);
});
Main window
const electron = require('electron');
const ipcRenderer = electron.ipcRenderer;
ipcRenderer.on('worker-message', (event, message) => console.log(message));
You can also see this stack overflow topic for ways to write to stdout in the main process.
Console.log in background process not working. You can't see a single output out of it. How to debug it? Is there a way to change stdout of this bakground process to main process stdout so that all console.log() of background process start show in main process console.