Giter Club home page Giter Club logo

Comments (10)

megahertz avatar megahertz commented on August 25, 2024

You call log.info when BrowserWindow is still creating. If you would like to see this log record in dev tools you should wrap this code into setTimeout with timeout 300-500ms.

from electron-log.

qual avatar qual commented on August 25, 2024

@megahertz I have tried that as well. Its not working. I have tried putting log configuration post window creation as well where its giving me error.

Could you please check if there is issue in my code. Here is the link to my code: https://gist.github.com/qual/61907d22db5956014055890b88e473c4

from electron-log.

megahertz avatar megahertz commented on August 25, 2024

You shouldn't configure logger inside timeout. Try this:

let i = 0;
setInterval(() => {
  log.info(`Logging from the main process #{i}`);
}, 300);

from electron-log.

qual avatar qual commented on August 25, 2024

Just tried. Its still not working. Node console logs are working properly. But not a single log has appeared in in chrome renderer console.
JFYI, I am using electron-prebuilt-compile and react js. Can this cause any issue to renderer logs ?

from electron-log.

megahertz avatar megahertz commented on August 25, 2024

from electron-log.

qual avatar qual commented on August 25, 2024

Not sure if I understand what you are saying. If your asking about whether I have included require statement in my renderer.js files, then I am actually exposing the global log object to all the renderer processes. so I am not doing multiple requires in my renderer.js files (renderer process)

from electron-log.

megahertz avatar megahertz commented on August 25, 2024

Pls show me a part of your renderer code

from electron-log.

qual avatar qual commented on August 25, 2024
  1. Just to summarize I am declaring and exporting log module in main process as follows:
    let log = require('electron-log');
    log.info('hello from main');
    global.logger = log; //export

  2. I am importing the same log module in renderer process as follows
    let log = require('electron').remote.getGlobal('logger');
    log.info('hello from renderer');

Any issue in above code ?

from electron-log.

megahertz avatar megahertz commented on August 25, 2024

That's why it doesn't work. You need to import electron-log directly, not through remote

from electron-log.

qual avatar qual commented on August 25, 2024

Oh. My bad. I incorrectly assumed that I will have to share the same log instance across renderer processes using remote. But looks like it is taking the same log instance across main and renderer.

Now I have fixed the code. Now its working as a charm everywhere in node console, file and renderer console !

This library is extremely useful ! Thanks a lot @megahertz for your prompt help !

from electron-log.

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.