Comments (10)
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.
@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.
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.
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.
from electron-log.
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.
Pls show me a part of your renderer code
from electron-log.
-
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 -
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.
That's why it doesn't work. You need to import electron-log directly, not through remote
from electron-log.
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)
- How to output renderer log to custom filePath
- Environment variable for log.transports.console.level? HOT 3
- Error when calling readAllLogs
- 5.1.4 (and 5.1.3) missing from NPM HOT 1
- log.transport.file not accessible in Angular app HOT 1
- Can not log when `undefined` return by getAppName() HOT 2
- [possible malware alert] forked package `log-electron` contains a possibly-malicious payload loader. HOT 1
- Packaged log output
- Got a error "data.map is not a function" when I custom a transport.file.format. HOT 1
- logRender cannot write log to file. HOT 1
- How to disable scope padding? HOT 1
- Log rotation overrride old log files HOT 2
- Add ability to configure electron-log via a config object HOT 5
- "electron-log: logger isn't initialized in the main process" error in browser console HOT 6
- [Node] File transport - variables not interpolated? HOT 1
- Unable to restrict the log file permissions HOT 1
- Issues with transport format functions and lack of clear documentation HOT 1
- Electron Events (eventLogger) Handler Arguments are undefined. HOT 3
- Add a `getScope` method to scoped loggers HOT 1
- Cannot use `electron-log/preload` in preload script HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from electron-log.