Skip to content

Commit

Permalink
v0.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
philoskim committed Aug 10, 2021
1 parent d4ef567 commit f71e762
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 37 deletions.
15 changes: 9 additions & 6 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ To include `debux` in your project for development, simply add the following to

[source]
....
[philoskim/debux "0.8.0"]
[philoskim/debux "0.8.1"]
....

and this to your *production* dependencies.

[source]
....
[philoskim/debux-stubs "0.8.0"]
[philoskim/debux-stubs "0.8.1"]
....


Expand All @@ -65,6 +65,9 @@ and this to your *production* dependencies.
NOTE: You can see _All change logs since v0.3.0_
https://github.com/philoskim/debux/tree/master/doc/change-logs.adoc[here].

* v0.8.1
** `dbgt` and `clogt` macro bugs fixed.
* v0.8.0
** `dbgt` and `clogt` macros for debugging transducers added. See the details
<<dbgt, here>>.
Expand Down Expand Up @@ -2265,7 +2268,7 @@ dbgt: (filter odd?)
|< [1 3]
----

### .Debugging composed transducers
### Debugging composed transducers

[source]
.Example
Expand Down Expand Up @@ -2319,9 +2322,9 @@ dbgt: (comp (map inc) (filter odd?))

| string | O | O | O | O | O | O | O
| :msg or :m | O | O | O | O | O | O | X
| number | O | O | O | O | X | X | X
| number | O | O | O | O | O | O | X
| :if | O | O | O | O | O | O | O
| :locals or :l | O | O | O | O | X | X | X
| :locals or :l | O | O | O | O | O | O | X
| :print or :p | O | X | O | X | X | X | X
| :dup | X | 0 | X | 0 | X | X | X
| :level | O | O | O | O | O | O | X
Expand Down Expand Up @@ -3611,7 +3614,7 @@ an example about running the link:https://github.com/bhauman/lein-figwheel[figwh
(defproject examples "0.1.0-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.8.0"]
[org.clojure/clojurescript "1.10.238"]
[philoskim/debux "0.8.0"]]
[philoskim/debux "0.8.1"]]
:plugins [[lein-cljsbuild "1.1.6"]
[lein-figwheel "0.5.10"]]
:source-paths ["src/clj"]
Expand Down
3 changes: 3 additions & 0 deletions doc/change-logs.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
:source-highlighter: coderay
:sectnums:

* v0.8.1
** `dbgt` and `clogt` macro bugs fixed.
* v0.8.0
** `dbgt` and `clogt` macros for debugging transducers added.
** `set-debug-level!` removed. Instead, use `with-level` macro.
Expand Down
2 changes: 1 addition & 1 deletion examples/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
:dependencies [[org.clojure/clojure "1.8.0"]
[org.clojure/clojurescript "1.10.238"]
[org.clojure/core.async "0.3.465"]
[philoskim/debux "0.8.0"]]
[philoskim/debux "0.8.1"]]
:plugins [[lein-cljsbuild "1.1.7"]
[lein-figwheel "0.5.18"]]
:source-paths ["src/clj" "src/cljc"]
Expand Down
9 changes: 9 additions & 0 deletions examples/src/clj/examples/lab.clj
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
(ns examples.lab)

(use 'debux.core)

;;; dbgt for transducers
(transduce (dbgt (filter odd?))
conj (range 10))

(transduce (dbgt (comp (map inc) (filter odd?)))
conj (range 5))

(dbg (range))
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject philoskim/debux "0.8.0"
(defproject philoskim/debux "0.8.1"
:description "A trace-based debugging library for Clojure and ClojureScript"
:url "https://github.com/philoskim/debux"
:license {:name "Eclipse Public License - v 1.0"
Expand Down
38 changes: 23 additions & 15 deletions src/debux/common/util.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,15 @@
;;; print
(def dbg-symbols*
'#{debux.dbgn/d
dbg dbgn dbg-last
dbg_ dbgn_ dbg-last_
dbg dbgn dbgt dbg-last dbg-prn
dbg_ dbgn_ dbgt_ dbg-last_ dbg-prn_
debux.core/dbg* debux.core/dbgn*
debux.core/dbgt*
debux.cs.clogn/d
clog clogn clog-last
clog_ clogn_ clog-last_
debux.cs.core/clog* debux.cs.core/clogn*})
clog clogn clogt clog-last
clog_ clogn_ clogt_ clog-last_
debux.cs.core/clog* debux.cs.core/clogn*
debux.cs.core/clogt*})

