var Q = require('q');
var request = require('request');
var globalOptions = require('./options');

function requestorModule() {

  var getUrl = function(url) {
    console.log('Requesting ', url);
    var defer = Q.defer();

    try {

      var requestOptions = {
        url: url,
        rejectUnauthorized: false,
        auth: globalOptions.authInfo()
      };

      request(requestOptions, function (error, response, body) {
        // TODO .auth('username', 'password', false); // https://www.npmjs.com/package/request#http-authentication
        if (error) {
          console.log('failed to get', url, error);
          defer.reject();
        } else {
          defer.resolve(body);
        }
      });
    } catch(error) {
      defer.reject(error);
    }

    return defer.promise;
  };

  return {
    getUrl: getUrl
  };
}

var requestor = requestorModule();
exports.getUrl = requestor.getUrl;

@@ -90,16 +90,50 @@
 tions');
+%0Avar logger = require('./logger');
 %0A%0Afuncti
@@ -191,26 +191,27 @@
 ) %7B%0A    
-console.lo
+logger.debu
 g('Reque

Decrease logging level