Experimental, subject to change. Minimal Telemere facade API for library authors, etc. Allows library code to use Telemere if it's present, or fall back to something like `tools.logging` otherwise. (ns my-lib (:require [taoensso.telemere.api :as t] ; `com.taoensso/telemere-api` dependency [clojure.tools.logging :as ctl] ; `org.clojure/tools.logging` dependency )) (t/require-telemere-if-present) ; Just below `ns` form ;; Optional convenience for library users (defn set-min-level! "If using Telemere, sets Telemere's minimum level for <library> namespaces. Possible levels: #{:trace :debug :info :warn :error :fatal :report}. Default level: `:warn`. [min-level] (t/if-telemere (do (t/set-min-level! nil "my-lib(.*)" min-level) true) false)) (defonce ^:private __set-default-min-level (set-min-level! :warn)) (signal! {:kind :log, :id :my-id, :level :warn, :let [x :x] :msg ["Hello" "world" x] :data {:a :A :x x} :fallback (ctl/warn (str "Hello world" x))})
(if-telemere then)
(if-telemere then else)
Evaluates to `then` form if Telemere is present when expanding macro. Otherwise expands to `else` form.
(require-telemere-if-present)
Experimental, subject to change. Requires Telemere if it's present, otherwise noops. Used in cooperation with `signal!`, etc. For Cljs: - MUST be placed at top of file, just below `ns` form - Needs ClojureScript >= v1.9.293 (Oct 2016)
(set-min-level! min-level)
(set-min-level! kind min-level)
(set-min-level! kind ns-filter min-level)
Expands to `taoensso.telemere/set-min-level!` call iff Telemere is present. Otherwise expands to `nil` (noops).
(signal! {:as opts
:keys [fallback elidable? location inst uid middleware sample-rate
kind ns id level when rate-limit ctx parent root trace? do let
data msg error run & kvs]})
Experimental, subject to change. Telemere facade API for library authors, etc. Expands to `taoensso.telemere/signal!` call if Telemere is present. Otherwise expands to arbitrary `fallback` opt form. Allows library code to use Telemere if it's present, or fall back to something like `tools.logging` otherwise. MUST be used with `require-telemere-if-present`, example: (ns my-lib (:require [taoensso.telemere.api :as t] ; `com.taoensso/telemere-api` dependency [clojure.tools.logging :as ctl] ; `org.clojure/tools.logging` dependency )) (t/require-telemere-if-present) ; Just below `ns` form! (t/signal! {:kind :log, :id :my-id, :level :warn, :let [x :x] :msg ["Hello" "world" x] :data {:a :A :x x} :fallback (ctl/warn (str "Hello world" x))}) For more info, see: - Telemere `signal!`, Ref. <https://www.taoensso.com/telemere/signal!> - Telemere docs, Ref. <https://www.taoensso.com/telemere>
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close