3

For logging to console for node.js, currently I do

var log = function(msg)
{
  var util = require('util');
  console.log('some prefix(like "core-module")---------'),
  console.log(util.inspect(msg,
  {
    depth: 99,
    colors: true
  }));
};

In this manner, object depth is logged correctly. If I do,

console.log('some-module: '+ 
util.inspect(msg,
      {
        depth: 99,
        colors: true
      })
) 

Although this is logged as a single line, but since the content becomes String, the object depth is presented merely [object] which is not good.

So, my question here is is there any way to console.log in a single line as

'some-prefix: '+ detailed log?

In another words, is it possible to suppress new-line after console.log?

Thanks.

1 Answers1

3

Ok, I do

var log = function(msg)
{
  var util = require('util');
  process.stdout.write('CORE: ');
  process.stdout.write(util.inspect(msg,
  {
    depth: 99,
    colors: true
  }));
  process.stdout.write('\n');
};