Remove console.{log,error} from most parts of the codebase (#220)

* Remove console.{log,error} from most parts of the codebase

A standard pattern in this package is to print the contents of the
Cloudant response to stdout through console.log before returning it
in to the runtime. This is redundant because OpenWhisk itself provides
methods to record and view the data being passed between actions. It's
also harmful for two reasons:

1. Unneccesarry platform logging. The platform logs for our Cloudant
   instance are captured for compliance reasons. In our workload, we
   were literally paying twice as much for log file parsing as for
   our OpenWhisk processing, as the body of every database document
   was ending up in the logs (and some were quite big)

2. Security. The document bodies ending up in the logs meant that
   log file 'read' permissions were being effectively escalalted
   to ersatz database 'read' permissions. In particular, our
   compliance team could, but shouldn't have been able to, view
   some customer data.

This PR removes all console.log and console.error with the exception
of one (in common.js constructObject). Most of the removals were
required to fix point 2 above though there were some that were pure
simple debug output that could be left in, but were removed based
on point 1. The one instance left was left because without it, there
would have been an empty catch block and I'm not familiar enough with
the code to understand the implications of that here!

I'm happy to revise the PR to reinstate some of the pure debug
outputs if required.

* Remove further console.error that can leak database information

The error object includes headers, statuscode but also the
originating request body which in this case (in insertOrUpdate)
will include a document body.
diff --git a/actions/account-actions/create-database.js b/actions/account-actions/create-database.js
index 8d7d348..cf0a5af 100644
--- a/actions/account-actions/create-database.js
+++ b/actions/account-actions/create-database.js
@@ -41,10 +41,8 @@
   return new Promise(function(resolve, reject) {
     cloudant.db.create(dbName, function(error, response) {
       if (!error) {
-        console.log('success', response);
         resolve(response);
       } else {
-        console.log('error', error);
         reject(error);
       }
     });
diff --git a/actions/account-actions/delete-database.js b/actions/account-actions/delete-database.js
index 2678f79..d8b9106 100644
--- a/actions/account-actions/delete-database.js
+++ b/actions/account-actions/delete-database.js
@@ -39,10 +39,8 @@
   return new Promise(function(resolve, reject) {
     cloudant.db.destroy(dbName, function(error, response) {
       if (!error) {
-        console.log('success', response);
         resolve(response);
       } else {
-        console.log('error', error);
         reject(error);
       }
     });
diff --git a/actions/account-actions/list-all-databases.js b/actions/account-actions/list-all-databases.js
index a595e2d..e335292 100644
--- a/actions/account-actions/list-all-databases.js
+++ b/actions/account-actions/list-all-databases.js
@@ -34,13 +34,11 @@
   return new Promise(function(resolve, reject) {
     cloudant.db.list(function(error, response) {
       if (!error) {
-        console.log('success', response);
         //Response is an array and only JSON objects can be passed
         var responseObj = {};
         responseObj.all_databases = response;
         resolve(responseObj);
       } else {
-        console.log('error', error);
         reject(error);
       }
     });
diff --git a/actions/account-actions/read-database.js b/actions/account-actions/read-database.js
index 28a5e70..647fa46 100644
--- a/actions/account-actions/read-database.js
+++ b/actions/account-actions/read-database.js
@@ -38,10 +38,8 @@
   return new Promise(function(resolve, reject) {
     cloudant.db.get(dbName, function(error, response) {
       if (!error) {
-        console.log('success', response);
         resolve(response);
       } else {
-        console.log('error', error);
         reject(error);
       }
     });
diff --git a/actions/account-actions/read-updates-feed.js b/actions/account-actions/read-updates-feed.js
index 6569658..2fd3a50 100644
--- a/actions/account-actions/read-updates-feed.js
+++ b/actions/account-actions/read-updates-feed.js
@@ -45,10 +45,8 @@
   return new Promise(function(resolve, reject) {
     cloudant.updates(params, function(error, response) {
       if (!error) {
-        console.log('success', response);
         resolve(response);
       } else {
-        console.log('error', error);
         reject(error);
       }
     });
diff --git a/actions/database-actions/create-document.js b/actions/database-actions/create-document.js
index 1e35ad9..44fcb79 100644
--- a/actions/database-actions/create-document.js
+++ b/actions/database-actions/create-document.js
@@ -70,10 +70,8 @@
   return new Promise(function(resolve, reject) {
     cloudantDb.insert(doc, params, function(error, response) {
       if (!error) {
-        console.log("success", response);
         resolve(response);
       } else {
-        console.log("error", error);
         reject(error);
       }
     });
diff --git a/actions/database-actions/create-query-index.js b/actions/database-actions/create-query-index.js
index 3eb8b55..67b37e0 100644
--- a/actions/database-actions/create-query-index.js
+++ b/actions/database-actions/create-query-index.js
@@ -55,10 +55,8 @@
   return new Promise(function(resolve, reject) {
     cloudantDb.index(index, function(error, response) {
       if (!error) {
-        console.log('success', response);
         resolve(response);
       } else {
-        console.log('error', error);
         reject(response);
       }
     });
diff --git a/actions/database-actions/create-update-attachment.js b/actions/database-actions/create-update-attachment.js
index dda3367..f065eff 100644
--- a/actions/database-actions/create-update-attachment.js
+++ b/actions/database-actions/create-update-attachment.js
@@ -74,10 +74,8 @@
   return new Promise(function(resolve, reject) {
     cloudantDb.attachment.insert(docId, attName, att, contentType, params, function(error, response) {
       if (!error) {
-        console.log("success", response);
         resolve(response);
       } else {
-        console.log("error", error);
         reject(error);
       }
     });
diff --git a/actions/database-actions/delete-attachment.js b/actions/database-actions/delete-attachment.js
index 35cf103..fcc99aa 100644
--- a/actions/database-actions/delete-attachment.js
+++ b/actions/database-actions/delete-attachment.js
@@ -69,10 +69,8 @@
   return new Promise(function(resolve, reject) {
     cloudantDb.attachment.destroy(docId, attName, params, function(error, response) {
       if (!error) {
-        console.log("success", response);
         resolve(response);
       } else {
-        console.log("error", error);
         reject(error);
       }
     });
diff --git a/actions/database-actions/delete-document.js b/actions/database-actions/delete-document.js
index 91893b2..aa45730 100644
--- a/actions/database-actions/delete-document.js
+++ b/actions/database-actions/delete-document.js
@@ -52,10 +52,8 @@
   return new Promise(function(resolve, reject) {
     cloudantDb.destroy(docId, docRev, function(error, response) {
       if (!error) {
-        console.log('success', response);
         resolve(response);
       } else {
-        console.error('error', error);
         reject(error);
       }
     });
diff --git a/actions/database-actions/delete-query-index.js b/actions/database-actions/delete-query-index.js
index b0d2b9c..4c99a6b 100644
--- a/actions/database-actions/delete-query-index.js
+++ b/actions/database-actions/delete-query-index.js
@@ -60,10 +60,8 @@
         path : path
       }, function(error, response) {
       if (!error) {
-        console.log('success', response);
         resolve(response);
       } else {
-        console.log('error', error);
         reject(error);
       }
     });
diff --git a/actions/database-actions/delete-view.js b/actions/database-actions/delete-view.js
index 29d7c8c..be7d8d3 100644
--- a/actions/database-actions/delete-view.js
+++ b/actions/database-actions/delete-view.js
@@ -65,7 +65,6 @@
 
   return getDocument(cloudantDb, docId)
     .then(function(document) {
-        console.log("Got document: " + document);
         delete document.views[viewName];
 
         //Update the design document after removing the view
@@ -77,10 +76,8 @@
   return new Promise(function(resolve, reject) {
     cloudantDb.get(docId, function(error, response) {
       if (!error) {
-        console.log("Got response: " + response);
         resolve(response);
       } else {
-        console.log("Got error: " + error);
         reject(error);
       }
     });
@@ -91,10 +88,8 @@
   return new Promise(function(resolve, reject) {
     cloudantDb.insert(doc, params, function(error, response) {
       if (!error) {
-        console.log('success', response);
         resolve(response);
       } else {
-        console.log('error', error);
         reject(error);
       }
     });
diff --git a/actions/database-actions/exec-query-find.js b/actions/database-actions/exec-query-find.js
index 6e12a31..bc21ffc 100644
--- a/actions/database-actions/exec-query-find.js
+++ b/actions/database-actions/exec-query-find.js
@@ -57,10 +57,8 @@
   return new Promise(function(resolve, reject) {
     cloudantDb.find(query, function(error, response) {
       if (!error) {
-        console.log('success', response);
         resolve(response);
       } else {
-        console.log('error', error);
         reject(error);
       }
     });
diff --git a/actions/database-actions/exec-query-search.js b/actions/database-actions/exec-query-search.js
index c95b6d6..2249534 100644
--- a/actions/database-actions/exec-query-search.js
+++ b/actions/database-actions/exec-query-search.js
@@ -65,10 +65,8 @@
   return new Promise(function(resolve, reject) {
     cloudantDb.search(designDocId, designViewName, search, function(error, response) {
       if (!error) {
-        console.log('success', response);
         resolve(response);
       } else {
-        console.log('error', error);
         reject(error);
       }
     });
diff --git a/actions/database-actions/exec-query-view.js b/actions/database-actions/exec-query-view.js
index f21840d..2146bdc 100644
--- a/actions/database-actions/exec-query-view.js
+++ b/actions/database-actions/exec-query-view.js
@@ -62,10 +62,8 @@
   return new Promise(function(resolve, reject) {
     cloudantDb.view(designDocId, designDocViewName, params, function(error, response) {
       if (!error) {
-        console.log('success', response);
         resolve(response);
       } else {
-        console.error('error', error);
         reject(error);
       }
     });
diff --git a/actions/database-actions/list-design-documents.js b/actions/database-actions/list-design-documents.js
index 74cc8cf..41d61cd 100644
--- a/actions/database-actions/list-design-documents.js
+++ b/actions/database-actions/list-design-documents.js
@@ -40,7 +40,6 @@
 
   //If includeDoc exists and is true, add field to additional params object
   includeDocs = includeDocs.toString().trim().toLowerCase();
-  console.log('includeDocs: ' + includeDocs);
   if(includeDocs === 'true') {
     params.include_docs = 'true';
   }
@@ -55,10 +54,8 @@
   return new Promise(function(resolve, reject) {
     cloudantDb.list(params, function(error, response) {
       if (!error) {
-        console.log('success', response);
         resolve(response);
       } else {
-        console.error("error", error);
         reject(error);
       }
     });
diff --git a/actions/database-actions/list-documents.js b/actions/database-actions/list-documents.js
index dd4f71a..bc508b5 100644
--- a/actions/database-actions/list-documents.js
+++ b/actions/database-actions/list-documents.js
@@ -54,10 +54,8 @@
   return new Promise(function(resolve, reject) {
     cloudantDb.list(params, function(error, response) {
       if (!error) {
-        console.log('success', response);
         resolve(response);
       } else {
-        console.error("error", error);
         reject(error);
       }
     });
diff --git a/actions/database-actions/list-query-indexes.js b/actions/database-actions/list-query-indexes.js
index 74de1e1..081ed84 100644
--- a/actions/database-actions/list-query-indexes.js
+++ b/actions/database-actions/list-query-indexes.js
@@ -40,10 +40,8 @@
   return new Promise(function(resolve, reject) {
     cloudantDb.index(function(error, response) {
       if (!error) {
-        console.log('success', response);
         resolve(response);
       } else {
-        console.log('error', error);
         reject(error);
       }
     });
diff --git a/actions/database-actions/manage-bulk-documents.js b/actions/database-actions/manage-bulk-documents.js
index d312607..9c4de09 100644
--- a/actions/database-actions/manage-bulk-documents.js
+++ b/actions/database-actions/manage-bulk-documents.js
@@ -69,10 +69,8 @@
       if (!error) {
         var responseDocs = {};
         responseDocs.docs = response;
-        console.log('success', response);
         resolve(responseDocs);
       } else {
-        console.log('Error: ', error);
         reject(error);
       }
     });
diff --git a/actions/database-actions/read-attachment.js b/actions/database-actions/read-attachment.js
index 836d922..1a56f4c 100644
--- a/actions/database-actions/read-attachment.js
+++ b/actions/database-actions/read-attachment.js
@@ -67,10 +67,8 @@
   return new Promise(function(resolve, reject) {
     cloudantDb.attachment.get(docId, attName, params, function(error, response) {
       if (!error) {
-        console.log("success", response);
         resolve(response);
       } else {
-        console.log("error", error);
         reject(error);
       }
     });
diff --git a/actions/database-actions/read-changes-feed.js b/actions/database-actions/read-changes-feed.js
index aada654..a086f3e 100644
--- a/actions/database-actions/read-changes-feed.js
+++ b/actions/database-actions/read-changes-feed.js
@@ -50,10 +50,8 @@
   return new Promise(function(resolve, reject) {
     cloudant.db.changes(dbName, params, function(error, response) {
       if (!error) {
-        console.log('success', response);
         resolve(response);
       } else {
-        console.error('error', error);
         reject(error);
       }
     });
diff --git a/actions/database-actions/read-document.js b/actions/database-actions/read-document.js
index d0ead34..5465979 100644
--- a/actions/database-actions/read-document.js
+++ b/actions/database-actions/read-document.js
@@ -55,10 +55,8 @@
   return new Promise(function(resolve, reject) {
     cloudantDb.get(docId, params, function(error, response) {
       if (!error) {
-        console.log('success', response);
         resolve(response);
       } else {
-        console.error('error', error);
         reject(error);
       }
     });
diff --git a/actions/database-actions/update-document.js b/actions/database-actions/update-document.js
index bd9fb06..bad2751 100644
--- a/actions/database-actions/update-document.js
+++ b/actions/database-actions/update-document.js
@@ -70,10 +70,8 @@
   return new Promise(function(resolve, reject) {
     cloudantDb.insert(doc, params, function(error, response) {
       if (!error) {
-        console.log('success', response);
         resolve(response);
       } else {
-        console.log('error', error);
         reject(error);
       }
     });
diff --git a/actions/database-actions/write-document.js b/actions/database-actions/write-document.js
index 1e738e7..07e75ad 100644
--- a/actions/database-actions/write-document.js
+++ b/actions/database-actions/write-document.js
@@ -89,7 +89,6 @@
                                     reject(err);
                                 });
                         } else {
-                            console.error('error', error);
                             reject(error);
                         }
                     }
@@ -112,10 +111,8 @@
     return new Promise(function(resolve, reject) {
         cloudantDb.insert(doc, function(error, response) {
             if (!error) {
-                console.log('success', response);
                 resolve(response);
             } else {
-                console.log('error', error);
                 reject(error);
             }
         });
diff --git a/actions/event-actions/changesWebAction.js b/actions/event-actions/changesWebAction.js
index 53cb3cf..6256e3c 100644
--- a/actions/event-actions/changesWebAction.js
+++ b/actions/event-actions/changesWebAction.js
@@ -106,7 +106,6 @@
                 return db.getWorkerID(workers);
             })
             .then((worker) => {
-                console.log('trigger will be assigned to worker ' + worker);
                 newTrigger.worker = worker;
                 return db.createTrigger(triggerID, newTrigger);
             })
diff --git a/actions/event-actions/lib/common.js b/actions/event-actions/lib/common.js
index 523ee5b..e3d1d8a 100644
--- a/actions/event-actions/lib/common.js
+++ b/actions/event-actions/lib/common.js
@@ -43,11 +43,9 @@
             }
             else {
                 if (response) {
-                    console.log('cloudant: Error invoking whisk action:', response.statusCode, body);
                     reject(body);
                 }
                 else {
-                    console.log('cloudant: Error invoking whisk action:', error);
                     reject(error);
                 }
             }
@@ -132,7 +130,7 @@
                 jsonObject = JSON.parse(data);
             }
             catch (e) {
-                console.log('error parsing ' + data);
+                console.error('error parsing ' + data);
             }
         }
         if (typeof data === 'object') {