loglevel-mixin 7.0.1 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/package.json +9 -9
- package/src/loglevel-mixin.mjs +18 -16
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[](https://www.npmjs.com/package/loglevel-mixin)
|
|
2
2
|
[](https://opensource.org/licenses/BSD-3-Clause)
|
|
3
|
-
[](https://bundlejs.com/?q=loglevel-mixin)
|
|
4
4
|
[](https://npmjs.org/package/loglevel-mixin)
|
|
5
5
|
[](https://github.com/arlac77/loglevel-mixin/issues)
|
|
6
6
|
[](https://actions-badge.atrox.dev/arlac77/loglevel-mixin/goto)
|
|
@@ -123,7 +123,7 @@ For each loglevel a method with the name of the log level will be created.
|
|
|
123
123
|
|
|
124
124
|
* `object` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** target where to assign properties to
|
|
125
125
|
* `logLevels` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Hash with all the available loglevels. Stored by there name (optional, default `defaultLogLevels`)
|
|
126
|
-
* `theFunction` **[Logger](#logger)
|
|
126
|
+
* `theFunction` **[Logger](#logger)?** to be added under the loglevel name.
|
|
127
127
|
This function will only be called if the current loglevel is greater equal
|
|
128
128
|
the log level of the called logging function.
|
|
129
129
|
By default a method log(level,message) will be used
|
|
@@ -144,9 +144,9 @@ Returns **[undefined](https://developer.mozilla.org/docs/Web/JavaScript/Referenc
|
|
|
144
144
|
|
|
145
145
|
### Parameters
|
|
146
146
|
|
|
147
|
-
* `superclass` **
|
|
147
|
+
* `superclass` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** class to be extendet
|
|
148
148
|
* `logLevels` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object with all the available loglevels. Stored by their name (optional, default `defaultLogLevels`)
|
|
149
|
-
* `initialLogLevel` **[
|
|
149
|
+
* `initialLogLevel` **[Loglevel](#loglevel)** the default value for the logLevel property (optional, default `defaultLogLevels.info`)
|
|
150
150
|
|
|
151
151
|
### Examples
|
|
152
152
|
|
|
@@ -159,7 +159,7 @@ class LoggingEnabledClass extends LogLevelMixin(BaseClass) {
|
|
|
159
159
|
}
|
|
160
160
|
```
|
|
161
161
|
|
|
162
|
-
Returns **
|
|
162
|
+
Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** newly created class ready to be further extendet/used
|
|
163
163
|
|
|
164
164
|
## makeLogEvent
|
|
165
165
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "loglevel-mixin",
|
|
3
|
-
"version": "7.0
|
|
3
|
+
"version": "7.1.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -21,22 +21,22 @@
|
|
|
21
21
|
"license": "BSD-2-Clause",
|
|
22
22
|
"scripts": {
|
|
23
23
|
"test": "npm run test:browser-ava && npm run test:ava",
|
|
24
|
-
"test:ava": "ava --timeout
|
|
24
|
+
"test:ava": "ava --timeout 4m tests/*-ava.mjs tests/*-ava-node.mjs",
|
|
25
25
|
"test:browser-ava": "browser-ava --headless --no-keep-open tests/*-ava.mjs tests/*-ava-browser.mjs",
|
|
26
|
-
"cover": "c8 -x 'tests/**/*' --temp-directory build/tmp ava --timeout
|
|
26
|
+
"cover": "c8 -x 'tests/**/*' --temp-directory build/tmp ava --timeout 4m tests/*-ava.mjs tests/*-ava-node.mjs && c8 report -r lcov -o build/coverage --temp-directory build/tmp",
|
|
27
27
|
"docs": "documentation readme --section=API ./src/**/*.mjs",
|
|
28
28
|
"lint": "npm run lint:docs",
|
|
29
29
|
"lint:docs": "documentation lint ./src/**/*.mjs"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"ava": "^
|
|
33
|
-
"browser-ava": "^1.
|
|
34
|
-
"c8": "^
|
|
35
|
-
"documentation": "^14.0.
|
|
36
|
-
"semantic-release": "^
|
|
32
|
+
"ava": "^6.0.1",
|
|
33
|
+
"browser-ava": "^2.1.4",
|
|
34
|
+
"c8": "^8.0.1",
|
|
35
|
+
"documentation": "^14.0.2",
|
|
36
|
+
"semantic-release": "^22.0.10"
|
|
37
37
|
},
|
|
38
38
|
"engines": {
|
|
39
|
-
"node": ">=16.
|
|
39
|
+
"node": ">=16.20.2"
|
|
40
40
|
},
|
|
41
41
|
"repository": {
|
|
42
42
|
"type": "git",
|
package/src/loglevel-mixin.mjs
CHANGED
|
@@ -20,16 +20,16 @@
|
|
|
20
20
|
* - crit
|
|
21
21
|
* - alert
|
|
22
22
|
*/
|
|
23
|
-
export const defaultLogLevels =
|
|
24
|
-
"trace",
|
|
25
|
-
"debug",
|
|
26
|
-
"info",
|
|
27
|
-
"notice",
|
|
28
|
-
"warn",
|
|
29
|
-
"error",
|
|
30
|
-
"crit",
|
|
31
|
-
"alert"
|
|
32
|
-
|
|
23
|
+
export const defaultLogLevels = {
|
|
24
|
+
trace: { name: "trace", priority: 8 },
|
|
25
|
+
debug: { name: "debug", priority: 7 },
|
|
26
|
+
info: { name: "info", priority: 6 },
|
|
27
|
+
notice: { name: "notice", priority: 5 },
|
|
28
|
+
warn: { name: "warn", priority: 4 },
|
|
29
|
+
error: { name: "error", priority: 3 },
|
|
30
|
+
crit: { name: "crit", priority: 2 },
|
|
31
|
+
alert: { name: "alert", priority: 1 }
|
|
32
|
+
};
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* Generate the loglevel objects out of a list of log level names.
|
|
@@ -49,7 +49,7 @@ export function declareLevels(list) {
|
|
|
49
49
|
* For each loglevel a method with the name of the log level will be created.
|
|
50
50
|
* @param {Object} object target where to assign properties to
|
|
51
51
|
* @param {Object} logLevels Hash with all the available loglevels. Stored by there name
|
|
52
|
-
* @param {Logger} theFunction to be added under the loglevel name.
|
|
52
|
+
* @param {Logger} [theFunction] to be added under the loglevel name.
|
|
53
53
|
* This function will only be called if the current loglevel is greater equal
|
|
54
54
|
* the log level of the called logging function.
|
|
55
55
|
* By default a method log(level,message) will be used
|
|
@@ -105,10 +105,10 @@ export function defineLoggerMethods(
|
|
|
105
105
|
* <!-- skip-example -->
|
|
106
106
|
* @class
|
|
107
107
|
* @classdesc This function is a mixin for ES2015 classes.
|
|
108
|
-
* @param {
|
|
108
|
+
* @param {Object} superclass class to be extendet
|
|
109
109
|
* @param {Object} logLevels Object with all the available loglevels. Stored by their name
|
|
110
|
-
* @param {
|
|
111
|
-
* @return {
|
|
110
|
+
* @param {Loglevel} initialLogLevel the default value for the logLevel property
|
|
111
|
+
* @return {Object} newly created class ready to be further extendet/used
|
|
112
112
|
* @example
|
|
113
113
|
* import { LogLevelMixin } = from 'loglevel-mixin';
|
|
114
114
|
* class BaseClass {
|
|
@@ -173,7 +173,9 @@ export function makeLogEvent(severity, arg, args) {
|
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
const logevent = {
|
|
176
|
-
severity
|
|
176
|
+
severity,
|
|
177
|
+
...arg,
|
|
178
|
+
...args
|
|
177
179
|
};
|
|
178
180
|
|
|
179
181
|
if (arg instanceof Error) {
|
|
@@ -182,7 +184,7 @@ export function makeLogEvent(severity, arg, args) {
|
|
|
182
184
|
mapError(logevent, arg.error);
|
|
183
185
|
}
|
|
184
186
|
|
|
185
|
-
return
|
|
187
|
+
return logevent;
|
|
186
188
|
}
|
|
187
189
|
}
|
|
188
190
|
|