From 7b9baef165aa1064281a5f2fe81d6eb8f23f3fbd Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 27 Dec 2023 20:39:38 -0600 Subject: [PATCH] debug: streaming, simplify other logs --- src/controllers/api/streaming.ts | 5 ++++- src/subs.ts | 2 +- src/utils/nip05.ts | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/controllers/api/streaming.ts b/src/controllers/api/streaming.ts index 8cdd7d47..07512608 100644 --- a/src/controllers/api/streaming.ts +++ b/src/controllers/api/streaming.ts @@ -1,11 +1,13 @@ import { type AppController } from '@/app.ts'; -import { z } from '@/deps.ts'; +import { Debug, z } from '@/deps.ts'; import { type DittoFilter } from '@/filter.ts'; import { getAuthor, getFeedPubkeys } from '@/queries.ts'; import { Sub } from '@/subs.ts'; import { bech32ToPubkey } from '@/utils.ts'; import { renderStatus } from '@/views/mastodon/statuses.ts'; +const debug = Debug('ditto:streaming'); + /** * Streaming timelines/categories. * https://docs.joinmastodon.org/methods/streaming/#streams @@ -49,6 +51,7 @@ const streamingController: AppController = (c) => { function send(name: string, payload: object) { if (socket.readyState === WebSocket.OPEN) { + debug('send', name, JSON.stringify(payload)); socket.send(JSON.stringify({ event: name, payload: JSON.stringify(payload), diff --git a/src/subs.ts b/src/subs.ts index be2ec9cd..c716e018 100644 --- a/src/subs.ts +++ b/src/subs.ts @@ -23,7 +23,7 @@ class SubscriptionStore { * ``` */ sub(socket: unknown, id: string, filters: DittoFilter[]): Subscription { - debug('sub', id, filters); + debug('sub', id, JSON.stringify(filters)); let subs = this.#store.get(socket); if (!subs) { diff --git a/src/utils/nip05.ts b/src/utils/nip05.ts index 1364c382..4fa38084 100644 --- a/src/utils/nip05.ts +++ b/src/utils/nip05.ts @@ -48,7 +48,7 @@ function lookupNip05Cached(value: string): Promise { const cached = nip05Cache.get(value); if (cached !== undefined) return cached; - debug(`Looking up NIP-05 for ${value}`); + debug(`Lookup ${value}`); const result = lookup(value); nip05Cache.set(value, result);