console
- {Object}
The console functions are synchronous when the destination is a terminal or
a file (to avoid lost messages in case of premature exit) and asynchronous
when it’s a pipe (to avoid blocking for long periods of time).
That is, in the following example, stdout is non-blocking while stderr
is blocking:
In daily use, the blocking/non-blocking dichotomy is not something you
should worry about unless you log huge amounts of data.
Prints to stdout with newline. This function can take multiple arguments in a
-like way. Example:
console.info([data][, …])
Same as console.log
.
console.error([data][, …])
Same as console.log
but prints to stderr.
Same as console.error
.
console.dir(obj[, options])
Uses util.inspect
on obj
and prints resulting string to stdout. This function
bypasses any custom function on obj
. An optional options object
may be passed that alters certain aspects of the formatted string:
colors
- iftrue
, then the output will be styled with ANSI color codes.
Defaults tofalse
. Colors are customizable, see below.
console.time(label)
Mark a time.
Finish timer, record output. Example:
console.trace(message[, …])
console.assert(value[, message][, …])
Similar to assert.ok(), but the error message is formatted asutil.format(message...)
.