From c45fdb12df7a5d93b5ea3da935f513d8dafb9a3b Mon Sep 17 00:00:00 2001 From: Eric Mastro Date: Tue, 5 Jun 2018 11:39:28 +1000 Subject: [PATCH] Improve storage logging (during --loglevel trace) Includes IPFS command run Includes response from IPFS/Swarm service checks Includes url being checked during IPFS/Swarm service checks. --- lib/modules/ipfs/index.js | 4 +++- lib/modules/swarm/index.js | 3 ++- lib/processes/storageProcesses/ipfs.js | 5 +++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/modules/ipfs/index.js b/lib/modules/ipfs/index.js index bbeeecf52..f28dd8817 100644 --- a/lib/modules/ipfs/index.js +++ b/lib/modules/ipfs/index.js @@ -48,8 +48,8 @@ class IPFS { }); self.events.request("services:register", 'IPFS', function (cb) { - self.logger.trace("Checking IPFS version..."); let url = (self.protocol || 'http') + '://' + self.host + ':' + self.port + '/api/v0/version'; + self.logger.trace(`Checking IPFS version on ${url}...`); if(self.protocol !== 'https'){ utils.httpGetJson(url, versionCb); } else { @@ -61,8 +61,10 @@ class IPFS { return cb({name: "IPFS ", status: 'off'}); } if (body.Version) { + self.logger.trace("Swarm available"); return cb({name: ("IPFS " + body.Version), status: 'on'}); } + self.logger.trace("Swarm available"); return cb({name: "IPFS ", status: 'on'}); } }); diff --git a/lib/modules/swarm/index.js b/lib/modules/swarm/index.js index 59b3b9d86..d5affec64 100644 --- a/lib/modules/swarm/index.js +++ b/lib/modules/swarm/index.js @@ -54,8 +54,9 @@ class Swarm { }); self.events.request("services:register", 'Swarm', function(cb){ - self.logger.trace("Checking Swarm availability..."); + self.logger.trace(`Checking Swarm availability on ${self.bzz.currentProvider}...`); self.bzz.isAvailable().then(result => { + self.logger.trace("Swarm " + (result ? '':'un') + "available"); return cb({name: "Swarm ", status: result ? 'on':'off'}); }).catch(err => { self.logger.trace("Check Swarm availability error: " + err); diff --git a/lib/processes/storageProcesses/ipfs.js b/lib/processes/storageProcesses/ipfs.js index 933505020..83fedc2af 100644 --- a/lib/processes/storageProcesses/ipfs.js +++ b/lib/processes/storageProcesses/ipfs.js @@ -51,8 +51,9 @@ class IPFSProcess extends ProcessWrapper { self.readyCalled = true; // update IPFS cors before spawning a daemon (muhaha) - console.log(`RUNNING IPFS CORS UPDATE COMMAND: ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin "[\\"${self.cors.join('\\", \\"')}\\"]"`); - child_process.exec(`ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin "[\\"${self.cors.join('\\", \\"')}\\"]"`, {silent: true}, (err, stdout, _stderr) => { + let ipfsCorsCmd = `ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin "[\\"${self.cors.join('\\", \\"')}\\"]"`; + console.trace(`Updating IPFS CORS using command: ${ipfsCorsCmd}`); + child_process.exec(ipfsCorsCmd, {silent: true}, (err, stdout, _stderr) => { if(err){ err = err.toString(); console.error('IPFS CORS update error: ', err);