Comparing version 1.1.0-beta.2 to 1.1.0-beta.3
@@ -113,3 +113,3 @@ /** | ||
/** | ||
* An Adapter accepts the AnyLogger function and adapts it | ||
* An Adapter accepts the `anyLogger` function and adapts it | ||
* by overriding the default extension | ||
@@ -151,6 +151,6 @@ */ | ||
*/ | ||
export type LogLevel = keyof LogLevels; | ||
export type LogLevel = string; | ||
/** | ||
* A mapping of level name `string` to level `number` that consists | ||
* at least the keys from `logLevels` | ||
* of at least the keys from `logLevels` plus arbitrary other keys | ||
*/ | ||
@@ -157,0 +157,0 @@ export type LogLevels = typeof logLevels & { |
@@ -27,12 +27,14 @@ var anylogger = (function () { | ||
[name]); | ||
// a default no-op extension | ||
const noop = (logfn) => { | ||
logfn.enabledFor = () => { }; | ||
for (const lvl in anylogger.levels) { | ||
logfn[lvl] = () => { }; | ||
} | ||
return logfn; | ||
}; | ||
// anylogger.ext extends the given `logger` function | ||
// the implementation here only adds no-ops | ||
// adapters should change this behavior | ||
anylogger.ext = (logger) => { | ||
logger.enabledFor = () => { }; | ||
for (const lvl in anylogger.levels) { | ||
logger[lvl] = () => { }; | ||
} | ||
return logger; | ||
}; | ||
anylogger.ext = noop; | ||
/** | ||
@@ -39,0 +41,0 @@ * A default set of level name/value pairs that maps well to the console. |
@@ -25,12 +25,14 @@ /** | ||
[name]); | ||
// a default no-op extension | ||
const noop = (logfn) => { | ||
logfn.enabledFor = () => { }; | ||
for (const lvl in anylogger.levels) { | ||
logfn[lvl] = () => { }; | ||
} | ||
return logfn; | ||
}; | ||
// anylogger.ext extends the given `logger` function | ||
// the implementation here only adds no-ops | ||
// adapters should change this behavior | ||
anylogger.ext = (logger) => { | ||
logger.enabledFor = () => { }; | ||
for (const lvl in anylogger.levels) { | ||
logger[lvl] = () => { }; | ||
} | ||
return logger; | ||
}; | ||
anylogger.ext = noop; | ||
/** | ||
@@ -37,0 +39,0 @@ * A default set of level name/value pairs that maps well to the console. |
@@ -1,1 +0,1 @@ | ||
var anylogger=function(){const n=e=>n.all[e]||(n.all[e]=n.ext(n.new(e)));n.all=Object.create(null),n.new=l=>({[l]:(...e)=>n.log(l,...e)})[l],n.ext=e=>{e.enabledFor=()=>{};for(const l in n.levels)e[l]=()=>{};return e};return n.levels={error:1,warn:2,info:3,log:4,debug:5,trace:6},n.log=(e,...l)=>n(e)[1<l.length&&n.levels[l[0]]?l.shift():"log"](...l),n}(); | ||
var anylogger=function(){const n=e=>n.all[e]||(n.all[e]=n.ext(n.new(e)));n.all=Object.create(null),n.new=l=>({[l]:(...e)=>n.log(l,...e)})[l];n.ext=e=>{e.enabledFor=()=>{};for(const l in n.levels)e[l]=()=>{};return e};return n.levels={error:1,warn:2,info:3,log:4,debug:5,trace:6},n.log=(e,...l)=>n(e)[1<l.length&&n.levels[l[0]]?l.shift():"log"](...l),n}(); |
@@ -146,7 +146,10 @@ /** | ||
/** | ||
* An Adapter accepts the AnyLogger function and adapts it | ||
* by overriding the default extension | ||
*/ | ||
export type Adapter = (anylogger: AnyLogger) => void | ||
// a default no-op extension | ||
const noop: Extension = (logfn: LogFunction): Logger => { | ||
(logfn as Logger).enabledFor = ()=>{} | ||
for (const lvl in anylogger.levels) { | ||
(logfn as Logger)[lvl as LogLevel] = ()=>{} | ||
} | ||
return logfn as Logger | ||
} | ||
@@ -156,11 +159,11 @@ // anylogger.ext extends the given `logger` function | ||
// adapters should change this behavior | ||
anylogger.ext = (logger: LogFunction): Logger => { | ||
(logger as Logger).enabledFor = ()=>{} | ||
for (const lvl in anylogger.levels) { | ||
(logger as Logger)[lvl as LogLevel] = ()=>{} | ||
} | ||
return logger as Logger | ||
} | ||
anylogger.ext = noop | ||
/** | ||
* An Adapter accepts the `anyLogger` function and adapts it | ||
* by overriding the default extension | ||
*/ | ||
export type Adapter = (anylogger: AnyLogger) => void | ||
/** | ||
* Anylogger supports the concept of levels. | ||
@@ -200,7 +203,7 @@ */ | ||
*/ | ||
export type LogLevel = keyof LogLevels | ||
export type LogLevel = string | ||
/** | ||
* A mapping of level name `string` to level `number` that consists | ||
* at least the keys from `logLevels` | ||
* of at least the keys from `logLevels` plus arbitrary other keys | ||
*/ | ||
@@ -207,0 +210,0 @@ export type LogLevels = typeof logLevels & { [level: string]: number } |
{ | ||
"name": "anylogger", | ||
"version": "1.1.0-beta.2", | ||
"version": "1.1.0-beta.3", | ||
"description": "Get a logger. Any logger.", | ||
@@ -12,3 +12,3 @@ "type": "module", | ||
}, | ||
"src": "./anylogger.js", | ||
"src": "./anylogger.ts", | ||
"main": "./anylogger.js", | ||
@@ -15,0 +15,0 @@ "cjs": "./anylogger.cjs", |
@@ -1,2 +0,2 @@ | ||
# anylogger <sub><sup>1.1.0-beta.2</sup></sub> | ||
# anylogger <sub><sup>1.1.0-beta.3</sup></sub> | ||
### Get a logger. Any logger. | ||
@@ -133,11 +133,11 @@ | ||
* [anylogger.ts](https://unpkg.com/anylogger@1.1.0-beta.2/anylogger.ts) | ||
* [anylogger.ts](https://unpkg.com/anylogger@1.1.0-beta.3/anylogger.ts) | ||
(fully commented source ~7kB) | ||
* [anylogger.d.ts](https://unpkg.com/anylogger@1.1.0-beta.2/anylogger.d.ts) | ||
* [anylogger.d.ts](https://unpkg.com/anylogger@1.1.0-beta.3/anylogger.d.ts) | ||
(typescript type definitions ~6kB) | ||
* [anylogger.js](https://unpkg.com/anylogger@1.1.0-beta.2/anylogger.js) | ||
* [anylogger.js](https://unpkg.com/anylogger@1.1.0-beta.3/anylogger.js) | ||
(javascript esm module ~2kB) | ||
* [anylogger.cjs](https://unpkg.com/anylogger@1.1.0-beta.2/anylogger.cjs) | ||
* [anylogger.cjs](https://unpkg.com/anylogger@1.1.0-beta.3/anylogger.cjs) | ||
(javascript commonjs module ~2kB) | ||
* [anylogger.min.js](https://unpkg.com/anylogger@1.1.0-beta.2/anylogger.min.js) | ||
* [anylogger.min.js](https://unpkg.com/anylogger@1.1.0-beta.3/anylogger.min.js) | ||
(minified 355 bytes, gzipped ~[259](#gzip-size) bytes) | ||
@@ -150,3 +150,3 @@ | ||
```html | ||
<script src="https://unpkg.com/anylogger@1.1.0-beta.2"></script> | ||
<script src="https://unpkg.com/anylogger@1.1.0-beta.3"></script> | ||
<script>(function(){ // IIFE | ||
@@ -650,3 +650,3 @@ var log = anylogger('index.html') | ||
Please have a look at the | ||
[source](https://unpkg.com/anylogger@1.1.0-beta.2/anylogger.js) | ||
[source](https://unpkg.com/anylogger@1.1.0-beta.3/anylogger.js) | ||
it should make it more clear how to write an adapter. Also consider studying | ||
@@ -653,0 +653,0 @@ the [available adapters](https://www.npmjs.com/search?q=keywords:anylogger) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
52877
733