Recent Changes - Search:

edit SideBar


The console module is a JavaScript module for outputting messages. This implementation is designed to be compatible with the console module in Node.js. It requires the util module. Because this is a built-in module for accessors that subclass JSAccessor, there is no need to specify a requires tag in the interface specification. A simple use of the module in an accessor might look like this: = function() {
    var value = get(input);
    console.log('Input value is: %d', value);

The functions provided in this module are:

  • console.log(...): Print a message. This may go to stdout or to any other output appropriate for the particular accessor host. The first argument can be a printf-style formatting string, followed by arguments to insert into the output, as in the example above. If the first string does not contain any formatting elements, then util.inspect() is applied to all arguments to convert them to strings.
  • Same as log().
  • console.error(...): Same as log(), but the message is prefixed with "ERROR: " and sent to stderr (or some other suitable destination).
  • console.warn(...): Same as log(), but the message is prefixed with "WARNING: " and sent to stderr (or some other suitable destination).
  • console.dir(object, options): Apply util.inspect() to the specified object (possibly with options) and then report as done by log(). The optional options argument is an object that may contain the following fields:
    • showHidden - if true then non-enumerable properties will be shown as well. Defaults to false.
    • depth - tells inspect how many times to recurse while formatting the object. Defaults to 2. Use null to get unbounded depth.
    • colors - if true, then the output will be styled with ANSI color codes. Defaults to false.
    • customInspect - if false, then custom inspect() functions defined on the objects being inspected won't be called. Defaults to true.
  • console.time(label): Record the current time using the specified label for use by a later call to timeEnd().
  • console.timeEnd(label): Log the time elapsed since the last call to time(label) that gave the same label (using the log() function to report the time).
  • console.trace(...): Send a stack trace to stderr or some other suitable output prefixed by "TRACE: " and any supplied message formatted as with the log() function.
  • console.assert(assertion, message): If the first argument is not "truthy", then throw an error that includes a (formatted) message given by the remaining arguments.

Back to Built-In JavaScript Modules

Edit - History - Print - Recent Changes - Search
Page last modified on May 02, 2015, at 09:21 PM