diagnostics
Advanced tools
Comparing version 0.0.2 to 0.0.3
42
index.js
'use strict'; | ||
var human = require('pretty-hrtime') | ||
, env = require('env-variable') | ||
var env = require('env-variable') | ||
, Stream = require('stream') | ||
@@ -12,11 +11,2 @@ , colorjs = require('color') | ||
/** | ||
* All the different name spaces that are currently using this module. | ||
* | ||
* @type {Array} | ||
* @private | ||
*/ | ||
var namespaces = [] | ||
, max; | ||
/** | ||
* Check if the terminal we're using allows the use of colors. | ||
@@ -85,16 +75,5 @@ * | ||
// | ||
// Add the namespace an re-calculate the max-length of the namespace so we can | ||
// have a consistent indentation. | ||
// | ||
namespaces.push(name); | ||
max = Math.max.apply(Math, namespaces.map(function map(namespace) { | ||
return namespace.toString().length; | ||
})); | ||
// | ||
// The actual debug function which does the logging magic. | ||
// | ||
return function debug(line) { | ||
debug.prev = debug.prev || process.hrtime(); | ||
// | ||
@@ -107,7 +86,2 @@ // Better formatting for error instances. | ||
// | ||
// Add extra padding so all log messages start at the same line. | ||
// | ||
(new Array(max + 1 - name.length)).join(' '), | ||
// | ||
// Add the colorized namespace. | ||
@@ -118,9 +92,2 @@ // | ||
// | ||
// Add the duration since the last call. | ||
// | ||
' ' + human(process.hrtime(debug.prev), { | ||
precise: !!options.precise | ||
}), | ||
// | ||
// The total time we took to execute the next debug statement. | ||
@@ -142,7 +109,2 @@ // | ||
}); | ||
// | ||
// Update the previous call with the current time. | ||
// | ||
debug.prev = process.hrtime(); | ||
}; | ||
@@ -164,3 +126,3 @@ } | ||
return variable.split(/[\s,]+/).every(function checks(check) { | ||
return variable.split(/[\s,]+/).some(function checks(check) { | ||
check = check.replace('*', '.*?'); | ||
@@ -167,0 +129,0 @@ |
{ | ||
"name": "diagnostics", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Tools for debugging your node.js modules and event loop", | ||
@@ -36,9 +36,8 @@ "main": "index.js", | ||
"dependencies": { | ||
"color": "^0.6.0", | ||
"color": "0.6.x", | ||
"colornames": "0.0.x", | ||
"env-variable": "0.0.x", | ||
"kuler": "0.0.x", | ||
"pretty-hrtime": "0.2.x", | ||
"text-hex": "0.0.x" | ||
} | ||
} |
10
test.js
@@ -9,2 +9,3 @@ describe('diagnostics', function () { | ||
process.env.DEBUG = ''; | ||
process.env.DIAGNOSTICS = ''; | ||
}); | ||
@@ -55,2 +56,11 @@ | ||
assume(debug.enabled('primus')).to.be.false(); | ||
}); | ||
it('supports multiple ranges', function () { | ||
process.env.DEBUG = 'bigpipe*,primus*'; | ||
assume(debug.enabled('bigpipe:')).to.be.true(); | ||
assume(debug.enabled('bigpipes')).to.be.true(); | ||
assume(debug.enabled('primus:')).to.be.true(); | ||
assume(debug.enabled('primush')).to.be.true(); | ||
assume(debug.enabled('unknown')).to.be.false(); | ||
@@ -57,0 +67,0 @@ }); |
5
12294
297
11
- Removedpretty-hrtime@0.2.x
- Removedpretty-hrtime@0.2.2(transitive)
Updatedcolor@0.6.x