From 3e046acc509876d7692d937ca5d23f4053882dbe Mon Sep 17 00:00:00 2001 From: Tristian Flanagan Date: Wed, 4 Nov 2015 10:51:43 -0500 Subject: [PATCH] doc: sort console alphabetically Reorders, with no contextual changes, the console documentation alphabetically. PR-URL: https://github.com/nodejs/node/pull/3662 Reviewed-By: Evan Lucas Reviewed-By: James M Snell Reviewed-By: Jeremiah Senkpiel --- doc/api/console.markdown | 123 +++++++++++++++++++-------------------- 1 file changed, 61 insertions(+), 62 deletions(-) diff --git a/doc/api/console.markdown b/doc/api/console.markdown index f3a69ce95104e2..6fe5a400f6f159 100644 --- a/doc/api/console.markdown +++ b/doc/api/console.markdown @@ -10,6 +10,42 @@ sent to stdout or stderr. For ease of use, `console` is defined as a global object and can be used directly without `require`. +## Class: Console + + + +Use `require('console').Console` or `console.Console` to access this class. + + var Console = require('console').Console; + var Console = console.Console; + +You can use `Console` class to custom simple logger like `console`, but with +different output streams. + +### new Console(stdout[, stderr]) + +Create a new `Console` by passing one or two writable stream instances. +`stdout` is a writable stream to print log or info output. `stderr` +is used for warning or error output. If `stderr` isn't passed, the warning +and error output will be sent to the `stdout`. + + var output = fs.createWriteStream('./stdout.log'); + var errorOutput = fs.createWriteStream('./stderr.log'); + // custom simple logger + var logger = new Console(output, errorOutput); + // use it like console + var count = 5; + logger.log('count: %d', count); + // in stdout.log: count 5 + +The global `console` is a special `Console` whose output is sent to +`process.stdout` and `process.stderr`: + + new Console(process.stdout, process.stderr); + +[assert.ok()]: assert.html#assert_assert_value_message_assert_ok_value_message +[util.format()]: util.html#util_util_format_format + ## console * {Object} @@ -31,30 +67,10 @@ is blocking: In daily use, the blocking/non-blocking dichotomy is not something you should worry about unless you log huge amounts of data. +### console.assert(value[, message][, ...]) -### console.log([data][, ...]) - -Prints to stdout with newline. This function can take multiple arguments in a -`printf()`-like way. Example: - - var count = 5; - console.log('count: %d', count); - // prints 'count: 5' - -If formatting elements are not found in the first string then `util.inspect` -is used on each argument. See [util.format()][] for more information. - -### console.info([data][, ...]) - -Same as `console.log`. - -### console.error([data][, ...]) - -Same as `console.log` but prints to stderr. - -### console.warn([data][, ...]) - -Same as `console.error`. +Similar to [assert.ok()][], but the error message is formatted as +`util.format(message...)`. ### console.dir(obj[, options]) @@ -72,6 +88,26 @@ object. This is useful for inspecting large complicated objects. Defaults to - `colors` - if `true`, then the output will be styled with ANSI color codes. Defaults to `false`. Colors are customizable, see below. +### console.error([data][, ...]) + +Same as `console.log` but prints to stderr. + +### console.info([data][, ...]) + +Same as `console.log`. + +### console.log([data][, ...]) + +Prints to stdout with newline. This function can take multiple arguments in a +`printf()`-like way. Example: + + var count = 5; + console.log('count: %d', count); + // prints 'count: 5' + +If formatting elements are not found in the first string then `util.inspect` +is used on each argument. See [util.format()][] for more information. + ### console.time(label) Starts a timer that can be used to compute the duration of an operation. Timers @@ -100,43 +136,6 @@ Example: Print to stderr `'Trace :'`, followed by the formatted message and stack trace to the current position. -### console.assert(value[, message][, ...]) - -Similar to [assert.ok()][], but the error message is formatted as -`util.format(message...)`. - -## Class: Console - - - -Use `require('console').Console` or `console.Console` to access this class. - - var Console = require('console').Console; - var Console = console.Console; - -You can use `Console` class to custom simple logger like `console`, but with -different output streams. - -### new Console(stdout[, stderr]) - -Create a new `Console` by passing one or two writable stream instances. -`stdout` is a writable stream to print log or info output. `stderr` -is used for warning or error output. If `stderr` isn't passed, the warning -and error output will be sent to the `stdout`. - - var output = fs.createWriteStream('./stdout.log'); - var errorOutput = fs.createWriteStream('./stderr.log'); - // custom simple logger - var logger = new Console(output, errorOutput); - // use it like console - var count = 5; - logger.log('count: %d', count); - // in stdout.log: count 5 - -The global `console` is a special `Console` whose output is sent to -`process.stdout` and `process.stderr`: - - new Console(process.stdout, process.stderr); +### console.warn([data][, ...]) -[assert.ok()]: assert.html#assert_assert_value_message_assert_ok_value_message -[util.format()]: util.html#util_util_format_format +Same as `console.error`.