[Pkg-javascript-commits] [node-coveralls] 40/332: use log-driver for logging levels.

Bastien Roucariès rouca at moszumanska.debian.org
Thu Nov 9 13:53:38 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-coveralls.

commit 0f5612ec5c9783f640894f547ce339c1dfd8c7c7
Author: cainus <gregg at caines.ca>
Date:   Sun Jun 2 20:32:52 2013 -0700

    use log-driver for logging levels.
---
 bin/coveralls.js              |  4 ++++
 fixtures/lib/index.js         | 52 -------------------------------------------
 lib/convertLcovToCoveralls.js |  7 +++---
 lib/handleInput.js            | 13 ++++++-----
 package.json                  |  3 ++-
 5 files changed, 17 insertions(+), 62 deletions(-)

diff --git a/bin/coveralls.js b/bin/coveralls.js
index 6f3eb57..578c692 100755
--- a/bin/coveralls.js
+++ b/bin/coveralls.js
@@ -1,10 +1,14 @@
 #!/usr/bin/env node
 var handleInput = require('../lib/handleInput');
+var logger = require('log-driver')({level : 'warn'});
 
 var options = {};
 if (process.argv[2]) {
   if (~['-v', '--verbose'].indexOf(process.argv[2])) {
     options.verbose = true;
+    if (options.verbose){
+      logger = require('log-driver')({level : 'debug'});
+    }
     if (process.argv[3]) {
       options.filepath = process.argv[3];
     }
diff --git a/fixtures/lib/index.js b/fixtures/lib/index.js
index 4a22c7a..052e296 100644
--- a/fixtures/lib/index.js
+++ b/fixtures/lib/index.js
@@ -155,58 +155,6 @@ UrlGrey.prototype.toString = function(){
   return retval;
 };
 
-/*
-UrlGrey.prototype.absolute = function(path){
-  if (path[0] == '/'){
-    path = path.substring(1);
-  }
-  var parsed = nodeUrl.parse(path);
-  if (!!parsed.protocol){  // if it's already absolute, just return it
-    return path;
-  }
-  return this._protocol + "://" + this._host + '/' + path;
-};
-
-// TODO make this interpolate vars into the url.   both sinatra style and url-tempates
-// TODO name this: 
-UrlGrey.prototype.get = function(nameOrPath, varDict){
-  if (!!nameOrPath){
-    if (!!varDict){
-      return this.absolute(this._router.getUrl(nameOrPath, varDict));
-    }
-    return this.absolute(this._router.getUrl(nameOrPath));
-  }
-  return this.url;
-};*/
-
-/*
-// TODO needs to take a template as an input
-UrlGrey.prototype.param = function(key, defaultValue){
-  var value = this.params()[key];
-  if (!!value) { 
-    return value; 
-  }
-  return defaultValue;
-};
-
-// TODO extract params, given a template?
-// TODO needs to take a template as an input
-UrlGrey.prototype.params = function(inUrl){
-  if (!!inUrl){
-    return this._router.pathVariables(inUrl);
-  }
-  if (!!this._params){
-    return this._params;
-  }
-  return this._router.pathVariables(this.url);
-};
-*/
-
-// TODO relative()  // takes an absolutepath and returns a relative one
-// TODO absolute() // takes a relative path and returns an absolute one.
-
-
-
 module.exports = function(url){ return new UrlGrey(url); };
 
 function addPropertyGetterSetter(propertyName, methodName){
diff --git a/lib/convertLcovToCoveralls.js b/lib/convertLcovToCoveralls.js
index 6290d0c..ed5ec8b 100644
--- a/lib/convertLcovToCoveralls.js
+++ b/lib/convertLcovToCoveralls.js
@@ -2,6 +2,7 @@ var TRAVIS_JOB_ID = process.env.TRAVIS_JOB_ID || 'unknown';
 var fs = require('fs');
 var lcovParse = require('lcov-parse');
 var path = require('path');
+var logger = require('log-driver').logger;
 
 var detailsToCoverage = function(length, details){
   var coverage = new Array(length);
@@ -28,14 +29,14 @@ var convertLcovFileObject = function(file, filepath){
 var convertLcovToCoveralls = function(input, options, cb){
   var repo_token = options.repo_token,
       filepath = options.filepath || '';
-  options.verbose && console.log("in: ", filepath);
+  logger.debug("in: ", filepath);
   if (filepath[0] !== '/'){
     filepath = path.join(process.cwd(), filepath);
   }
   lcovParse(input, function(err, parsed){
     if (err){
-      console.error("error from lcovParse: ", err);
-      console.error("input: ", input);
+      logger.error("error from lcovParse: ", err);
+      logger.error("input: ", input);
       return cb(err); 
     }
     var postJson = {
diff --git a/lib/handleInput.js b/lib/handleInput.js
index be85c4a..703c87d 100644
--- a/lib/handleInput.js
+++ b/lib/handleInput.js
@@ -3,9 +3,10 @@ var path = require('path');
 var YAML = require('libyaml');
 var sendToCoveralls = require('../index').sendToCoveralls;
 var convertLcovToCoveralls = require('../index').convertLcovToCoveralls;
+var logger = require('log-driver').logger;
 
 var handleInput = function(input, options){
-  options.verbose && console.log(input);
+  logger.debug(input);
 
   if (process.env.COVERALLS_REPO_TOKEN) {
     options.repo_token = process.env.COVERALLS_REPO_TOKEN;
@@ -16,16 +17,16 @@ var handleInput = function(input, options){
         options.repo_token = YAML.readFileSync(yml)[0].repo_token;
       }
     } catch(ex){
-      console.warn("Repo token could not be determined.  Continuing without it.");
+      logger.warn("Repo token could not be determined.  Continuing without it.");
     }
   }
 
   convertLcovToCoveralls(input, options, function(err, postData){
     if (err){
-      console.error("error from convertLcovToCoveralls");
+      logger.error("error from convertLcovToCoveralls");
       throw err;
     }
-    options.verbose && console.info("sending this to coveralls.io: ", postData);
+    logger.info("sending this to coveralls.io: ", JSON.stringify(postData));
     sendToCoveralls(postData, function(err, response, body){
       if (err){
         throw err;
@@ -33,8 +34,8 @@ var handleInput = function(input, options){
       if (response.statusCode >= 400){
         throw "Bad response: " + response.statusCode + " " + body;
       }
-      options.verbose && console.log(response.statusCode);
-      options.verbose && console.log(body);
+      logger.debug(response.statusCode);
+      logger.debug(body);
     });
   });
 
diff --git a/package.json b/package.json
index 815e135..8f7f5fc 100644
--- a/package.json
+++ b/package.json
@@ -26,7 +26,8 @@
   "dependencies": {
     "libyaml": "0.2.2",
     "request": "2.16.2",
-    "lcov-parse": "0.0.4"
+    "lcov-parse": "0.0.4",
+    "log-driver": "1.2.1"
   },
   "devDependencies": {
     "mocha-lcov-reporter": "0.0.1",

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-coveralls.git



More information about the Pkg-javascript-commits mailing list