From 0175a86d4c792396997fee38393facf9047d2c41 Mon Sep 17 00:00:00 2001 From: James Allen Date: Thu, 26 May 2016 13:54:34 +0100 Subject: [PATCH] Add in debugging console.logs which only display if ?debug=true is in URL --- services/web/public/coffee/base.coffee | 4 ++++ .../public/coffee/ide/connection/ConnectionManager.coffee | 3 +++ services/web/public/coffee/ide/editor/Document.coffee | 5 +++-- services/web/public/coffee/ide/editor/ShareJsDoc.coffee | 5 +++-- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/services/web/public/coffee/base.coffee b/services/web/public/coffee/base.coffee index 98cdb3a871..b62635170a 100644 --- a/services/web/public/coffee/base.coffee +++ b/services/web/public/coffee/base.coffee @@ -23,5 +23,9 @@ define [ baseUrl: window.sharelatex.sixpackDomain client_id: window.user_id }) + + sl_debugging = window.location?.search?.match(/debug=true/)? + window.sl_console = + log: (args...) -> console.log(args...) if sl_debugging return App diff --git a/services/web/public/coffee/ide/connection/ConnectionManager.coffee b/services/web/public/coffee/ide/connection/ConnectionManager.coffee index 7a52aa16de..4db3efdbe6 100644 --- a/services/web/public/coffee/ide/connection/ConnectionManager.coffee +++ b/services/web/public/coffee/ide/connection/ConnectionManager.coffee @@ -61,6 +61,8 @@ define [], () -> if @$scope.state.loading @$scope.state.load_progress = 70 + sl_console.log "[socket.io connect] Connected" + setTimeout(() => @joinProject() , 100) @@ -97,6 +99,7 @@ define [], () -> , 10 * 1000 joinProject: () -> + sl_console.log "[joinProject] joining..." @ide.socket.emit 'joinProject', { project_id: @ide.project_id }, (err, project, permissionsLevel, protocolVersion) => diff --git a/services/web/public/coffee/ide/editor/Document.coffee b/services/web/public/coffee/ide/editor/Document.coffee index e00573aef1..eb8843629c 100644 --- a/services/web/public/coffee/ide/editor/Document.coffee +++ b/services/web/public/coffee/ide/editor/Document.coffee @@ -172,14 +172,14 @@ define [ update: update if window.disconnectOnAck? and Math.random() < window.disconnectOnAck - console.log "Disconnecting on ack", update + sl_console.log "Disconnecting on ack", update window._ide.socket.socket.disconnect() # Pretend we never received the ack return if window.dropAcks? and Math.random() < window.dropAcks if !update.op? # Only drop our own acks, not collaborator updates - console.log "Simulating a lost ack", update + sl_console.log "Simulating a lost ack", update return if update?.doc == @doc_id and @doc? @@ -194,6 +194,7 @@ define [ @doc?.updateConnectionState "disconnected" _onReconnect: () -> + sl_console.log "[onReconnect] reconnected (joined project)" @ide.pushEvent "reconnected:afterJoinProject" @connected = true diff --git a/services/web/public/coffee/ide/editor/ShareJsDoc.coffee b/services/web/public/coffee/ide/editor/ShareJsDoc.coffee index 61b9ffb6cf..176ceee51f 100644 --- a/services/web/public/coffee/ide/editor/ShareJsDoc.coffee +++ b/services/web/public/coffee/ide/editor/ShareJsDoc.coffee @@ -29,10 +29,10 @@ define [ send: (update) => @_startInflightOpTimeout(update) if window.disconnectOnUpdate? and Math.random() < window.disconnectOnUpdate - console.log "Disconnecting on update", update + sl_console.log "Disconnecting on update", update window._ide.socket.socket.disconnect() if window.dropUpdates? and Math.random() < window.dropUpdates - console.log "Simulating a lost update", update + sl_console.log "Simulating a lost update", update return @socket.emit "applyOtUpdate", @doc_id, update state: "ok" @@ -95,6 +95,7 @@ define [ @_doc.flush() updateConnectionState: (state) -> + sl_console.log "[updateConnectionState] Setting state to #{state}" @connection.state = state @connection.id = @socket.socket.sessionid @_doc.autoOpen = false