Fork me on GitHub
#cider
<
2023-11-03
>
John14:11:02

what 'the' way to redirect prints and stuff to my repl from a thread? I expected (def something *out) evaluated from the REPL then binding *out from within the thread to work, but I guess the bound *out* that I save is meant for a single nrepl message

vemv14:11:42

I sense that

(binding [*out* (io/writer System/out)]
  (println 42))
should do it, however currently it stack overflows 😱 Otherwise I hadn't hard of an "api" that we had for this. You can however use any logging framework - its output should go to the repl

John14:11:20

info on timbre doesn't go to the repl (as is at least). i jacked in remotely, and due to issues i dont have a way to read stdout/journal right now

John14:11:28

well, not from within the thread at least

vemv14:11:54

remotely as in production?

vemv14:11:07

> info on timbre doesn't go to the repl IIRC it does for basic cases on local connections. Using the repl as a stdout viewer for remote connections is kind of a fringe use case IMO, there are simpler tools e.g tail / less over ssh. We'd welcome a PR that made this easier (w/o losing simplicity), otherwise it seems an unlikely improvement

vemv14:11:37

The mentioned Stackoverflow shouldn't really happen, maybe by fixing it we'd enable more usage patterns

John14:11:46

hm I'm not starting nrepl with the cider handler, maybe that's a cause

John14:11:12

yeah exactly 😛 I can't tail right now due to a bug, which I can fix but I took the opportunity to figure out what if I couldn't

vemv14:11:31

> hm I'm not starting nrepl with the cider handler, maybe that's a cause likely, cider-nrepl has a special out middleware

John14:11:50

stumbled on it's source and now here https://docs.cider.mx/cider-nrepl/nrepl-api/supplied_middleware.html

wrap-out
	
-
	
Yes
	
out-subscribe/out-unsubscribe
	
Echo the server's output stream to client sessions.

John14:11:09

yeah it was the missing handler 🙃

🙌 1
vemv15:11:00

Nice. A useful pattern here could be to selectively enable that middleware in production (otherwise you'll get more stuff required and altering your environment, nrepl functionality, etc)