Re: api.log() does not output to node-inspector

35 views
Skip to first unread message
Message has been deleted

Justin

unread,
May 24, 2015, 3:32:20 AM5/24/15
to action...@googlegroups.com
*Weird, can't  seem to edit  my post. Here's a corrected version*

Hi!

In a nutshell, console.log() outputs fine in node-inspector and yet api.log() doesn't seem to.
I've left the default winston.transports.Console transport alone in logger.js.
Any thoughts?

Thanks :)
Justin

Evan Tahler

unread,
May 25, 2015, 12:43:14 PM5/25/15
to Justin, action...@googlegroups.com
What's node-inspector?  This package?

If that's the case, it looks like node-inspector only captures one of the methods node can express output (conosle.log), but none of the others (stderr, stdout, etc).  This is an "issue" with the node-inspector project, but I actually like their implementation (monkeypatching console.log), and I wouldn't suggest they change it.  console.log really should only be used for logging (so it's ok to patch), but the std* pipes may actually be used by your application to send data to other processes, so they shouldn't be messed with.

I also like Winston's choice to log via the std* pipes rather than use console.log, as it is a streaming API while conosle.log is blocking.  You don't want your production application blocking for a long log message! 

With these notes, I think you are out of luck here... it's also (IMO) a strange use case... are you attaching to a production process and trying to capture output that you aren't otherwise logging? 

Test Action:

exports.loggy = {
  name: 'loggy',
  description: 'loggy',
  run: function(api, data, next){
    console.log('CONSOLE');
    api.log('API. LOG');
    process.stderr.write('STDERR' + '\n');
    process.stdout.write('STDOUT' + '\n');
    next();
  }
};

Console:

Inline image 1

Inspector:

Inline image 2

--
You received this message because you are subscribed to the Google Groups "actionHero.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to actionhero-j...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Justin

unread,
May 25, 2015, 9:31:08 PM5/25/15
to action...@googlegroups.com, justin...@gmail.com
Hi Evan,

Thanks for the extensive explanation! I didn't realize winston.transports.Console and console.log had different implementations behind them.

I'm just trying to debug an application and with node-inspector, it's quite easy to inspect an object compared to outputting it in the console.
The same thing can be done via breakpoints/watch expressions so it's not actually a big deal; the node-inspector console just makes things a little bit faster.
In my OC head, I didn't want to be redundant putting in console.log and api.log at the same time.

Thanks again for the invaluable input!
Justin
Reply all
Reply to author
Forward
0 new messages