debug-logtron
Advanced tools
Comparing version 3.1.0 to 3.2.0
@@ -29,2 +29,3 @@ 'use strict'; | ||
self.console = opts.console || globalConsole; | ||
self.assert = opts.assert; | ||
self.colors = typeof opts.colors === 'boolean' ? | ||
@@ -58,2 +59,3 @@ opts.colors : true; | ||
console: self.console, | ||
assert: self.assert, | ||
colors: self.colors, | ||
@@ -74,2 +76,3 @@ enabled: self.enabled, | ||
self.console = opts.console; | ||
self.assert = opts.assert; | ||
self.colors = opts.colors; | ||
@@ -81,2 +84,3 @@ self.enabled = opts.enabled; | ||
DebugLogStream.prototype.write = function write(logRecord, cb) { | ||
/*eslint complexity: [2, 15]*/ | ||
var self = this; | ||
@@ -95,3 +99,7 @@ | ||
var msg = self.formatMessage(logRecord); | ||
self.console.error(msg); | ||
if (self.assert) { | ||
self.assert.comment(msg); | ||
} else { | ||
self.console.error(msg); | ||
} | ||
} | ||
@@ -111,6 +119,5 @@ | ||
var self = this; | ||
var pid = process.pid; | ||
var prefix = self.namespace + ' ' + pid + ': ' + | ||
logRecord.levelName.toUpperCase(); | ||
var prefix = self.namespace + ' ' + | ||
logRecord.levelName.toUpperCase() + ':'; | ||
var color = COLOR_MAP[logRecord.levelName]; | ||
@@ -123,4 +130,4 @@ | ||
return prefix + ': ' + logRecord.fields.msg + ' ~ ' + | ||
return prefix + ' ' + logRecord.fields.msg + ' ~ ' + | ||
inspect(logRecord.meta); | ||
}; |
{ | ||
"name": "debug-logtron", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"description": "A debug logger with a logtron interface.", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
@@ -210,3 +210,3 @@ 'use strict'; | ||
assert.ok( | ||
line2.indexOf('INFO\u001b[49m\u001b[22m: hi ~ null') >= 0 | ||
line2.indexOf('INFO:\u001b[49m\u001b[22m hi ~ null') >= 0 | ||
); | ||
@@ -356,2 +356,29 @@ | ||
test('writes to assert comment', function t(assert) { | ||
var lines = []; | ||
var comments = []; | ||
var logger = DebugLogtron('wat', { | ||
console: { | ||
error: function log(x) { | ||
lines.push(x); | ||
} | ||
}, | ||
assert: { | ||
comment: function comment(x) { | ||
comments.push(x); | ||
} | ||
}, | ||
verbose: true | ||
}); | ||
logger.debug('hi'); | ||
assert.equal(lines.length, 0); | ||
assert.equal(comments.length, 1); | ||
assert.ok(comments[0].indexOf('DEBUG: hi ~ null') >= 0); | ||
assert.end(); | ||
}); | ||
function allocLogger(opts) { | ||
@@ -358,0 +385,0 @@ opts = opts || {}; |
24427
563