Synchronous Writing to Output Streams

A useful feature of the util module is the ability to write data out to stdout and stderr synchronously, which means blocking the process until the data is written out. This allows you to ensure that when the data is written, the system wasn’t in the act of changing it.

To synchronously write data out, you can use one of the following calls, each of which blocks the process until the write completes:

Image util.debug(string): Writes the string out to stderr.

Image util.error([...]): Accepts multiple arguments and writes them out to stderr. For example:

util.error(errorCode, "errorname");

Image util.puts([...]): Accepts multiple arguments and writes them out to stdout.

Image util.print([...]): Accepts multiple arguments, converts each one to a string, and then writes them out to stdout.

Image util.log(string): Writes the string out to stdout, along with a timestamp. For example:

util.log('Some message.'),  //  30 Nov 13:26:20 - Some message.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.225.98.18