diff --git a/src/controllers/nostr/relay.ts b/src/controllers/nostr/relay.ts index 3fd6b29a..2a38e751 100644 --- a/src/controllers/nostr/relay.ts +++ b/src/controllers/nostr/relay.ts @@ -1,3 +1,4 @@ +import { Stickynotes } from '@soapbox/stickynotes'; import TTLCache from '@isaacs/ttlcache'; import { NostrClientCLOSE, @@ -29,6 +30,8 @@ const limiter = new TTLCache(); /** Connections for metrics purposes. */ const connections = new Set(); +const console = new Stickynotes('ditto:relay'); + /** Set up the Websocket connection. */ function connectStream(socket: WebSocket, ip: string | undefined) { const controllers = new Map(); diff --git a/src/pipeline.ts b/src/pipeline.ts index eb06c12b..a1222767 100644 --- a/src/pipeline.ts +++ b/src/pipeline.ts @@ -1,5 +1,5 @@ import { NKinds, NostrEvent, NSchema as n } from '@nostrify/nostrify'; -import Debug from '@soapbox/stickynotes/debug'; +import { Stickynotes } from '@soapbox/stickynotes'; import ISO6391 from 'iso-639-1'; import { Kysely, sql } from 'kysely'; import lande from 'lande'; @@ -23,7 +23,7 @@ import { purifyEvent } from '@/utils/purify.ts'; import { updateStats } from '@/utils/stats.ts'; import { getTagSet } from '@/utils/tags.ts'; -const debug = Debug('ditto:pipeline'); +const console = new Stickynotes('ditto:pipeline'); /** * Common pipeline function to process (and maybe store) events. @@ -41,7 +41,7 @@ async function handleEvent(event: DittoEvent, signal: AbortSignal): Promise ${event.id}`); + console.info(`NostrEvent<${event.kind}> ${event.id}`); pipelineEventsCounter.inc({ kind: event.kind }); if (isProtectedEvent(event)) { @@ -76,18 +76,18 @@ async function handleEvent(event: DittoEvent, signal: AbortSignal): Promise { - const debug = Debug('ditto:policy'); + const console = new Stickynotes('ditto:policy'); try { const result = await policyWorker.call(event, signal); policyEventsCounter.inc({ ok: String(result[2]) }); - debug(JSON.stringify(result)); + console.log(JSON.stringify(result)); RelayError.assert(result); } catch (e) { if (e instanceof RelayError) { throw e; } else { - console.error('POLICY ERROR:', e); + console.error(e); throw new RelayError('blocked', 'policy error'); } } @@ -136,7 +136,7 @@ async function storeEvent(event: DittoEvent, signal?: AbortSignal): Promise { - await updateStats({ event, store, kysely }); + await updateStats({ event, store, kysely }).catch((e) => console.error(e)); await store.event(event, { signal }); }); }