From 41525ec20ce048953f90be00490f8a25376a4670 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Astori?= Date: Mon, 3 Oct 2016 19:40:26 -0400 Subject: [PATCH] Add hostmasks in logs when possible This will augment logs for `join`/`part`/`quit` with something similar to: ``` [2016-10-03 23:19:29] * astorije2 (~lounge-us@123.45.67.89) join [2016-10-03 23:22:04] * foobar (~foo@irc.example.com) join [2016-10-03 23:22:00] * foo (foo@gateway/web/freenode/ip.12.34.56.789) quit Quit: Page closed [2016-10-03 23:22:12] * bar (~foo@unaffiliated/bar) quit Ping timeout: 252 seconds [2016-10-03 23:31:23] * astorije (~astorije@128.30.0.0) part ``` --- src/userLog.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/userLog.js b/src/userLog.js index 2d4e4ba1..1e10f4d4 100644 --- a/src/userLog.js +++ b/src/userLog.js @@ -16,19 +16,26 @@ module.exports.write = function(user, network, chan, msg) { var tz = Helper.config.logs.timezone || "UTC+00:00"; var time = moment().utcOffset(tz).format(format); - var line = "[" + time + "] "; + var line = `[${time}] `; var type = msg.type.trim(); if (type === "message" || type === "highlight") { // Format: // [2014-01-01 00:00:00] Put that cookie down.. Now!! - line += "<" + msg.from + "> " + msg.text; + line += `<${msg.from}> ${msg.text}`; } else { // Format: // [2014-01-01 00:00:00] * Arnold quit - line += "* " + msg.from + " " + msg.type; + line += `* ${msg.from} `; + + if (msg.hostmask) { + line += `(${msg.hostmask}) `; + } + + line += msg.type; + if (msg.text) { - line += " " + msg.text; + line += ` ${msg.text}`; } }