mirror of
https://github.com/taoensso/telemere.git
synced 2025-12-16 17:41:12 +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
|
||||
:expected
|
||||
#?(:clj '#{:edn unary-fn}
|
||||
:cljs '#{:edn :json unary-fn})}))
|
||||
|
||||
(have fn? pr-fn)))]
|
||||
:cljs '#{:edn :json unary-fn})}))))]
|
||||
|
||||
(fn pr-signal [signal]
|
||||
(let [not-map? (not (map? signal))
|
||||
|
|
@ -635,7 +633,9 @@
|
|||
(str output nl)
|
||||
(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
|
||||
"Experimental, subject to change.
|
||||
|
|
|
|||
|
|
@ -686,28 +686,33 @@
|
|||
(is (enc/str-ends-with? preamble "::ev-id"))
|
||||
(is (string? (re-find #"taoensso.telemere-tests\(\d+,\d+\)" preamble)))]))
|
||||
|
||||
(testing "pr-signal-fn/edn"
|
||||
(let [sig (update (with-sig (tel/event! ::ev-id {:inst t0})) :inst enc/inst->udt)
|
||||
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?}))))
|
||||
(testing "pr-signal-fn"
|
||||
(let [sig (with-sig (tel/event! ::ev-id {:inst t0}))]
|
||||
|
||||
#?(:cljs
|
||||
(testing "pr-signal-fn/json"
|
||||
(let [sig (with-sig (tel/event! ::ev-id {:inst t0}))
|
||||
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 ":edn"
|
||||
(let [sig (update sig :inst enc/inst->udt)
|
||||
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 ":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"
|
||||
(let [sig (with-sig (tel/event! ::ev-id {:inst t0}))]
|
||||
|
|
|
|||
Loading…
Reference in a new issue