mirror of
https://github.com/penpot/penpot.git
synced 2025-02-14 19:19:09 -05:00
📎 Add debug helpers for jvm/tap
This commit is contained in:
parent
036bf84ecd
commit
26f4082b5f
3 changed files with 59 additions and 7 deletions
|
@ -7,6 +7,7 @@
|
||||||
(ns user
|
(ns user
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
|
[app.common.debug :as debug]
|
||||||
[app.common.exceptions :as ex]
|
[app.common.exceptions :as ex]
|
||||||
[app.common.files.helpers :as cfh]
|
[app.common.files.helpers :as cfh]
|
||||||
[app.common.fressian :as fres]
|
[app.common.fressian :as fres]
|
||||||
|
@ -55,8 +56,12 @@
|
||||||
[promesa.exec :as px]))
|
[promesa.exec :as px]))
|
||||||
|
|
||||||
(repl/disable-reload! (find-ns 'integrant.core))
|
(repl/disable-reload! (find-ns 'integrant.core))
|
||||||
|
(repl/disable-reload! (find-ns 'app.common.debug))
|
||||||
|
|
||||||
(set! *warn-on-reflection* true)
|
(set! *warn-on-reflection* true)
|
||||||
|
|
||||||
|
(add-tap #'debug/tap-handler)
|
||||||
|
|
||||||
;; --- Benchmarking Tools
|
;; --- Benchmarking Tools
|
||||||
|
|
||||||
(defmacro run-quick-bench
|
(defmacro run-quick-bench
|
||||||
|
@ -132,12 +137,6 @@
|
||||||
;; :v6 v6
|
;; :v6 v6
|
||||||
;; }])))
|
;; }])))
|
||||||
|
|
||||||
(defonce debug-tap
|
|
||||||
(do
|
|
||||||
(add-tap #(locking debug-tap
|
|
||||||
(prn "tap debug:" %)))
|
|
||||||
1))
|
|
||||||
|
|
||||||
|
|
||||||
(defn calculate-frames
|
(defn calculate-frames
|
||||||
[{:keys [data]}]
|
[{:keys [data]}]
|
||||||
|
|
36
common/src/app/common/debug.clj
Normal file
36
common/src/app/common/debug.clj
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
;;
|
||||||
|
;; Copyright (c) KALEIDOS INC
|
||||||
|
|
||||||
|
(ns app.common.debug
|
||||||
|
(:require
|
||||||
|
[app.common.logging :as l]
|
||||||
|
[app.common.pprint :as pp]))
|
||||||
|
|
||||||
|
(defn pprint
|
||||||
|
[expr]
|
||||||
|
(l/raw! :debug
|
||||||
|
(binding [*print-level* pp/default-level
|
||||||
|
*print-length* pp/default-length]
|
||||||
|
(with-out-str
|
||||||
|
(println "tap dbg:")
|
||||||
|
(pp/pprint expr {:max-width pp/default-width})))))
|
||||||
|
|
||||||
|
|
||||||
|
(def store (atom {}))
|
||||||
|
|
||||||
|
(defn get-stored
|
||||||
|
[]
|
||||||
|
(deref store))
|
||||||
|
|
||||||
|
(defn tap-handler
|
||||||
|
[v]
|
||||||
|
(if (and (vector? v)
|
||||||
|
(keyword (first v)))
|
||||||
|
(let [[command obj] v]
|
||||||
|
(case command
|
||||||
|
(:print :prn :pprint) (pprint obj)
|
||||||
|
:store (reset! store obj)))
|
||||||
|
(pprint v)))
|
|
@ -9,9 +9,26 @@
|
||||||
(:require
|
(:require
|
||||||
[me.flowthing.pp :as pp]))
|
[me.flowthing.pp :as pp]))
|
||||||
|
|
||||||
|
(def default-level 8)
|
||||||
|
(def default-length 25)
|
||||||
|
(def default-width 120)
|
||||||
|
|
||||||
|
#?(:clj
|
||||||
|
(defn set-defaults
|
||||||
|
[& {:keys [level width length]}]
|
||||||
|
(when length
|
||||||
|
(alter-var-root #'default-length (constantly length)))
|
||||||
|
(when width
|
||||||
|
(alter-var-root #'default-width (constantly width)))
|
||||||
|
(when level
|
||||||
|
(alter-var-root #'default-level (constantly level)))
|
||||||
|
nil))
|
||||||
|
|
||||||
(defn pprint
|
(defn pprint
|
||||||
[expr & {:keys [width level length]
|
[expr & {:keys [width level length]
|
||||||
:or {width 120 level 8 length 25}}]
|
:or {width default-width
|
||||||
|
level default-level
|
||||||
|
length default-length}}]
|
||||||
(binding [*print-level* level
|
(binding [*print-level* level
|
||||||
*print-length* length]
|
*print-length* length]
|
||||||
(pp/pprint expr {:max-width width})))
|
(pp/pprint expr {:max-width width})))
|
||||||
|
|
Loading…
Add table
Reference in a new issue