0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-15 17:21:17 -05:00

💄 Improve debug traces of libraries helpers

This commit is contained in:
Andrés Moya 2024-02-14 16:54:08 +01:00
parent d3dd9ffd9b
commit f8b574be81

View file

@ -64,6 +64,11 @@
"<local>" "<local>"
(str "<" (get-in state [:workspace-libraries file-id :name]) ">"))) (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 ---- ;; ---- Components and instances creation ----
(defn duplicate-component (defn duplicate-component
@ -1004,7 +1009,10 @@
(defn- add-shape-to-instance (defn- add-shape-to-instance
[changes component-shape index component-page container root-instance root-main omit-touched? set-remote-synced?] [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)) (let [component-parent-shape (ctn/get-shape component-page (:parent-id component-shape))
parent-shape (d/seek #(ctk/is-main-of? component-parent-shape %) parent-shape (d/seek #(ctk/is-main-of? component-parent-shape %)
(cfh/get-children-with-self (:objects container) (cfh/get-children-with-self (:objects container)
@ -1075,7 +1083,10 @@
(defn- add-shape-to-main (defn- add-shape-to-main
[changes shape index component component-container page root-instance root-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)) (let [parent-shape (ctn/get-shape page (:parent-id shape))
component-parent-shape (d/seek #(ctk/is-main-of? % parent-shape) component-parent-shape (d/seek #(ctk/is-main-of? % parent-shape)
(cfh/get-children-with-self (:objects component-container) (cfh/get-children-with-self (:objects component-container)
@ -1176,8 +1187,11 @@
(defn- remove-shape (defn- remove-shape
[changes shape container omit-touched?] [changes shape container omit-touched?]
(log/info :msg (str "REMOVE-SHAPE " (log/info :msg (str "REMOVE-SHAPE "
(if (cfh/page? container) "[P] " "[C] ") (if (cfh/page? container) "[P " "[C ")
(:name shape))) (pretty-uuid (:id container)) "] "
(:name shape)
" "
(pretty-uuid (:id shape))))
(let [objects (get container :objects) (let [objects (get container :objects)
parents (cfh/get-parent-ids objects (:id shape)) parents (cfh/get-parent-ids objects (:id shape))
parent (first parents) parent (first parents)
@ -1225,9 +1239,12 @@
(defn- move-shape (defn- move-shape
[changes shape index-before index-after container omit-touched?] [changes shape index-before index-after container omit-touched?]
(log/info :msg (str "MOVE " (log/info :msg (str "MOVE "
(if (cfh/page? container) "[P] " "[C] ") (if (cfh/page? container) "[P " "[C ")
(pretty-uuid (:id container)) "] "
(:name shape) (:name shape)
" " " "
(pretty-uuid (:id shape))
" "
index-before index-before
" -> " " -> "
index-after)) index-after))
@ -1263,8 +1280,11 @@
changes changes
(do (do
(log/info :msg (str "CHANGE-TOUCHED " (log/info :msg (str "CHANGE-TOUCHED "
(if (cfh/page? container) "[P] " "[C] ") (if (cfh/page? container) "[P " "[C ")
(:name dest-shape)) (pretty-uuid (:id container)) "] "
(:name dest-shape)
" "
(pretty-uuid (:id dest-shape)))
:options options) :options options)
(let [new-touched (cond (let [new-touched (cond
reset-touched? reset-touched?
@ -1298,8 +1318,11 @@
changes changes
(do (do
(log/info :msg (str "CHANGE-REMOTE-SYNCED? " (log/info :msg (str "CHANGE-REMOTE-SYNCED? "
(if (cfh/page? container) "[P] " "[C] ") (if (cfh/page? container) "[P " "[C ")
(:name shape)) (pretty-uuid (:id container)) "] "
(:name shape)
" "
(pretty-uuid (:id shape)))
:remote-synced remote-synced?) :remote-synced remote-synced?)
(-> changes (-> changes
(update :redo-changes conj (make-change (update :redo-changes conj (make-change
@ -1327,9 +1350,14 @@
(log/info :msg (str "SYNC " (log/info :msg (str "SYNC "
(:name origin-shape) (:name origin-shape)
" "
(pretty-uuid (:id origin-shape))
" -> " " -> "
(if (cfh/page? container) "[P] " "[C] ") (if (cfh/page? container) "[P " "[C ")
(:name dest-shape))) (pretty-uuid (:id container)) "] "
(:name dest-shape)
" "
(pretty-uuid (:id dest-shape))))
(let [;; To synchronize geometry attributes we need to make a prior (let [;; To synchronize geometry attributes we need to make a prior
;; operation, because coordinates are absolute, but we need to ;; operation, because coordinates are absolute, but we need to