Control Desk
Used to print characters to stdout and stderr. Similar to the console object functions provided by most WEB browsers, here is the output to stdout or stderr.
When the output target is a terminal or a file, the console function is synchronized (to prevent the loss of information in case of premature exit). They are asynchronous when the output target is a pipe (prevents blocking for too long).
In other words, in the following example, stdout is non-blocking, while stderr is blocked.
$ node Script JS 2 > error Log | tee info Log
in daily use, you don't need to worry too much about blocking/non-blocking differences unless you need to log large amounts of data.
Console.log ([data], [...])Print to stdout and start a new line. This function can be like
printf()
that takes multiple parameters, such as:
console log ( " Count:%d ' count"
If a formatting element is not found in the first string, then util.inspect
will be applied to each parameter. See Util.format ().
Console.info ([data], [...])with
console.log
.
Console.error ([data], [...])with
console.log
, but output to stderr.
Console.warn ([data], [...])with
console.error
.
Console.dir (obj)the
obj
Use
util.inspect
and output the resulting string to stdout. This function ignores
obj
any customizations on the
inspect()
.
Console.time (label) marks the time.
Console.timeend (label)End timer, record output. Example:
Console. Time(' 100-elements '); for (varI= 0;I< -;I++) { ;}Console.Timeend(' 100-elements ');
Console.trace (message, [...])output stderr through formatted messages and stack traces to the current location
‘Trace :‘
.
Console.assert (value, [message], [...])with theAssert.ok ()same, but error messages use
util.format(message...)
to format.
node. JS V0.10.31API Manual-Console