Browse Source

add more debug log

Tienson Qin 4 tuần trước cách đây
mục cha
commit
2495d9bf89

+ 4 - 1
src/main/frontend/common/thread_api.cljc

@@ -2,7 +2,8 @@
   "Macro for defining thread apis, which is invokeable by other threads"
   #?(:cljs (:require-macros [frontend.common.thread-api]))
   #?(:cljs (:require [logseq.db :as ldb]
-                     [promesa.core :as p])))
+                     [promesa.core :as p]
+                     [lambdaisland.glogi :as log])))
 
 #?(:cljs
    (def *thread-apis (volatile! {})))
@@ -27,6 +28,8 @@
      "Return a promise whose value is transit-str."
      [qualified-kw-str direct-pass? args-transit-str-or-args-array]
      (let [qkw (keyword qualified-kw-str)]
+       (log/info ::remote-function qualified-kw-str
+                 :thread-api-exists? (fn? (@*thread-apis qkw)))
        (vswap! *profile update qkw inc)
        (if-let [f (@*thread-apis qkw)]
          (let [result (if (= qkw :thread-api/set-infer-worker-proxy)

+ 8 - 2
src/main/frontend/db/transact.cljs

@@ -1,6 +1,7 @@
 (ns frontend.db.transact
   "Provides async transact for use with ldb/transact!"
   (:require [clojure.core.async :as async]
+            [clojure.core.async.impl.protocols :as async-protocols]
             [clojure.core.async.interop :refer [p->c]]
             [frontend.common.async-util :include-macros true :refer [<?]]
             [frontend.state :as state]
@@ -27,7 +28,12 @@
                      :request request-f
                      :response resp}]
     (swap! *unfinished-request-ids conj request-id)
-    (async/go (async/>! requests new-request))
+    (async/go
+      (let [result (async/>! requests new-request)]
+        (when (false? result)
+          (log/error ::failed-to-add-transact-request
+                     {:request-id request-id
+                      :requests-chan-closed? (async-protocols/closed? requests)}))))
     resp))
 
 (defn remove-request!
@@ -41,7 +47,7 @@
                       :payload {:type :worker-request-failed}}]))
 
 (defn listen-for-requests []
-  (prn "[debug] setup listen for worker request!")
+  (log/info ::transact-listen-to-requests {})
   (async/go-loop []
     (when-let [{:keys [id request response]} (async/<! requests)]
       (try

+ 2 - 1
src/main/frontend/handler.cljs

@@ -159,8 +159,9 @@
 
   (events/run!)
 
+  (log/info ::start-web-worker {})
+
   (p/do!
-   (prn :debug :start-db-worker)
    (-> (p/let [_ (db-browser/start-db-worker!)
                repos (repo-handler/get-repos)
                _ (state/set-repos! repos)

+ 3 - 0
src/main/frontend/handler/editor.cljs

@@ -327,6 +327,7 @@
 (defn outliner-insert-block!
   [config current-block new-block {:keys [sibling? keep-uuid? ordered-list?
                                           replace-empty-target?]}]
+  (log/info ::outliner-insert-block new-block)
   (let [ref-query-top-block? (and (or (:ref? config)
                                       (:custom-query? config))
                                   (not (:ref-query-child? config)))
@@ -505,6 +506,7 @@
   ([state]
    (insert-new-block! state nil))
   ([_state block-value]
+   (log/info ::insert-new-block {})
    (->
     (when (not config/publishing?)
       (when-let [state (get-state)]
@@ -2464,6 +2466,7 @@
 
 (defn- keydown-new-block
   [state]
+  (log/info ::keydown {})
   (when-not (auto-complete?)
     (let [{:keys [block config]} (get-state)]
       (when block

+ 2 - 0
src/main/frontend/state.cljs

@@ -18,6 +18,7 @@
             [frontend.util.cursor :as cursor]
             [goog.dom :as gdom]
             [goog.object :as gobj]
+            [lambdaisland.glogi :as log]
             [logseq.common.config :as common-config]
             [logseq.db :as ldb]
             [logseq.db.common.entity-plus :as entity-plus]
@@ -48,6 +49,7 @@
     (when (nil? worker)
       (prn :<invoke-db-worker-error qkw)
       (throw (ex-info "db-worker has not been initialized" {})))
+    (log/info ::invoke-db-worker {:qkw qkw})
     (apply worker qkw direct-pass? args-list)))
 
 (defn <invoke-db-worker

+ 2 - 4
src/main/frontend/worker/db_worker.cljs

@@ -629,12 +629,10 @@
 
 (def-thread-api :thread-api/apply-outliner-ops
   [repo ops opts]
+  (log/info ::apply-outliner-ops ops)
+  (log/info ::before-tx-id (:max-tx (worker-state/get-datascript-conn repo)))
   (when-let [conn (worker-state/get-datascript-conn repo)]
     (try
-      (when (worker-state/mobile?)
-        (log/info ::apply-outliner-ops ops)
-        (log/info ::before-apply-outliner-ops ops
-                  ::tx-id (:max-tx @conn)))
       (worker-util/profile
        "apply outliner ops"
        (outliner-op/apply-ops! repo conn ops (worker-state/get-date-formatter repo) opts))

+ 4 - 4
src/main/mobile/init.cljs

@@ -64,10 +64,10 @@
 (defn- app-state-change-handler
   "NOTE: don't add more logic in this listener, use mobile-flows instead"
   [^js state]
-  (println :debug :app-state-change-handler state (js/Date.)
-           :current-graph (state/get-current-repo)
-           :app-active? (.-isActive state)
-           :worker-client-id @state/*db-worker-client-id)
+  (log/info :app-state-change-handler state
+            :current-graph (state/get-current-repo)
+            :app-active? (.-isActive state)
+            :worker-client-id @state/*db-worker-client-id)
   (when (state/get-current-repo)
     (let [is-active? (.-isActive state)]
       (if (not is-active?)