iodide-project / iodide

Literate scientific computing and communication for the web
Mozilla Public License 2.0
1.49k stars 143 forks source link

capture`console.log` and direct to iodide console #727

Open bcolloran opened 6 years ago

bcolloran commented 6 years ago
bcolloran commented 6 years ago

this could be a replacement for iodide.print, or we could try something else

bcolloran commented 6 years ago

we can proxy window.console.log and direct it's input to our console, but should we? will a lot of noise filter though from libraries? something to experiment with

wlach commented 6 years ago

codepen.io does this, it seems pretty useful.

hamilton commented 6 years ago

I suggested doing this a while ago in lieu of iodide.print to maximally make things clear to users, and still think it should be trivial to intercept this AND also forward to console.*.

bcolloran commented 6 years ago

a lib that might help: https://github.com/samdenty99/console-feed (also has pretty good reps (not universally great reps tho))

bcolloran commented 6 years ago

we'll also need to figure out how to not include things like the dev mode redux logs for when reduxVerbose===true

MayeulC commented 5 years ago

I agree with the proposal. I looked at iodide after a high school maths teacher asked me if I knew of any way to run modern python in the browser, to make it easier on High-schoolers to perform their homework without the need for installing additional software (nor dedicated servers).

As-is, iodide could fit the bill quite well, if there was an additional "python console" tab, or any other mechanism to get the script's stdout. Of course, the interface could be trimmed down to a minimum for such a use-case, at a later point, but just having stdout would likely make this a viable option.

bcolloran commented 5 years ago

@MayeulC -- regarding the interface, did you notice that the panes can be moved and resized? if you just want to see the editor and the console, you can drag by the tabs to arrange the view you want, and we have an open issue about toggling layouts via menu here: https://github.com/iodide-project/iodide/issues/1468

bcolloran commented 5 years ago

mental note: now that we've really stripped down the console code, noise from console.log calls in libraries will be greatly reduced, and in particular redux logging from the editor side won't get in the way.

MayeulC commented 5 years ago

@MayeulC -- regarding the interface, did you notice that the panes can be moved and resized? if you just want to see the editor and the console, you can drag by the tabs to arrange the view you want, and we have an open issue about toggling layouts via menu here: #1468

Well, I am sorry to reply this late. I ended up going with Brython: https://github.com/brython-dev/brython/issues/1131

The issue I had was that writing print("hello") in python would not print any output, except in the browser console. I would have liked it that simple for students and beginners alike.