Comparing version 0.6.1 to 0.6.2
@@ -0,1 +1,5 @@ | ||
0.6.2 / 2012-06-25 | ||
================== | ||
* 0.8 test support by ditching expresso for tap | ||
0.6.1 / 2012-02-25 | ||
@@ -2,0 +6,0 @@ ================== |
{ | ||
"author": "Eirik Albrigtsen <analsandblaster@gmail.com>", | ||
"name": "logule", | ||
"description": "An advanced logger for nodejs", | ||
"version": "0.6.1", | ||
"description": "An advanced console logging library", | ||
"version": "0.6.2", | ||
"repository": { | ||
@@ -15,3 +15,3 @@ "type": "git", | ||
"scripts": { | ||
"test": "expresso" | ||
"test": "tap ./test" | ||
}, | ||
@@ -23,3 +23,3 @@ "dependencies": { | ||
"devDependencies": { | ||
"expresso": "~0.9.2" | ||
"tap": "~0.2.5" | ||
}, | ||
@@ -29,3 +29,4 @@ "bugs": { | ||
}, | ||
"licence": "MIT", | ||
"optionalDependencies": {} | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# Logule  | ||
# Logule [](http://travis-ci.org/clux/logule) | ||
@@ -9,3 +9,3 @@ Logule is an advanced logging utility for nodejs. It is analogous to `console.log` | ||
Shortcut methods for the log levels are available as: `log.error`, `log.warn`, | ||
`log.info`, `log.debug`, `log.trace`, `log.line`, `log.zalgo`, and as a bonus, | ||
`log.info`, `log.debug`, `log.trace`, `log.zalgo`, and as a bonus, | ||
`log.line`. These methods are additionally chainable. | ||
@@ -87,3 +87,3 @@ | ||
`sublog` would here provide same output as `logule.sub('BUILD', 'COMPILE')`. | ||
Here `sublog` would provide same output as `logule.sub('BUILD', 'COMPILE')`. | ||
@@ -94,3 +94,3 @@ It is advantageous to do 'one namespace sub at a time', as then it is easier | ||
`log.sub()` maintains all padding, suppressed log levels, its locked status, | ||
A `log.sub()` maintains all padding, suppressed log levels, its locked status, | ||
and namespace properties set on the original `log` instance. Therefore, it works as if there's | ||
@@ -169,3 +169,5 @@ an implicit link between the sub and its parent. | ||
$ export LOGULE_ALLOW=ERROR,WARN | ||
````bash | ||
$ export LOGULE_ALLOW=error,warn | ||
```` | ||
@@ -172,0 +174,0 @@ This will hide all output from any othes methods than `warn()` and `error()`. |
var logule = require('../') | ||
, assert = require('assert') | ||
, test = require('tap').test | ||
, levels = ['trace', 'debug', 'info', 'warn', 'error', 'zalgo', 'line'] | ||
@@ -17,28 +17,26 @@ , l = logule.sub('suppressed').suppress.apply({}, levels) | ||
exports["test chaining"] = function () { | ||
test("chaining", function (t) { | ||
levels.forEach(function (lvl) { | ||
var sub = l.sub('wee') | ||
, single = sub.get(lvl); | ||
assert.equal(l, l[lvl](1), 'l.' + lvl + " chains"); | ||
assert.isUndefined(l.get(lvl)(1), "l.get('" + lvl + "') does not chain"); | ||
assert.equal(sub.info('wat'), sub, "sub chains"); | ||
assert.isUndefined(single('wat'), "sub single returns undefined"); | ||
t.equal(l, l[lvl](1), 'l.' + lvl + " chains"); | ||
t.equal(l.get(lvl)(1), undefined, "l.get('" + lvl + "') does not chain"); | ||
t.equal(sub.info('wat'), sub, "sub chains"); | ||
t.equal(single('wat'), undefined, "sub single returns undefined"); | ||
}); | ||
t.end(); | ||
}); | ||
log('chaining - completed:', 4 * levels.length); | ||
}; | ||
exports["test encapsulation"] = function () { | ||
test("encapsulation", function (t) { | ||
privates.forEach(function (p) { | ||
assert.isUndefined(l[p], 'l.' + p + ' is encapsulated'); | ||
t.equal(l[p], undefined, 'l.' + p + ' is encapsulated'); | ||
}); | ||
log('encapsulation - completed:', privates.length); | ||
}; | ||
t.end(); | ||
}); | ||
exports["test exports"] = function () { | ||
var testCount = 2 * (pubs.length - 1) | ||
, expectedExports = levels.concat(pubs); | ||
test("exports", function (t) { | ||
var expectedExports = levels.concat(pubs); | ||
@@ -49,16 +47,14 @@ pubs.forEach(function (p) { | ||
} | ||
assert.isDefined(l[p], "l." + p + " is exported"); | ||
assert.type(l[p], 'function', "l." + p + " is function"); | ||
t.ok(!!l[p], "l." + p + " is exported"); | ||
t.type(l[p], 'function', "l." + p + " is function"); | ||
}); | ||
testCount += 3; | ||
assert.isDefined(l.data, "l.data is exported"); | ||
assert.isDefined(l.data.version, "l.data.version is exported"); | ||
assert.isDefined(l.data.namespaces, "l.data.namespaces is exported"); | ||
t.ok(l.data !== undefined, "l.data is exported"); | ||
t.ok(l.data.version !== undefined, "l.data.version is exported"); | ||
t.ok(l.data.namespaces !== undefined, "l.data.namespaces is exported"); | ||
levels.forEach(function (lvl) { | ||
var fn = l.get(lvl); | ||
assert.type(fn, 'function', "l.get('" + lvl + "') returns a function"); | ||
assert.isUndefined(fn(), "l.get('" + lvl + "')() returns undefined"); | ||
testCount += 2; | ||
t.type(fn, 'function', "l.get('" + lvl + "') returns a function"); | ||
t.ok(fn() === undefined, "l.get('" + lvl + "')() returns undefined"); | ||
}); | ||
@@ -68,35 +64,32 @@ | ||
var val = l[exprt]; | ||
assert.ok(expectedExports.indexOf(exprt) >= 0, "l exported key " + exprt + " is either a log convenience or one of the public functions"); | ||
testCount += 1; | ||
t.ok(expectedExports.indexOf(exprt) >= 0, "l exported key " + exprt + " is either a log convenience or one of the public functions"); | ||
}); | ||
log("exports - completed:", testCount); | ||
}; | ||
t.end(); | ||
}); | ||
exports["test verify"] = function () { | ||
var testCount = 0; | ||
assert.ok(logule.verify(logule), "logule.verify(logule) is logule"); | ||
assert.ok(!(logule.verify(logule.get('info'))), "logule.verify(logule.get('info')) is false"); | ||
assert.ok(logule.sub('arst').verify(logule), "logule.sub('arst').verify(logule) is true"); | ||
assert.ok(logule.verify(logule.sub('arst')), "logule.verify(logule.sub('arst')) is true"); | ||
assert.ok(logule.verify(l), "logule.verify(l)"); | ||
assert.ok(logule.verify(l.sub('arst')), "logule.verify(l.sub('arst'))"); | ||
assert.ok(l.verify(logule), "l.verify(logule)"); | ||
assert.ok(l.sub('arst').verify(logule), "l.sub('arst').verify(logule)"); | ||
assert.ok(!l.verify(), "!l.verify()"); | ||
assert.ok(!l.verify(null), "!l.verify(null)"); | ||
assert.ok(!l.verify({}), "!l.verify({})"); | ||
assert.ok(!l.verify({data:{version:null}}), "!l.verify(fakeObj)"); | ||
testCount += 10; | ||
test("verify", function (t) { | ||
t.ok(logule.verify(logule), "logule.verify(logule) is logule"); | ||
t.ok(!(logule.verify(logule.get('info'))), "logule.verify(logule.get('info')) is false"); | ||
t.ok(logule.sub('arst').verify(logule), "logule.sub('arst').verify(logule) is true"); | ||
t.ok(logule.verify(logule.sub('arst')), "logule.verify(logule.sub('arst')) is true"); | ||
t.ok(logule.verify(l), "logule.verify(l)"); | ||
t.ok(logule.verify(l.sub('arst')), "logule.verify(l.sub('arst'))"); | ||
t.ok(l.verify(logule), "l.verify(logule)"); | ||
t.ok(l.sub('arst').verify(logule), "l.sub('arst').verify(logule)"); | ||
t.ok(!l.verify(), "!l.verify()"); | ||
t.ok(!l.verify(null), "!l.verify(null)"); | ||
t.ok(!l.verify({}), "!l.verify({})"); | ||
t.ok(!l.verify({data:{version:null}}), "!l.verify(fakeObj)"); | ||
levels.forEach(function (lvl) { | ||
assert.ok(l.get(lvl) instanceof Function, "l.get('" + lvl + "') returns a function"); | ||
testCount += 1; | ||
t.ok(l.get(lvl) instanceof Function, "l.get('" + lvl + "') returns a function"); | ||
}); | ||
log("exports - completed:", testCount); | ||
}; | ||
t.end(); | ||
}); | ||
exports["test sub"] = function () { | ||
assert.ok(logule === logule, "obvious test"); | ||
assert.ok(logule !== logule.sub(), "logule.sub() does not return this"); | ||
log('sub - completed', 2); | ||
}; | ||
test("subs", function (t) { | ||
t.ok(logule === logule, "obvious test"); | ||
t.ok(logule !== logule.sub(), "logule.sub() does not return this"); | ||
t.end(); | ||
}); | ||
var logule = require('../') | ||
, assert = require('assert') | ||
, test = require('tap').test | ||
, levels = ['trace', 'debug', 'info', 'warn', 'error', 'zalgo', 'line'] | ||
@@ -24,5 +24,4 @@ , l = logule.sub('suppressed').suppress.apply({}, levels) | ||
exports["test stdout"] = function () { | ||
var testCount = 0 | ||
, stdlog = logule.sub('STDOUT') | ||
test("stdout", function (t) { | ||
var stdlog = logule.sub('STDOUT') | ||
, output = []; | ||
@@ -38,2 +37,6 @@ | ||
lastIncludes = function (x) { | ||
return last().indexOf(x) >= 0; | ||
} | ||
// output from all shortcut methods is sensible | ||
@@ -43,7 +46,6 @@ levels.forEach(function (lvl) { | ||
stdlog[lvl](testMsg); | ||
assert.includes(last(), lvl.toUpperCase(), "captured stdlog contains correct log type"); | ||
assert.includes(last(), testMsg, "captured stdlog contains input message"); | ||
assert.includes(last(), "STDOUT", "captured stdlog contains namespace"); | ||
assert.equal(oldsize + 1, output.length, "hook pushed a str onto the output array"); | ||
testCount += 4; | ||
t.ok(lastIncludes(lvl.toUpperCase()), "captured stdlog contains correct log type"); | ||
t.ok(lastIncludes(testMsg), "captured stdlog contains input message"); | ||
t.ok(lastIncludes("STDOUT"), "captured stdlog contains namespace"); | ||
t.equal(oldsize + 1, output.length, "hook pushed a str onto the output array"); | ||
}); | ||
@@ -54,13 +56,11 @@ | ||
stdlog.sub('GOTTEN').get(lvl)(testMsg); | ||
assert.includes(last(), testMsg, "stdlog.get('" + lvl + "') logged the message"); | ||
assert.includes(last(), lvl.toUpperCase(), "stdlog.get('" + lvl + "') preserves log level correctly"); | ||
assert.includes(last(), 'STDOUT', "stdlog.get('" + lvl + "') preserves namespace1"); | ||
assert.includes(last(), 'GOTTEN', "stdlog.get('" + lvl + "') preserves namespace2"); | ||
testCount += 4; | ||
t.ok(lastIncludes(testMsg), "stdlog.get('" + lvl + "') logged the message"); | ||
t.ok(lastIncludes(lvl.toUpperCase()), "stdlog.get('" + lvl + "') preserves log level correctly"); | ||
t.ok(lastIncludes('STDOUT'), "stdlog.get('" + lvl + "') preserves namespace1"); | ||
t.ok(lastIncludes('GOTTEN'), "stdlog.get('" + lvl + "') preserves namespace2"); | ||
}); | ||
stdlog.info('storing previous message'); | ||
assert.includes(last(), "storing previous message", "storing works before testing suppressed functions"); | ||
t.ok(lastIncludes("storing previous message"), "storing works before testing suppressed functions"); | ||
var oldmsg = last(); | ||
testCount += 1; | ||
@@ -72,6 +72,5 @@ // suppressed methods do not send to stdout | ||
stdsub[lvl](testMsg); | ||
assert.equal(oldmsg, last(), "suppressed logger function does not send to stdout"); | ||
t.equal(oldmsg, last(), "suppressed logger function does not send to stdout"); | ||
single(testMsg); | ||
assert.equal(oldmsg, last(), "suppressed logger single function does not send to stdout"); | ||
testCount += 2; | ||
t.equal(oldmsg, last(), "suppressed logger single function does not send to stdout"); | ||
}); | ||
@@ -83,6 +82,5 @@ | ||
stdsub.sub('SUBSUB')[lvl](testMsg); | ||
assert.equal(oldmsg, last(), "sub()." + lvl + " does not send to stdout when parent was suppressed"); | ||
t.equal(oldmsg, last(), "sub()." + lvl + " does not send to stdout when parent was suppressed"); | ||
stdsub.sub('SUBSUB').get(lvl)(testMsg); | ||
assert.equal(oldmsg, last(), "sub().get('" + lvl + "') does not send to stdout when parent was suppressed"); | ||
testCount += 2; | ||
t.equal(oldmsg, last(), "sub().get('" + lvl + "') does not send to stdout when parent was suppressed"); | ||
}); | ||
@@ -95,6 +93,6 @@ | ||
stdsub[lvl]('i am suppressed'); | ||
assert.equal(lastOut, last(), "suppresed message ignored for " + lvl); | ||
t.equal(lastOut, last(), "suppresed message ignored for " + lvl); | ||
stdsub.allow(lvl); | ||
stdsub[lvl]('i am resurrected'); | ||
assert.notEqual(lastOut, last(), "ressurrected method logs " + lvl + "again"); | ||
t.ok(lastOut !== last(), "ressurrected method logs " + lvl + "again"); | ||
lastOut = last(); // save new lastOut for later | ||
@@ -114,7 +112,6 @@ }); | ||
stdsub[lvl2](testMsg); | ||
assert.includes(last(), "SEMI", "semi suppressed logger outputs when " + lvl2 + " not suppressed"); | ||
assert.includes(last(), testMsg, "semi suppressed logger outputs when " + lvl2 + " not suppressed"); | ||
assert.includes(last(), lvl2.toUpperCase(), "semi suppressed logger does indeed output as the log level matches " + lvl2); | ||
assert.equal(oldsize + 1, output.length, "hook pushed a str onto the output array (semi suppress)"); | ||
testCount += 4; | ||
t.ok(lastIncludes("SEMI"), "semi suppressed logger outputs when " + lvl2 + " not suppressed"); | ||
t.ok(lastIncludes(testMsg), "semi suppressed logger outputs when " + lvl2 + " not suppressed"); | ||
t.ok(lastIncludes(lvl2.toUpperCase()), "semi suppressed logger does indeed output as the log level matches " + lvl2); | ||
t.equal(oldsize + 1, output.length, "hook pushed a str onto the output array (semi suppress)"); | ||
}); | ||
@@ -129,7 +126,6 @@ | ||
stdsub.get(lvl2)(testMsg); | ||
assert.includes(last(), "SEMI", "semi suppressed logger outputs when " + lvl2 + " not suppressed"); | ||
assert.includes(last(), testMsg, "semi suppressed logger single outputs when " + lvl2 + " not suppressed"); | ||
assert.includes(last(), lvl2.toUpperCase(), "semi suppressed logger single does indeed output as the log level matches " + lvl2); | ||
assert.equal(oldsize + 1, output.length, "hook pushed a str onto the output array (semi suppress single)"); | ||
testCount += 4; | ||
t.ok(lastIncludes("SEMI"), "semi suppressed logger outputs when " + lvl2 + " not suppressed"); | ||
t.ok(lastIncludes(testMsg), "semi suppressed logger single outputs when " + lvl2 + " not suppressed"); | ||
t.ok(lastIncludes(lvl2.toUpperCase()), "semi suppressed logger single does indeed output as the log level matches " + lvl2); | ||
t.equal(oldsize + 1, output.length, "hook pushed a str onto the output array (semi suppress single)"); | ||
}); | ||
@@ -144,8 +140,7 @@ | ||
stdsub.sub('subSemi')[lvl2](testMsg); | ||
assert.includes(last(), "SEMI", "semi suppressed logger sub outputs when " + lvl2 + " not suppressed"); | ||
assert.includes(last(), "subSemi", "semi suppressed logger sub outputs when " + lvl2 + " not suppressed"); | ||
assert.includes(last(), testMsg, "semi suppressed logger single outputs when " + lvl2 + " not suppressed"); | ||
assert.includes(last(), lvl2.toUpperCase(), "semi suppressed logger does indeed output as the log level matches " + lvl2); | ||
assert.equal(oldsize + 1, output.length, "hook pushed a str onto the output array (semi suppress sub)"); | ||
testCount += 5; | ||
t.ok(lastIncludes("SEMI"), "semi suppressed logger sub outputs when " + lvl2 + " not suppressed"); | ||
t.ok(lastIncludes("subSemi"), "semi suppressed logger sub outputs when " + lvl2 + " not suppressed"); | ||
t.ok(lastIncludes(testMsg), "semi suppressed logger single outputs when " + lvl2 + " not suppressed"); | ||
t.ok(lastIncludes(lvl2.toUpperCase()), "semi suppressed logger does indeed output as the log level matches " + lvl2); | ||
t.equal(oldsize + 1, output.length, "hook pushed a str onto the output array (semi suppress sub)"); | ||
}); | ||
@@ -160,8 +155,7 @@ | ||
stdsub.sub('subSemi').get(lvl2)(testMsg); | ||
assert.includes(last(), "SEMI", "semi suppressed logger sub single outputs when " + lvl2 + " not suppressed"); | ||
assert.includes(last(), "subSemi", "semi suppressed logger sub single outputs when " + lvl2 + " not suppressed"); | ||
assert.includes(last(), testMsg, "semi suppressed logger sub single outputs when " + lvl2 + " not suppressed"); | ||
assert.includes(last(), lvl2.toUpperCase(), "semi suppressed logger sub single does indeed output as the log level matches " + lvl2); | ||
assert.equal(oldsize + 1, output.length, "hook pushed a str onto the output array (semi suppress sub single)"); | ||
testCount += 5; | ||
t.ok(lastIncludes("SEMI"), "semi suppressed logger sub single outputs when " + lvl2 + " not suppressed"); | ||
t.ok(lastIncludes("subSemi"), "semi suppressed logger sub single outputs when " + lvl2 + " not suppressed"); | ||
t.ok(lastIncludes(testMsg), "semi suppressed logger sub single outputs when " + lvl2 + " not suppressed"); | ||
t.ok(lastIncludes(lvl2.toUpperCase()), "semi suppressed logger sub single does indeed output as the log level matches " + lvl2); | ||
t.equal(oldsize + 1, output.length, "hook pushed a str onto the output array (semi suppress sub single)"); | ||
}); | ||
@@ -178,5 +172,4 @@ }); | ||
stdsub[lvl]('suppressed message').info('working message')[lvl]('another suppressed'); | ||
assert.equal(oldsize + 1, output.length, "hook pushed a str onto the output array (chained 3 calls but 2 suppressed)"); | ||
assert.includes(last(), 'working message', "chaining message for " + lvl + " onto suppressed info does log what we want"); | ||
testCount += 2; | ||
t.equal(oldsize + 1, output.length, "hook pushed a str onto the output array (chained 3 calls but 2 suppressed)"); | ||
t.ok(lastIncludes('working message'), "chaining message for " + lvl + " onto suppressed info does log what we want"); | ||
}); | ||
@@ -187,7 +180,6 @@ | ||
stdlog.sub('multi')[lvl](testMsg, 160000, 'WOWZA', {}); | ||
assert.includes(last(), testMsg, "multi argument message to " + lvl + " contains argument 1"); | ||
assert.includes(last(), 160000, "multi argument message to " + lvl + " contains argument 2"); | ||
assert.includes(last(), "WOWZA", "multi argument message to " + lvl + " contains argument 3"); | ||
assert.includes(last(), "{}", "multi argument message to " + lvl + " contains argument 4"); | ||
testCount += 4; | ||
t.ok(lastIncludes(testMsg), "multi argument message to " + lvl + " contains argument 1"); | ||
t.ok(lastIncludes(160000), "multi argument message to " + lvl + " contains argument 2"); | ||
t.ok(lastIncludes("WOWZA"), "multi argument message to " + lvl + " contains argument 3"); | ||
t.ok(lastIncludes("{}"), "multi argument message to " + lvl + " contains argument 4"); | ||
}); | ||
@@ -198,12 +190,11 @@ | ||
stdlog.sub('multi').get(lvl)(testMsg, 160000, 'WOWZA', {}); | ||
assert.includes(last(), testMsg, "multi argument message to " + lvl + " contains argument 1"); | ||
assert.includes(last(), 160000, "multi argument message to " + lvl + " contains argument 2"); | ||
assert.includes(last(), "WOWZA", "multi argument message to " + lvl + " contains argument 3"); | ||
assert.includes(last(), "{}", "multi argument message to " + lvl + " contains argument 4"); | ||
testCount += 4; | ||
t.ok(lastIncludes(testMsg), "multi argument message to " + lvl + " contains argument 1"); | ||
t.ok(lastIncludes(160000), "multi argument message to " + lvl + " contains argument 2"); | ||
t.ok(lastIncludes("WOWZA"), "multi argument message to " + lvl + " contains argument 3"); | ||
t.ok(lastIncludes("{}"), "multi argument message to " + lvl + " contains argument 4"); | ||
}); | ||
unhook(); | ||
log("stdout - completed", testCount); | ||
}; | ||
t.end(); | ||
}); | ||
Sorry, the diff of this file is not supported yet
226
82016
433