Some logging cleanup

This commit is contained in:
Bryan Ashby 2022-05-07 11:47:04 -06:00
parent 18420fd7a7
commit bd28de9a69
No known key found for this signature in database
GPG Key ID: C2C1B501E4EFD994
6 changed files with 14 additions and 13 deletions

View File

@ -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);
});

View File

@ -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})`
);
}

View File

@ -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

View File

@ -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);

View File

@ -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);
});

View File

@ -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;
}