Rewrite error and warning messages using Logger class.

* Move Logging function into separate Logger class and create
  logger property in env. Logger can handle different types of
  message-creation parameters, including strings, arrays, and
  errors.

* Replace most instances of console.error / "ERROR:" and
  console.warn / "WARNING:" with env.log("warning",...) and
  env.log("error",...). Also append prefixes "WARNING:" and
  "ERROR:" to log message depending on logType.

* The logging level "fatal" terminates a process and will end
  an HTTP request if it exists, while "fatal/request" ends an
  HTTP request. Also, "error" is for errors that must be known
  about at runtime, while "warning" is for errors that need not
  be known about at runtime.

* Remove MWParserEnv.errCB and most instances where an errCB is
  created / called, replacing errCB with env.log("fatal",...).

* Set up default backend to log errors to and make it possible
  to register new backends (generally error callback functions).
  Backends can be registered using both regular expressions
  (e.g. /fatal|warning/) or logType strings ("fatal").

* emitMessage now emits objects to backends, rather than message
  strings.

* When logType is fatal, waits until all backends have
  been logged to before ending the process.

* Modify DOMTraverser constructor and other functions where
  env is not available to take env as a parameter.

* Prevent infinite error recursion in the logger using a
  processingLogRequest boolean. Put fatal requests on a queue
  to ensure they are dealt with.

* Prevents infinite error recursion in ParsoidService by
  checking to see whether headers have already been sent
  before setting headers / ending and sending responses.

Change-Id: I26d96c9b6801dcc3ef1c4793747402bf8c0d6761
Merge "Rewrite error and warning messages using Logger class."