Is there anyway to get the formatted result that's printed when using
console.log?
I am trying to write a custom logger in JavaScript which wraps
console.log. I am supporting things like a shortened logging syntax,
prefixes, callbacks, etc. Currently I can do something like the following:
var debug = require('./debug');
var log = debug.getLogger({
prefix: '[Log]- ',
enabled: true
});
// ....
// The following log call prints: "[Log]- Current time is: 1378178552655"
// after which it then calls callback if the last arg is a function
log('Current time is: %o', Date.now(), callback);
Is there anyway to get the formatted text that console.log creates? For
example, with a statement like this:
console.log('[Log]- %s', 'Hello world');
// prints: '[Log]- Hello world', returns undefined
Is there anyway to get the final printed text that is created through the
printf style formatting?
No comments:
Post a Comment