Skip to content

Commit

Permalink
doc: sort console alphabetically
Browse files Browse the repository at this point in the history
Reorders, with no contextual changes, the console documentation
alphabetically.

PR-URL: #3662
Reviewed-By: Evan Lucas <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
  • Loading branch information
tflanagan authored and rvagg committed Nov 13, 2015
1 parent 05f1af7 commit 3e046ac
Showing 1 changed file with 61 additions and 62 deletions.
123 changes: 61 additions & 62 deletions doc/api/console.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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

<!--type=class-->

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}
Expand All @@ -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])

Expand All @@ -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
Expand Down Expand Up @@ -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

<!--type=class-->

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`.

0 comments on commit 3e046ac

Please sign in to comment.