Spaces:
Runtime error
Runtime error
File size: 829 Bytes
9c34cd3 df835e2 9c34cd3 df835e2 9c34cd3 df835e2 9c34cd3 df835e2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | 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.')
}
|