CC 4.0 许可证
本节内容来自以下链接的内容,并受 CC BY 4.0 许可证约束。
除非另有说明,否则以下内容可以认为是基于原始内容进行修改和删除的结果。
基础设施日志记录
用于基础设施级别日志记录的选项。通常用于与 Compilation 无关的日志。
infrastructureLogging.appendOnly
将行追加到输出而不是更新现有输出,这对状态消息很有用。此选项仅在没有提供自定义 console 时使用。
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
为基础设施级别日志记录启用彩色输出。此选项仅在没有提供自定义 console 时使用。
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
自定义用于基础设施级别日志记录的控制台。
rspack.config.js
module.exports = {
//...
infrastructureLogging: {
console: yourCustomConsole(),
},
};
infrastructureLogging.debug
- 类型:
boolean | RegExp | function(name) => boolean | [string, RegExp, function(name) => boolean]
- 默认值:
'false'
启用指定日志记录器(如插件或加载器)的调试信息。类似于 stats.loggingDebug 选项,但针对基础设施。默认为 false
。
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'
- 记录除调试和跟踪之外的所有内容。折叠的组将以展开状态显示。
rspack.config.js
module.exports = {
//...
infrastructureLogging: {
level: 'info',
},
};
infrastructureLogging.stream
- 类型:
NodeJS.WritableStream
- 默认值:
process.stderr
用于日志记录输出的流。默认为 process.stderr
。此选项仅在没有提供自定义 console 时使用。
rspack.config.js
module.exports = {
//...
infrastructureLogging: {
stream: process.stderr,
},
};