Closed FlyBooks closed 8 months ago
code from electron-log/main shouldn't be used in the preload script.
Really appreciated for your hint! So i just use the __ELECTRON_LOG__ in the ipcRenderer
electronLoggingRecord: (logContent: string) => {
ipcRenderer.send('__ELECTRON_LOG__', {
data: [logContent],
level: 'information',
scope: "user"
});
}
main.ts:
app.whenReady().then(() => {
createWindow();
// electron-log
log.initialize();
log.addLevel("critical");
log.addLevel("warning", 1);
log.addLevel("information", 3);
});
It works and is that a recommended way in electron-log?
Yes, that's fine. The only hint is to call the code in main.ts without waiting for the ready event.
Hello~, Could you please give me some hints ? logging-util/index.ts:
Those code will be executed in file preload.js.
But it always runs failed with error: Error: Attempted to register a second handler for '__ELECTRON_LOG__' at IpcMainImpl.handle (node:electron/js2c/browser_init:2:105646) at ElectronExternalApi.onIpcInvoke (C:\projects\Hummingbird\dist-electron\main\index.js:523:94) at Object. (C:\projects\Hummingbird\dist-electron\main\index.js:2060:13)
Thanks a lot in advance! Eva