Skip to content

Commit

Permalink
[new] Support runtime :loc override
Browse files Browse the repository at this point in the history
  • Loading branch information
ptaoussanis committed Oct 30, 2024
1 parent 4e1435f commit 52d2bfc
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/taoensso/timbre.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -632,15 +632,16 @@

(have [:or nil? sequential? symbol?] args)
(let [callsite-id (callsite-counter)
loc (or loc (enc/get-source &form &env))
{:keys [ns file line column]} loc
loc-form (or loc (enc/get-source &form &env))
loc-map (when (map? loc-form) loc-form)
loc-sym (when (symbol? loc-form) loc-form)

ns (or (get opts :?ns-str) ns)
file (or (get opts :?file) file)
line (or (get opts :?line) line)
column (or (get opts :?column) column)
ns-form (get opts :?ns-str (get loc-map :ns (when loc-sym `(get ~loc-sym :ns))))
file-form (get opts :?file (get loc-map :file (when loc-sym `(get ~loc-sym :file))))
line-form (get opts :?line (get loc-map :line (when loc-sym `(get ~loc-sym :line))))
column-form (get opts :?column (get loc-map :column (when loc-sym `(get ~loc-sym :column))))

elide? (and (enc/const-forms? level ns) (-elide? level ns))]
elide? (and (enc/const-forms? level ns-form) (-elide? level ns-form))]

(when-not elide?
(let [vargs-form
Expand All @@ -650,7 +651,7 @@
`[ ~@args]))]

;; Note pre-resolved expansion
`(taoensso.timbre/-log! ~config ~level ~ns ~file ~line ~column ~msg-type ~?err
`(taoensso.timbre/-log! ~config ~level ~ns-form ~file-form ~line-form ~column-form ~msg-type ~?err
(delay ~vargs-form) ~?base-data ~callsite-id ~spying?
~(get opts :instant)
~(get opts :may-log?))))))
Expand Down

0 comments on commit 52d2bfc

Please sign in to comment.