Add username to client.log

This commit is contained in:
Bryan Ashby 2016-01-01 21:17:13 -07:00
parent 1212eb41eb
commit b3e1490d63
2 changed files with 6 additions and 4 deletions

View File

@ -18,6 +18,7 @@ function addNewClient(client, clientSock) {
var id = client.session.id = clientConnections.push(client) - 1; var id = client.session.id = clientConnections.push(client) - 1;
// Create a client specific logger // Create a client specific logger
// Note that this will be updated @ login with additional information
client.log = logger.log.child( { clientId : id } ); client.log = logger.log.child( { clientId : id } );
var connInfo = { var connInfo = {

View File

@ -5,6 +5,7 @@ var theme = require('./theme.js');
var clientConnections = require('./client_connections.js').clientConnections; var clientConnections = require('./client_connections.js').clientConnections;
var userDb = require('./database.js').dbs.user; var userDb = require('./database.js').dbs.user;
var sysProp = require('./system_property.js'); var sysProp = require('./system_property.js');
var logger = require('./logger.js');
var async = require('async'); var async = require('async');
var _ = require('lodash'); var _ = require('lodash');
@ -48,13 +49,13 @@ function userLogin(client, username, password, cb) {
var existingConnError = new Error('Already logged in as supplied user'); var existingConnError = new Error('Already logged in as supplied user');
existingClientConnection.existingConn = true; existingClientConnection.existingConn = true;
cb(existingClientConnection); return cb(existingClientConnection);
return;
} }
// use client.user so we can get correct case // update client logger with addition of username
client.log.info( { username : user.username }, 'Successful login'); client.log = logger.log.child( { clientId : client.log.fields.clientId, username : user.username });
client.log.info('Successful login');
async.parallel( async.parallel(
[ [