debug-logtron
Advanced tools
Comparing version 3.0.0 to 3.1.0
@@ -21,2 +21,3 @@ 'use strict'; | ||
function DebugLogBackend(namespace, opts) { | ||
/*eslint max-statements: [2, 25]*/ | ||
if (!(this instanceof DebugLogBackend)) { | ||
@@ -44,3 +45,6 @@ return new DebugLogBackend(namespace, opts); | ||
if (self.verbose) { | ||
if (opts.verbose) { | ||
self.verbose = true; | ||
} | ||
if (self.verbose || opts.enabled) { | ||
self.enabled = true; | ||
@@ -47,0 +51,0 @@ } |
{ | ||
"name": "debug-logtron", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"description": "A debug logger with a logtron interface.", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
@@ -267,2 +267,26 @@ 'use strict'; | ||
test('prints warn/info if enabled', function t(assert) { | ||
var lines = []; | ||
var logger = DebugLogtron('wat', { | ||
console: { | ||
error: function log(x) { | ||
lines.push(x); | ||
} | ||
}, | ||
enabled: true | ||
}); | ||
logger.info('hi'); | ||
assert.equal(lines.length, 1); | ||
assert.ok(lines[0].indexOf('INFO: hi ~ null') >= 0); | ||
lines = []; | ||
logger.debug('roflcopter'); | ||
assert.equal(lines.length, 0); | ||
assert.end(); | ||
}); | ||
test('prints debug/access/trace if NODE_DEBUG verbose', function t(assert) { | ||
@@ -301,2 +325,33 @@ var lines = []; | ||
test('prints debug/access/trace if verbose', function t(assert) { | ||
var lines = []; | ||
var logger = DebugLogtron('wat', { | ||
console: { | ||
error: function log(x) { | ||
lines.push(x); | ||
} | ||
}, | ||
verbose: true | ||
}); | ||
logger.debug('hi'); | ||
assert.equal(lines.length, 1); | ||
assert.ok(lines[0].indexOf('DEBUG: hi ~ null') >= 0); | ||
logger.info('hi'); | ||
assert.equal(lines.length, 2); | ||
assert.ok(lines[1].indexOf('INFO: hi ~ null') >= 0); | ||
assert.throws(function throwIt() { | ||
logger.error('hi'); | ||
}, 'hi'); | ||
assert.equal(lines.length, 3); | ||
assert.ok(lines[2].indexOf('ERROR: hi ~ null') >= 0); | ||
assert.end(); | ||
}); | ||
function allocLogger(opts) { | ||
@@ -303,0 +358,0 @@ opts = opts || {}; |
23657
534