mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-12 22:26:08 -04:00
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>
This commit is contained in:
parent
6462968e84
commit
b5fc6db75d
15 changed files with 56 additions and 71 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue