mirror of
https://github.com/OpenSquawk/OpenSquawk
synced 2026-08-05 00:42:27 +08:00
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>
This commit is contained in:
26
shared/utils/pmLog.ts
Normal file
26
shared/utils/pmLog.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
// ---------------------------------------------------------------------------
|
||||
// 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()
|
||||
},
|
||||
}
|
||||
})()
|
||||
Reference in New Issue
Block a user