From 3aa6a9d3f863fcfa521d4a6ba6c2379579c1aa39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20P=C4=99dzich?= Date: Sun, 1 Sep 2024 10:28:20 +0200 Subject: [PATCH] Log shortest path queries --- src/pages/index.astro | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/pages/index.astro b/src/pages/index.astro index 05dae7b..2343a59 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -22,8 +22,14 @@ let graphProps: Awaited> = { try { driverNames = await getDriverNames(); - if (noEmptyParams && paramsNotEqual) + if (noEmptyParams && paramsNotEqual) { + const timestamp = new Date().toLocaleString('pl'); + const clientIp = + Astro.request.headers.get('X-Forwarded-For') || Astro.clientAddress; + + console.log(`[${timestamp}] ${clientIp} FROM ${source} TO ${dest}`); graphProps = await getShortestPaths(source, dest); + } } catch (error) { return Astro.redirect('/error'); }