{ "source": "doc/api/console.markdown", "globals": [ { "textRaw": "console", "name": "console", "stability": 4, "stabilityText": "API Frozen", "type": "global", "desc": "

For printing to stdout and stderr. Similar to the console object functions\nprovided by most web browsers, here the output is sent to stdout or stderr.\n\n

\n

The console functions are synchronous when the destination is a terminal or\na file (to avoid lost messages in case of premature exit) and asynchronous\nwhen it's a pipe (to avoid blocking for long periods of time).\n\n

\n

That is, in the following example, stdout is non-blocking while stderr\nis blocking:\n\n

\n
$ node script.js 2> error.log | tee info.log
\n

In daily use, the blocking/non-blocking dichotomy is not something you\nshould worry about unless you log huge amounts of data.\n\n\n

\n", "methods": [ { "textRaw": "console.log([data][, ...])", "type": "method", "name": "log", "desc": "

Prints to stdout with newline. This function can take multiple arguments in a\nprintf()-like way. Example:\n\n

\n
var count = 5;\nconsole.log('count: %d', count);\n// prints 'count: 5'
\n

If formatting elements are not found in the first string then util.inspect\nis used on each argument. See [util.format()][] for more information.\n\n

\n", "signatures": [ { "params": [ { "name": "data", "optional": true }, { "name": "...", "optional": true } ] } ] }, { "textRaw": "console.info([data][, ...])", "type": "method", "name": "info", "desc": "

Same as console.log.\n\n

\n", "signatures": [ { "params": [ { "name": "data", "optional": true }, { "name": "...", "optional": true } ] } ] }, { "textRaw": "console.error([data][, ...])", "type": "method", "name": "error", "desc": "

Same as console.log but prints to stderr.\n\n

\n", "signatures": [ { "params": [ { "name": "data", "optional": true }, { "name": "...", "optional": true } ] } ] }, { "textRaw": "console.warn([data][, ...])", "type": "method", "name": "warn", "desc": "

Same as console.error.\n\n

\n", "signatures": [ { "params": [ { "name": "data", "optional": true }, { "name": "...", "optional": true } ] } ] }, { "textRaw": "console.dir(obj[, options])", "type": "method", "name": "dir", "desc": "

Uses util.inspect on obj and prints resulting string to stdout. This function\nbypasses any custom inspect() function on obj. An optional options object\nmay be passed that alters certain aspects of the formatted string:\n\n

\n\n", "signatures": [ { "params": [ { "name": "obj" }, { "name": "options", "optional": true } ] } ] }, { "textRaw": "console.time(label)", "type": "method", "name": "time", "desc": "

Mark a time.\n\n

\n", "signatures": [ { "params": [ { "name": "label" } ] } ] }, { "textRaw": "console.timeEnd(label)", "type": "method", "name": "timeEnd", "desc": "

Finish timer, record output. Example:\n\n

\n
console.time('100-elements');\nfor (var i = 0; i < 100; i++) {\n  ;\n}\nconsole.timeEnd('100-elements');\n// prints 100-elements: 262ms
\n", "signatures": [ { "params": [ { "name": "label" } ] } ] }, { "textRaw": "console.trace(message[, ...])", "type": "method", "name": "trace", "desc": "

Print to stderr 'Trace :', followed by the formatted message and stack trace\nto the current position.\n\n

\n", "signatures": [ { "params": [ { "name": "message" }, { "name": "...", "optional": true } ] } ] }, { "textRaw": "console.assert(value[, message][, ...])", "type": "method", "name": "assert", "desc": "

Similar to [assert.ok()][], but the error message is formatted as\nutil.format(message...).\n\n

\n", "signatures": [ { "params": [ { "name": "value" }, { "name": "message", "optional": true }, { "name": "...", "optional": true } ] } ] } ] } ] }