Merge pull request #3475 from overleaf/jpa-frontend-logging

[frontend] proper source location for console.log calls with debug=true

GitOrigin-RevId: b82860e6c113745694c3dc0617cc1bfe7daefbfb
This commit is contained in:
Jakob Ackermann 2020-12-11 10:41:41 +00:00 committed by Copybot
parent f560ee6d53
commit b7e4ece352
2 changed files with 3 additions and 20 deletions

View file

@ -85,26 +85,9 @@ App.run(($rootScope, $templateCache) => {
) )
}) })
const sl_debugging = const sl_debugging = window.location.search.match(/debug=true/)
__guard__(window.location != null ? window.location.search : undefined, x =>
x.match(/debug=true/)
) != null
var sl_console_last_log = null
window.sl_debugging = sl_debugging // make a global flag for debugging code window.sl_debugging = sl_debugging // make a global flag for debugging code
window.sl_console = { window.sl_console = sl_debugging ? console : { log() {} }
log(...args) {
if (sl_debugging) {
sl_console_last_log = null
return console.log(...Array.from(args || []))
}
},
logOnce(...args) {
if (sl_debugging && args[0] !== sl_console_last_log) {
sl_console_last_log = args[0]
return console.log(...Array.from(args || []))
}
}
}
export default App export default App

View file

@ -328,7 +328,7 @@ export default (Document = (function() {
if (inflightOp == null && pendingOp == null) { if (inflightOp == null && pendingOp == null) {
// there's nothing going on, this is ok. // there's nothing going on, this is ok.
saved = true saved = true
sl_console.logOnce('[pollSavedStatus] no inflight or pending ops') sl_console.log('[pollSavedStatus] no inflight or pending ops')
} else if (inflightOp != null && inflightOp === this.oldInflightOp) { } else if (inflightOp != null && inflightOp === this.oldInflightOp) {
// The same inflight op has been sitting unacked since we // The same inflight op has been sitting unacked since we
// last checked, this is bad. // last checked, this is bad.