Skip to content

Instantly share code, notes, and snippets.

@ptaoussanis
Last active February 27, 2026 22:44
Show Gist options
  • Select an option

  • Save ptaoussanis/f8a80f85d3e0f89b307a470ce6e044b5 to your computer and use it in GitHub Desktop.

Select an option

Save ptaoussanis/f8a80f85d3e0f89b307a470ce6e044b5 to your computer and use it in GitHub Desktop.
Example of using Telemere with Bling (rich text console printing lib for Clj/s+)
;; Example created: 2024-12-23
;; Last updated: 2025-03-11 by @paintparty
;; Dependencies:
;; Telemere - Ref. https://github.com/taoensso/telemere v1.0.0-RC5 (2025-03-10)
;; Bling - Ref. https://github.com/paintparty/bling v0.5.2 (2025-03-11)
;; Platform: Clj only for now (haven't tried yet with Cljs)
;; Improvements very welcome!
;; Original context: https://github.com/taoensso/telemere/issues/33
(require '[taoensso.telemere :as tel])
(require '[taoensso.telemere.utils :as tel-utils])
(require '[bling.core :as bling])
(defn- signal->callout-opts
"Returns {:keys [type label data?]} for use with `bling/callout`, etc."
[{:keys [level]}]
(let [label (tel-utils/format-level level)
type
(case level
(:report :info) :info
(:fatal :error) :error
(:warn) :warning
(do nil))
colorway
(case level
(:trace :debug) :subtle
(do :neutral))]
{:type type,
:colorway colorway
:label label,
:data? true,
:margin-top 0,
:margin-bottom 1}))
(tel/add-handler! :my-bling-handler
(let [;; Set your preferred formatting options below as usual:
format-signal-fn (tel/format-signal-fn {:incl-newline? false})
my-output-fn
(fn [signal]
(let [norm-output (format-signal-fn signal)] ; Normal Telemere output
(bling.core/callout ; Add Bling "callout" formatting
(signal->callout-opts signal)
norm-output)))]
(tel/handler:console {:output-fn my-output-fn})))
@cormacc
Copy link
Copy Markdown

cormacc commented Feb 27, 2026

Thanks yourself Jeremiah for a very useful (and fun) library

Re. colour translation choices --they're entirely my fault. Had spent some of the afternoon writing an indexed-db handler for telemere, which reminded me that I'd stolen this gist ages ago but not used it because it wasn't compatible with the cljs-devtools formatters. Did this quickly for fun before shuttting down -- first asked claude to format the log preamble using 'appropriate colors -- e.g. red for error, orange for warning'. Its initial choice for :info was green -- so then asked it to use blue instead, then to use a darker blue -- and here we are :) I'lll certainly use the semantic aliases you've provided going forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment