megahertz / electron-log

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

Electronforge + Webpack + preload.js script rise an error #383

Closed xavier7179 closed 8 months ago

xavier7179 commented 9 months ago

Due to some issues with the logs working in the renderer with an electronforge-based app, I moved from version 4 to 5. Unfortunately, with the current setup, I cannot start the application because I always get the following error:

Error: electron-log isn't initialized in the main process. Please call log.initialize() before. Error invoking remote method '__ELECTRON_LOG__': No handler registered for '__ELECTRON_LOG__'

I though the problem was that the app was starting with a preload.js script to export some IPC to the renderer, but I checked all available documentation but needed help finding a working solution.

megahertz commented 9 months ago

It should work fine with default settings. The only known case when it doesn't work is when using a custom session. Could you create a sample project that reproduces the issue?

xavier7179 commented 9 months ago

I'm trying to... but it's not easy as I have a rather big and complex project, but I confirm that with the bare project out of the electronforge cli is working.

In my case, a further investigation clarifies that it works on the main process (I see a couple of logs I placed when the app starts) but then on the render it generates the error

megahertz commented 8 months ago

Try to use the latest version. If that isn't helpful, please provide an example that reproduces the issue, and I'll reopen the issue.