mirror of
https://github.com/vitejs/vite.git
synced 2024-11-21 22:59:10 +00:00
docs: document debug logging (#4457)
This commit is contained in:
parent
304cc6b87b
commit
1e711c0ef6
4
.github/contributing.md
vendored
4
.github/contributing.md
vendored
@ -75,6 +75,10 @@ test('?raw import', async () => {
|
||||
})
|
||||
```
|
||||
|
||||
## Debug Logging
|
||||
|
||||
You can set the `DEBUG` environment variable to turn on debugging logs. E.g. `DEBUG="vite:resolve"`. To see all debug logs you can set `DEBUG="vite:*"`, but be warned that it will be quite noisy. You can run `grep -r "createDebugger('vite:" packages/vite/src/` to see a list of available debug scopes.
|
||||
|
||||
## Pull Request Guidelines
|
||||
|
||||
- Checkout a topic branch from a base branch, e.g. `main`, and merge back against that branch.
|
||||
|
@ -58,13 +58,16 @@ interface DebuggerOptions {
|
||||
onlyWhenFocused?: boolean | string
|
||||
}
|
||||
|
||||
export type ViteDebugScope = `vite:${string}`
|
||||
|
||||
export function createDebugger(
|
||||
ns: string,
|
||||
namespace: ViteDebugScope,
|
||||
options: DebuggerOptions = {}
|
||||
): debug.Debugger['log'] {
|
||||
const log = debug(ns)
|
||||
const log = debug(namespace)
|
||||
const { onlyWhenFocused } = options
|
||||
const focus = typeof onlyWhenFocused === 'string' ? onlyWhenFocused : ns
|
||||
const focus =
|
||||
typeof onlyWhenFocused === 'string' ? onlyWhenFocused : namespace
|
||||
return (msg: string, ...args: any[]) => {
|
||||
if (filter && !msg.includes(filter)) {
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user