Files
OpenSquawk/shared/utils/pmLog.ts
itsrubberduck 5c695f96fb refactor(live-atc): extract ATIS playback/loop scheduling to useAtisPlayback
Moves ATIS carrier/broadcast loop, TTS audio caching, METAR fallback,
and the background airport-data refresh scheduler out of live-atc.vue.
Also extracts the pmLog debug logger to shared/utils/pmLog.ts since it
has no Vue/component dependency and multiple composables need it —
threading it through every composable's parameter list would've been
worse than giving it one shared home. Verified via typecheck plus a
browser mount/redirect smoke test.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-10 09:33:03 +02:00

27 lines
1.1 KiB
TypeScript

// ---------------------------------------------------------------------------
// Debug logger — prefix [PM] so it's easy to filter in DevTools.
// Disable at runtime: localStorage.setItem('PM_DEBUG', '0')
// Re-enable: localStorage.setItem('PM_DEBUG', '1')
// Show trace detail: localStorage.setItem('PM_DEBUG', 'verbose')
// ---------------------------------------------------------------------------
export const pmLog = (() => {
const level = () => {
if (typeof localStorage === 'undefined') return 'on'
return localStorage.getItem('PM_DEBUG') ?? 'on'
}
const enabled = () => level() !== '0'
const verbose = () => level() === 'verbose'
return {
info: (...a: any[]) => enabled() && console.log ('[PM]', ...a),
warn: (...a: any[]) => enabled() && console.warn ('[PM]', ...a),
error: (...a: any[]) => enabled() && console.error ('[PM]', ...a),
debug: (...a: any[]) => verbose() && console.debug ('[PM:v]', ...a),
group: (label: string, fn: () => void) => {
if (!enabled()) { fn(); return }
console.groupCollapsed(`[PM] ${label}`)
fn()
console.groupEnd()
},
}
})()