node. JS Api--console (console)

Source: Internet
Author: User
Tags first string

//Descriptionthe Node API version is v0.10.31.
Chinese Reference: Http://blog.sina.com.cn/oleoneoythis Keweibo main note.
Directory Control Desk
0 Console.log ([data], [...])
0 Console.info ([data], [...])
0 Console.error ([data], [...])
0 Console.warn ([data], [...])
0 console.dir (obj)
0 console.time (label)
0 console.timeend (label)
0 console.trace (message, [...])
0 Console.assert (value, [message], [...]) Control Desk

Stability: 4-api freeze

Object
Used to print to standard output and standard error output. Similar to the console object functions provided by most web browsers, the output here is also sent to standard output and standard error output.
When the output target is a terminal or a file, the console functions are synchronized (in case of premature exit of lost information), and when the target is a pipe, it is asynchronous (in case of prolonged blocking).
Therefore, in the following example, the standard output is non-blocking and the standard error output is blocked.

1 2 Tee info. log

In everyday use, the difference between blocking and non-blocking is not something you should worry about unless you record huge amounts of data.

Console.log ([data], [...])

Prints another line to the standard output. This function can use printf () to take multiple parameters in a similar way. For example:

1 console.log (' Count:%d ', count);

If the first string argument is not a formatted string, Util.inspect is applied to each parameter. See Util.format ()for more information.
In fact, when encountering the first parameter that cannot be passed into a formatted string, all its arguments are converted to a string using Util.inspect, separated by a space.
%d is the output integer,%s is the output string,%j is the string format of the output JSON

Console.info ([data], [...])

Same as Console.log .

Console.error ([data], [...])

Same as Console.log , just print to standard error output.

Console.warn ([data], [...])

Same as Console.error .

Console.dir (obj)

Use util.inspect for obj and print the resulting string to the standard output.

Console.time (label)

Mark a time.

Console.timeend (label)

End a timer and record the output. Example:

1 console.time (' 100-elements '); 2  for (var i = 0; i <; i++) {3    ; 4 }5 console.timeend (' 100-elements ');
Console.trace (message, [...])

Print formatted information and the current position of the stack information to the standard error output, the above output immediately after the ' Trace: ' .

Console.assert (value, [message], [...])

Similar to Assert.ok (), but the error message is formatted using util.format (Message ...) .

node. JS Api--console (console)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.