Tuesday, 29 May 2018

009 Node.js Console

The console module provides a debugging console that is similar to the JavaScript console mechanism works in web browsers.

  • console.log([data][, ...])
          Prints to stdout with newline. Multiple arguments can be passed,first used as the primary message and all additional used as substitution values.

Example (main.js)

console.log('hello world');
console.log('hello %s', 'world');


Output :











  • console.info([data][, ...])
         The console.info() function is alias for console.log().
Prints to stdout with newline with Optional Multiple arguments.


Example (main.js)

console.info('Hi,I am learing node.js');

Output :









  • console.error([data][, ...])
         Prints to stderr with newline. Multiple arguments can be passed ,first used as the primary message and all additional used as substitution values.




Example (main.js)

console.error(new Error('Hi,I am learing node.js'));

Output :












  • console.warn([data][, ...])
          The console.warn() function is alias for console.error().
Prints to stderr with newline. Multiple arguments can be passed,
first used as the primary message and all additional used as substitution values.

Example (main.js)

console.warn('Hi,I am learing node.js');

Output :








  • console.dir(obj[, options])
       Uses util.inspect on obj and prints resulting string to stdout.

 





  • console.time(label)
        Starts a timer that can be used to compute the duration of an operation.

 




  • console.timeEnd(label)
Finish timer. Example (main.js)

console.time('myTimeExample');

//Your Statement

console.timeEnd('myTimeExample');


Output :










  • console.trace(message[, ...])
      Print to stderr 'Trace :', followed by the formatted message and stack trace to the current position with util.format().

Example (main.js)

console.trace("I am learning nodejs");

Output :








  • console.assert(value[, message][, ...])
 Similar to assert.ok(), but the error message is formatted as util.format(message...).
 


  • console.dirxml(...data)
      This method calls console.log() passing it the arguments received. Please note that this method does not produce any XML formatting.




No comments:

Post a Comment

বাঙালির বেড়ানো সেরা চারটি ঠিকানা

  বাঙালি মানে ঘোড়া পাগল | দু একদিন ছুটি পেলো মানে বাঙালি চলল ঘুরতে | সে সমুদ্রই হোক , পাহাড়ি হোক বা নদী হোক। বাঙালির ...