Spaces:
Runtime error
Runtime error
| const enabled = import.meta.env.DEV || new URLSearchParams(window.location.search).has('debug') | |
| const PAD = 18 | |
| function fmt(...args: unknown[]): string { | |
| return args.map(a => | |
| typeof a === 'object' && a !== null | |
| ? JSON.stringify(a, null, 0) | |
| : String(a) | |
| ).join(' ') | |
| } | |
| export function debug(namespace: string, ...args: unknown[]): void { | |
| if (!enabled) return | |
| const ts = performance.now().toFixed(1) | |
| console.log(`[${ts}ms] [${namespace.padEnd(PAD)}]`, ...args) | |
| } | |
| export function debugEnabled(): boolean { | |
| return enabled | |
| } | |
| export function enableDebug(): void { | |
| console.info('[debug] Add ?debug=1 to the URL to enable debug logging in this Space build.') | |
| } | |
| export function disableDebug(): void { | |
| console.info('[debug] Remove ?debug=1 from the URL to disable debug logging in this Space build.') | |
| } | |