-
-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
send console output to nREPL clients #305
Comments
Since I'm not sure what is the consequence of messing with |
Sure, here is a naive implementation in userspace to replicate (ns user
(:require ["util" :as util]))
(def console-log-original
"The original console.log fn."
js/console.log)
(defn console-log-to-*out*-replicate!
"Replaces `js/console.log` with a fn that forwards its messages both
to `js/console.log`, and Clojure's `*out*` stream."
[]
(set! (.-log js/console)
(fn console-log-new
([data]
(console-log-original data)
(println :js/console.log data))
([& args]
(let [txt (apply util.format args)]
(console-log-new txt))))))
#_(console-log-to-*out*-replicate!) Btw, should nbb automatically read from Thanks |
Does your workaround above work for you in the nREPL? |
OK thanks, I find this feature quite useful for REPL driven development.
Yes, after evaluating the above in a CIDER nbb nREPL and executing nrepl-server buffer
cider-repl buffer
|
As long as the original output is also still visible, I think it's a reasonable fix |
Would you like me to prepare a PR to explore this? |
Sounds good |
Is your feature request related to a problem? Please describe.
When developing interactively on the REPL, is essential for the user to observe the serve responses.
nbb can use javascript packages that sent their text output to the console. When interacting on nREPL, console output is sent to the server stdout/stderr streams, which are not forwarded to the nREPL client, thus the user is likely to miss important output information.
For example if we were to jack-in to nbb with cider on a project with puppeteer installed and eval the following
puppeteer
will log to the console thatWaiting for selector `xyz` failed: Waiting failed: 1000ms exceeded
, but there will be nothing displayed on the user nREPL client, so they will not be aware that something has gone wrong (this information will be printed in the*nrepl-server ...*
buffer, but users are most unlikely to monitor this buffer).Describe the solution you'd like
Either intercept and replicate all js console output or stdout/stderr streams to the nREPL client, possibly using
print
.Describe alternatives you've considered
Replace console.log/err fn with ones that use
println
.Happy to have a look if a solution is agreed.
Thanks
The text was updated successfully, but these errors were encountered: