Skip to content

Commit

Permalink
clogn :js option implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
philoskim committed Jan 21, 2019
1 parent 8a58002 commit 519e20c
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 50 deletions.
13 changes: 8 additions & 5 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.5.2"]
[philoskim/debux "0.5.3"]
....

and this to your production dependencies (make sure they are production only):

[source]
....
[philoskim/debux-stubs "0.5.2"]
[philoskim/debux-stubs "0.5.3"]
....


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

* v0.5.3
** The `:js` option can be used in `clogn` now.
* v0.5.2
** The `:js` option error of `clog` is fixed.
Expand Down Expand Up @@ -1857,7 +1860,7 @@ dbgn: (+ n (mul2 3 4) (add2 10 20)) =>
| :dup | X | 0 | X | 0 | X
| :style | X | X | O | O | X
| :once | X | X | O | X | X
| :js | X | X | O | X | X
| :js | X | X | O | O | X

|===

Expand Down Expand Up @@ -2304,7 +2307,7 @@ you can inspect the internal structures of ClojureScript data types.
(clog {:a 10 :b 20} :js)
....

image::clog-5.png[title=":js option example", width=550]
image::clog-5.png[title=":js option example", width=750]



Expand Down Expand Up @@ -2517,7 +2520,7 @@ an example about running the link:https://github.com/bhauman/lein-figwheel[figwh
(defproject example "0.1.0-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.8.0"]
[org.clojure/clojurescript "1.9.854"]
[philoskim/debux "0.5.2"]]
[philoskim/debux "0.5.3"]]
: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.5.3
** The `:js` option can be used in `clogn` now.
* v0.5.2
** The `:js` option error of `clog` is fixed.
Expand Down
Binary file modified doc/img/clog-5.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion example/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.5.2"]]
[philoskim/debux "0.5.3"]]
:plugins [[lein-cljsbuild "1.1.6"]
[lein-figwheel "0.5.18"]]
:source-paths ["src/clj" "src/cljc"]
Expand Down
14 changes: 7 additions & 7 deletions example/src/cljs/example/core.cljs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
(ns example.core
(:require example.lab
;example.common
;example.clogn
;example.clog
;example.dbgn
;example.dbg
;example.options
(:require ;example.lab
example.common
example.clogn
example.clog
example.dbgn
example.dbg
example.options
))

33 changes: 0 additions & 33 deletions example/src/cljs/example/lab.cljs
Original file line number Diff line number Diff line change
@@ -1,36 +1,3 @@
(ns example.lab
(:require [debux.cs.core :as d :refer-macros [clog clogn dbg dbgn break]]))

(clog #(+ 2 3) :js)

(clog (-> "a b c d"
.toUpperCase
(.replace "A" "X")
(.split " ")
first) :js)

(def person
{:name "Mark Volkmann"
:address {:street "644 Glen Summit"
:city "St. Charles"
:state "Missouri"
:zip 63304}
:employer {:name "Object Computing, Inc."
:address {:street "12140 Woodcrest Dr."
:city "Creve Coeur"
:state "Missouri"
:zip 63141}}})

(clog (-> person :employer :address :city) :js)

(def c 5)
(clog (->> c (+ 3) (/ 2) (- 1)) :js)

(clog (let [a (take 5 (range))
{:keys [b c d] :or {d 10 b 20 c 30}} {:c 50 :d 100}
[e f g & h] ["a" "b" "c" "d" "e"]]
[a b c d e f g h]) :js)

(def c (clog (comp inc inc +) :js))

(c 10 20)
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.5.2"
(defproject philoskim/debux "0.5.3"
:description "A trace-based debugging library for Clojure and ClojureScript"
:url "https://github.com/philoskim/debux"
:license {"Eclipse Public License"
Expand Down
2 changes: 1 addition & 1 deletion src/debux/common/util.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
(defn pprint-result-with-indent
[result]
(let [pprint (str/trim (with-out-str (pp/pprint result)))
prefix (str (make-bars *indent-level*) " ")]
prefix (str (make-bars *indent-level*) " ")]
(println (->> (str/split pprint #"\n")
(mapv #(str prefix %))
(str/join "\n")))
Expand Down
5 changes: 3 additions & 2 deletions src/debux/cs/clogn.clj
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@
(defmacro d [form]
`(let [opts# ~'+debux-dbg-opts+
n# (or (:n opts#) (:print-seq-length @ut/config*))
js# (:js opts#)
form-style# (or (:style opts#) :debug)
form# '~(dbgn/remove-d form 'debux.cs.clogn/d)
result# ~form
result2# (ut/take-n-if-seq n# result#)]
(when (or (:dup opts#) (ut/eval-changed? (:evals opts#) form# result2#))
(cs.ut/clog-form-with-indent (cs.ut/form-header form# (:msg opts#))
form-style#)
(cs.ut/clog-result-with-indent result2#))
(cs.ut/clog-result-with-indent result2# js#))
result#))

(defmacro clogn
"Console LOG every Nested forms of a form."
[form & [{:keys [condition msg style] :as opts}]]
`(let [~'+debux-dbg-opts+ ~(dissoc opts :js :once)
`(let [~'+debux-dbg-opts+ ~(dissoc opts :once)
condition# ~condition]
(if (or (nil? condition#) condition#)
(let [title# (str "%cclogn: %c " (ut/truncate (pr-str '~form))
Expand Down

0 comments on commit 519e20c

Please sign in to comment.