anylogger-debug
Advanced tools
Comparing version
(function () { | ||
// override anylogger.ext() to make every log method use debug | ||
anylogger.ext = function(logger) { | ||
var method = debug(logger.name); | ||
for (var level in anylogger.levels) { | ||
logger[level] = method; | ||
} | ||
logger.enabledFor = debug.enabled.bind(logger, logger.name); | ||
return logger | ||
}; | ||
// override anylogger.ext() to make every log method use debug | ||
anylogger.ext = function (logger) { | ||
var method = debug(logger.name); | ||
for (var level in anylogger.levels) { | ||
logger[level] = method; | ||
} | ||
logger.enabledFor = debug.enabled.bind(logger, logger.name); | ||
return logger; | ||
}; | ||
}()); | ||
})(); |
@@ -1,12 +0,12 @@ | ||
import anylogger from 'anylogger' | ||
import debug from 'debug' | ||
import anylogger from 'anylogger'; | ||
import debug from 'debug'; | ||
// override anylogger.ext() to make every log method use debug | ||
anylogger.ext = function(logger) { | ||
var method = debug(logger.name) | ||
for (var level in anylogger.levels) { | ||
logger[level] = method | ||
} | ||
logger.enabledFor = debug.enabled.bind(logger, logger.name) | ||
return logger | ||
} | ||
anylogger.ext = function (logger) { | ||
var method = debug(logger.name); | ||
for (var level in anylogger.levels) { | ||
logger[level] = method; | ||
} | ||
logger.enabledFor = debug.enabled.bind(logger, logger.name); | ||
return logger; | ||
}; | ||
//# sourceMappingURL=anylogger-debug.js.map |
@@ -1,6 +0,6 @@ | ||
var expect = require('chai').expect | ||
var sinon = require('sinon') | ||
var adapter = require('./anylogger-debug.cjs') | ||
var anylogger = require('anylogger') | ||
var debug = require('debug') | ||
import { expect } from 'chai' | ||
import sinon from 'sinon' | ||
import 'anylogger-debug' | ||
import anylogger from 'anylogger' | ||
import debug from 'debug' | ||
@@ -17,5 +17,5 @@ var sandbox = sinon.createSandbox(); | ||
// clear any loggers that were created | ||
Object.keys(anylogger()).forEach(function(key){ | ||
delete anylogger()[key] | ||
}) | ||
for (const name in anylogger.all) { | ||
delete anylogger.all[name] | ||
} | ||
// restore original console methods | ||
@@ -30,12 +30,2 @@ sandbox.restore() | ||
it('returns an object mapping names to loggers when called without arguments', function(){ | ||
var result = anylogger() | ||
expect(result).to.be.an('object') | ||
expect(Object.keys(result)).to.deep.eq([]) | ||
anylogger('test') | ||
result = anylogger() | ||
expect(result).to.be.an('object') | ||
expect(Object.keys(result)).to.deep.eq(['test']) | ||
}) | ||
it('returns a named logger when called with a name', function(){ | ||
@@ -155,3 +145,3 @@ var name = 'test' | ||
expect(log.enabledFor).to.be.a('function') | ||
expect(log.enabledFor()).to.equal(false) | ||
expect(log.enabledFor()).to.not.equal(true) | ||
debug.enable('test') | ||
@@ -181,5 +171,2 @@ expect(log.enabledFor()).to.equal(true) | ||
var log = anylogger('test') | ||
var out = { | ||
log: debug.log | ||
} | ||
sandbox.spy(log, 'log') | ||
@@ -190,3 +177,3 @@ sandbox.spy(log, 'info') | ||
expect(log.info.callCount).to.equal(1) | ||
} | ||
} | ||
finally { | ||
@@ -193,0 +180,0 @@ debug.disable() |
{ | ||
"name": "anylogger-debug", | ||
"version": "1.0.3", | ||
"version": "1.1.0-beta.0", | ||
"description": "Anylogger adapter for debug", | ||
"src": "./anylogger-debug.js", | ||
"main": "./anylogger-debug.cjs.js", | ||
"type": "module", | ||
"exports": { | ||
".": { | ||
"import": "./anylogger-debug.js", | ||
"require": "./anylogger-debug.cjs" | ||
} | ||
}, | ||
"src": "./anylogger-debug.ts", | ||
"main": "./anylogger-debug.js", | ||
"cjs": "./anylogger-debug.cjs", | ||
"iife": "./anylogger-debug.iife.js", | ||
@@ -11,7 +19,11 @@ "min": "./anylogger-debug.min.js", | ||
"files": [ | ||
"anylogger-debug.cjs", | ||
"anylogger-debug.d.ts", | ||
"anylogger-debug.d.ts.map", | ||
"anylogger-debug.iife.js", | ||
"anylogger-debug.js", | ||
"anylogger-debug.cjs.js", | ||
"anylogger-debug.iife.js", | ||
"anylogger-debug.js.map", | ||
"anylogger-debug.min.js", | ||
"anylogger-debug.spec.js", | ||
"anylogger-debug.ts", | ||
"test.html" | ||
@@ -21,5 +33,6 @@ ], | ||
"scripts": { | ||
"build": "npm run test -s && npm run minify -s && npm run docs -s", | ||
"docs": "cross-env NODE_ENV=production node build.js docs", | ||
"minify": "cross-env NODE_ENV=production node build.js minify", | ||
"build": "tsc && npm run test && npm run minify && npm run docs", | ||
"clean": "rimraf anylogger-debug.cjs anylogger-debug.d.ts anylogger-debug.d.ts.map anylogger-debug.iife.js anylogger-debug.js anylogger-debug.js.map anylogger-debug.min.js", | ||
"docs": "cross-env NODE_ENV=production DEBUG=anylogger-debug node build.js docs", | ||
"minify": "cross-env NODE_ENV=production DEBUG=anylogger-debug node build.js minify", | ||
"package": "cross-env NODE_ENV=production rollup -c", | ||
@@ -45,20 +58,21 @@ "prepare": "npm run build", | ||
"homepage": "https://github.com/download/anylogger-debug#readme", | ||
"dependencies": { | ||
"anylogger": "^1.0.6", | ||
"debug": "^4.3.1" | ||
}, | ||
"peerDependencies": { | ||
"anylogger": "^1.0.1", | ||
"debug": "^4.1.1" | ||
"anylogger": "1.x || 1.1.0-beta.x || 1.2.0-beta.x || 1.3.0-beta.x", | ||
"debug": "4.x" | ||
}, | ||
"devDependencies": { | ||
"chai": "^4.2.0", | ||
"cross-env": "^7.0.2", | ||
"gzip-size": "^6.0.0", | ||
"mocha": "^8.2.1", | ||
"rollup": "^2.33.3", | ||
"@types/debug": "^4.1.12", | ||
"anylogger": "^1.1.0-beta.0", | ||
"chai": "^5.1.0", | ||
"cross-env": "^7.0.3", | ||
"debug": "^4.3.4", | ||
"gzip-size": "^7.0.0", | ||
"mocha": "^10.3.0", | ||
"rimraf": "^5.0.5", | ||
"rollup": "^4.12.0", | ||
"rollup-plugin-re": "^1.0.7", | ||
"sinon": "^9.2.1", | ||
"uglify-js": "^3.11.6" | ||
"sinon": "^17.0.1", | ||
"typescript": "^5.3.3", | ||
"uglify-js": "^3.17.4" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# anylogger-debug <sub><sup>1.0.3</sup></sub> | ||
# anylogger-debug <sub><sup>1.1.0-beta.0</sup></sub> | ||
### Anylogger adapter for debug | ||
@@ -6,3 +6,2 @@ | ||
[](https://opensource.org/licenses/MIT) | ||
[](https://travis-ci.org/Download/anylogger-debug) | ||
 | ||
@@ -15,4 +14,4 @@ | ||
This package is meant for application projects that are using libraries using | ||
`anylogger`. By including this adapter in your project, all libraries using | ||
This package is meant for application projects that are using libraries using | ||
`anylogger`. By including this adapter in your project, all libraries using | ||
`anylogger` will automatically start to use `debug` as their logging framework. | ||
@@ -22,5 +21,5 @@ | ||
* [anylogger-debug.js](https://unpkg.com/anylogger-debug@1.0.3/anylogger-debug.js) | ||
* [anylogger-debug.js](https://unpkg.com/anylogger-debug@1.1.0-beta.0/anylogger-debug.js) | ||
(fully commented source ~5kB) | ||
* [anylogger-debug.min.js](https://unpkg.com/anylogger-debug@1.0.3/anylogger-debug.min.js) | ||
* [anylogger-debug.min.js](https://unpkg.com/anylogger-debug@1.1.0-beta.0/anylogger-debug.min.js) | ||
(minified 133 bytes, gzipped ~[121](#gzip-size) bytes) | ||
@@ -33,5 +32,5 @@ | ||
```html | ||
<script src="https://unpkg.com/anylogger@1.0.6/anylogger.min.js"></script> | ||
<script src="https://unpkg.com/anylogger-debug@1.0.3/browserified-debug-4.1.1.min.js"></script> | ||
<script src="https://unpkg.com/anylogger-debug@1.0.3/anylogger-debug.min.js"></script> | ||
<script src="https://unpkg.com/anylogger@1.1.0-beta.0/anylogger.min.js"></script> | ||
<script src="https://unpkg.com/anylogger-debug@1.1.0-beta.0/browserified-debug-4.1.1.min.js"></script> | ||
<script src="https://unpkg.com/anylogger-debug@1.1.0-beta.0/anylogger-debug.min.js"></script> | ||
<script>(function(){ // IIFE | ||
@@ -55,9 +54,9 @@ var log = anylogger('index.html') | ||
This package is meant for application projects. If you are writing a library to | ||
be NPM installed into some other project, most likely you should not include | ||
be NPM installed into some other project, most likely you should not include | ||
any adapter, but instead just use `anylogger` directly. | ||
The `anylogger-debug` adapter will modify the `anylogger` factory in such a way | ||
that the loggers it creates will be logging to `debug`. | ||
that the loggers it creates will be logging to `debug`. | ||
> When using `debug`, all logging is supressed by default. As such, you should make sure to activate debug mode with the environment variable or localStorage key [as usual](https://www.npmjs.com/package/debug#usage) before expecting to see any output. | ||
> When using `debug`, all logging is supressed by default. As such, you should make sure to activate debug mode with the environment variable or localStorage key [as usual](https://www.npmjs.com/package/debug#usage) before expecting to see any output. | ||
@@ -81,3 +80,3 @@ To activate the adapter, include it in your application entry point. | ||
## Logging in the application project | ||
In your application module code, only use anylogger to stay framework | ||
In your application module code, only use anylogger to stay framework | ||
independent: | ||
@@ -115,4 +114,4 @@ | ||
Add an issue in this project's | ||
[issue tracker](https://github.com/download/anylogger-debug/issues) | ||
Add an issue in this project's | ||
[issue tracker](https://github.com/download/anylogger-debug/issues) | ||
to let me know of any problems you find, or questions you may have. | ||
@@ -131,5 +130,5 @@ | ||
## gzip-size | ||
The GZIP algorithm is available in different flavours and with different | ||
The GZIP algorithm is available in different flavours and with different | ||
possible compression settings. The sizes quoted in this README have been | ||
measured using [gzip-size](https://npmjs.com/package/gzip-size) | ||
measured using [gzip-size](https://npmjs.com/package/gzip-size) | ||
by [Sindre Sorhus](https://github.com/sindresorhus), your mileage may vary. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
16209
4.93%2
-50%13
44.44%222
0.45%Yes
NaN13
62.5%1
Infinity%127
-0.78%- Removed
- Removed
- Removed