protected function errorStop($use) {
    foreach (libxml_get_errors() as $error) {
      switch ($error->level) {
        case LIBXML_ERR_WARNING:
        case LIBXML_ERR_ERROR:
          $level = LogLevel::WARNING;
          break;

        case LIBXML_ERR_FATAL:
          $level = LogLevel::ERROR;
          break;

        default:
          $level = LogLevel::INFO;
      }

      $this->log($level, '%error on line %num. Error code: %code.', array(
        '%error' => trim($error->message),
        '%num' => $error->line,
        '%code' => $error->code,
      ));
    }
    libxml_clear_errors();
    libxml_use_internal_errors($use);
  }