Is there a way, in Linux, to make the electron
executable copy or redirect output sent to its console to the shell console, i.e. when I run it from a terminal?
For instance, if I run, in a shell, electron foo.js
, where foo.js
contains simply console.log("foo")
, I get the foo
message echoed back to my terminal.
However, when I run a React app, the output of console.log
is directed to the browser's console (as explained here).
Is there a way to copy/redirect the outputs sent to the browser Console, so that they will also be sent to the shell console? This can be very useful for some kinds of debugging (e.g. using grep
and regexes).
Alternatively, if there are other methods than console.log
that allow writing to the shell which created the browser process, that would also be helpful.
Edit: @0stone0 mentioned the difference between server code and client code; from the point of view of debugging, since I am running a local process, the browser could very well decide to copy its console output to stdout
/stderr
. I fail to see why technically Chromium could not do it; requiring an API or websockets for this use case seems excessive, but if that is indeed necessary (e.g. for security reasons), that is a valid answer for me.