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

@ -24,4 +24,8 @@ define [
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

View file

@ -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) =>

View file

@ -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

View file

@ -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