From cefba35e7f1b46bcef1dcbd854043ce4f9051b74 Mon Sep 17 00:00:00 2001 From: Tom Kirkpatrick Date: Wed, 13 Mar 2024 12:20:05 +0100 Subject: [PATCH] Use custom logger in api middleware pipeline --- src/server.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/server.tsx b/src/server.tsx index 9a0bc6f..fe1a3b9 100644 --- a/src/server.tsx +++ b/src/server.tsx @@ -41,6 +41,10 @@ const CACHE_CHECKPERIOD = config.get("cache.checkperiod"); const log = logger(LOGLEVEL); +const middlewareLogger = (message: string, ...rest: string[]) => { + log.info({ msg: message, ...rest }); +} + // Log the configuration values. log.info(config.util.toObject()); @@ -105,7 +109,7 @@ app.get("/health/live", async (c) => { }); // Add middleware. -app.use("*", honoLogger()); +app.use("*", honoLogger(middlewareLogger)); app.use("*", etag()); app.use("*", cors({ origin: "*" })); app.use("/static/*", serveStatic({ root: "./" }));