Skip to content

Commit

Permalink
docs: added custom logger info (#10108)
Browse files Browse the repository at this point in the history
Co-authored-by: 翠 / green <[email protected]>
Co-authored-by: bluwy <[email protected]>
  • Loading branch information
3 people authored Feb 24, 2023
1 parent ebbd587 commit 8477b07
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions docs/config/shared-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,40 @@ export default defineConfig({

Adjust console output verbosity. Default is `'info'`.

## customLogger

- **Type:**
```ts
interface Logger {
info(msg: string, options?: LogOptions): void
warn(msg: string, options?: LogOptions): void
warnOnce(msg: string, options?: LogOptions): void
error(msg: string, options?: LogErrorOptions): void
clearScreen(type: LogType): void
hasErrorLogged(error: Error | RollupError): boolean
hasWarned: boolean
}
```

Use a custom logger to log messages. You can use Vite's `createLogger` API to get the default logger and customize it to, for example, change the message or filter out certain warnings.

```js
import { createLogger, defineConfig } from 'vite'

const logger = createLogger()
const loggerWarn = logger.warn

logger.warn = (msg, options) => {
// Ignore empty CSS files warning
if (msg.includes('vite:css') && msg.includes(' is empty')) return
loggerWarn(msg, options)
}

export default defineConfig({
customLogger: logger,
})
```

## clearScreen

- **Type:** `boolean`
Expand Down

0 comments on commit 8477b07

Please sign in to comment.