From 25fad11afb331868423c3649cb3d6d06a8c01d45 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Thu, 17 Oct 2024 02:55:32 +0200 Subject: [PATCH] Setup logging --- src/main.ts | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/main.ts b/src/main.ts index 470acc6..356e6d6 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,15 +1,31 @@ import {createFederation} from "@fedify/fedify" +import {configure, getConsoleSink, getLogger} from "@logtape/logtape" import {RedisKvStore} from "https://jsr.io/@fedify/redis/0.3.0/src/kv.ts" import {Redis} from "ioredis" -const federation = createFederation({ - kv: new RedisKvStore( - new Redis({}), - {}, - ), +await configure({ + sinks: {console: getConsoleSink()}, + filters: {}, + loggers: [ + {category: ["logtape", "meta"], sinks: ["console"], level: "warning"}, + {category: ["fedify"], sinks: ["console"], level: "info"}, + {category: ["dotino-veloce"], sinks: ["console"], level: "debug"}, + ], }); +const l = getLogger(["dotino-veloce", "main"]) + +l.debug`Creating redis object...` +const redis = new Redis({}) + +l.debug`Creating federation object...` +const kv = new RedisKvStore(redis, {}) + +l.debug`Creating federation object...` +const federation = createFederation({kv}) + +l.debug`Creating Deno handler...` const handler: Deno.ServeHandler = function handler(request) { const response = federation.fetch( request, @@ -21,9 +37,12 @@ const handler: Deno.ServeHandler = function handler(request) { return response }; +l.info`Starting server...` Deno.serve( { port: 8080, + onListen: (_localAddr) => { + }, }, handler, );