question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cannot log message when react app be loaded by electron

See original GitHub issue

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')
);

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
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 https://github.com/debug-js/debug/issues/808#issuecomment-1027516372) to the README. 🙂

Good catch!

0reactions
gitnamecommented, 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Electron React app not getting same instance of the logger as ...
I log a message from main.js and it appears in the log file and the console ... Do you load electron-log by the...
Read more >
Electron React : Unable to view console log from react
The react app having console logs however not able to view the logs anywhere. how do I view these log messages.
Read more >
Build a Secure Desktop App with Electron Forge and React
In this article, we'll create a simple desktop application using Electron and React. It will be a small text editor called “scratchpad” that ......
Read more >
Electron with React JS under 40 min! - YouTube
Your browser can't play this video. Learn more.
Read more >
Building an Electron application with create-react-app
I recently built an Electron app using create-react-app. I didn't need to muck about with Webpack, or “eject” my app, either.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found