Make more use of DefineConsoleMethod

Resubmission of #887 with some fixes.
Pretty sure `if (str)` should be `if (str[0])`.