xplat
xplat copied to clipboard
Electron Main Process logging.
It seems that console.log('Test main process'); inside main process located in: xplat-project/apps/electron-app/src/index.ts is not outputting anything to terminal.
@dmitryr117 if you open the electron dev tools do you see it in the console?
@NathanWalker logging in dev tools works ok for the front end code. However when I create a main process hook inside project/apps/electron-project/src/index.ts and say add a hook like this:
function initMainListener() {
ipcMain.on('ELECTRON_BRIDGE_HOST', (event, msg) => {
console.log('msg received', msg);
if (msg === 'ping') {
dialog.showErrorBox('error', `content`);
event.sender.send('ELECTRON_BRIDGE_CLIENT', 'pong');
}
});
ipcMain.on('OPEN_DIALOG', (event, msg) => {
console.log('msg received');
//dialog.showErrorBox('error', `content ${msg}`);
event.sender.send('ELECTRON_BRIDGE_CLIENT', 'pong');
});
}
The console.log does not output anything in the main terminal. Main terminal just shows the Angular compilation data. I am not sure what to do to have that node terminal although I suspect that in this case 2 terminals will need to be opened. One to watch for project compilation and another to serve Electron. Or another option that I am using for now is I send some data to the front end with event.sender.send() method. Then I can console.log() it there and at that point I can see it with dev tools.
Now for anyone reading this thread and having interest in electron ipcMain hooks:
Important. When editing code in project/apps/electron-project/src/index.ts always Ctrl-C your terminal and rebuild project using npm run start.electron.appname otherwise your new ipcMain hooks will not work.