Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot log message when react app be loaded by electron #808

Closed
huyinghuan opened this issue Jan 13, 2021 · 6 comments
Closed

cannot log message when react app be loaded by electron #808

huyinghuan opened this issue Jan 13, 2021 · 6 comments
Labels
help-wanted This issue has an actionable item needs-documentation This issue or change requires additional documentation pr-welcome This issue has an approved change; a pull request would be appreciated

Comments

@huyinghuan
Copy link

I create a react app and use debug , debug(xxx) can work well on browser. but on electron user window.loadUrl("http://localhost:3000") load page, open electron dev tools, debug() cannot work.

code demo: https://github.com/huyinghuan/debug-issue

setup install deps:

cd $project
yarn install
cd ui
yarn install

run react app

cd $project
cd ui
yarn start

open browser, http://localhost:3000 in console debug work well.

run electron:
new terminal

cd $project
yarn start

when loaded page, in dev tools debug output nothing.

react app index.js:

import React from 'react';
import ReactDOM from 'react-dom';
import Debug from "debug";
const debug = Debug("ui:App");
localStorage.debug = "ui:*"
debug("hello")
ReactDOM.render(
  <React.StrictMode>
    <div className="App">
      debug test
    </div>
  </React.StrictMode>,
  document.getElementById('root')
);
@mqliutie
Copy link

兄弟, 咋解决的? 我这也是electron中不显示, localstorage也设置了, 甚至都主动设置了 enable = true 都不行

@mqliutie
Copy link

兄弟, 咋解决的? 我这也是electron中不显示, localstorage也设置了, 甚至都主动设置了 enable = true 都不行

原来 levels 要设置要把 Verbose 也选上

@gitname
Copy link
Contributor

gitname commented Feb 2, 2022

Thanks @mqliutie for posting your findings and @huyinghuan for reporting the issue.


For future readers, here's how I got it working:

  1. Open the Electron Developer Tools.

    image

  2. In the Electron Developer Tools: On the "Application" tab, expand the "Local Storage" item in the sidebar, then click on the URL in the list. Then, on the right side of the panel, create an item whose key is debug and whose value is * (you can change the value to something more restrictive once you get the baseline functionality working).

    image

  3. In the Electron Developer Tools: On the "Console" tab, click the "Levels" menu (its label might be "Default Levels," "Custom Levels," or "All Levels") and ensure there is a check mark next to the word, "Verbose" (you can click on the word to add/remove the check mark next to it).

    image

Now, the "Console" will show the messages logged via the debug package.

@Qix- Qix- reopened this Feb 2, 2022
@Qix- Qix- added help-wanted This issue has an actionable item needs-documentation This issue or change requires additional documentation pr-welcome This issue has an approved change; a pull request would be appreciated labels Feb 2, 2022
@Qix-
Copy link
Member

Qix- commented Feb 2, 2022

Yeah I guess it didn't occur to me that Verbose is off by default, and since we now use console.debug by default, this is going to hit a few people.

The localStorage stuff is indeed documented, but the call to enable Verbose logging is not. I would merge a PR if you (or someone) added that last screenshot (in #808 (comment)) to the README. 🙂

Good catch!

@gitname
Copy link
Contributor

gitname commented Feb 2, 2022

Thanks! I'll open a PR with it in a few minutes.

@gitname
Copy link
Contributor

gitname commented Feb 2, 2022

@Qix- , I opened a PR just now (linked above). Thanks for telling me about this package's use of console.debug, as that helped me include some context about the issue and screenshot in the README.

@Qix- Qix- closed this as completed Feb 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help-wanted This issue has an actionable item needs-documentation This issue or change requires additional documentation pr-welcome This issue has an approved change; a pull request would be appreciated
Development

No branches or pull requests

4 participants