Просмотр исходного кода

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

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

GitOrigin-RevId: b82860e6c113745694c3dc0617cc1bfe7daefbfb
Jakob Ackermann 5 лет назад
Родитель
Сommit
b7e4ece352
2 измененных файлов с 3 добавлено и 20 удалено
  1. 2 19
      services/web/frontend/js/base.js
  2. 1 1
      services/web/frontend/js/ide/editor/Document.js

+ 2 - 19
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
 

+ 1 - 1
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.