megahertz / electron-log

Simple logging module Electron/Node.js/NW.js application. No dependencies. No complicated configuration.
MIT License
1.32k stars 128 forks source link

Main process IPC transport is not initialised #395

Closed BTMorton closed 10 months ago

BTMorton commented 10 months ago

I've just updated to electron-log v5 and noticed that the main process logs aren't being forwarded to the renderer. I tried setting the log level as per the docs using:

log.transports.ipc.level  = 'silly';

but I get an undefined error:

TypeError: Cannot set properties of undefined (setting 'level')

I noticed that the IPC factory is not set when creating the default logger, so I tried manually instantiating the IPC transport explicitly and setting the level:

import * as ipcTransport from 'electron-log/src/main/transports/ipc';
...
log.transports.ipc = ipcTransport(log, log.dependencies);
log.transports.ipc.level  = 'silly';

which does forward the main process logs correctly, but also results in the renderer logs being printed twice. as the renderer logs are re-forwarded back to the renderer as a main process log.

I guess I have two questions:

  1. Is the IPC transport main -> renderer still supported or has there been a decision to deprecate it?
  2. How does the IPC forwarding of server logs work and is there something that can be done on my side to resolve the duplicate log issue?
megahertz commented 10 months ago

That will be fixed in v5.1, which I will release in 2-3 weeks. I think there's no way to fix that on your side before the release.