mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 06:23:38 -05:00
Unify logging
This commit is contained in:
parent
7b275e9e0e
commit
8bc6d0e291
1 changed files with 24 additions and 20 deletions
|
@ -38,6 +38,7 @@ module.exports = WebsocketController =
|
||||||
client.set("login_count", user?.loginCount)
|
client.set("login_count", user?.loginCount)
|
||||||
|
|
||||||
callback null, project, privilegeLevel, WebsocketController.PROTOCOL_VERSION
|
callback null, project, privilegeLevel, WebsocketController.PROTOCOL_VERSION
|
||||||
|
logger.log {user_id, project_id, client_id: client.id}, "user joined project"
|
||||||
|
|
||||||
# No need to block for setting the user as connected in the cursor tracking
|
# No need to block for setting the user as connected in the cursor tracking
|
||||||
ConnectedUsersManager.updateUserPosition project_id, client.id, user, null, () ->
|
ConnectedUsersManager.updateUserPosition project_id, client.id, user, null, () ->
|
||||||
|
@ -72,13 +73,12 @@ module.exports = WebsocketController =
|
||||||
|
|
||||||
joinDoc: (client, doc_id, fromVersion = -1, callback = (error, doclines, version, ops) ->) ->
|
joinDoc: (client, doc_id, fromVersion = -1, callback = (error, doclines, version, ops) ->) ->
|
||||||
Utils.getClientAttributes client, ["project_id", "user_id"], (error, {project_id, user_id}) ->
|
Utils.getClientAttributes client, ["project_id", "user_id"], (error, {project_id, user_id}) ->
|
||||||
|
return callback(error) if error?
|
||||||
|
return callback(new Error("no project_id found on client")) if !project_id?
|
||||||
logger.log {user_id, project_id, doc_id, fromVersion, client_id: client.id}, "client joining doc"
|
logger.log {user_id, project_id, doc_id, fromVersion, client_id: client.id}, "client joining doc"
|
||||||
|
|
||||||
AuthorizationManager.assertClientCanViewProject client, (error) ->
|
AuthorizationManager.assertClientCanViewProject client, (error) ->
|
||||||
return callback(error) if error?
|
return callback(error) if error?
|
||||||
client.get "project_id", (error, project_id) ->
|
|
||||||
return callback(error) if error?
|
|
||||||
return callback(new Error("no project_id found on client")) if !project_id?
|
|
||||||
DocumentUpdaterManager.getDocument project_id, doc_id, fromVersion, (error, lines, version, ops) ->
|
DocumentUpdaterManager.getDocument project_id, doc_id, fromVersion, (error, lines, version, ops) ->
|
||||||
return callback(error) if error?
|
return callback(error) if error?
|
||||||
# Encode any binary bits of data so it can go via WebSockets
|
# Encode any binary bits of data so it can go via WebSockets
|
||||||
|
@ -93,6 +93,7 @@ module.exports = WebsocketController =
|
||||||
escapedLines.push line
|
escapedLines.push line
|
||||||
client.join(doc_id)
|
client.join(doc_id)
|
||||||
callback null, escapedLines, version, ops
|
callback null, escapedLines, version, ops
|
||||||
|
logger.log {user_id, project_id, doc_id, fromVersion, client_id: client.id}, "client joined doc"
|
||||||
|
|
||||||
leaveDoc: (client, doc_id, callback = (error) ->) ->
|
leaveDoc: (client, doc_id, callback = (error) ->) ->
|
||||||
Utils.getClientAttributes client, ["project_id", "user_id"], (error, {project_id, user_id}) ->
|
Utils.getClientAttributes client, ["project_id", "user_id"], (error, {project_id, user_id}) ->
|
||||||
|
@ -128,18 +129,23 @@ module.exports = WebsocketController =
|
||||||
|
|
||||||
getConnectedUsers: (client, callback = (error, users) ->) ->
|
getConnectedUsers: (client, callback = (error, users) ->) ->
|
||||||
Utils.getClientAttributes client, ["project_id", "user_id"], (error, {project_id, user_id}) ->
|
Utils.getClientAttributes client, ["project_id", "user_id"], (error, {project_id, user_id}) ->
|
||||||
logger.log {user_id, project_id, client_id: client.id}, "getting connected users"
|
|
||||||
|
|
||||||
AuthorizationManager.assertClientCanViewProject client, (error) ->
|
|
||||||
return callback(error) if error?
|
|
||||||
client.get "project_id", (error, project_id) ->
|
|
||||||
return callback(error) if error?
|
return callback(error) if error?
|
||||||
return callback(new Error("no project_id found on client")) if !project_id?
|
return callback(new Error("no project_id found on client")) if !project_id?
|
||||||
|
logger.log {user_id, project_id, client_id: client.id}, "getting connected users"
|
||||||
|
AuthorizationManager.assertClientCanViewProject client, (error) ->
|
||||||
|
return callback(error) if error?
|
||||||
ConnectedUsersManager.getConnectedUsers project_id, (error, users) ->
|
ConnectedUsersManager.getConnectedUsers project_id, (error, users) ->
|
||||||
return callback(error) if error?
|
return callback(error) if error?
|
||||||
callback null, users
|
callback null, users
|
||||||
|
logger.log {user_id, project_id, client_id: client.id}, "got connected users"
|
||||||
|
|
||||||
|
|
||||||
applyOtUpdate: (client, doc_id, update, callback = (error) ->) ->
|
applyOtUpdate: (client, doc_id, update, callback = (error) ->) ->
|
||||||
|
Utils.getClientAttributes client, ["user_id", "project_id"], (error, {user_id, project_id}) ->
|
||||||
|
return callback(error) if error?
|
||||||
|
return callback(new Error("no project_id found on client")) if !project_id?
|
||||||
|
# Omit this logging for now since it's likely too noisey
|
||||||
|
#logger.log {user_id, project_id, doc_id, client_id: client.id, update: update}, "applying update"
|
||||||
AuthorizationManager.assertClientCanEditProject client, (error) ->
|
AuthorizationManager.assertClientCanEditProject client, (error) ->
|
||||||
if error?
|
if error?
|
||||||
logger.error {err: error, doc_id, client_id: client.id, version: update.v}, "client is not authorized to make update"
|
logger.error {err: error, doc_id, client_id: client.id, version: update.v}, "client is not authorized to make update"
|
||||||
|
@ -148,9 +154,6 @@ module.exports = WebsocketController =
|
||||||
client.disconnect()
|
client.disconnect()
|
||||||
, 100
|
, 100
|
||||||
return callback(error)
|
return callback(error)
|
||||||
|
|
||||||
Utils.getClientAttributes client, ["user_id", "project_id"], (error, {user_id, project_id}) ->
|
|
||||||
return callback(error) if error?
|
|
||||||
update.meta ||= {}
|
update.meta ||= {}
|
||||||
update.meta.source = client.id
|
update.meta.source = client.id
|
||||||
update.meta.user_id = user_id
|
update.meta.user_id = user_id
|
||||||
|
@ -165,3 +168,4 @@ module.exports = WebsocketController =
|
||||||
logger.error {err: error, project_id, doc_id, client_id: client.id, version: update.v}, "document was not available for update"
|
logger.error {err: error, project_id, doc_id, client_id: client.id, version: update.v}, "document was not available for update"
|
||||||
client.disconnect()
|
client.disconnect()
|
||||||
callback(error)
|
callback(error)
|
||||||
|
#logger.log {user_id, project_id, doc_id, client_id: client.id}, "applied update"
|
||||||
|
|
Loading…
Reference in a new issue