Skip to content

Instantly share code, notes, and snippets.

@gabrielhpugliese
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gabrielhpugliese/4c2b7de33ad1495ae6f8 to your computer and use it in GitHub Desktop.
Save gabrielhpugliese/4c2b7de33ad1495ae6f8 to your computer and use it in GitHub Desktop.
Logentries guest post

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: http://docs.meteor.com/#/full/reactivity).

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: meteor/meteor#284

So here comes the logentries package to the rescue. Follow these few step install it on your app:

  1. Inside your project folder:

     meteor add gabrielhpugliese:logentries
    
  2. 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'
     });
    
  3. 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment