Giter Site home page Giter Site logo

Logging? about electron-with-create-react-app HOT 4 CLOSED

csepulv avatar csepulv commented on August 20, 2024 1
Logging?

from electron-with-create-react-app.

Comments (4)

csepulv avatar csepulv commented on August 20, 2024

Unfortunately I don't know. I've never tried logging from the bootstrap script that loads the window.

What do you need to log that isn't loggable elsewhere?

from electron-with-create-react-app.

sebassdc avatar sebassdc commented on August 20, 2024

i think its beacause the server is constantly realoading and re-renders everything
im triying a simple ipc comunication and i dont know how to manually test it. How can i stop server and hot reloading?

from electron-with-create-react-app.

csepulv avatar csepulv commented on August 20, 2024

You probably need to eject your app, as the hot reloading it part of create-react-app.

from electron-with-create-react-app.

pikiaboy avatar pikiaboy commented on August 20, 2024

There is no logging from electron-starter.js because if you take a look at electron-wait-react.js, you can see that electron is actually being called from a child_process via exec. Because of this, the logging goes to a buffer that we have to provide in a callback. However, this gets really inefficient, as you'd have to close the electron app each time to check the logging.

The best way I've found to fix this issue would be to run electron from a child_process.spawn(). This way, we can bind the stdout of the child_process and log it right away.

`onst tryConnection = () => client.connect({port: port}, () => {
client.end();
if(!startedElectron) {
console.log('starting electron');
startedElectron = true;

        const { spawn } = require('child_process');
        const child = spawn('npm', ['run', 'electron']);
        child.stdout.on('data', (data) => {
            console.log(`child stdout: ${data}`);
          });
          
          child.stderr.on('data', (data) => {
            console.error(`child stderr: ${data}`);
          });
          child.on('exit', function (code, signal) {
            console.log('child process exited with ' +
                        `code ${code} and signal ${signal}`);
          });



        // const exec = require('child_process').exec;

        // exec('npm run electron',(error,stdout,stderr) => {
        //     console.log(stdout);
        // });
    }
}

);`

from electron-with-create-react-app.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.