* The file descriptor to write the `debug()` calls to.
* Set the `DEBUG_FD` env variable to override with another value. i.e.:
*
* $ DEBUG_FD=3 node script.js 3>debug.log
*/
varfd=parseInt(process.env.DEBUG_FD,10)||2;
if(1!==fd&&2!==fd){
util.deprecate(function(){},'except for stderr(2) and stdout(1), any other usage of DEBUG_FD is deprecated. Override debug.log if you want to use a different log function (https://git.io/debug_fd)')()
}
varstream=1===fd ? process.stdout :
2===fd ? process.stderr :
createWritableStdioStream(fd);
/**
* Is stdout a TTY? Colored output is enabled when `true`.
*/
functionuseColors(){
return'colors'inexports.inspectOpts
? Boolean(exports.inspectOpts.colors)
: tty.isatty(fd);
}
/**
* Map %o to `util.inspect()`, all on a single line.
*/
exports.formatters.o=function(v){
this.inspectOpts.colors=this.useColors;
returnutil.inspect(v,this.inspectOpts)
.split('\n').map(function(str){
returnstr.trim()
}).join(' ');
};
/**
* Map %o to `util.inspect()`, allowing multiple lines if needed.