mirror of
https://github.com/taoensso/telemere.git
synced 2025-12-17 01:51:10 +00:00
[fix] pr-signal pr-fn support broken
Thanks to @DenisMc for the report!
This commit is contained in:
parent
8afb25dbf0
commit
e7cce0c12b
2 changed files with 30 additions and 25 deletions
|
|
@ -620,9 +620,7 @@
|
||||||
:param 'pr-fn
|
:param 'pr-fn
|
||||||
:expected
|
:expected
|
||||||
#?(:clj '#{:edn unary-fn}
|
#?(:clj '#{:edn unary-fn}
|
||||||
:cljs '#{:edn :json unary-fn})}))
|
:cljs '#{:edn :json unary-fn})}))))]
|
||||||
|
|
||||||
(have fn? pr-fn)))]
|
|
||||||
|
|
||||||
(fn pr-signal [signal]
|
(fn pr-signal [signal]
|
||||||
(let [not-map? (not (map? signal))
|
(let [not-map? (not (map? signal))
|
||||||
|
|
@ -635,7 +633,9 @@
|
||||||
(str output nl)
|
(str output nl)
|
||||||
(do output)))))))
|
(do output)))))))
|
||||||
|
|
||||||
(comment ((pr-signal-fn :edn) (tel/with-signal (tel/event! ::ev-id {:kvs {:k1 "v1"}}))))
|
(comment
|
||||||
|
((pr-signal-fn :edn) (tel/with-signal (tel/event! ::ev-id {:kvs {:k1 "v1"}})))
|
||||||
|
((pr-signal-fn (fn [_] "str")) (tel/with-signal (tel/event! ::ev-id {:kvs {:k1 "v1"}}))))
|
||||||
|
|
||||||
(defn format-signal-fn
|
(defn format-signal-fn
|
||||||
"Experimental, subject to change.
|
"Experimental, subject to change.
|
||||||
|
|
|
||||||
|
|
@ -686,28 +686,33 @@
|
||||||
(is (enc/str-ends-with? preamble "::ev-id"))
|
(is (enc/str-ends-with? preamble "::ev-id"))
|
||||||
(is (string? (re-find #"taoensso.telemere-tests\(\d+,\d+\)" preamble)))]))
|
(is (string? (re-find #"taoensso.telemere-tests\(\d+,\d+\)" preamble)))]))
|
||||||
|
|
||||||
(testing "pr-signal-fn/edn"
|
(testing "pr-signal-fn"
|
||||||
(let [sig (update (with-sig (tel/event! ::ev-id {:inst t0})) :inst enc/inst->udt)
|
(let [sig (with-sig (tel/event! ::ev-id {:inst t0}))]
|
||||||
sig* (enc/read-edn ((tel/pr-signal-fn :edn) sig))]
|
|
||||||
(is
|
|
||||||
(enc/submap? sig*
|
|
||||||
{:schema 1, :kind :event, :id ::ev-id, :level :info,
|
|
||||||
:ns "taoensso.telemere-tests"
|
|
||||||
:inst udt0
|
|
||||||
:line pnat-int?
|
|
||||||
:column pnat-int?}))))
|
|
||||||
|
|
||||||
#?(:cljs
|
[(testing ":edn"
|
||||||
(testing "pr-signal-fn/json"
|
(let [sig (update sig :inst enc/inst->udt)
|
||||||
(let [sig (with-sig (tel/event! ::ev-id {:inst t0}))
|
sig* (enc/read-edn ((tel/pr-signal-fn :edn) sig))]
|
||||||
sig* (enc/read-json ((tel/pr-signal-fn :json) sig))]
|
(is
|
||||||
(is
|
(enc/submap? sig*
|
||||||
(enc/submap? sig*
|
{:schema 1, :kind :event, :id ::ev-id, :level :info,
|
||||||
{"schema" 1, "kind" "event", "id" "taoensso.telemere-tests/ev-id",
|
:ns "taoensso.telemere-tests"
|
||||||
"level" "info", "ns" "taoensso.telemere-tests",
|
:inst udt0
|
||||||
"inst" t0s
|
:line pnat-int?
|
||||||
"line" pnat-int?
|
:column pnat-int?}))))
|
||||||
"column" pnat-int?})))))
|
|
||||||
|
#?(:cljs
|
||||||
|
(testing ":json"
|
||||||
|
(let [sig* (enc/read-json ((tel/pr-signal-fn :json) sig))]
|
||||||
|
(is
|
||||||
|
(enc/submap? sig*
|
||||||
|
{"schema" 1, "kind" "event", "id" "taoensso.telemere-tests/ev-id",
|
||||||
|
"level" "info", "ns" "taoensso.telemere-tests",
|
||||||
|
"inst" t0s
|
||||||
|
"line" pnat-int?
|
||||||
|
"column" pnat-int?})))))
|
||||||
|
|
||||||
|
(testing "user fn"
|
||||||
|
(is (= ((tel/pr-signal-fn (fn [_] "str")) sig) (str "str" utils/newline))))]))
|
||||||
|
|
||||||
(testing "format-signal-fn"
|
(testing "format-signal-fn"
|
||||||
(let [sig (with-sig (tel/event! ::ev-id {:inst t0}))]
|
(let [sig (with-sig (tel/event! ::ev-id {:inst t0}))]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue