Add in debugging console.logs which only display if ?debug=true is in URL

This commit is contained in:
James Allen 2016-05-26 13:54:34 +01:00
parent 41f789a313
commit 0175a86d4c
4 changed files with 13 additions and 4 deletions

View file

@ -23,5 +23,9 @@ define [
baseUrl: window.sharelatex.sixpackDomain baseUrl: window.sharelatex.sixpackDomain
client_id: window.user_id 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 return App

View file

@ -61,6 +61,8 @@ define [], () ->
if @$scope.state.loading if @$scope.state.loading
@$scope.state.load_progress = 70 @$scope.state.load_progress = 70
sl_console.log "[socket.io connect] Connected"
setTimeout(() => setTimeout(() =>
@joinProject() @joinProject()
, 100) , 100)
@ -97,6 +99,7 @@ define [], () ->
, 10 * 1000 , 10 * 1000
joinProject: () -> joinProject: () ->
sl_console.log "[joinProject] joining..."
@ide.socket.emit 'joinProject', { @ide.socket.emit 'joinProject', {
project_id: @ide.project_id project_id: @ide.project_id
}, (err, project, permissionsLevel, protocolVersion) => }, (err, project, permissionsLevel, protocolVersion) =>

View file

@ -172,14 +172,14 @@ define [
update: update update: update
if window.disconnectOnAck? and Math.random() < window.disconnectOnAck 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() window._ide.socket.socket.disconnect()
# Pretend we never received the ack # Pretend we never received the ack
return return
if window.dropAcks? and Math.random() < window.dropAcks if window.dropAcks? and Math.random() < window.dropAcks
if !update.op? # Only drop our own acks, not collaborator updates 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 return
if update?.doc == @doc_id and @doc? if update?.doc == @doc_id and @doc?
@ -194,6 +194,7 @@ define [
@doc?.updateConnectionState "disconnected" @doc?.updateConnectionState "disconnected"
_onReconnect: () -> _onReconnect: () ->
sl_console.log "[onReconnect] reconnected (joined project)"
@ide.pushEvent "reconnected:afterJoinProject" @ide.pushEvent "reconnected:afterJoinProject"
@connected = true @connected = true

View file

@ -29,10 +29,10 @@ define [
send: (update) => send: (update) =>
@_startInflightOpTimeout(update) @_startInflightOpTimeout(update)
if window.disconnectOnUpdate? and Math.random() < window.disconnectOnUpdate 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() window._ide.socket.socket.disconnect()
if window.dropUpdates? and Math.random() < window.dropUpdates if window.dropUpdates? and Math.random() < window.dropUpdates
console.log "Simulating a lost update", update sl_console.log "Simulating a lost update", update
return return
@socket.emit "applyOtUpdate", @doc_id, update @socket.emit "applyOtUpdate", @doc_id, update
state: "ok" state: "ok"
@ -95,6 +95,7 @@ define [
@_doc.flush() @_doc.flush()
updateConnectionState: (state) -> updateConnectionState: (state) ->
sl_console.log "[updateConnectionState] Setting state to #{state}"
@connection.state = state @connection.state = state
@connection.id = @socket.socket.sessionid @connection.id = @socket.socket.sessionid
@_doc.autoOpen = false @_doc.autoOpen = false