summaryrefslogtreecommitdiff
path: root/lib/realtime.js
diff options
context:
space:
mode:
authorSheogorath2019-06-08 20:51:24 +0200
committerSheogorath2019-06-08 21:27:29 +0200
commitb5fc6db75db61d9765da38e0f085dd737380f9f4 (patch)
treed221b850be9f961f357b7592636cd35868675383 /lib/realtime.js
parent6462968e84e8d92292dd23764a9e558d7800147d (diff)
Rework debug logging
We have various places with overly simple if statements that could be handled by our logging library. Also a lot of those logs are not marked as debug logs but as info logs, which can cause confusion during debugging. This patch removed unneeded if clauses around debug logging statements, reworks debug log messages towards ECMA templates and add some new logging statements which might be helpful in order to debug things like image uploads. Signed-off-by: Sheogorath <sheogorath@shivering-isles.com>
Diffstat (limited to 'lib/realtime.js')
-rw-r--r--lib/realtime.js30
1 files changed, 14 insertions, 16 deletions
diff --git a/lib/realtime.js b/lib/realtime.js
index d04ffdc2..d85d728e 100644
--- a/lib/realtime.js
+++ b/lib/realtime.js
@@ -49,7 +49,7 @@ function secure (socket, next) {
if (handshakeData.sessionID &&
handshakeData.cookie[config.sessionName] &&
handshakeData.cookie[config.sessionName] !== handshakeData.sessionID) {
- if (config.debug) { logger.info('AUTH success cookie: ' + handshakeData.sessionID) }
+ logger.debug(`AUTH success cookie: ${handshakeData.sessionID}`)
return next()
} else {
next(new Error('AUTH failed: Cookie is invalid.'))
@@ -82,7 +82,7 @@ setInterval(function () {
async.each(Object.keys(notes), function (key, callback) {
var note = notes[key]
if (note.server.isDirty) {
- if (config.debug) logger.info('updater found dirty note: ' + key)
+ logger.debug(`updater found dirty note: ${key}`)
note.server.isDirty = false
updateNote(note, function (err, _note) {
// handle when note already been clean up
@@ -182,7 +182,7 @@ setInterval(function () {
var socket = realtime.io.sockets.connected[key]
if ((!socket && users[key]) ||
(socket && (!socket.rooms || socket.rooms.length <= 0))) {
- if (config.debug) { logger.info('cleaner found redundant user: ' + key) }
+ logger.debug(`cleaner found redundant user: ${key}`)
if (!socket) {
socket = {
id: key
@@ -429,11 +429,11 @@ function finishConnection (socket, noteId, socketId) {
if (config.debug) {
let noteId = socket.noteId
- logger.info('SERVER connected a client to [' + noteId + ']:')
- logger.info(JSON.stringify(user))
- // logger.info(notes);
+ logger.debug(`SERVER connected a client to [${noteId}]:`)
+ logger.debug(JSON.stringify(user))
+ logger.debug(notes)
getStatus(function (data) {
- logger.info(JSON.stringify(data))
+ logger.debug(JSON.stringify(data))
})
}
}
@@ -541,10 +541,8 @@ function disconnect (socket) {
if (isDisconnectBusy) return
isDisconnectBusy = true
- if (config.debug) {
- logger.info('SERVER disconnected a client')
- logger.info(JSON.stringify(users[socket.id]))
- }
+ logger.debug('SERVER disconnected a client')
+ logger.debug(JSON.stringify(users[socket.id]))
if (users[socket.id]) {
delete users[socket.id]
@@ -574,9 +572,9 @@ function disconnect (socket) {
delete note.server
delete notes[noteId]
if (config.debug) {
- // logger.info(notes);
+ logger.debug(notes)
getStatus(function (data) {
- logger.info(JSON.stringify(data))
+ logger.debug(JSON.stringify(data))
})
}
})
@@ -595,9 +593,9 @@ function disconnect (socket) {
if (disconnectSocketQueue.length > 0) { disconnect(disconnectSocketQueue[0]) }
if (config.debug) {
- // logger.info(notes);
+ logger.debug(notes)
getStatus(function (data) {
- logger.info(JSON.stringify(data))
+ logger.debug(JSON.stringify(data))
})
}
}
@@ -774,7 +772,7 @@ function connection (socket) {
var noteId = socket.noteId
var user = users[socket.id]
if (!noteId || !notes[noteId] || !user) return
- if (config.debug) { logger.info('SERVER received [' + noteId + '] user status from [' + socket.id + ']: ' + JSON.stringify(data)) }
+ logger.debug(`SERVER received [${noteId}] user status from [${socket.id}]: ${JSON.stringify(data)}`)
if (data) {
user.idle = data.idle
user.type = data.type