console.log('delay is %s', chalk.green(delay));
where as it's much clearer to say
console.log('delay is', chalk.green(delay));
This works in node as of at least v0.10.33 and chrome, but probably most modern browsers.
console.log('delay is %s', chalk.green(delay));
where as it's much clearer to say
console.log('delay is', chalk.green(delay));
This works in node as of at least v0.10.33 and chrome, but probably most modern browsers.
console.log('delay is ' + chalk.green(delay)));
as it is more consistent with non console.log expressions. For example, just with copy/paste I could replace the above with:
var msg = 'delay is ' + chalk.green(delay); console.log(msg);
But it's really just a matter of preference as long as only one convention is used throughout the same codebase.
console.log(`delay is ${ chalk.green(delay) }`);The prolem with using console.log(object) is that in Node.js the object is not stringified and on browsers the debugger displays the current state of the object, not the state when it was printed. I found that out the hard way..
And when you're using your own logging function you can use a proper logging framework like winston to save the logs to a database and a file in addition to the console (we also send client-side logs to the backend using socket.io for easy debugging).
> console.log('hello', 'world')
hello world
undefined
>
:)That said... I still prefer the format string.
Shameless plug (co-author here), but if you have any questions about it: feel free to ask.