How do I record something to the console from a meteor rocket?

This issue GitHub reports that the console does not output anything to the meteor shell. Are there any workarounds? By default, all statements console.log()

will be output in the STDOUT application (not in the shell).

Let's say we want to print certain items from a collection:

Meteor.users.find().forEach(function (user) { 
    if (...) console.log(user.emails[0].address;
});

      

This won't print anything. Here's what I've tried:

  • process.stdout.write()

    - prints nothing
  • Create a string buffer, add what we want to write to it and evaluate it.

    var output = '';
    Meteor.users.find().forEach(function (user) {
        if (...)
            output += user.emails[0].address + "\n"
    });
    output;
    
          

    This works, but is \n

    reproduced literally, not as a string.

  • Evaluate the expression in the function. As expected, this doesn't print anything.
+3


source to share


1 answer


One workaround I have used is to start the application in the background and then start a shell in the same window. i.e.

meteor run &
meteor shell

      



This way, whatever is output to the application console is printed to your window. Admittedly, it won't help if you only want to log certain messages to your shell, but it does help if all you need is not to switch between different windows all the time.

+2


source







All Articles