This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-10-06
Channels
- # babashka (19)
- # beginners (68)
- # calva (9)
- # cider (27)
- # clj-kondo (64)
- # clj-on-windows (2)
- # cljdoc (8)
- # clojure (11)
- # clojure-europe (58)
- # clojure-italy (1)
- # clojure-nl (23)
- # clojure-uk (5)
- # clojurescript (9)
- # cryogen (18)
- # cursive (14)
- # data-science (17)
- # emacs (6)
- # gorilla (6)
- # graphql (1)
- # gratitude (2)
- # holy-lambda (10)
- # introduce-yourself (1)
- # jackdaw (3)
- # jobs (1)
- # leiningen (2)
- # malli (3)
- # missionary (33)
- # off-topic (21)
- # pedestal (7)
- # polylith (8)
- # quil (3)
- # random (1)
- # releases (1)
- # remote-jobs (7)
- # shadow-cljs (18)
- # specter (1)
- # sql (8)
is there a nice character literal for the escape key like there is for \newline
and \space
?
the list there is the list
Hey guys, so I decided to go with mulog for a logging framework. It prints to the console and is minimal. Now I’m trying to integrate it into my swing/seesaw application.
(defn display-progress []
(-> (s/frame
:title "Progress"
:minimum-size [640 :by 400]
:content (s/border-panel
:center (s/scrollable
(l/log-window :id :log-window
:auto-scroll? true)
:vscroll :always)
:south (s/vertical-panel
:items [(s/action :name "Start"
:handler (fn [_] (dl/download-all-paintings)))
(s/action :name "Cancel"
;; TODO Change this to something a little more graceful.
;; I just want it to stop downloading when I hit cancel.
:handler (fn [_] (System/exit 1)))]))
:on-close :dispose)
(s/pack!)
(s/show!)
((fn [w] (go-loop []
(log-to-window w (str (async/<! log-chan) "\n"))
(recur))))))
I’m wondering if there’s a way to make a custom publisher, that can log to a core.async channel.ya, publishers are pretty easy to write, just use one of the base publishers as a template: https://github.com/BrunoBonacci/mulog/blob/master/mulog-core/src/com/brunobonacci/mulog/publisher.clj#L42
you can do whatever you’d like in the publish
fn
(def log-chan (async/chan))
(deftype MyCustomPublisher [config buffer channel]
com.brunobonacci.mulog.publisher.PPublisher
(agent-buffer [_]
buffer)
(publish-delay [_]
500)
(publish [_ buffer]
(go
(doseq [item (map second (rb/items buffer))]
(async/>! channel (str item)))
(rb/clear buffer))))
(defn my-custom-publisher
[config]
(MyCustomPublisher. config (rb/agent-buffer 10000) log-chan))
(def my-publisher (my-custom-publisher {}))
(mu/start-publisher!
{:type :multi
:publishers [{:type :console}
{:type :inline
:publisher my-publisher
:pretty-print true}]})
Alright, well I got something coming along.
I just have no idea how to debug it lol.I’d be wary about wrapping publish (and rb/clear) in a go block: it’s already async so you can use <!! Without blocking your main thread. As for testing you should just be able to pull from the logging chan as you log stuff
@U02EA2T7FEH Thanks for that pointer. I’m still just starting to understand how core.async works.
No worries! I’m not sure if it WILL be a problem, but I could see multiple go threads calling rb/clear at the same time or calling it with unsent messages which could cause dropped logs. So better safe than sorry I’d say :)