Rework implementation to work on older versions of node.js.

The previous implementation used a non-standard console.Console object
that didn't work on older versions of node.js. Rework it to explicitly
check whether to call console.{log,error} directly or to use util.format
before calling into the file stream.