Clean up logging of error and debug messages.

Right now all stderr is going to the Javascript console as well as to the
terminal window. This would be better if it didn't go to the terminal at all,
since that interferes with the terminal, and some messages are never visible
because they get put on the "alternate screen", which is disabled when the
program exits. There should be some sort of popup error window or some such,
but alert() is not allowed in packaged apps, so it'll take a bit more work.