Last updated at Mon, 06 Nov 2017 18:35:40 GMT
This blog post is written by Logentries customer Gabriel Pugliese, Founder and developer of CodersTV.
There are a lot of implicit computation going on with Meteor’s reactivity. Tracker, Session variables, Cursors, Templates etc. They create lots of implicit recalculations that we can easily lose their tails and create a seven-headed dragon that will haunt you! For me, the immediate valuable technique is logging everything that is going to recompute on reactive data contexts (see more here).
On CodersTV, I’m starting to send my logs to Logentries, from both client and server. It is useful if you don’t want to care about log rotation and other hard disk concerns on small machines. Also valuable if you have a balancer with autoscale and need to send logs to the same entry point. Or maybe if you are using meteor.com server, where it is most valuable.
On Meteor’s servers, you can access your logs running the command meteor logs <site>.meteor.com
, but it will give you only the latest logs and you can’t tail it making it a hell to cross old and new logs information. In Meteor’s repo, tailing the logs is a closed feature request:https://github.com/meteor/meteor/issues/284
So here comes the logentries package to the rescue. Follow these few step install it on your app:
- Inside your project folder:
meteor add gabrielhpugliese:logentries
- On your server/lib/ folder, create a file called logentries.js with the content (change YOUR_TOKEN_HERE to your logentries token):
le_meteor = logentries.logger({
token: 'YOUR_TOKEN_HERE'
});
- Pronto! You have access to the log variable that will work on client, server or even on your Cordova app:
log.log('info', 'Worked!!');
Meteor.subscribe('myPublication', function () {
log.log('info', 'Subscribed to myPublication');
});
Tracker.autorun(function () {
Session.get('someVar');
log.log('info', 'Recomputed data context X');
});
If you have any questions or feedback, you can send me a tweet (@gabrielsapo) or open a Github issue here.