electron-log icon indicating copy to clipboard operation
electron-log copied to clipboard

Enabling IPC from renderer in prod

Open publicvirtualvoid opened this issue 3 years ago • 2 comments

Apologies if I'm missing something obvious, but I'm having a tough time figuring out how to enable the IPC transport from the renderer in a packaged application.

Setting the log level for the IPC transport in the renderer doesn't appear to work.

publicvirtualvoid avatar Jul 20 '22 02:07 publicvirtualvoid

Make sure you've set level for both main and renderer side

megahertz avatar Jul 20 '22 03:07 megahertz

This doesn't appear to make a difference for me. In main (main.ts):

logger.transports.file.level = 'silly';
(logger.transports.ipc as any).level = 'silly';
const log = logger.scope('main');

In renderer (main.tsx):

(logger.transports.ipc as any).level = 'silly';
logger.catchErrors({
  showDialog: false,
  onError: (e) => {
    logger.error(e);
  },
});
const log = logger.scope('ui');

Is there anything else I could try?

publicvirtualvoid avatar Jul 20 '22 03:07 publicvirtualvoid

having the same issue, does anyone have a hint of what's the easiest way to get electronLog to log the console from the renderer process ? it used to be as simple as:

console.log = electronLog.log;
Object.assign(console, electronLog.functions);

but with IPC you cannot pass objects directly or you get an Error: An object could not be cloned (as it should). Does that mean we cannot easily redirect console.log anymore or is there a trick?

Zhell1 avatar Oct 30 '22 18:10 Zhell1

@Zhell1 you've passed some type of object restricted by Structured Clone Algorithm. In the next version of electron-log such a type will be stringified.

megahertz avatar Oct 31 '22 05:10 megahertz

In v5 logs from a renderer process are always displayed in the main console.

megahertz avatar Nov 24 '22 13:11 megahertz

@Zhell1 you've passed some type of object restricted by Structured Clone Algorithm. In the next version of electron-log such a type will be stringified.

I'm using 5.0.0-beta.25, and have same error when I use "console.log". Is this fixed or not yet ?

cnhuye avatar Aug 09 '23 04:08 cnhuye

@cnhuye Could you provide an example?

megahertz avatar Aug 09 '23 04:08 megahertz