From b7e4ece35203ca71ae18069f9091307b874c8ff3 Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Fri, 11 Dec 2020 10:41:41 +0000 Subject: [PATCH] Merge pull request #3475 from overleaf/jpa-frontend-logging [frontend] proper source location for console.log calls with debug=true GitOrigin-RevId: b82860e6c113745694c3dc0617cc1bfe7daefbfb --- services/web/frontend/js/base.js | 21 ++----------------- .../web/frontend/js/ide/editor/Document.js | 2 +- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/services/web/frontend/js/base.js b/services/web/frontend/js/base.js index 346ece296c..657d7d46d0 100644 --- a/services/web/frontend/js/base.js +++ b/services/web/frontend/js/base.js @@ -85,26 +85,9 @@ App.run(($rootScope, $templateCache) => { ) }) -const sl_debugging = - __guard__(window.location != null ? window.location.search : undefined, x => - x.match(/debug=true/) - ) != null -var sl_console_last_log = null +const sl_debugging = window.location.search.match(/debug=true/) window.sl_debugging = sl_debugging // make a global flag for debugging code -window.sl_console = { - 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 || [])) - } - } -} +window.sl_console = sl_debugging ? console : { log() {} } export default App diff --git a/services/web/frontend/js/ide/editor/Document.js b/services/web/frontend/js/ide/editor/Document.js index ce0f89fe07..053c6ab57e 100644 --- a/services/web/frontend/js/ide/editor/Document.js +++ b/services/web/frontend/js/ide/editor/Document.js @@ -328,7 +328,7 @@ export default (Document = (function() { if (inflightOp == null && pendingOp == null) { // there's nothing going on, this is ok. 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) { // The same inflight op has been sitting unacked since we // last checked, this is bad.