From bd28de9a69f46ae5f7490769faf7db30b31b97b6 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Sat, 7 May 2022 11:47:04 -0600 Subject: [PATCH] Some logging cleanup --- core/file_transfer.js | 2 +- core/msg_area_post_fse.js | 2 +- core/nua.js | 4 ++-- core/telnet_bridge.js | 2 +- core/user_config.js | 7 ++++--- core/user_login.js | 10 +++++----- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/core/file_transfer.js b/core/file_transfer.js index bb341051..f2596fe2 100644 --- a/core/file_transfer.js +++ b/core/file_transfer.js @@ -144,7 +144,7 @@ exports.getModule = class TransferFileModule extends MenuModule { }); - this.client.log.info( { sentFiles : sentFiles }, `Successfully sent ${sentFiles.length} file(s)` ); + this.client.log.info( { sentFiles : sentFiles }, `User "${self.client.user.username}" uploaded ${sentFiles.length} file(s)` ); } return cb(err); }); diff --git a/core/msg_area_post_fse.js b/core/msg_area_post_fse.js index 5f25fa19..edb6f1f5 100644 --- a/core/msg_area_post_fse.js +++ b/core/msg_area_post_fse.js @@ -50,7 +50,7 @@ exports.getModule = class AreaPostFSEModule extends FullScreenEditorModule { // note: not logging 'from' here as it's part of client.log.xxxx() self.client.log.info( { to : msg.toUserName, subject : msg.subject, uuid : msg.messageUuid }, - 'Message persisted' + `User "${self.client.user.username}" posted message to "${msg.toUserName}" (${msg.areaTag})` ); } diff --git a/core/nua.js b/core/nua.js index 2cb4c26b..9d65833e 100644 --- a/core/nua.js +++ b/core/nua.js @@ -117,7 +117,7 @@ exports.getModule = class NewUserAppModule extends MenuModule { }; newUser.create(createUserInfo, err => { if(err) { - self.client.log.info( { error : err, username : formData.value.username }, 'New user creation failed'); + self.client.log.warn( { error : err, username : formData.value.username }, 'New user creation failed'); self.gotoMenu(extraArgs.error, err => { if(err) { @@ -126,7 +126,7 @@ exports.getModule = class NewUserAppModule extends MenuModule { return cb(null); }); } else { - self.client.log.info( { username : formData.value.username, userId : newUser.userId }, 'New user created'); + self.client.log.info( { username : formData.value.username, userId : newUser.userId }, `New user "${formData.value.username}" created`); // Cache SysOp information now // :TODO: Similar to bbs.js. DRY diff --git a/core/telnet_bridge.js b/core/telnet_bridge.js index b7ff09e1..ccb53d43 100644 --- a/core/telnet_bridge.js +++ b/core/telnet_bridge.js @@ -215,7 +215,7 @@ exports.getModule = class TelnetBridgeModule extends MenuModule { self.client.removeListener('key press', connectionKeyPressHandler); if(err) { - self.client.log.info(`Telnet bridge connection error: ${err.message}`); + self.client.log.warn(`Telnet bridge connection error: ${err.message}`); } callback(clientTerminated ? new Error('Client connection terminated') : null); diff --git a/core/user_config.js b/core/user_config.js index 4ccd7017..3c7b3060 100644 --- a/core/user_config.js +++ b/core/user_config.js @@ -128,17 +128,18 @@ exports.getModule = class UserConfigModule extends MenuModule { // :TODO: warn end user! return self.prevMenu(cb); } + + self.client.log.info(`User "${self.client.user.username}" updated configuration`); + // // New password if it's not empty // - self.client.log.info('User updated properties'); - if(formData.value.password.length > 0) { self.client.user.setNewAuthCredentials(formData.value.password, err => { if(err) { self.client.log.error( { err : err }, 'Failed storing new authentication credentials'); } else { - self.client.log.info('User changed authentication credentials'); + self.client.log.info(`User "${self.client.user.username}" updated authentication credentials`); } return self.prevMenu(cb); }); diff --git a/core/user_login.js b/core/user_login.js index 2f8c502d..a5e2ece3 100644 --- a/core/user_login.js +++ b/core/user_login.js @@ -45,7 +45,7 @@ function userLogin(client, username, password, options, cb) { const config = Config(); if(config.users.badUserNames.includes(username.toLowerCase())) { - client.log.info( { username, ip : client.remoteAddress }, 'Attempt to login with banned username'); + client.log.info( { username, ip : client.remoteAddress }, `Attempt to login with banned username "${username}"`); // slow down a bit to thwart brute force attacks return setTimeout( () => { @@ -80,13 +80,13 @@ function userLogin(client, username, password, options, cb) { }); if(existingClientConnection) { - client.log.info( + client.log.warn( { existingNodeId : existingClientConnection.node, username : user.username, userId : user.userId }, - `User ${user.username} already logged in` + `User "${user.username}" already logged in on node ${existingClientConnection.node}` ); return cb(Errors.BadLogin( @@ -104,7 +104,7 @@ function userLogin(client, username, password, options, cb) { } ); - client.log.info(`User ${user.username} successfully logged in`); + client.log.info(`User "${user.username}" successfully logged in`); // User's unique session identifier is the same as the connection itself user.sessionId = client.session.uniqueId; // convenience @@ -238,6 +238,6 @@ function transformLoginError(err, client, username) { err = Errors.BadLogin('To many failed login attempts', ErrorReasons.TooMany); } - client.log.info( { username, ip : client.remoteAddress, reason : err.message }, 'Failed login attempt'); + client.log.warn( { username, ip : client.remoteAddress, reason : err.message }, `Failed login attempt for user "${username}", ${client.remoteAddress}`); return err; } \ No newline at end of file