0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-28 07:31:25 -05:00

Merge pull request #2616 from penpot/hiru-pretty-debug

💄 Make cleaner debug logs
This commit is contained in:
Andrey Antukh 2022-11-30 14:56:20 +01:00 committed by GitHub
commit 678b6a285f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -8,6 +8,7 @@
(:require
[app.common.data :as d]
[app.common.logging :as l]
[app.common.math :as mth]
[app.common.transit :as t]
[app.common.types.file :as ctf]
[app.common.uuid :as uuid]
@ -120,17 +121,28 @@
(effect-fn input)
(rf result input)))))
(defn prettify
"Prepare x fror cleaner output when logged."
[x]
(cond
(map? x) (d/mapm #(prettify %2) x)
(vector? x) (mapv prettify x)
(seq? x) (map prettify x)
(set? x) (into #{} (map prettify x))
(number? x) (mth/precision x 4)
(uuid? x) (str "#uuid " x)
:else x))
(defn ^:export logjs
([str] (tap (partial logjs str)))
([str val]
(js/console.log str (clj->js val))
(js/console.log str (clj->js (prettify val)))
val))
(when (exists? js/window)
(set! (.-dbg ^js js/window) clj->js)
(set! (.-pp ^js js/window) pprint))
(defonce widget-style "
background: black;
bottom: 10px;