PadMessageHandler: Logging improvements
parent
4332affba6
commit
3bb71e14d1
|
@ -134,7 +134,13 @@ exports.handleDisconnect = async function(client)
|
||||||
ip = 'ANONYMOUS';
|
ip = 'ANONYMOUS';
|
||||||
}
|
}
|
||||||
|
|
||||||
accessLogger.info('[LEAVE] Pad "' + session.padId + '": Author "' + session.author + '" on client ' + client.id + ' with IP "' + ip + '" left the pad');
|
const {session: {user} = {}} = client.client.request;
|
||||||
|
accessLogger.info('[LEAVE]' +
|
||||||
|
` pad:${session.padId}` +
|
||||||
|
` socket:${client.id}` +
|
||||||
|
` IP:${ip}` +
|
||||||
|
` authorID:${session.author}` +
|
||||||
|
((user && user.username) ? ` username:${user.username}` : ''));
|
||||||
|
|
||||||
// get the author color out of the db
|
// get the author color out of the db
|
||||||
let color = await authorManager.getAuthorColorId(session.author);
|
let color = await authorManager.getAuthorColorId(session.author);
|
||||||
|
@ -235,6 +241,7 @@ exports.handleMessage = async function(client, message)
|
||||||
` IP:${settings.disableIPlogging ? ANONYMOUS : remoteAddress[client.id]}` +
|
` IP:${settings.disableIPlogging ? ANONYMOUS : remoteAddress[client.id]}` +
|
||||||
` originalAuthorID:${thisSession.author}` +
|
` originalAuthorID:${thisSession.author}` +
|
||||||
` newAuthorID:${authorID}` +
|
` newAuthorID:${authorID}` +
|
||||||
|
((user && user.username) ? ` username:${user.username}` : '') +
|
||||||
` message:${message}`);
|
` message:${message}`);
|
||||||
client.json.send({disconnect: 'rejected'});
|
client.json.send({disconnect: 'rejected'});
|
||||||
return;
|
return;
|
||||||
|
@ -618,7 +625,7 @@ async function handleUserChanges(data)
|
||||||
|
|
||||||
// the empty author is used in the clearAuthorship functionality so this should be the only exception
|
// the empty author is used in the clearAuthorship functionality so this should be the only exception
|
||||||
if ('author' === attr[0] && (attr[1] !== thisSession.author && attr[1] !== '')) {
|
if ('author' === attr[0] && (attr[1] !== thisSession.author && attr[1] !== '')) {
|
||||||
throw new Error("Trying to submit changes as another author in changeset " + changeset);
|
throw new Error(`Author ${thisSession.author} tried to submit changes as author ${attr[1]} in changeset ${changeset}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -632,7 +639,7 @@ async function handleUserChanges(data)
|
||||||
// There is an error in this changeset, so just refuse it
|
// There is an error in this changeset, so just refuse it
|
||||||
client.json.send({ disconnect: "badChangeset" });
|
client.json.send({ disconnect: "badChangeset" });
|
||||||
stats.meter('failedChangesets').mark();
|
stats.meter('failedChangesets').mark();
|
||||||
throw new Error("Can't apply USER_CHANGES, because " + e.message);
|
throw new Error(`Can't apply USER_CHANGES from Socket ${client.id} because: ${e.message}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ex. applyUserChanges
|
// ex. applyUserChanges
|
||||||
|
@ -976,11 +983,13 @@ async function handleClientReady(client, message, authorID)
|
||||||
ip = 'ANONYMOUS';
|
ip = 'ANONYMOUS';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pad.head > 0) {
|
const {session: {user} = {}} = client.client.request;
|
||||||
accessLogger.info('[ENTER] Pad "' + padIds.padId + '": Client ' + client.id + ' with IP "' + ip + '" entered the pad');
|
accessLogger.info(`[${pad.head > 0 ? 'ENTER' : 'CREATE'}]` +
|
||||||
} else if (pad.head === 0) {
|
` pad:${padIds.padId}` +
|
||||||
accessLogger.info('[CREATE] Pad "' + padIds.padId + '": Client ' + client.id + ' with IP "' + ip + '" created the pad');
|
` socket:${client.id}` +
|
||||||
}
|
` IP:${ip}` +
|
||||||
|
` authorID:${authorID}` +
|
||||||
|
((user && user.username) ? ` username:${user.username}` : ''));
|
||||||
|
|
||||||
if (message.reconnect) {
|
if (message.reconnect) {
|
||||||
// If this is a reconnect, we don't have to send the client the ClientVars again
|
// If this is a reconnect, we don't have to send the client the ClientVars again
|
||||||
|
|
Loading…
Reference in New Issue