From 90a9b31d0798cab61bfbdc3b01f066693f3e9ff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20P=C4=99dzich?= Date: Thu, 25 Jul 2024 23:04:36 +0200 Subject: [PATCH] Use Polish date format in the logs --- index.mjs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/index.mjs b/index.mjs index 42a056a..e31a7d7 100644 --- a/index.mjs +++ b/index.mjs @@ -1,18 +1,18 @@ import { createServer } from 'node:http'; import { clearInterval, setInterval } from 'node:timers'; +const msg = ':) you are an idiot hahahahaha :)'; + const server = createServer((req, res) => { const connOpenDate = new Date(); + const dateLogText = connOpenDate.toLocaleString('pl'); const attacker = req.headers['x-forwarded-for']; const host = req.headers['x-forwarded-host']; console.log( - `[${connOpenDate.toLocaleString()}] ${attacker} targeted ${host} on ${ - req.method - } ${req.url}` + `[${dateLogText}] ${attacker} targeted ${host} on ${req.method} ${req.url}` ); - const msg = ':) you are an idiot hahahahaha :)'; let charIdx = 0; const intervalId = setInterval(() => { @@ -27,11 +27,12 @@ const server = createServer((req, res) => { res.once('close', () => { const connCloseDate = new Date(); const timeDiff = connCloseDate.getTime() - connOpenDate.getTime(); + const dateLogText = connCloseDate.toLocaleString('pl'); const diffText = new Date(timeDiff).toISOString().substring(11, 19); clearInterval(intervalId); console.log( - `[${connCloseDate.toLocaleString()}] ${attacker} aborted connection after ${diffText}` + `[${dateLogText}] ${attacker} aborted connection after ${diffText}` ); }); });