Skip to content

Commit b3e5360

Browse files
tflanaganrvagg
authored andcommitted
doc: sort console alphabetically
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]>
1 parent dc79480 commit b3e5360

File tree

1 file changed

+61
-62
lines changed

1 file changed

+61
-62
lines changed

doc/api/console.markdown

+61-62
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,42 @@ sent to stdout or stderr.
1010
For ease of use, `console` is defined as a global object and can be used
1111
directly without `require`.
1212

13+
## Class: Console
14+
15+
<!--type=class-->
16+
17+
Use `require('console').Console` or `console.Console` to access this class.
18+
19+
var Console = require('console').Console;
20+
var Console = console.Console;
21+
22+
You can use `Console` class to custom simple logger like `console`, but with
23+
different output streams.
24+
25+
### new Console(stdout[, stderr])
26+
27+
Create a new `Console` by passing one or two writable stream instances.
28+
`stdout` is a writable stream to print log or info output. `stderr`
29+
is used for warning or error output. If `stderr` isn't passed, the warning
30+
and error output will be sent to the `stdout`.
31+
32+
var output = fs.createWriteStream('./stdout.log');
33+
var errorOutput = fs.createWriteStream('./stderr.log');
34+
// custom simple logger
35+
var logger = new Console(output, errorOutput);
36+
// use it like console
37+
var count = 5;
38+
logger.log('count: %d', count);
39+
// in stdout.log: count 5
40+
41+
The global `console` is a special `Console` whose output is sent to
42+
`process.stdout` and `process.stderr`:
43+
44+
new Console(process.stdout, process.stderr);
45+
46+
[assert.ok()]: assert.html#assert_assert_value_message_assert_ok_value_message
47+
[util.format()]: util.html#util_util_format_format
48+
1349
## console
1450

1551
* {Object}
@@ -31,30 +67,10 @@ is blocking:
3167
In daily use, the blocking/non-blocking dichotomy is not something you
3268
should worry about unless you log huge amounts of data.
3369

70+
### console.assert(value[, message][, ...])
3471

35-
### console.log([data][, ...])
36-
37-
Prints to stdout with newline. This function can take multiple arguments in a
38-
`printf()`-like way. Example:
39-
40-
var count = 5;
41-
console.log('count: %d', count);
42-
// prints 'count: 5'
43-
44-
If formatting elements are not found in the first string then `util.inspect`
45-
is used on each argument. See [util.format()][] for more information.
46-
47-
### console.info([data][, ...])
48-
49-
Same as `console.log`.
50-
51-
### console.error([data][, ...])
52-
53-
Same as `console.log` but prints to stderr.
54-
55-
### console.warn([data][, ...])
56-
57-
Same as `console.error`.
72+
Similar to [assert.ok()][], but the error message is formatted as
73+
`util.format(message...)`.
5874

5975
### console.dir(obj[, options])
6076

@@ -72,6 +88,26 @@ object. This is useful for inspecting large complicated objects. Defaults to
7288
- `colors` - if `true`, then the output will be styled with ANSI color codes.
7389
Defaults to `false`. Colors are customizable, see below.
7490

91+
### console.error([data][, ...])
92+
93+
Same as `console.log` but prints to stderr.
94+
95+
### console.info([data][, ...])
96+
97+
Same as `console.log`.
98+
99+
### console.log([data][, ...])
100+
101+
Prints to stdout with newline. This function can take multiple arguments in a
102+
`printf()`-like way. Example:
103+
104+
var count = 5;
105+
console.log('count: %d', count);
106+
// prints 'count: 5'
107+
108+
If formatting elements are not found in the first string then `util.inspect`
109+
is used on each argument. See [util.format()][] for more information.
110+
75111
### console.time(label)
76112

77113
Used to calculate the duration of a specific operation. To start a timer, call
@@ -100,43 +136,6 @@ Example:
100136
Print to stderr `'Trace :'`, followed by the formatted message and stack trace
101137
to the current position.
102138

103-
### console.assert(value[, message][, ...])
104-
105-
Similar to [assert.ok()][], but the error message is formatted as
106-
`util.format(message...)`.
107-
108-
## Class: Console
109-
110-
<!--type=class-->
111-
112-
Use `require('console').Console` or `console.Console` to access this class.
113-
114-
var Console = require('console').Console;
115-
var Console = console.Console;
116-
117-
You can use `Console` class to custom simple logger like `console`, but with
118-
different output streams.
119-
120-
### new Console(stdout[, stderr])
121-
122-
Create a new `Console` by passing one or two writable stream instances.
123-
`stdout` is a writable stream to print log or info output. `stderr`
124-
is used for warning or error output. If `stderr` isn't passed, the warning
125-
and error output will be sent to the `stdout`.
126-
127-
var output = fs.createWriteStream('./stdout.log');
128-
var errorOutput = fs.createWriteStream('./stderr.log');
129-
// custom simple logger
130-
var logger = new Console(output, errorOutput);
131-
// use it like console
132-
var count = 5;
133-
logger.log('count: %d', count);
134-
// in stdout.log: count 5
135-
136-
The global `console` is a special `Console` whose output is sent to
137-
`process.stdout` and `process.stderr`:
138-
139-
new Console(process.stdout, process.stderr);
139+
### console.warn([data][, ...])
140140

141-
[assert.ok()]: assert.html#assert_assert_value_message_assert_ok_value_message
142-
[util.format()]: util.html#util_util_format_format
141+
Same as `console.error`.

0 commit comments

Comments
 (0)