Comparing version 1.0.1 to 1.0.2
@@ -13,4 +13,4 @@ 'use strict'; | ||
name: { | ||
delimeter: ':', | ||
ext: false | ||
delimeter: '/', | ||
ext: true | ||
}, | ||
@@ -62,2 +62,6 @@ line: true, | ||
var str = ''; | ||
if (opts.line) { | ||
str += '\b:%s'; | ||
args.push(callee.getLineNumber()); | ||
} | ||
if (opts.func) { | ||
@@ -67,6 +71,2 @@ str += ' %s'; | ||
} | ||
if (opts.line) { | ||
str += ' %s'; | ||
args.push(callee.getLineNumber()); | ||
} | ||
if (opts.args) { | ||
@@ -130,6 +130,2 @@ str += ' %o'; | ||
var arg; | ||
if (opts.line) { | ||
arg = callee.getLineNumber(); | ||
this.prependArgs(args, arg); | ||
} | ||
if (opts.func) { | ||
@@ -139,2 +135,6 @@ arg = callee.getFunctionName() || 'anonymous'; | ||
} | ||
if (opts.line) { | ||
arg = callee.getLineNumber(); | ||
this.prependArgs(args, '\b:'+arg); | ||
} | ||
return args; | ||
@@ -141,0 +141,0 @@ }; |
{ | ||
"name": "auto-debug", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Uses debug but automatically assumes file as log namespace. Optionally logs line numbers, function arguments, and even traces. ", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# auto-debug | ||
Uses debug but automatically assumes file as log namespace. Optionally logs line numbers, function arguments, and even traces. | ||
Uses [debug](http://github.com/tj/debug) but automatically assumes filenames as the log namespace. | ||
Optionally logs line numbers, function arguments, and caller location. | ||
@@ -16,6 +17,6 @@ | ||
prints: | ||
lib:example someFunction 5 hello | ||
lib/example.js:5 someFunction hello | ||
*/ | ||
/* | ||
equivalent to require('debug')(lib:example)('someFunction 5 hello') | ||
equivalent to require('debug')('lib/example.js')(':5 someFunction hello') | ||
*/ | ||
@@ -34,6 +35,6 @@ }; | ||
prints: | ||
lib:example add 5 hello { a:10, b:20, c:30} from main lib/example2.js:16 | ||
lib/example2.js:5 add hello { a:10, b:20, c:30} from main lib/example2.js:16 | ||
*/ | ||
/* | ||
equivalent to require('debug')(lib:example2)('add 5 hello { a:10, b:20, c:30} from main lib/example2.js:16') | ||
equivalent to require('debug')('lib/example2.js')(':5 add hello { a:10, b:20, c:30} from main lib/example2.js:16') | ||
*/ | ||
@@ -40,0 +41,0 @@ }; |
@@ -49,3 +49,3 @@ var Code = require('code'); | ||
expect(spy.calledOnce).to.be.true(); | ||
expect(spy.firstCall.args).to.deep.equal(['anonymous 42']); | ||
expect(spy.firstCall.args).to.deep.equal(['\b:42 anonymous']); | ||
done(); | ||
@@ -62,3 +62,3 @@ }); | ||
expect(spy.calledOnce).to.be.true(); | ||
expect(spy.firstCall.args).to.deep.equal(['hello 54']); | ||
expect(spy.firstCall.args).to.deep.equal(['\b:54 hello']); | ||
done(); | ||
@@ -85,3 +85,3 @@ }); | ||
expect(spy.calledOnce).to.be.true(); | ||
expect(spy.firstCall.args).to.deep.equal(['76']); | ||
expect(spy.firstCall.args).to.deep.equal(['\b:76']); | ||
done(); | ||
@@ -98,3 +98,3 @@ }); | ||
expect(spy.calledOnce).to.be.true(); | ||
expect(spy.firstCall.args).to.deep.equal(['88']); | ||
expect(spy.firstCall.args).to.deep.equal(['\b:88']); | ||
done(); | ||
@@ -101,0 +101,0 @@ }); |
@@ -58,3 +58,3 @@ var Code = require('code'); | ||
delimeter: '/', | ||
ext: true | ||
ext: false | ||
} | ||
@@ -69,3 +69,3 @@ }); | ||
expect(name).to.exist(); | ||
expect(name).to.equal('test/name-opts.test.js'); | ||
expect(name).to.equal('test/name-opts.test'); | ||
done(); | ||
@@ -72,0 +72,0 @@ }); |
@@ -64,4 +64,4 @@ var Code = require('code'); | ||
expect(spy.calledTwice).to.be.true(); | ||
expect(spy.firstCall.args).to.deep.equal(['%s %s %o %s', 'yolo', 54, {}, 'from test/trace.test.js:55']); | ||
expect(spy.secondCall.args).to.deep.equal(['%s %s %o %s', 'anonymous', 57, {}, 'from test/trace.test.js:58']); | ||
expect(spy.firstCall.args).to.deep.equal(['\b:%s %s %o %s', 54, 'yolo', {}, 'from test/trace.test.js:55']); | ||
expect(spy.secondCall.args).to.deep.equal(['\b:%s %s %o %s', 57, 'anonymous', {}, 'from test/trace.test.js:58']); | ||
done(); | ||
@@ -97,3 +97,3 @@ }); | ||
expect(spy.calledOnce).to.be.true(); | ||
expect(spy.firstCall.args).to.deep.equal(['%s %o %s', 89, {}, 'from test/trace.test.js:90']); | ||
expect(spy.firstCall.args).to.deep.equal(['\b:%s %o %s', 89, {}, 'from test/trace.test.js:90']); | ||
done(); | ||
@@ -100,0 +100,0 @@ }); |
22401
48