Use debug instead of console.* everywhere

No need to patch up console.* anymore

also removes supererror
This commit is contained in:
Girish Ramakrishnan
2020-08-02 11:43:18 -07:00
parent aa747cea85
commit 1b307632ab
16 changed files with 46 additions and 110 deletions
+3 -2
View File
@@ -8,6 +8,7 @@ exports = module.exports = {
var assert = require('assert'),
async = require('async'),
BoxError = require('../boxerror.js'),
debug = require('debug')('box:sysinfo/generic'),
superagent = require('superagent');
function getServerIp(config, callback) {
@@ -19,11 +20,11 @@ function getServerIp(config, callback) {
async.retry({ times: 10, interval: 5000 }, function (callback) {
superagent.get('https://api.cloudron.io/api/v1/helper/public_ip').timeout(30 * 1000).end(function (error, result) {
if (error || result.statusCode !== 200) {
console.error('Error getting IP', error);
debug('Error getting IP', error);
return callback(new BoxError(BoxError.EXTERNAL_ERROR, 'Unable to detect IP. API server unreachable'));
}
if (!result.body && !result.body.ip) {
console.error('Unexpected answer. No "ip" found in response body.', result.body);
debug('Unexpected answer. No "ip" found in response body.', result.body);
return callback(new BoxError(BoxError.EXTERNAL_ERROR, 'Unable to detect IP. No IP found in response'));
}