Skip to content

Commit

Permalink
docs: infrastructureLogging (#6808)
Browse files Browse the repository at this point in the history
* docs: infrastructureLogging

* fix

* fix: link

* u
  • Loading branch information
SyMind authored Jun 14, 2024
1 parent 4128819 commit bdc2037
Show file tree
Hide file tree
Showing 4 changed files with 254 additions and 0 deletions.
1 change: 1 addition & 0 deletions website/docs/en/config/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@
"stats",
"experiments",
"builtins",
"infrastructure-logging",
"other-options"
]
126 changes: 126 additions & 0 deletions website/docs/en/config/infrastructure-logging.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
import WebpackLicense from '@components/webpack-license';

<WebpackLicense from="https://webpack.js.org/configuration/infrastructureLogging/" />

# InfrastructureLogging

Options for infrastructure level logging. Generally used for logs unrelated to the Compilation.

## infrastructureLogging.appendOnly

- **Type:** `boolean`

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.

```js title=rspack.config.js
module.exports = {
//...
infrastructureLogging: {
appendOnly: true,
level: 'verbose',
},
plugins: [
compiler => {
const logger = compiler.getInfrastructureLogger('MyPlugin');
logger.status('first output'); // this line won't be overridden with `appendOnly` enabled
logger.status('second output');
},
],
};
```

## infrastructureLogging.colors

- **Type:** `boolean`

Enable colorful output for infrastructure level logging. This option is used only when no custom [console](#infrastructureloggingconsole) is provided.

```js title=rspack.config.js
module.exports = {
//...
infrastructureLogging: {
colors: true,
level: 'verbose',
},
plugins: [
compiler => {
const logger = compiler.getInfrastructureLogger('MyPlugin');
logger.log('this output will be colorful');
},
],
};
```

## infrastructureLogging.console

- **Type:** `Console`
- **Default:** `Console`

Customize the console used for infrastructure level logging.

```js title=rspack.config.js
module.exports = {
//...
infrastructureLogging: {
console: yourCustomConsole(),
},
};
```

## infrastructureLogging.debug

- **Type:** `boolean | RegExp | function(name) => boolean | [string, RegExp, function(name) => boolean]`
- **Default:** `'false'`

Enable debug information of specified loggers such as plugins or loaders. Similar to [stats.loggingDebug](/config/stats#statsloggingdebug) option but for infrastructure. Defaults to `false`.

```js title=rspack.config.js
module.exports = {
//...
infrastructureLogging: {
level: 'info',
debug: ['MyPlugin', /MyPlugin/, name => name.contains('MyPlugin')],
},
};
```

## infrastructureLogging.level

- **Type:** `'none' | 'error' | 'warn' | 'info' | 'log' | 'verbose'`
- **Default:** `'info'`

Enable infrastructure logging output. Similar to (stats.logging)[/config/stats#statslogging] option but for infrastructure. Defaults to `'info'`.

Possible values:

- `'none'` - disable logging
- `'error'` - errors only
- `'warn'` - errors and warnings only
- `'info'` - errors, warnings, and info messages
- `'log'` - errors, warnings, info messages, log messages, groups, clears. Collapsed groups are displayed in a collapsed state.
- `'verbose'` - log everything except debug and trace. Collapsed groups are displayed in expanded state.

```js title=rspack.config.js
module.exports = {
//...
infrastructureLogging: {
level: 'info',
},
};
```

## infrastructureLogging.stream

- **Type:** `NodeJS.WritableStream`
- **Default:** `process.stderr`

Stream used for logging output. Defaults to `process.stderr`. This option is used only when no custom [console](#infrastructureloggingconsole) is provided.

```js title=rspack.config.js
module.exports = {
//...
infrastructureLogging: {
stream: process.stderr,
},
};
```
1 change: 1 addition & 0 deletions website/docs/zh/config/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@
"stats",
"experiments",
"builtins",
"infrastructure-logging",
"other-options"
]
126 changes: 126 additions & 0 deletions website/docs/zh/config/infrastructure-logging.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
import WebpackLicense from '@components/webpack-license';

<WebpackLicense from="https://webpack.js.org/configuration/infrastructureLogging/" />

# InfrastructureLogging

控制基础架构级别的日志记录。一般用于与 Compilation 无关的日志。

## infrastructureLogging.appendOnly

- **类型:** `boolean`

将内容逐行追加到输出中,而不更新现有的输出。这对状态消息非常有用。只有在未提供自定义 [console](#infrastructureloggingconsole) 时才会使用此选项。

```js title=rspack.config.js
module.exports = {
//...
infrastructureLogging: {
appendOnly: true,
level: 'verbose',
},
plugins: [
compiler => {
const logger = compiler.getInfrastructureLogger('MyPlugin');
logger.status('first output'); // 当启用 `appendOnly` 时,此行不会被覆盖
logger.status('second output');
},
],
};
```

## infrastructureLogging.colors

- **类型:** `boolean`

基础架构级别的输出颜色。只有在未提供自定义 [console](#infrastructureloggingconsole) 时才会使用此选项。

```js title=rspack.config.js
module.exports = {
//...
infrastructureLogging: {
colors: true,
level: 'verbose',
},
plugins: [
compiler => {
const logger = compiler.getInfrastructureLogger('MyPlugin');
logger.log('this output will be colorful');
},
],
};
```

## infrastructureLogging.console

- **类型:** `Console`
- **默认值:** `Console`

自定义用于基础架构级别日志记录的控制台。

```js title=rspack.config.js
module.exports = {
//...
infrastructureLogging: {
console: yourCustomConsole(),
},
};
```

## infrastructureLogging.debug

- **类型:** `boolean | RegExp | function(name) => boolean | [string, RegExp, function(name) => boolean]`
- **默认值:** `'false'`

指定输出(如特定的插件或 loader)的调试信息。类似 [stats.loggingDebug](/config/stats#statsloggingdebug) 选项,但适用于基础架构。默认为 `false`

```js title=rspack.config.js
module.exports = {
//...
infrastructureLogging: {
level: 'info',
debug: ['MyPlugin', /MyPlugin/, name => name.contains('MyPlugin')],
},
};
```

## infrastructureLogging.level

- **类型:** `'none' | 'error' | 'warn' | 'info' | 'log' | 'verbose'`
- **默认值:** `'info'`

启用基础架构日志输出。类似于 [stats.logging](/config/stats#statslogging) 选项,但适用于基础架构。默认为 `'info'`

可能的值:

- `'none'` - 禁用日志记录
- `'error'` - 仅记录错误
- `'warn'` - 仅记录错误和警告
- `'info'` - 记录错误、警告和信息消息
- `'log'` - 记录错误、警告、信息消息、日志消息、组和清除。折叠的组以折叠状态显示。
- `'verbose'` - 记录除调试和跟踪以外的所有内容。折叠的组以扩展状态显示。

```js title=rspack.config.js
module.exports = {
//...
infrastructureLogging: {
level: 'info',
},
};
```

## infrastructureLogging.stream

- **类型:** `NodeJS.WritableStream`
- **默认值:** `process.stderr`

用于日志记录输出的流。默认为 `process.stderr`。只有在未提供自定义 [console](#infrastructureloggingconsole) 时才会使用此选项。

```js title=rspack.config.js
module.exports = {
//...
infrastructureLogging: {
stream: process.stderr,
},
};
```

0 comments on commit bdc2037

Please sign in to comment.