mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-19 14:13:34 +01:00
SocketIORouter: Logging improvements
This commit is contained in:
parent
b9609a749d
commit
2e93fca699
1 changed files with 7 additions and 2 deletions
|
@ -21,9 +21,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const log4js = require('log4js');
|
const log4js = require('log4js');
|
||||||
|
const settings = require('../utils/Settings');
|
||||||
const stats = require('../stats');
|
const stats = require('../stats');
|
||||||
|
|
||||||
const logger = log4js.getLogger('message');
|
const logger = log4js.getLogger('socket.io');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves all components
|
* Saves all components
|
||||||
|
@ -50,6 +51,9 @@ exports.setSocketIO = (_io) => {
|
||||||
io = _io;
|
io = _io;
|
||||||
|
|
||||||
io.sockets.on('connection', (socket) => {
|
io.sockets.on('connection', (socket) => {
|
||||||
|
const ip = settings.disableIPlogging ? 'ANONYMOUS' : socket.request.ip;
|
||||||
|
logger.debug(`${socket.id} connected from IP ${ip}`);
|
||||||
|
|
||||||
// wrap the original send function to log the messages
|
// wrap the original send function to log the messages
|
||||||
socket._send = socket.send;
|
socket._send = socket.send;
|
||||||
socket.send = (message) => {
|
socket.send = (message) => {
|
||||||
|
@ -75,7 +79,8 @@ exports.setSocketIO = (_io) => {
|
||||||
await components[message.component].handleMessage(socket, message);
|
await components[message.component].handleMessage(socket, message);
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('disconnect', () => {
|
socket.on('disconnect', (reason) => {
|
||||||
|
logger.debug(`${socket.id} disconnected: ${reason}`);
|
||||||
// store the lastDisconnect as a timestamp, this is useful if you want to know
|
// store the lastDisconnect as a timestamp, this is useful if you want to know
|
||||||
// when the last user disconnected. If your activePads is 0 and totalUsers is 0
|
// when the last user disconnected. If your activePads is 0 and totalUsers is 0
|
||||||
// you can say, if there has been no active pads or active users for 10 minutes
|
// you can say, if there has been no active pads or active users for 10 minutes
|
||||||
|
|
Loading…
Reference in a new issue