Log shortest path queries

This commit is contained in:
Maciej Pędzich 2024-09-01 10:28:20 +02:00
parent 98711d228b
commit 3aa6a9d3f8
Signed by: maciejpedzich
GPG Key ID: CE4A303D84882F0D

View File

@ -22,8 +22,14 @@ let graphProps: Awaited<ReturnType<typeof getShortestPaths>> = {
try { try {
driverNames = await getDriverNames(); 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); graphProps = await getShortestPaths(source, dest);
}
} catch (error) { } catch (error) {
return Astro.redirect('/error'); return Astro.redirect('/error');
} }