mirror of
https://github.com/debug-js/debug.git
synced 2026-01-18 16:12:38 +00:00
node: map "%o" to util.inspect()
This commit is contained in:
parent
84951941a8
commit
b38496e03b
11
node.js
11
node.js
@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
var tty = require('tty');
|
||||
var util = require('util');
|
||||
|
||||
/**
|
||||
* This is the Node.js implementation of `debug()`.
|
||||
@ -34,6 +35,16 @@ var prevColor = 0;
|
||||
|
||||
var useColors = tty.isatty(1) || process.env.DEBUG_COLORS;
|
||||
|
||||
/**
|
||||
* Map %o to `util.inspect()`, since Node doesn't do that out of the box.
|
||||
*/
|
||||
|
||||
exports.formatters.o = function(v) {
|
||||
var str = (useColors ? '\u001b[0m' : '')
|
||||
+ util.inspect(v, { colors: useColors }).replace(/\s*\n\s*/g, ' ');
|
||||
return str;
|
||||
};
|
||||
|
||||
/**
|
||||
* Select a color.
|
||||
*
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user