Comparing version 0.0.0 to 0.1.0
{ | ||
"name": "dbug", | ||
"version": "0.0.0", | ||
"version": "0.1.0", | ||
"description": "debug improvements", | ||
@@ -10,4 +10,5 @@ "main": "./lib/dbug.js", | ||
"devDependencies": { | ||
"mocha": "*" | ||
"mocha": "1.x" | ||
}, | ||
"readmeFilename": "README.md", | ||
"keywords": [ | ||
@@ -21,3 +22,9 @@ "debug", | ||
"author": "Sean McArthur <sean.monstar@gmail.com> (http://seanmonstar.com)", | ||
"bugs": "https://github.com/seanmonstar/dbug/issues", | ||
"homepage": "https://github.com/seanmonstar/dbug", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/seanmonstar/dbug.git" | ||
}, | ||
"license": "MPLv2.0" | ||
} |
# dbug | ||
[![Build Status](https://travis-ci.org/seanmonstar/dbug.png?branch=master)](https://travis-ci.org/seanmonstar/dbug) | ||
[![NPM version](https://badge.fury.io/js/dbug.png)](http://badge.fury.io/js/dbug) | ||
A drop-in replacement for [debug][], for slightly more utility. | ||
```js | ||
var dbug = require('dbug')('foo:bar'); | ||
dbug('just like debug'); // except goes to stdout, not stderr | ||
dbug(new Error('also like debug')); | ||
// additional methods | ||
dbug.info('info'); | ||
dbug.warn('warning'); | ||
dbug.error('red alert'); | ||
``` | ||
Just like debug, `dbug` won't do anything unless the `DEBUG` env variable matches the `dbug` logger, but with slightly more lenient matching. | ||
``` | ||
DEBUG=* | ||
DEBUG=foo,quux | ||
DEBUG=foo // also acts as foo:* | ||
``` | ||
[debug]: https://npmjs.org/package/debug |
@@ -12,3 +12,2 @@ /* This Source Code Form is subject to the terms of the Mozilla Public | ||
const stdout = { | ||
@@ -28,7 +27,20 @@ lastWrite: '', | ||
// XXX: v0.8 support. remove when dropped | ||
var out = process.stdout.write; | ||
var err = process.stderr.write; | ||
function testOut(v) { | ||
stdout.lastWrite = v; | ||
return true; | ||
} | ||
function testErr(v) { | ||
stderr.lastWrite = v; | ||
return true; | ||
} | ||
module.exports = { | ||
'dbug': { | ||
'before': function() { | ||
console._stdout = stdout; | ||
console._stderr = stderr; | ||
//console._stdout = stdout; | ||
//console._stderr = stderr; | ||
}, | ||
@@ -62,2 +74,5 @@ 'matching': { | ||
process.stdout.write = testOut; | ||
process.stderr.write = testErr; | ||
function contains(haystack, needle) { | ||
@@ -81,2 +96,5 @@ return haystack.indexOf(needle) !== -1; | ||
assert(contains(stderr.lastWrite, 'foo.error')); | ||
process.stdout.write = out; | ||
process.stderr.write = err; | ||
}, | ||
@@ -97,2 +115,5 @@ | ||
'should be disabled': function() { | ||
process.stdout.write = testOut; | ||
process.stderr.write = testErr; | ||
assert(!bar.enabled); | ||
@@ -103,2 +124,5 @@ bar('a'); | ||
assert.notEqual(stdout.lastWrite, 'b'); | ||
process.stdout.write = out; | ||
process.stderr.write = err; | ||
} | ||
@@ -108,6 +132,6 @@ }, | ||
'after': function() { | ||
console._stdout = process.stdout; | ||
console._stderr = process.stderr; | ||
//console._stdout = process.stdout; | ||
//console._stderr = process.stderr; | ||
} | ||
} | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
24730
8
200
1
29
3