aboutsummaryrefslogtreecommitdiffstats
path: root/src/debug.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-09-26 22:51:52 -0700
committerAdam Soltys <[email protected]>2026-09-26 22:51:52 -0700
commitb3df6e629a8d165ac2d6f9fb6c4962d47da0f0cf (patch)
tree72aeae840b025804248e2d0de33f1c488a501f7a /src/debug.js
parentdd395c511973fc240a00a4e9295f4255da9b4935 (diff)
downloadcoinosv3-b3df6e629a8d165ac2d6f9fb6c4962d47da0f0cf.tar.gz
coinosv3-b3df6e629a8d165ac2d6f9fb6c4962d47da0f0cf.zip
Console: NWC chatter behind a debug switch; dead relays remembered longer and dropped from the pool.
`coinosDebug(true)` in the console (or ?debug=1) turns the nwc: listener logs back on; they are off by default. Warnings and errors stay. The red WebSocket lines were the pool's own reconnect loop redialling relays from other people's relay lists that have been dead for weeks — the sick list only stopped NEW dials, for ten minutes, and forgot on reload. A dead relay is now dropped from the pool (no reconnect loop), skipped twice as long each time it fails (up to a day), keyed by normalized URL, and the verdict survives a reload. A relay the pool has failed to reconnect to three times counts as dead. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01VhUKyXKtsJ67QAFfb7QR9D
Diffstat (limited to 'src/debug.js')
-rw-r--r--src/debug.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/debug.js b/src/debug.js
new file mode 100644
index 0000000..5d7d085
--- /dev/null
+++ b/src/debug.js
@@ -0,0 +1,17 @@
+// A console kept quiet by default. The chatter that helps when something is
+// being chased (the NWC listener's generations, relay health) goes through
+// dlog and shows only once debugging is switched on — from the console with
+// `coinosDebug(true)`, or by opening the app with `?debug=1`. `coinosDebug(false)`
+// turns it off again. Warnings and errors that mean something is wrong are
+// not gated; they stay on console.warn / console.error.
+const KEY = 'coinos-debug';
+export const debugOn = () => { try { return localStorage.getItem(KEY) === '1'; } catch { return false; } };
+export const dlog = (...a) => { if (debugOn()) console.log(...a); };
+if (typeof window !== 'undefined') {
+ window.coinosDebug = (on = true) => {
+ try { localStorage.setItem(KEY, on ? '1' : '0'); } catch {}
+ console.log('coinos debug ' + (on ? 'on' : 'off'));
+ return on;
+ };
+ try { if (new URLSearchParams(location.search).get('debug') === '1') localStorage.setItem(KEY, '1'); } catch {}
+}