loglevel-mixin 7.0.2 → 7.2.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/LICENSE +1 -1
- package/README.md +1 -0
- package/dist/loglevel-mixin.d.mts +122 -0
- package/package.json +25 -15
- package/src/loglevel-mixin.mjs +10 -10
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
[](https://www.npmjs.com/package/loglevel-mixin)
|
|
2
2
|
[](https://opensource.org/licenses/BSD-3-Clause)
|
|
3
|
+
[](https://typescriptlang.org)
|
|
3
4
|
[](https://bundlejs.com/?q=loglevel-mixin)
|
|
4
5
|
[](https://npmjs.org/package/loglevel-mixin)
|
|
5
6
|
[](https://github.com/arlac77/loglevel-mixin/issues)
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate the loglevel objects out of a list of log level names.
|
|
3
|
+
* @param {string[]} list A list of log level names. The last name in the list will become the one with the highest priority.
|
|
4
|
+
* @return {Object} levels object a hash with all the loglevels. Stored by there name.
|
|
5
|
+
*/
|
|
6
|
+
export function declareLevels(list: string[]): any;
|
|
7
|
+
/**
|
|
8
|
+
* <!-- skip-example -->
|
|
9
|
+
* Adds logging methods to an existing object.
|
|
10
|
+
* For each loglevel a method with the name of the log level will be created.
|
|
11
|
+
* @param {Object} object target where to assign properties to
|
|
12
|
+
* @param {Object} logLevels Hash with all the available loglevels. Stored by there name
|
|
13
|
+
* @param {Logger} [theFunction] to be added under the loglevel name.
|
|
14
|
+
* This function will only be called if the current loglevel is greater equal
|
|
15
|
+
* the log level of the called logging function.
|
|
16
|
+
* By default a method log(level,message) will be used
|
|
17
|
+
* @return {undefined}
|
|
18
|
+
* @example
|
|
19
|
+
* defineLoggerMethods( obj)
|
|
20
|
+
* obj.info('info entry'); // will redirect to theFunction if obj.loglevel is at least info
|
|
21
|
+
* obj.error('error entry'); // will redirect to theFunction if obj.loglevel is at least error
|
|
22
|
+
*/
|
|
23
|
+
export function defineLoggerMethods(object: any, logLevels?: any, theFunction?: Logger): undefined;
|
|
24
|
+
/**
|
|
25
|
+
* <!-- skip-example -->
|
|
26
|
+
* @class
|
|
27
|
+
* @classdesc This function is a mixin for ES2015 classes.
|
|
28
|
+
* @param {Object} superclass class to be extendet
|
|
29
|
+
* @param {Object} logLevels Object with all the available loglevels. Stored by their name
|
|
30
|
+
* @param {Loglevel} initialLogLevel the default value for the logLevel property
|
|
31
|
+
* @return {Object} newly created class ready to be further extendet/used
|
|
32
|
+
* @example
|
|
33
|
+
* import { LogLevelMixin } = from 'loglevel-mixin';
|
|
34
|
+
* class BaseClass {
|
|
35
|
+
* log(level, message) { console.log(`${level} ${message}`); }
|
|
36
|
+
* }
|
|
37
|
+
* class LoggingEnabledClass extends LogLevelMixin(BaseClass) {
|
|
38
|
+
* }
|
|
39
|
+
* @mixin
|
|
40
|
+
*/
|
|
41
|
+
export function LogLevelMixin(superclass: any, logLevels?: any, initialLogLevel?: Loglevel): any;
|
|
42
|
+
export class LogLevelMixin {
|
|
43
|
+
/**
|
|
44
|
+
* <!-- skip-example -->
|
|
45
|
+
* @class
|
|
46
|
+
* @classdesc This function is a mixin for ES2015 classes.
|
|
47
|
+
* @param {Object} superclass class to be extendet
|
|
48
|
+
* @param {Object} logLevels Object with all the available loglevels. Stored by their name
|
|
49
|
+
* @param {Loglevel} initialLogLevel the default value for the logLevel property
|
|
50
|
+
* @return {Object} newly created class ready to be further extendet/used
|
|
51
|
+
* @example
|
|
52
|
+
* import { LogLevelMixin } = from 'loglevel-mixin';
|
|
53
|
+
* class BaseClass {
|
|
54
|
+
* log(level, message) { console.log(`${level} ${message}`); }
|
|
55
|
+
* }
|
|
56
|
+
* class LoggingEnabledClass extends LogLevelMixin(BaseClass) {
|
|
57
|
+
* }
|
|
58
|
+
* @mixin
|
|
59
|
+
*/
|
|
60
|
+
constructor(superclass: any, logLevels?: any, initialLogLevel?: Loglevel);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Helper function to aggregate values into a log event.
|
|
64
|
+
* @param {string} severity log severity
|
|
65
|
+
* @param {string|Object} arg original log message - level may be overwritten
|
|
66
|
+
* @param {Object} [args] additional values to be merged into the final log event - values have precedence
|
|
67
|
+
* @return {Object} suitable for log event processing
|
|
68
|
+
*/
|
|
69
|
+
export function makeLogEvent(severity: string, arg: string | any, args?: any): any;
|
|
70
|
+
export namespace defaultLogLevels {
|
|
71
|
+
namespace trace {
|
|
72
|
+
let name: string;
|
|
73
|
+
let priority: number;
|
|
74
|
+
}
|
|
75
|
+
namespace debug {
|
|
76
|
+
let name_1: string;
|
|
77
|
+
export { name_1 as name };
|
|
78
|
+
let priority_1: number;
|
|
79
|
+
export { priority_1 as priority };
|
|
80
|
+
}
|
|
81
|
+
namespace info {
|
|
82
|
+
let name_2: string;
|
|
83
|
+
export { name_2 as name };
|
|
84
|
+
let priority_2: number;
|
|
85
|
+
export { priority_2 as priority };
|
|
86
|
+
}
|
|
87
|
+
namespace notice {
|
|
88
|
+
let name_3: string;
|
|
89
|
+
export { name_3 as name };
|
|
90
|
+
let priority_3: number;
|
|
91
|
+
export { priority_3 as priority };
|
|
92
|
+
}
|
|
93
|
+
namespace warn {
|
|
94
|
+
let name_4: string;
|
|
95
|
+
export { name_4 as name };
|
|
96
|
+
let priority_4: number;
|
|
97
|
+
export { priority_4 as priority };
|
|
98
|
+
}
|
|
99
|
+
namespace error {
|
|
100
|
+
let name_5: string;
|
|
101
|
+
export { name_5 as name };
|
|
102
|
+
let priority_5: number;
|
|
103
|
+
export { priority_5 as priority };
|
|
104
|
+
}
|
|
105
|
+
namespace crit {
|
|
106
|
+
let name_6: string;
|
|
107
|
+
export { name_6 as name };
|
|
108
|
+
let priority_6: number;
|
|
109
|
+
export { priority_6 as priority };
|
|
110
|
+
}
|
|
111
|
+
namespace alert {
|
|
112
|
+
let name_7: string;
|
|
113
|
+
export { name_7 as name };
|
|
114
|
+
let priority_7: number;
|
|
115
|
+
export { priority_7 as priority };
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
export type Logger = () => any;
|
|
119
|
+
export type Loglevel = {
|
|
120
|
+
name: string;
|
|
121
|
+
priority: number;
|
|
122
|
+
};
|
package/package.json
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "loglevel-mixin",
|
|
3
|
-
"version": "7.0
|
|
3
|
+
"version": "7.2.0",
|
|
4
4
|
"publishConfig": {
|
|
5
|
-
"access": "public"
|
|
5
|
+
"access": "public",
|
|
6
|
+
"provenance": true
|
|
6
7
|
},
|
|
7
8
|
"exports": {
|
|
8
|
-
".":
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/loglevel-mixin.d.mts",
|
|
11
|
+
"default": "./src/loglevel-mixin.mjs"
|
|
12
|
+
}
|
|
9
13
|
},
|
|
14
|
+
"types": "./dist/loglevel-mixin.d.mts",
|
|
10
15
|
"description": "mixin to declare logging methods named after a set of log levels",
|
|
11
16
|
"keywords": [
|
|
12
17
|
"logging",
|
|
@@ -20,27 +25,30 @@
|
|
|
20
25
|
],
|
|
21
26
|
"license": "BSD-2-Clause",
|
|
22
27
|
"scripts": {
|
|
28
|
+
"prepare": "tsc --allowJs --declaration --emitDeclarationOnly --declarationDir dist -t esnext -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs",
|
|
23
29
|
"test": "npm run test:browser-ava && npm run test:ava",
|
|
24
|
-
"test:ava": "ava --timeout
|
|
30
|
+
"test:ava": "ava --timeout 4m tests/*-ava.mjs tests/*-ava-node.mjs",
|
|
25
31
|
"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
|
|
32
|
+
"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
33
|
"docs": "documentation readme --section=API ./src/**/*.mjs",
|
|
28
|
-
"lint": "npm run lint:docs",
|
|
29
|
-
"lint:docs": "documentation lint ./src/**/*.mjs"
|
|
34
|
+
"lint": "npm run lint:docs && npm run lint:tsc",
|
|
35
|
+
"lint:docs": "documentation lint ./src/**/*.mjs",
|
|
36
|
+
"lint:tsc": "tsc --allowJs --checkJs --noEmit -t esnext -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs"
|
|
30
37
|
},
|
|
31
38
|
"devDependencies": {
|
|
32
|
-
"ava": "^
|
|
33
|
-
"browser-ava": "^
|
|
34
|
-
"c8": "^
|
|
35
|
-
"documentation": "^14.0.
|
|
36
|
-
"semantic-release": "^
|
|
39
|
+
"ava": "^6.1.1",
|
|
40
|
+
"browser-ava": "^2.2.0",
|
|
41
|
+
"c8": "^9.1.0",
|
|
42
|
+
"documentation": "^14.0.3",
|
|
43
|
+
"semantic-release": "^23.0.2",
|
|
44
|
+
"typescript": "^5.3.3"
|
|
37
45
|
},
|
|
38
46
|
"engines": {
|
|
39
|
-
"node": ">=
|
|
47
|
+
"node": ">=20.11.0"
|
|
40
48
|
},
|
|
41
49
|
"repository": {
|
|
42
50
|
"type": "git",
|
|
43
|
-
"url": "https://github.com/arlac77/loglevel-mixin"
|
|
51
|
+
"url": "git+https://github.com/arlac77/loglevel-mixin.git"
|
|
44
52
|
},
|
|
45
53
|
"bugs": {
|
|
46
54
|
"url": "https://github.com/arlac77/loglevel-mixin/issues"
|
|
@@ -50,7 +58,9 @@
|
|
|
50
58
|
"inheritFrom": [
|
|
51
59
|
"arlac77/template-arlac77-github",
|
|
52
60
|
"arlac77/template-browser-ava",
|
|
53
|
-
"arlac77/template-
|
|
61
|
+
"arlac77/template-javascript-component",
|
|
62
|
+
"arlac77/template-node-component",
|
|
63
|
+
"arlac77/template-typescript"
|
|
54
64
|
]
|
|
55
65
|
}
|
|
56
66
|
}
|
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.
|