(defn remove-dbg-symbols [form]
(loop [loc (sequential-zip form)]
Expand Down Expand Up @@ -418,16 +420,22 @@
result#))

(defn print-xform [quoted-xform indent-level]
(fn [rf]
(fn ([] (rf))
([result] (rf result))
([result input]
(pprint-xform-with-indent ">" input indent-level)
(let [output (rf result input)]
(pprint-xform-with-indent"<" output indent-level)
(when (or (nil? indent-level) (= 1 indent-level))
(insert-blank-line))
output) ))))
(let [print-length *print-length*
debug-level *debug-level*]
(fn [rf]
(fn ([] (rf))
([result] (rf result))
([result input]
;; transducers seem to work in another threads,
;; so dynamic vars have to be reset here.
(binding [*print-length* print-length
*debug-level* debug-level]
(pprint-xform-with-indent ">" input indent-level)
(let [output (rf result input)]
(pprint-xform-with-indent"<" output indent-level)
(when (or (nil? indent-level) (= 1 indent-level))
(insert-blank-line))
output) ))))))

(defmacro spy-xform
[xform & [indent-level]]
Expand Down
8 changes: 4 additions & 4 deletions src/debux/cs/macro_types.clj
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
:skip-form-itself-type
'#{catch cljs.core/defprotocol cljs.core/defrecord cljs.core/deftype finally
cljs.core/js-comment cljs.core/js-inline-comment
debux.core/dbg debux.core/dbgn
debux.core/dbg* debux.core/dbgn*
debux.cs.core/dbg debux.cs.core/dbgn
debux.cs.core/dbg* debux.cs.core/dbgn*
debux.core/dbg debux.core/dbgn debux.core/dbgt
debux.core/dbg* debux.core/dbgn* debux.core/dbgt*
debux.cs.core/dbg debux.cs.core/dbgn debux.cs.core/dbgt
debux.cs.core/dbg* debux.cs.core/dbgn* debux.cs.core/dbgt*
debux.cs.core/clog debux.cs.core/clogn
debux.cs.core/clog* debux.cs.core/clogn*}

Expand Down
12 changes: 6 additions & 6 deletions src/debux/dbgt.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
(if (and (>= (or ~level 0) ut/*debug-level*)
(or ~(not (contains? opts :condition))
condition#))
(binding [ut/*indent-level* (inc ut/*indent-level*)]
(binding [ut/*indent-level* (inc ut/*indent-level*)
*print-length* (or ~n (:print-length @ut/config*))]
(let [src-info# (str (ut/src-info ~ns ~line))
title# (str "dbgt: " (ut/truncate (pr-str '~form))
(and ~msg (str " <" ~msg ">")))
Expand All @@ -18,9 +19,7 @@
(when ~(:locals opts)
(ut/pprint-locals-with-indent locals#)
(ut/insert-blank-line))

(binding [*print-length* (or ~n (:print-length @ut/config*))]
~body) ))
~body))
~form) ))

(defmacro dbg-xform
Expand Down Expand Up @@ -49,9 +48,10 @@

(comment

(dbgt (map inc) {} {:ns "ns" :line 12})
(transduce (dbgt (filter even?) {} {:ns "ns" :line 12})
(dbgt (map inc) {} {:ns "ns" :line 12 :n 2})
(transduce (dbgt (filter even?) {} {:ns "ns" :line 12 :n 2})
conj (range 10))
(dbg-xform (map inc) {} {:ns "ns", :line 12, :n 2})

(dbgt (comp (map inc) (filter odd?)) {} {:ns "ns" :line 12})
(transduce (dbgt (comp (map inc) (filter even?)) {} {:ns "ns" :line 12})
Expand Down
8 changes: 4 additions & 4 deletions src/debux/macro_types.clj
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
:skip-form-itself-type
`#{catch definline definterface defprotocol defrecord
deftype finally gen-class gen-interface
debux.core/dbg debux.core/dbgn
debux.core/dbg* debux.core/dbgn*
debux.cs.core/clog debux.cs.core/clogn
debux.cs.core/clog* debux.cs.core/clogn*}
debux.core/dbg debux.core/dbgn debux.core/dbgt
debux.core/dbg* debux.core/dbgn* debux.core/dbgt*
debux.cs.core/clog debux.cs.core/clogn debux.cs.core/clogt
debux.cs.core/clog* debux.cs.core/clogn* debux.cs.core/clogt*}

:expand-type
`#{clojure.core/.. -> ->> doto cond-> cond->> condp import
Expand Down

0 comments on commit f71e762

Please sign in to comment.