onLog()
- Type:
optionalonLog: (level,log,defaultHandler) =>void
Defined in: options/input-options.ts:416
A function that intercepts log messages. If not supplied, logs are printed to the console.
This handler will not be invoked if logs are filtered out by the logLevel option. I.e. by default, "debug" logs will be swallowed.
If the default handler is not invoked, the log will not be printed to the console. Moreover, you can change the log level by invoking the default handler with a different level. Using the additional level "error" will turn the log into a thrown error that has all properties of the log attached.
Parameters
level
"info" | "debug" | "warn"
log
defaultHandler
Returns
void
Example
js
export default defineConfig({
onLog(level, log, defaultHandler) {
if (log.code === 'CIRCULAR_DEPENDENCY') {
return; // Ignore circular dependency warnings
}
if (level === 'warn') {
defaultHandler('error', log); // turn other warnings into errors
} else {
defaultHandler(level, log); // otherwise, just print the log
}
}
})