var CDN = 'http://cdn.peerjs.com';
var FILE = 'peer.js';

var FULL_TEST_TIMEOUT = 30000;

function loadScript(v, cb) {
  if (!cb) {
    cb = noop;
  }
  var loadTimeout = setTimeout(function(){
    cb(new Error('Could not load PeerJS v' + v));
  }, 2000);
  var script = document.createElement('script');
  script.onload = function(){
    clearTimeout(loadTimeout);
    cb()
  };
  script.setAttribute("type", "text/javascript");
  script.setAttribute("src", CDN + "/" + v + "/" + FILE);
  document.getElementsByTagName("head")[0].appendChild(script);
}

function saveTestData(id, data, cb) {
  if (!cb) {
    cb = noop;
  }
  var out = {};
  out[ROLE] = data;
  out.testId = id;
  post('/save', out, cb);
}

function end(workerId, msg) {
  end = function(){};
  // Ensure end only runs once
  clearTimeout(testTimeout);
  if (TEST_ID && msg) {
    console.log(msg);
    saveTestData(TEST_ID, {ended: msg});
  }
  post('/end', {workerId: workerId, msg: msg}, noop);
}

// Load testing dependency
var queryData = getQueryData();

var WORKER_ID = queryData.WORKER_ID;
var TEST_ID = queryData.TEST_ID;
var ROLE = queryData.ROLE; // 'client' or 'host'
var PEERJS_VERSION = queryData.PEERJS_VERSION || '0';

if (!WORKER_ID) {
  // Shit
  throw new Error('No WORKER_ID');
}
if (!ROLE) {
  // Shit
  throw new Error('No ROLE specified');
}
if (!TEST_ID) {
  end(WORKER_ID, 'Missing TEST_ID');
  throw new Error('Missing TEST_ID');
}

loadScript(PEERJS_VERSION, function(err){
  if (err) {
    console.log('Error:', err.message);
    end(WORKER_ID, err.message);
  } else {
    console.log('Script loaded');
    saveTestData(TEST_ID, {
      browser: browserInfo(),
      peerJSVersion: PEERJS_VERSION
    });
    init();
  }
});

var testTimeout = setTimeout(function(){
  end(WORKER_ID, 'timeout');
}, FULL_TEST_TIMEOUT);


@@ -1,12 +1,206 @@
+var LOG_FUNC = console.log.bind(console);%0Avar logData = %5B%5D;%0Aconsole.log = function()%7B%0A  args = Array.prototype.slice(arguments);%0A  logData.push(args);%0A  LOG_FUNC(LOG_FUNC.apply(null, args);%0A%7D;%0A%0A
 var CDN = 'h
@@ -1025,15 +1025,8 @@
 T_ID
- && msg
 ) %7B%0A
@@ -1084,16 +1084,30 @@
 ded: msg
+, log: logData
 %7D);%0A  %7D%0A

Add log data recording