node. JS V0.10.31API Manual-Console

Source: Internet
Author: User
Tags first string

Control Desk
    • Object

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 objUse util.inspectand output the resulting string to stdout. This function ignores objany 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

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.