Skip to content

Commit

Permalink
Ready for PR.
Browse files Browse the repository at this point in the history
  • Loading branch information
philip-healy committed Apr 29, 2018
1 parent e02c05a commit 29ed727
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
@@ -1,6 +1,6 @@
# Spyscope

A Clojure library designed to make it easy to debug single- and multi-threaded applications.
A Clojure(Script) library designed to make it easy to debug single- and multi-threaded applications.

## Installation

Expand Down
6 changes: 3 additions & 3 deletions project.clj
Expand Up @@ -13,9 +13,9 @@
[clj-time "0.14.3"]
[com.andrewmcveigh/cljs-time "0.5.2"]
[net.cgrand/macrovich "0.2.1"]
;[mvxcvi/puget "1.0.2"]
[mvxcvi/puget "1.0.2" :exclusions [org.clojure/core.rrb-vector]]
[quantum/org.clojure.core.rrb-vector "0.0.12"]]
[mvxcvi/puget "1.0.2" :exclusions [brandonbloom/fipp]]
[bigml/fipp "0.6.8"]]


:plugins [[lein-cljsbuild "1.1.7"]
[lein-doo "0.1.10" :exclusions [org.clojure/clojurescript]]]
Expand Down
12 changes: 4 additions & 8 deletions src/spyscope/core.cljc
@@ -1,17 +1,13 @@
(ns spyscope.core
(:require [clojure.string :as str]

#?(:clj [clj-time.core :as time]
:cljs [cljs-time.core :as time])

#?(:clj [clj-time.format :as fmt]
:cljs [cljs-time.format :as fmt])

#?(:clj [puget.printer :as pp]))
#?(:clj (:require [net.cgrand.macrovich :as macrovich])
:cljs (:require-macros [net.cgrand.macrovich :as macrovich])))


(defn- indent
"Indents a string with `n` spaces."
[n string]
Expand Down Expand Up @@ -91,8 +87,7 @@
[form]
`(macrovich/case
:clj (doto ~form pp/cprint)
:cljs (println ~form)))

:cljs (doto ~form println)))

; Trace storage - an atom rather than an agent is used in cljs.
#?(:clj (def ^{:internal true} trace-storage (agent {:trace [] :generation 0}))
Expand All @@ -107,7 +102,9 @@
~(assoc (meta form)
::form (list 'quote form)))]
(when ~(::print? (meta form))
(print (str (:message value#) "\n")))
(macrovich/case
:clj (print (str (:message value#) "\n"))
:cljs (print (str (:message value#)))))
((macrovich/case :clj send-off :cljs swap!) trace-storage
(fn [{g# :generation t# :trace :as storage#}]
(assoc storage#
Expand All @@ -116,7 +113,6 @@
:generation g#)))))
f#))


(defn print-log-detailed
"Reader function to pprint a form's value with some extra information."
[form]
Expand Down
2 changes: 1 addition & 1 deletion test/spyscope/tests.cljs
Expand Up @@ -9,7 +9,7 @@

(deftest print-log-detailed-test
(spyscope.repl/trace-clear)
(is (re-matches #"spyscope\.tests\.print_log_detailed_test\.cljs.*\(\+ 1 2 3\) => 6\n"
(is (re-matches #"spyscope\.tests\.print_log_detailed_test\.cljs.*\(\+ 1 2 3\) => 6"
(with-out-str #spy/d (+ 1 2 3)))))

(deftest trace-test
Expand Down

0 comments on commit 29ed727

Please sign in to comment.