This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-05-09
Channels
- # announcements (3)
- # beginners (61)
- # biff (20)
- # cider (13)
- # clerk (6)
- # clojure (58)
- # clojure-brasil (5)
- # clojure-europe (30)
- # clojure-nl (1)
- # clojure-norway (10)
- # clojure-uk (5)
- # clr (25)
- # core-async (2)
- # cursive (19)
- # datahike (5)
- # datalevin (1)
- # docker (1)
- # emacs (3)
- # fulcro (4)
- # hoplon (3)
- # hyperfiddle (91)
- # java (2)
- # juxt (5)
- # london-clojurians (1)
- # lsp (38)
- # malli (12)
- # nrepl (9)
- # off-topic (7)
- # polylith (15)
- # portal (49)
- # rdf (2)
- # re-frame (43)
- # releases (2)
- # shadow-cljs (30)
- # spacemacs (15)
- # sql (36)
- # tools-build (20)
- # xtdb (3)
Not sure if this is an nrepl thing or a cider thing. I think it's a cider-nrepl thing. I start my repl using the following incantation:
clj -Sdeps '{:deps {nrepl/nrepl {:mvn/version,"1.0.0"},cider/cider-nrepl {:mvn/version,"0.28.5"}}}' -M:dev:test -m nrepl.cmdline --middleware "[cider.nrepl/cider-middleware]"
Logs that occur synchronously (same thread as the repl) go to the repl window. Logs from all other threads go to the console where I ran that command. I'd like to be able to route all logging to one or the other as I desire, but I can't find the settings to do this kind of toggle, or the binding I need to override. I found this: https://docs.cider.mx/cider-nrepl/nrepl-api/ops.html#out-unsubscribe but I'm not sure how to use it.I can't find that var in the cider-nrepl repo. Or in the nrepl repo. I'm not using emacs so I don't think cider itself is in play here. I'm using Calva.
There is an issue (and gist "fix") for this: https://github.com/nrepl/nrepl/issues/119
Sorry I'm incredibly late to respond. Yeah this helps a little bit but it doesn't let me redirect *out*
to System/out
which is what I need. And it appears this doesn't work:
(alter-var-root #'*out* (fn [_] (java.io.PrintWriter. System/out)))
I think something else is writing bindings on top of *out*
so my var altering is ignored. But I'm not sure where.
Since this thread is pretty old / stale I think I'm going to open up a new one and watch it a bit more closely this time.
Solved my issue, ironically around the time @pez is asking related questions, so I'll send this back to the channel. If I set a binding when I start the system, I can get the behavior I'm looking for: all logs go to the nREPL server out not client out.
(binding [*out* (java.io.PrintWriter. System/out)
*err* (java.io.PrintWriter. System/err)]
(def test-system (component/start (new-test-system default-test-config))))
If at any point I want to shift output to the client, I can restart the system and use the aforementioned gist.Solved my issue, ironically around the time @pez is asking related questions, so I'll send this back to the channel. If I set a binding when I start the system, I can get the behavior I'm looking for: all logs go to the nREPL server out not client out.
(binding [*out* (java.io.PrintWriter. System/out)
*err* (java.io.PrintWriter. System/err)]
(def test-system (component/start (new-test-system default-test-config))))
If at any point I want to shift output to the client, I can restart the system and use the aforementioned gist.