mirror of
https://github.com/taoensso/telemere.git
synced 2026-02-20 01:26:04 +00:00
[new] Add private format-location util
This commit is contained in:
parent
b58ec7359d
commit
385c671756
1 changed files with 18 additions and 1 deletions
|
|
@ -51,6 +51,23 @@
|
||||||
(format-id (str *ns*) ::id1)
|
(format-id (str *ns*) ::id1)
|
||||||
(format-id nil ::id1))
|
(format-id nil ::id1))
|
||||||
|
|
||||||
|
(enc/def* ^:private format-location
|
||||||
|
"Private, don't use.
|
||||||
|
Returns \"<ns/file>(<line>,<column>)\", etc."
|
||||||
|
{:tag #?(:clj 'String :cljs 'string)}
|
||||||
|
(enc/fmemoize
|
||||||
|
(fn [ns line column file]
|
||||||
|
(when-let [base (or ns file)]
|
||||||
|
(if line
|
||||||
|
(if column
|
||||||
|
(str base "(" line "," column ")")
|
||||||
|
(str base "(" line ")"))
|
||||||
|
base)))))
|
||||||
|
|
||||||
|
(comment
|
||||||
|
(format-location "my-ns" 120 8 nil)
|
||||||
|
(format-location nil 120 8 *file*))
|
||||||
|
|
||||||
;;;; Unique IDs (UIDs)
|
;;;; Unique IDs (UIDs)
|
||||||
|
|
||||||
(defn nano-uid-fn
|
(defn nano-uid-fn
|
||||||
|
|
@ -561,7 +578,7 @@
|
||||||
(if kind (s+spc (upper-qn kind)) (s+spc "DEFAULT"))
|
(if kind (s+spc (upper-qn kind)) (s+spc "DEFAULT"))
|
||||||
#?(:clj (s+spc (hostname)))
|
#?(:clj (s+spc (hostname)))
|
||||||
|
|
||||||
;; "<ns>(<line>,<column>)"
|
;; As `format-location`
|
||||||
(when-let [base (or ns (get signal :file))]
|
(when-let [base (or ns (get signal :file))]
|
||||||
(let [s+ (partial enc/sb-append sb)] ; Without separator
|
(let [s+ (partial enc/sb-append sb)] ; Without separator
|
||||||
(s+ " " base)
|
(s+ " " base)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue