diff options
author | Tor Andersson <tor@ccxvii.net> | 2022-04-15 14:33:53 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2022-04-15 14:34:52 +0200 |
commit | 1e2eb28a8dc2fe4cbcd1ffa17fc5f7d778c39d90 (patch) | |
tree | ba344b7e5017f1cde849e7f2beae67b03acafdb4 /server.js | |
parent | 017f4f89ef9af119caf9961e23c66994e8c3ff90 (diff) | |
download | server-1e2eb28a8dc2fe4cbcd1ffa17fc5f7d778c39d90.tar.gz |
Use builting string pad functions.
Diffstat (limited to 'server.js')
-rw-r--r-- | server.js | 14 |
1 files changed, 5 insertions, 9 deletions
@@ -152,14 +152,10 @@ function random_seed() { return crypto.randomInt(1, 0x7ffffffe); } -function pad(s, fmt) { - return s + fmt.slice(s.length); -} - function SLOG(socket, ...msg) { let time = new Date().toISOString().substring(11,19); - let name = pad(socket.user ? socket.user.name : "guest", " "); - let ip = pad(socket.ip, " "); + let name = (socket.user ? socket.user.name : "guest").padEnd(20); + let ip = String(socket.ip).padEnd(15); let ws = "----------"; console.log(time, ip, ws, name, "WS", socket.title_id, @@ -336,9 +332,9 @@ app.use(function (req, res, next) { // Log non-static accesses. let time = new Date().toISOString().substring(11,19); - let name = pad(req.user ? req.user.name : "guest", " "); - let ua = pad(req.user_agent, " "); - ip = pad(ip, " "); + let name = (req.user ? req.user.name : "guest").padEnd(20); + let ua = req.user_agent.padEnd(10); + ip = String(ip).padEnd(15); console.log(time, ip, ua, name, req.method, req.url); return next(); |