Problem overriding console.log in Meteor

I wanted to add console.log to add timestamps and potentially other stuff later. For this I decided to use the npm package console-stamp - https://www.npmjs.com/package/console-stamp.

To do this I added a simple file server\mylog.js which just has -

require('console-stamp')(console);

btw the symptoms are same even if I do this manually using a pattern like -

const oldlog = console.log;
console.log = function......<call oldlog>

I deployed this version to my server and it works great. However running in dev mode doesn’t work, I now see a log -

LISTENING

and the app never starts.

I looked thru the Meteor source code and it seems it depends on some daemon outputting this string and the runner process listens to it - I don’t fully understand the whole flow.

To fix this, I simply surrounded the require above with an -

if (Meteor.isProduction) {....}

So whats the right way to do this?

const consoleLogOriginal = console.log;
console.log = function(){
  if(arguments.length === 1 && arguments[0] === 'LISTENING') {
    return consoleLogOriginal.call(console, 'LISTENING');
  }
  // do override
}