Introduce debug instead of console.log
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
var async = require('async');
|
||||
var Q = require('q');
|
||||
var debug = require('debug')('ylt:phantomaswrapper');
|
||||
var phantomas = require('phantomas');
|
||||
|
||||
|
||||
var PhantomasWrapper = function() {
|
||||
'use strict';
|
||||
|
||||
@@ -47,16 +49,16 @@ var PhantomasWrapper = function() {
|
||||
};
|
||||
|
||||
// Output the command line for debugging purpose
|
||||
console.log('If you want to reproduce the phantomas task only, copy the following command line:');
|
||||
debug('If you want to reproduce the phantomas task only, copy the following command line:');
|
||||
var optionsString = '';
|
||||
for (var opt in options) {
|
||||
optionsString += ' ' + '--' + opt + '=' + options[opt];
|
||||
}
|
||||
console.log('node node_modules/phantomas/bin/phantomas.js --url=' + task.url + optionsString + ' --verbose');
|
||||
debug('node node_modules/phantomas/bin/phantomas.js --url=' + task.url + optionsString + ' --verbose');
|
||||
|
||||
// Kill the application if nothing happens for 10 minutes
|
||||
var killer = setTimeout(function() {
|
||||
console.log('Killing the app because the test on ' + task.url + ' was launched 10 minutes ago');
|
||||
debug('Killing the app because the test on ' + task.url + ' was launched 10 minutes ago');
|
||||
// If in server mode, forever will restart the server
|
||||
process.exit(1);
|
||||
}, 600000);
|
||||
@@ -66,7 +68,7 @@ var PhantomasWrapper = function() {
|
||||
|
||||
async.retry(triesNumber, function(cb) {
|
||||
phantomas(task.url, options, function(err, json, results) {
|
||||
console.log('Returning from Phantomas');
|
||||
debug('Returning from Phantomas');
|
||||
|
||||
// Adding some YellowLabTools errors here
|
||||
if (json && json.metrics && !json.metrics.javascriptExecutionTree) {
|
||||
@@ -79,12 +81,12 @@ var PhantomasWrapper = function() {
|
||||
|
||||
// Don't cancel test if it is a timeout and we've got some results
|
||||
if (err === 252 && json) {
|
||||
console.log('Timeout after ' + options.timeout + ' seconds. But it\'s not a problem, the test is valid.');
|
||||
debug('Timeout after ' + options.timeout + ' seconds. But it\'s not a problem, the test is valid.');
|
||||
err = null;
|
||||
}
|
||||
|
||||
if (err) {
|
||||
console.log('Attempt failed. Error code ' + err);
|
||||
debug('Attempt failed. Error code ' + err);
|
||||
}
|
||||
|
||||
cb(err, json);
|
||||
@@ -94,7 +96,7 @@ var PhantomasWrapper = function() {
|
||||
clearTimeout(killer);
|
||||
|
||||
if (err) {
|
||||
console.log('All ' + triesNumber + ' attemps failed for the test');
|
||||
debug('All ' + triesNumber + ' attemps failed for the test');
|
||||
deferred.reject(err);
|
||||
} else {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user