Skip to content

Commit 9b95f35

Browse files
authored
docs(configuration): move infrastructureLogging to its own page (#7210)
1 parent fd9d03a commit 9b95f35

File tree

5 files changed

+150
-148
lines changed

5 files changed

+150
-148
lines changed

src/content/api/compiler-hooks.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,14 +297,14 @@ Called when the compiler is closing.
297297

298298
`SyncBailHook`
299299

300-
Allows to use infrastructure logging when enabled in the configuration via [`infrastructureLogging` option](/configuration/other-options/#infrastructurelogging).
300+
Allows to use infrastructure logging when enabled in the configuration via [`infrastructureLogging` option](/configuration/infrastructureLogging/).
301301

302302
- Callback Parameters: `name`, `type`, `args`
303303

304304
### log
305305

306306
`SyncBailHook`
307307

308-
Allows to log into [stats](/configuration/stats/) when enabled, see [`stats.logging`, `stats.loggingDebug` and `stats.loggingTrace` options](/configuration/stats/#stats-options).
308+
Allows to log into [stats](/configuration/stats/) when enabled, see [`stats.logging`, `stats.loggingDebug` and `stats.loggingTrace` options](/configuration/infrastructureLogging/).
309309

310310
- Callback Parameters: `origin`, `logEntry`

src/content/api/loaders.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ module.exports = function (source) {
776776
777777
## Logging
778778
779-
Logging API is available since the release of webpack 4.37. When `logging` is enabled in [`stats configuration`](/configuration/stats/#statslogging) and/or when [`infrastructure logging`](/configuration/other-options/#infrastructurelogging) is enabled, loaders may log messages which will be printed out in the respective logger format (stats, infrastructure).
779+
Logging API is available since the release of webpack 4.37. When `logging` is enabled in [`stats configuration`](/configuration/stats/#statslogging) and/or when [`infrastructure logging`](/configuration/infrastructureLogging) is enabled, loaders may log messages which will be printed out in the respective logger format (stats, infrastructure).
780780
781781
- Loaders should prefer to use `this.getLogger()` for logging which is a shortcut to `compilation.getLogger()` with loader path and processed file. This kind of logging is stored to the Stats and formatted accordingly. It can be filtered and exported by the webpack user.
782782
- Loaders may use `this.getLogger('name')` to get an independent logger with a child name. Loader path and processed file is still added.

src/content/api/plugins.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ Note that only a subset of compiler and compilation hooks support the `reportPro
176176

177177
## Logging
178178

179-
Logging API is available since the release of webpack 4.37. When `logging` is enabled in [`stats configuration`](/configuration/stats/#statslogging) and/or when [`infrastructure logging`](/configuration/other-options/#infrastructurelogging) is enabled, plugins may log messages which will be printed out in the respective logger format (stats, infrastructure).
179+
Logging API is available since the release of webpack 4.37. When `logging` is enabled in [`stats configuration`](/configuration/stats/#statslogging) and/or when [`infrastructure logging`](/configuration/infrastructureLogging) is enabled, plugins may log messages which will be printed out in the respective logger format (stats, infrastructure).
180180

181181
- Plugins should prefer to use `compilation.getLogger('PluginName')` for logging. This kind of logging is stored in the Stats and formatted accordingly. It can be filtered and exported by the user.
182182
- Plugins may use the `compiler.getInfrastructureLogger('PluginName')` for logging. Using `infrastructure` logging is not stored in the Stats and therefore not formatted. It's usually logged to the console/dashboard/GUI directly. It can be filtered by the user.
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
---
2+
title: InfrastructureLogging
3+
sort: 20
4+
contributors:
5+
- snitin315
6+
---
7+
8+
Options for infrastructure level logging.
9+
10+
## infrastructureLogging.appendOnly
11+
12+
<Badge text="5.31.0+" />
13+
14+
`boolean`
15+
16+
Append lines to the output instead of updating existing output, useful for status messages. This option is used only when no custom [`console`](#infrastructureloggingconsole) is provided.
17+
18+
**webpack.config.js**
19+
20+
```javascript
21+
module.exports = {
22+
//...
23+
infrastructureLogging: {
24+
appendOnly: true,
25+
level: 'verbose',
26+
},
27+
plugins: [
28+
(compiler) => {
29+
const logger = compiler.getInfrastructureLogger('MyPlugin');
30+
logger.status('first output'); // this line won't be overridden with `appendOnly` enabled
31+
logger.status('second output');
32+
},
33+
],
34+
};
35+
```
36+
37+
## infrastructureLogging.colors
38+
39+
<Badge text="5.31.0+" />
40+
41+
`boolean`
42+
43+
Enable colorful output for infrastructure level logging. This option is used only when no custom [`console`](#infrastructureloggingconsole) is provided.
44+
45+
**webpack.config.js**
46+
47+
```javascript
48+
module.exports = {
49+
//...
50+
infrastructureLogging: {
51+
colors: true,
52+
level: 'verbose',
53+
},
54+
plugins: [
55+
(compiler) => {
56+
const logger = compiler.getInfrastructureLogger('MyPlugin');
57+
logger.log('this output will be colorful');
58+
},
59+
],
60+
};
61+
```
62+
63+
## infrastructureLogging.console
64+
65+
<Badge text="5.31.0+" />
66+
67+
`Console`
68+
69+
Customize the console used for infrastructure level logging.
70+
71+
**webpack.config.js**
72+
73+
```javascript
74+
module.exports = {
75+
//...
76+
infrastructureLogging: {
77+
console: yourCustomConsole(),
78+
},
79+
};
80+
```
81+
82+
## infrastructureLogging.debug
83+
84+
`string` `boolean = false` `RegExp` `function(name) => boolean` `[string, RegExp, function(name) => boolean]`
85+
86+
Enable debug information of specified loggers such as plugins or loaders. Similar to [`stats.loggingDebug`](/configuration/stats/#statsloggingdebug) option but for infrastructure. Defaults to `false`.
87+
88+
**webpack.config.js**
89+
90+
```javascript
91+
module.exports = {
92+
//...
93+
infrastructureLogging: {
94+
level: 'info',
95+
debug: ['MyPlugin', /MyPlugin/, (name) => name.contains('MyPlugin')],
96+
},
97+
};
98+
```
99+
100+
## infrastructureLogging.level
101+
102+
`string = 'info' : 'none' | 'error' | 'warn' | 'info' | 'log' | 'verbose'`
103+
104+
Enable infrastructure logging output. Similar to [`stats.logging`](/configuration/stats/#statslogging) option but for infrastructure. Defaults to `'info'`.
105+
106+
Possible values:
107+
108+
- `'none'` - disable logging
109+
- `'error'` - errors only
110+
- `'warn'` - errors and warnings only
111+
- `'info'` - errors, warnings, and info messages
112+
- `'log'` - errors, warnings, info messages, log messages, groups, clears. Collapsed groups are displayed in a collapsed state.
113+
- `'verbose'` - log everything except debug and trace. Collapsed groups are displayed in expanded state.
114+
115+
**webpack.config.js**
116+
117+
```javascript
118+
module.exports = {
119+
//...
120+
infrastructureLogging: {
121+
level: 'info',
122+
},
123+
};
124+
```
125+
126+
## infrastructureLogging.stream
127+
128+
<Badge text="5.31.0+" />
129+
130+
`NodeJS.WritableStream = process.stderr`
131+
132+
Stream used for logging output. Defaults to `process.stderr`. This option is used only when no custom [`console`](#infrastructureloggingconsole) is provided.
133+
134+
**webpack.config.js**
135+
136+
```javascript
137+
module.exports = {
138+
//...
139+
infrastructureLogging: {
140+
stream: process.stderr,
141+
},
142+
};
143+
```
144+
145+
T> In the case of a TTY stream, `colors` is enabled and `appendOnly` is disabled, and vice versa.

src/content/configuration/other-options.mdx

Lines changed: 1 addition & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Other Options
3-
sort: 20
3+
sort: 21
44
contributors:
55
- sokra
66
- skipjack
@@ -128,149 +128,6 @@ module.exports = {
128128
};
129129
```
130130

131-
## infrastructureLogging
132-
133-
Options for infrastructure level logging.
134-
135-
`object = {}`
136-
137-
### appendOnly
138-
139-
<Badge text="5.31.0+" />
140-
141-
`boolean`
142-
143-
Append lines to the output instead of updating existing output, useful for status messages. This option is used only when no custom [`console`](#console) is provided.
144-
145-
**webpack.config.js**
146-
147-
```javascript
148-
module.exports = {
149-
//...
150-
infrastructureLogging: {
151-
appendOnly: true,
152-
level: 'verbose',
153-
},
154-
plugins: [
155-
(compiler) => {
156-
const logger = compiler.getInfrastructureLogger('MyPlugin');
157-
logger.status('first output'); // this line won't be overridden with `appendOnly` enabled
158-
logger.status('second output');
159-
},
160-
],
161-
};
162-
```
163-
164-
### colors
165-
166-
<Badge text="5.31.0+" />
167-
168-
`boolean`
169-
170-
Enable colorful output for infrastructure level logging. This option is used only when no custom [`console`](#console) is provided.
171-
172-
**webpack.config.js**
173-
174-
```javascript
175-
module.exports = {
176-
//...
177-
infrastructureLogging: {
178-
colors: true,
179-
level: 'verbose',
180-
},
181-
plugins: [
182-
(compiler) => {
183-
const logger = compiler.getInfrastructureLogger('MyPlugin');
184-
logger.log('this output will be colorful');
185-
},
186-
],
187-
};
188-
```
189-
190-
### console
191-
192-
<Badge text="5.31.0+" />
193-
194-
`Console`
195-
196-
Customize the console used for infrastructure level logging.
197-
198-
**webpack.config.js**
199-
200-
```javascript
201-
module.exports = {
202-
//...
203-
infrastructureLogging: {
204-
console: yourCustomConsole(),
205-
},
206-
};
207-
```
208-
209-
### debug
210-
211-
`string` `boolean = false` `RegExp` `function(name) => boolean` `[string, RegExp, function(name) => boolean]`
212-
213-
Enable debug information of specified loggers such as plugins or loaders. Similar to [`stats.loggingDebug`](/configuration/stats/#statsloggingdebug) option but for infrastructure. Defaults to `false`.
214-
215-
**webpack.config.js**
216-
217-
```javascript
218-
module.exports = {
219-
//...
220-
infrastructureLogging: {
221-
level: 'info',
222-
debug: ['MyPlugin', /MyPlugin/, (name) => name.contains('MyPlugin')],
223-
},
224-
};
225-
```
226-
227-
### level
228-
229-
`string = 'info' : 'none' | 'error' | 'warn' | 'info' | 'log' | 'verbose'`
230-
231-
Enable infrastructure logging output. Similar to [`stats.logging`](/configuration/stats/#statslogging) option but for infrastructure. Defaults to `'info'`.
232-
233-
Possible values:
234-
235-
- `'none'` - disable logging
236-
- `'error'` - errors only
237-
- `'warn'` - errors and warnings only
238-
- `'info'` - errors, warnings, and info messages
239-
- `'log'` - errors, warnings, info messages, log messages, groups, clears. Collapsed groups are displayed in a collapsed state.
240-
- `'verbose'` - log everything except debug and trace. Collapsed groups are displayed in expanded state.
241-
242-
**webpack.config.js**
243-
244-
```javascript
245-
module.exports = {
246-
//...
247-
infrastructureLogging: {
248-
level: 'info',
249-
},
250-
};
251-
```
252-
253-
### stream
254-
255-
<Badge text="5.31.0+" />
256-
257-
`NodeJS.WritableStream = process.stderr`
258-
259-
Stream used for logging output. Defaults to `process.stderr`. This option is used only when no custom [`console`](#console) is provided.
260-
261-
**webpack.config.js**
262-
263-
```javascript
264-
module.exports = {
265-
//...
266-
infrastructureLogging: {
267-
stream: process.stderr,
268-
},
269-
};
270-
```
271-
272-
T> In the case of a TTY stream, `colors` is enabled and `appendOnly` is disabled, and vice versa.
273-
274131
## loader
275132

276133
`object`

0 commit comments

Comments
 (0)