Comparing version 1.1.0-beta.3 to 1.1.0-beta.4
@@ -113,6 +113,7 @@ /** | ||
/** | ||
* An Adapter accepts the `anyLogger` function and adapts it | ||
* by overriding the default extension | ||
* An Adapter accepts the `anyLogger` function and optionally | ||
* some logging framework and adapts anylogger to that logging | ||
* framework by overriding the default extension | ||
*/ | ||
export type Adapter = (anylogger: AnyLogger) => void; | ||
export type Adapter = (anylogger: AnyLogger, framework?: any) => void; | ||
/** | ||
@@ -119,0 +120,0 @@ * Anylogger supports the concept of levels. |
@@ -161,6 +161,7 @@ /** | ||
/** | ||
* An Adapter accepts the `anyLogger` function and adapts it | ||
* by overriding the default extension | ||
* An Adapter accepts the `anyLogger` function and optionally | ||
* some logging framework and adapts anylogger to that logging | ||
* framework by overriding the default extension | ||
*/ | ||
export type Adapter = (anylogger: AnyLogger) => void | ||
export type Adapter = (anylogger: AnyLogger, framework?: any) => void | ||
@@ -167,0 +168,0 @@ /** |
{ | ||
"name": "anylogger", | ||
"version": "1.1.0-beta.3", | ||
"version": "1.1.0-beta.4", | ||
"description": "Get a logger. Any logger.", | ||
@@ -15,5 +15,5 @@ "type": "module", | ||
"cjs": "./anylogger.cjs", | ||
"types": "./anylogger.d.ts", | ||
"iife": "./anylogger.iife.js", | ||
"min": "./anylogger.min.js", | ||
"types": "./anylogger.d.ts", | ||
"spec": "./anylogger.spec.js", | ||
@@ -27,5 +27,7 @@ "unpkg": "./anylogger.min.js", | ||
"anylogger.js", | ||
"anylogger.js.map", | ||
"anylogger.min.js", | ||
"anylogger.spec.js", | ||
"anylogger.ts" | ||
"anylogger.ts", | ||
"tsconfig.json" | ||
], | ||
@@ -32,0 +34,0 @@ "scripts": { |
107
README.md
@@ -1,2 +0,2 @@ | ||
# anylogger <sub><sup>1.1.0-beta.3</sup></sub> | ||
# anylogger <sub><sup>1.1.0-beta.4</sup></sub> | ||
### Get a logger. Any logger. | ||
@@ -22,2 +22,4 @@ | ||
<th><h3>Library</h3></th> | ||
<th><h3>App with <a href="https://npmjs.com/package/anylogger-console" | ||
><tt>console</tt></a></h3></th> | ||
<th><h3>App with <a href="https://npmjs.com/package/anylogger-debug" | ||
@@ -45,8 +47,24 @@ ><tt>debug</tt></a></h3></th> | ||
<pre>npm i -P anylogger | ||
anylogger-console</pre> | ||
<h5>Add to entry point</h5> | ||
<i>index.js</i> | ||
<pre>import adapter from | ||
'anylogger-console' | ||
import anylogger from 'anylogger' | ||
adapter(anylogger, console)</pre> | ||
<h5>Use</h5> | ||
<pre>import anylogger from 'anylogger' | ||
const log = anylogger('my-app') | ||
log('Anylogger is easy!')</pre> | ||
</td> | ||
<td><h5>Install</h5> | ||
<pre>npm i -P anylogger | ||
debug anylogger-debug</pre> | ||
<h5>Add to entry point</h5> | ||
<i>index.js</i> | ||
<pre>import adapter from "anylogger-debug" | ||
<pre>import adapter from | ||
'anylogger-debug' | ||
import anylogger from 'anylogger' | ||
adapter(anylogger)</pre> | ||
import debug from 'debug' | ||
adapter(anylogger, debug)</pre> | ||
<h5>Use</h5> | ||
@@ -64,3 +82,4 @@ <pre>import anylogger from 'anylogger' | ||
import anylogger from 'anylogger' | ||
adapter(anylogger)</pre> | ||
import loglevel from 'loglevel' | ||
adapter(anylogger, loglevel)</pre> | ||
<h5>Use</h5> | ||
@@ -72,9 +91,9 @@ <pre>import anylogger from 'anylogger' | ||
<td><h5>Install</h5> | ||
<pre>npm i -P anylogger | ||
ulog</pre> | ||
<pre>npm i -P anylogger ulog</pre> | ||
<h5>Add to entry point</h5> | ||
<i>index.js</i> | ||
<pre>import adapter from "ulog" | ||
<pre>import adapter from 'ulog/adapter' | ||
import anylogger from 'anylogger' | ||
adapter(anylogger)</pre> | ||
import ulog from 'ulog' | ||
adapter(anylogger, ulog)</pre> | ||
<h5>Use</h5> | ||
@@ -90,5 +109,6 @@ <pre>import anylogger from 'anylogger' | ||
<i>index.js</i> | ||
<pre>import adapter from "anylogger-log4js" | ||
<pre>import adapter from 'anylogger-log4js' | ||
import anylogger from 'anylogger' | ||
adapter(anylogger)</pre> | ||
import log4js from 'log4js' | ||
adapter(anylogger, log4js)</pre> | ||
<h5>Use</h5> | ||
@@ -138,11 +158,11 @@ <pre>import anylogger from 'anylogger' | ||
* [anylogger.ts](https://unpkg.com/anylogger@1.1.0-beta.3/anylogger.ts) | ||
* [anylogger.ts](https://unpkg.com/anylogger@1.1.0-beta.4/anylogger.ts) | ||
(fully commented source ~7kB) | ||
* [anylogger.d.ts](https://unpkg.com/anylogger@1.1.0-beta.3/anylogger.d.ts) | ||
* [anylogger.d.ts](https://unpkg.com/anylogger@1.1.0-beta.4/anylogger.d.ts) | ||
(typescript type definitions ~6kB) | ||
* [anylogger.js](https://unpkg.com/anylogger@1.1.0-beta.3/anylogger.js) | ||
* [anylogger.js](https://unpkg.com/anylogger@1.1.0-beta.4/anylogger.js) | ||
(javascript esm module ~2kB) | ||
* [anylogger.cjs](https://unpkg.com/anylogger@1.1.0-beta.3/anylogger.cjs) | ||
* [anylogger.cjs](https://unpkg.com/anylogger@1.1.0-beta.4/anylogger.cjs) | ||
(javascript commonjs module ~2kB) | ||
* [anylogger.min.js](https://unpkg.com/anylogger@1.1.0-beta.3/anylogger.min.js) | ||
* [anylogger.min.js](https://unpkg.com/anylogger@1.1.0-beta.4/anylogger.min.js) | ||
(minified 355 bytes, gzipped ~[259](#gzip-size) bytes) | ||
@@ -155,3 +175,3 @@ | ||
```html | ||
<script src="https://unpkg.com/anylogger@1.1.0-beta.3"></script> | ||
<script src="https://unpkg.com/anylogger@1.1.0-beta.4"></script> | ||
<script>(function(){ // IIFE | ||
@@ -204,3 +224,3 @@ var log = anylogger('index.html') | ||
``` | ||
> No adapter is needed for `ulog` | ||
> The adapter is included with `ulog` | ||
@@ -285,3 +305,3 @@ **For [log4js](https://npmjs.com/package/log4js)**: | ||
``` | ||
> No adapter is needed for `ulog` | ||
> The adapter is included with `ulog` | ||
@@ -296,3 +316,3 @@ **For [log4js](https://npmjs.com/package/log4js)**: | ||
## Use | ||
## Include | ||
@@ -302,3 +322,3 @@ Depending on the type of project, either just use anylogger, | ||
### Use in a library | ||
### Include in a library | ||
@@ -335,5 +355,6 @@ In your library code, only use anylogger and restrict yourself to the | ||
// e.g. for anylogger-console | ||
import 'anylogger-console' | ||
import adapter from 'anylogger-console' | ||
import anylogger from 'anylogger' | ||
adapter(anylogger, console) | ||
// all loggers will now use the console | ||
import anylogger from 'anylogger' | ||
const log = anylogger('my-lbrary:test') | ||
@@ -347,5 +368,6 @@ log.info('Logging is easy!') | ||
// e.g. for anylogger-console | ||
require('anylogger-console') | ||
const adapter = require('anylogger-console') | ||
const anylogger = require('anylogger') | ||
adapter(anylogger, console) | ||
// all loggers will now use the console | ||
const anylogger = require('anylogger') | ||
const log = anylogger('my-lbrary:test') | ||
@@ -367,3 +389,3 @@ log.info('Logging is easy!') | ||
import anylogger from 'anylogger' | ||
adapter(anylogger) | ||
adapter(anylogger, console) | ||
// all loggers will now use the console | ||
@@ -380,3 +402,3 @@ const log = anylogger('my-app') | ||
const anylogger = require('anylogger') | ||
adapter(anylogger) | ||
adapter(anylogger, console) | ||
// all loggers will now use the console | ||
@@ -501,11 +523,11 @@ const log = anylogger('my-app') | ||
```js | ||
log: function([level='log'], ...args) | ||
log.error: function(...args) | ||
log.warn: function(...args) | ||
log.info: function(...args) | ||
log.log: function(...args) | ||
log.debug: function(...args) | ||
log.trace: function(...args) | ||
log.enabledFor: function(level) => truthy or falsey | ||
```ts | ||
log: (level?:string, ...args: any) => void | ||
log.error: (...args) => void | ||
log.warn: (...args) => void | ||
log.info: (...args) => void | ||
log.log: (...args) => void | ||
log.debug: (...args) => void | ||
log.trace: (...args) => void | ||
log.enabledFor: (level: string) => boolean | void | ||
``` | ||
@@ -579,9 +601,8 @@ | ||
```js | ||
anylogger.new(name, options) => logger | ||
anylogger.new(name: string) => LogFunction | ||
``` | ||
Creates a new logger function that calls `anylogger.log` when invoked. | ||
Creates a new log function that calls `anylogger.log` when invoked. | ||
Uses `new Function(..)` to create a named function so that function.name | ||
corresponds to the module name given. Polyfills function.name on platforms | ||
where it is not natively available. | ||
Create a named function so that function.name corresponds to the module name | ||
given. | ||
@@ -626,3 +647,3 @@ ##### name | ||
```js | ||
anylogger.ext(logger) => logger | ||
anylogger.ext(logfn: LogFunction) => Logger | ||
``` | ||
@@ -666,3 +687,3 @@ | ||
Please have a look at the | ||
[source](https://unpkg.com/anylogger@1.1.0-beta.3/anylogger.js) | ||
[source](https://unpkg.com/anylogger@1.1.0-beta.4/anylogger.js) | ||
it should make it more clear how to write an adapter. Also consider studying | ||
@@ -698,3 +719,3 @@ the [available adapters](https://www.npmjs.com/search?q=keywords:anylogger) | ||
© 2020 by [Stijn de Witt](https://stijndewitt.com). Some rights reserved. | ||
© 2024 by [Stijn de Witt](https://stijndewitt.com). Some rights reserved. | ||
Contributions by [Jakub Jirutka](https://github.com/jirutka). | ||
@@ -701,0 +722,0 @@ |
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
61556
13
797
715