Class: Console
The
Console class can be used to create a simple logger with configurable output streams and can be accessed using either require('console').Console or console.Console:const Console = require('console').Console;
const Console = console.Console;
new Console(stdout[, stderr])
Creates a new
Console by passing one or two writable stream instances. stdout is a writable stream to print log or info output. stderr is used for warning or error output. If stderr isn't passed, warning and error output will be sent to stdout.const output = fs.createWriteStream('./stdout.log');
const errorOutput = fs.createWriteStream('./stderr.log');
// custom simple logger
const logger = new Console(output, errorOutput);
// use it like console
var count = 5;
logger.log('count: %d', count);
// in stdout.log: count 5
The global
new Console(process.stdout, process.stderr);console is a special Console whose output is sent to process.stdout and process.stderr. It is equivalent to calling:
댓글 없음:
댓글 쓰기