Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make callsite-id in log! macro deterministic for Clojure #354

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/taoensso/timbre.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,14 @@

(defn- fline [and-form] (:line (meta and-form)))


#?(:clj
(let [rand ^java.util.Random (java.util.Random. 715873)]
(defn deterministic-rand []
(.nextDouble rand)))
:cljs
(def deterministic-rand rand))

(defmacro log! ; Public wrapper around `-log!`
"Core low-level log macro. Useful for tooling/library authors, etc.

Expand Down Expand Up @@ -726,7 +734,7 @@
;; `slf4j-timbre`, etc.):
callsite-id
(hash [level msg-type args ; Unevaluated args (arg forms)
?ns-str ?file ?line (rand)])
?ns-str ?file ?line (deterministic-rand)])

vargs-form
(if (symbol? args)
Expand Down