This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-02-20
Channels
- # announcements (3)
- # babashka (74)
- # beginners (45)
- # biff (3)
- # calva (10)
- # cherry (1)
- # clojure (7)
- # clojure-austin (4)
- # clojure-europe (50)
- # clojure-losangeles (1)
- # clojure-nl (1)
- # clojure-norway (22)
- # clojure-uk (3)
- # cursive (14)
- # data-science (2)
- # datomic (1)
- # emacs (3)
- # events (5)
- # fulcro (13)
- # holy-lambda (64)
- # hyperfiddle (67)
- # introduce-yourself (1)
- # lsp (5)
- # off-topic (1)
- # rdf (1)
- # re-frame (5)
- # reitit (4)
- # releases (3)
- # shadow-cljs (89)
- # spacemacs (4)
- # squint (5)
- # timbre (9)
- # tools-deps (2)
Hi! I’m seeing duplication of my log message when logging with the raw console appender.
(t/merge-config! {:appenders {:console (t/console-appender {:raw-console? true})}})
With a plain (t/debug [:foo])
, the message is logged like:
timestamp DEBUG [namespace:line] [:foo] [:foo]
string-^ ^-object
With object
I mean that the console formatter properly handles it. I’m using version 6.3.1. Anyone else who have seen this or see what I am doing wrong?Hi there!
Has something changed on your end, is this new behaviour? It sounds like you might be observing the normal/expected behaviour of the default console appender when using raw logging.
When using raw logging, the console appender will send the following to your console:
1. A string representation of your output, based on your output configuration (`:output-fn`, etc.)
2. The raw arguments, for which your browser will choose its own visual representation
You can disable 1 if you like by changing your output-fn
. Or you can disable 2 by turning off the :raw-console?
option.
Hope that helps, but feel free to create a GitHub issue with more info in case I’ve misunderstood something!
Cheers 🙂
Hi! Thanks. Nothing has changed on my end. I am setting up Timbre logging for a project and ran into this. I can confirm that providing :output-fn (fn [_] "")
stops the duplication, but I also loose the timestamp, level info, and the namespace location, which I rather enjoyed. I guess I can snitch the code from default output-fn and strip the string representation of my output from it. Is that what you would suggest?
Ah, my apologies! I misspoke - what you’re seeing is actually a bug in the js console appender. I hadn’t quite understood exactly what you were seeing and thought you might not want any of the output text. The behaviour that I now believe you want should actually be the default. Sorry about that! Could you please try replace your console appender with the following, and let me know if this solves your problem?:
(let [unpatched (timbre/console-appender {})]
(update unpatched :fn
(fn [f] (fn [data] (f (assoc data :msg-type nil))))))
If that does the trick, I’ll push a quick hotfix.Thanks again! I get it to work if I replace my appender with this:
(let [unpatched (t/console-appender {:raw-console? true})]
(update unpatched :fn
(fn [f] (fn [data] (f (assoc data :msg-type nil))))))
Great, thanks for the confirmation. Will get a fix up later today, and ping you here when it’s ready.
Well that’s a charitable way of describing things ^^ I’ve just released https://github.com/taoensso/timbre/releases/tag/v6.4.0 which should address the issue. Again, apologies for the trouble!