基础设施级别日志选项。
布尔值
将行附加到输出而不是更新现有输出,这对于状态消息很有用。此选项仅在未提供自定义 console
时使用。
webpack.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');
},
],
};
布尔值
为基础设施级别日志启用彩色输出。此选项仅在未提供自定义 console
时使用。
webpack.config.js
module.exports = {
//...
infrastructureLogging: {
colors: true,
level: 'verbose',
},
plugins: [
(compiler) => {
const logger = compiler.getInfrastructureLogger('MyPlugin');
logger.log('this output will be colorful');
},
],
};
控制台
自定义用于基础设施级别日志的控制台。
webpack.config.js
module.exports = {
//...
infrastructureLogging: {
console: yourCustomConsole(),
},
};
string
boolean = false
RegExp
function(name) => boolean
[string, RegExp, function(name) => boolean]
启用指定日志器(如插件或加载器)的调试信息。与 stats.loggingDebug
选项类似,但适用于基础设施级别。默认为 false
。
webpack.config.js
module.exports = {
//...
infrastructureLogging: {
level: 'info',
debug: ['MyPlugin', /MyPlugin/, (name) => name.contains('MyPlugin')],
},
};
string = 'info' : 'none' | 'error' | 'warn' | 'info' | 'log' | 'verbose'
启用基础设施日志输出。与 stats.logging
选项类似,但适用于基础设施级别。默认为 'info'
。
可能的值
'none'
- 禁用日志'error'
- 仅错误'warn'
- 仅错误和警告'info'
- 错误、警告和信息消息'log'
- 错误、警告、信息消息、日志消息、分组、清除。折叠的分组以折叠状态显示。'verbose'
- 记录除调试和跟踪之外的所有内容。折叠组以展开状态显示。webpack.config.js
module.exports = {
//...
infrastructureLogging: {
level: 'info',
},
};
NodeJS.WritableStream = process.stderr
用于日志输出的流。默认为 process.stderr
。此选项仅在未提供自定义 console
时使用。
webpack.config.js
module.exports = {
//...
infrastructureLogging: {
stream: process.stderr,
},
};