loglevel-mixin 7.1.0 → 7.2.1

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 CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2015-2023 by Markus Felten
1
+ Copyright (c) 2015-2024 by Markus Felten
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without
package/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  [![npm](https://img.shields.io/npm/v/loglevel-mixin.svg)](https://www.npmjs.com/package/loglevel-mixin)
2
2
  [![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
3
+ [![Typed with TypeScript](https://flat.badgen.net/badge/icon/Typed?icon=typescript\&label\&labelColor=blue\&color=555555)](https://typescriptlang.org)
3
4
  [![bundlejs](https://deno.bundlejs.com/?q=loglevel-mixin\&badge=detailed)](https://bundlejs.com/?q=loglevel-mixin)
4
5
  [![downloads](http://img.shields.io/npm/dm/loglevel-mixin.svg?style=flat-square)](https://npmjs.org/package/loglevel-mixin)
5
6
  [![GitHub Issues](https://img.shields.io/github/issues/arlac77/loglevel-mixin.svg?style=flat-square)](https://github.com/arlac77/loglevel-mixin/issues)
package/package.json CHANGED
@@ -1,11 +1,16 @@
1
1
  {
2
2
  "name": "loglevel-mixin",
3
- "version": "7.1.0",
3
+ "version": "7.2.1",
4
4
  "publishConfig": {
5
- "access": "public"
5
+ "access": "public",
6
+ "provenance": true
6
7
  },
8
+ "types": "./types/loglevel-mixin.d.mts",
7
9
  "exports": {
8
- ".": "./src/loglevel-mixin.mjs"
10
+ ".": {
11
+ "types": "./types/loglevel-mixin.d.mts",
12
+ "default": "./src/loglevel-mixin.mjs"
13
+ }
9
14
  },
10
15
  "description": "mixin to declare logging methods named after a set of log levels",
11
16
  "keywords": [
@@ -20,27 +25,30 @@
20
25
  ],
21
26
  "license": "BSD-2-Clause",
22
27
  "scripts": {
28
+ "prepare": "tsc --allowJs --declaration --emitDeclarationOnly --declarationDir types -t esnext -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs",
23
29
  "test": "npm run test:browser-ava && npm run test:ava",
24
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
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": "^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"
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": ">=16.20.2"
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-esm-only"
61
+ "arlac77/template-javascript-component",
62
+ "arlac77/template-node-component",
63
+ "arlac77/template-typescript"
54
64
  ]
55
65
  }
56
66
  }
@@ -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
+ };