From ba5d2a85275424578d90ca6adbfa4c0df0804667 Mon Sep 17 00:00:00 2001 From: Paul Rodwell Date: Sun, 25 Jan 2026 13:58:26 +0000 Subject: [PATCH] fix logger issue defining morgan token is problematic. It wrongly reports requests are all to the last wiki server started --- lib/server.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/server.js b/lib/server.js index e2ad4cb..19dca5b 100644 --- a/lib/server.js +++ b/lib/server.js @@ -256,10 +256,22 @@ export default async argv => { // use logger, at least in development, probably needs a param to configure (or turn off). // use stream to direct to somewhere other than stdout. - logger.token('vhost', (req, res) => { - return colorString(wikiName) - }) - app.use(logger(':vhost :method :url :status :res[content-length] - :response-time ms')) + const vhost = colorString(wikiName) + app.use( + logger((tokens, req, res) => { + return [ + vhost, + tokens.method(req, res), + tokens.url(req, res), + tokens.status(req, res), + tokens.res(req, res, 'content-length'), + '-', + tokens['response-time'](req, res), + 'ms', + ].join(' ') + }), + ) + app.use(cookieParser()) app.use(bodyParser.json({ limit: argv.uploadLimit })) app.use(bodyParser.urlencoded({ extended: true, limit: argv.uploadLimit }))