From f8b574be816bedc95878043f061f4cba3b069602 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Moya?= Date: Wed, 14 Feb 2024 16:54:08 +0100 Subject: [PATCH] :lipstick: Improve debug traces of libraries helpers --- .../data/workspace/libraries_helpers.cljs | 50 +++++++++++++++---- 1 file changed, 39 insertions(+), 11 deletions(-) diff --git a/frontend/src/app/main/data/workspace/libraries_helpers.cljs b/frontend/src/app/main/data/workspace/libraries_helpers.cljs index ada7e31af2..fd830bb201 100644 --- a/frontend/src/app/main/data/workspace/libraries_helpers.cljs +++ b/frontend/src/app/main/data/workspace/libraries_helpers.cljs @@ -64,6 +64,11 @@ "" (str "<" (get-in state [:workspace-libraries file-id :name]) ">"))) +(defn pretty-uuid + [uuid] + (let [uuid-str (str uuid)] + (subs uuid-str (- (count uuid-str) 6)))) + ;; ---- Components and instances creation ---- (defn duplicate-component @@ -1004,7 +1009,10 @@ (defn- add-shape-to-instance [changes component-shape index component-page container root-instance root-main omit-touched? set-remote-synced?] - (log/info :msg (str "ADD [P] " (:name component-shape))) + (log/info :msg (str "ADD [P " (pretty-uuid (:id container)) "] " + (:name component-shape) + " " + (pretty-uuid (:id component-shape)))) (let [component-parent-shape (ctn/get-shape component-page (:parent-id component-shape)) parent-shape (d/seek #(ctk/is-main-of? component-parent-shape %) (cfh/get-children-with-self (:objects container) @@ -1075,7 +1083,10 @@ (defn- add-shape-to-main [changes shape index component component-container page root-instance root-main] - (log/info :msg (str "ADD [C] " (:name shape))) + (log/info :msg (str "ADD [C " (pretty-uuid (:id component-container)) "] " + (:name shape) + " " + (pretty-uuid (:id shape)))) (let [parent-shape (ctn/get-shape page (:parent-id shape)) component-parent-shape (d/seek #(ctk/is-main-of? % parent-shape) (cfh/get-children-with-self (:objects component-container) @@ -1176,8 +1187,11 @@ (defn- remove-shape [changes shape container omit-touched?] (log/info :msg (str "REMOVE-SHAPE " - (if (cfh/page? container) "[P] " "[C] ") - (:name shape))) + (if (cfh/page? container) "[P " "[C ") + (pretty-uuid (:id container)) "] " + (:name shape) + " " + (pretty-uuid (:id shape)))) (let [objects (get container :objects) parents (cfh/get-parent-ids objects (:id shape)) parent (first parents) @@ -1225,9 +1239,12 @@ (defn- move-shape [changes shape index-before index-after container omit-touched?] (log/info :msg (str "MOVE " - (if (cfh/page? container) "[P] " "[C] ") + (if (cfh/page? container) "[P " "[C ") + (pretty-uuid (:id container)) "] " (:name shape) " " + (pretty-uuid (:id shape)) + " " index-before " -> " index-after)) @@ -1263,8 +1280,11 @@ changes (do (log/info :msg (str "CHANGE-TOUCHED " - (if (cfh/page? container) "[P] " "[C] ") - (:name dest-shape)) + (if (cfh/page? container) "[P " "[C ") + (pretty-uuid (:id container)) "] " + (:name dest-shape) + " " + (pretty-uuid (:id dest-shape))) :options options) (let [new-touched (cond reset-touched? @@ -1298,8 +1318,11 @@ changes (do (log/info :msg (str "CHANGE-REMOTE-SYNCED? " - (if (cfh/page? container) "[P] " "[C] ") - (:name shape)) + (if (cfh/page? container) "[P " "[C ") + (pretty-uuid (:id container)) "] " + (:name shape) + " " + (pretty-uuid (:id shape))) :remote-synced remote-synced?) (-> changes (update :redo-changes conj (make-change @@ -1327,9 +1350,14 @@ (log/info :msg (str "SYNC " (:name origin-shape) + " " + (pretty-uuid (:id origin-shape)) " -> " - (if (cfh/page? container) "[P] " "[C] ") - (:name dest-shape))) + (if (cfh/page? container) "[P " "[C ") + (pretty-uuid (:id container)) "] " + (:name dest-shape) + " " + (pretty-uuid (:id dest-shape)))) (let [;; To synchronize geometry attributes we need to make a prior ;; operation, because coordinates are absolute, but we need to