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

[bugs] logger levels not defined in electron-log/renderer #354

Closed susanforme closed 1 year ago

susanforme commented 1 year ago
  1. in my renderer process
    
    import log from 'electron-log/renderer';
    const render = log.scope('render');
    Object.assign(console, render);

There was no error during development, but the following error occurred during packaging

![image](https://user-images.githubusercontent.com/51266600/226563508-e31a06c2-a6e1-45a0-9e00-b24fdffbe5f4.png)

I got the following message through debugger
![image](https://user-images.githubusercontent.com/51266600/226563691-9efffff3-941e-490c-9729-c10d0a0c6611.png)

The params of scope are taken from global, and global has no levels that cause a toss error
![image](https://user-images.githubusercontent.com/51266600/226563980-22eea419-14ea-4700-bc03-dfc335091d28.png)

so,Is there a solution ,thx

This is my info
os -> windows11
electron -> 21.3.3
electron-log -> 5.0.0-beta.16

main.ts
```ts
    const mainWindow = new BrowserWindow({
      width: 900,
      height: 670,
      show: false,
      autoHideMenuBar: true,
      ...(process.platform === 'linux' ? { icon } : {}),
      webPreferences: {
        preload: join(__dirname, '../preload/index.js'),
        sandbox: false,
        // devTools: isDev,
      },
    });
megahertz commented 1 year ago

Thank you for the detailed report. Will try to make a fix on this week.

megahertz commented 1 year ago

@susanforme Could you try v5.0.0-beta.20? I think it fixes the issue. If not, please provide your bundler config. I can't reproduce the issue.