Use a configurable logger object for all logging.

Introduces a new configuration option `logger_factory`.  This option
can be set to a function receiving one argument, `category`, and
returning an object with (at least) functions `debug`, `log`, `warn`,
and `error`.

If the `logger_factory` option isn't specified, the default is to log
using the `console` object, with each log message prefixed by the log
category in square brackets.  This means that logging will work as
before this change, except that the prefix is formatted differently.

This change makes logging calls more DRY (by obviating the need to
manually prefix log messages with `LOG_PREFIX`) and enables use of
third-party logging frameworks, such as log4javascript.