@loglayer/log-level-manager 1.0.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 +21 -0
- package/README.md +18 -0
- package/dist/index.cjs +147 -0
- package/dist/index.d.cts +68 -0
- package/dist/index.d.ts +68 -0
- package/dist/index.js +104 -0
- package/package.json +61 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Theo Gravity
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# @loglayer/log-level-manager
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@loglayer/log-level-manager)
|
|
4
|
+
[](https://www.npmjs.com/package/@loglayer/log-level-manager)
|
|
5
|
+
[](http://www.typescriptlang.org/)
|
|
6
|
+
|
|
7
|
+
Provides TypeScript types and base implementation for [loglayer](https://loglayer.dev) log level managers.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm i @loglayer/log-level-manager
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Documentation
|
|
16
|
+
|
|
17
|
+
Visit the [loglayer log level manager docs](https://loglayer.dev/log-level-managers) on how to use and create log level managers.
|
|
18
|
+
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
let __loglayer_shared = require("@loglayer/shared");
|
|
25
|
+
__loglayer_shared = __toESM(__loglayer_shared);
|
|
26
|
+
|
|
27
|
+
//#region src/DefaultLogLevelManager.ts
|
|
28
|
+
/**
|
|
29
|
+
* The default log level manager used by LogLayer. Children inherit log level from parent,
|
|
30
|
+
* but changes from parent do not propagate down to existing children.
|
|
31
|
+
*
|
|
32
|
+
* @see {@link https://loglayer.dev/log-level-managers/default.html | Default Log Level Manager Docs}
|
|
33
|
+
*/
|
|
34
|
+
var DefaultLogLevelManager = class DefaultLogLevelManager {
|
|
35
|
+
logLevelEnabledStatus = {
|
|
36
|
+
info: true,
|
|
37
|
+
warn: true,
|
|
38
|
+
error: true,
|
|
39
|
+
debug: true,
|
|
40
|
+
trace: true,
|
|
41
|
+
fatal: true
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Sets the minimum log level to be used by the logger. Only messages with
|
|
45
|
+
* this level or higher severity will be logged.
|
|
46
|
+
*/
|
|
47
|
+
setLevel(logLevel) {
|
|
48
|
+
const minLogValue = __loglayer_shared.LogLevelPriority[logLevel];
|
|
49
|
+
for (const level of Object.values(__loglayer_shared.LogLevel)) {
|
|
50
|
+
const levelKey = level;
|
|
51
|
+
const levelValue = __loglayer_shared.LogLevelPriority[level];
|
|
52
|
+
this.logLevelEnabledStatus[levelKey] = levelValue >= minLogValue;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Enables a specific log level
|
|
57
|
+
*/
|
|
58
|
+
enableIndividualLevel(logLevel) {
|
|
59
|
+
const level = logLevel;
|
|
60
|
+
if (level in this.logLevelEnabledStatus) this.logLevelEnabledStatus[level] = true;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Disables a specific log level
|
|
64
|
+
*/
|
|
65
|
+
disableIndividualLevel(logLevel) {
|
|
66
|
+
const level = logLevel;
|
|
67
|
+
if (level in this.logLevelEnabledStatus) this.logLevelEnabledStatus[level] = false;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Checks if a specific log level is enabled
|
|
71
|
+
*/
|
|
72
|
+
isLevelEnabled(logLevel) {
|
|
73
|
+
const level = logLevel;
|
|
74
|
+
return this.logLevelEnabledStatus[level];
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Enable sending logs to the logging library.
|
|
78
|
+
*/
|
|
79
|
+
enableLogging() {
|
|
80
|
+
for (const level of Object.keys(this.logLevelEnabledStatus)) this.logLevelEnabledStatus[level] = true;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* All logging inputs are dropped and stops sending logs to the logging library.
|
|
84
|
+
*/
|
|
85
|
+
disableLogging() {
|
|
86
|
+
for (const level of Object.keys(this.logLevelEnabledStatus)) this.logLevelEnabledStatus[level] = false;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Copies the parent log level status to the child log level manager.
|
|
90
|
+
* Children inherit log level from parent, but changes from parent do not propagate down.
|
|
91
|
+
*/
|
|
92
|
+
onChildLoggerCreated({ parentLogLevelManager, childLogLevelManager }) {
|
|
93
|
+
const parentStatus = parentLogLevelManager.logLevelEnabledStatus;
|
|
94
|
+
if (childLogLevelManager instanceof DefaultLogLevelManager) childLogLevelManager.logLevelEnabledStatus = { ...parentStatus };
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Creates a new instance of the log level manager with the same log level settings.
|
|
98
|
+
*/
|
|
99
|
+
clone() {
|
|
100
|
+
const clone = new DefaultLogLevelManager();
|
|
101
|
+
clone.logLevelEnabledStatus = { ...this.logLevelEnabledStatus };
|
|
102
|
+
return clone;
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region src/MockLogLevelManager.ts
|
|
108
|
+
/**
|
|
109
|
+
* A mock log level manager for testing purposes.
|
|
110
|
+
* All log levels are enabled by default.
|
|
111
|
+
*/
|
|
112
|
+
var MockLogLevelManager = class MockLogLevelManager {
|
|
113
|
+
setLevel(_logLevel) {}
|
|
114
|
+
enableIndividualLevel(_logLevel) {}
|
|
115
|
+
disableIndividualLevel(_logLevel) {}
|
|
116
|
+
isLevelEnabled(_logLevel) {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
enableLogging() {}
|
|
120
|
+
disableLogging() {}
|
|
121
|
+
onChildLoggerCreated(_params) {}
|
|
122
|
+
clone() {
|
|
123
|
+
return new MockLogLevelManager();
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
//#endregion
|
|
128
|
+
exports.DefaultLogLevelManager = DefaultLogLevelManager;
|
|
129
|
+
Object.defineProperty(exports, 'LogLevel', {
|
|
130
|
+
enumerable: true,
|
|
131
|
+
get: function () {
|
|
132
|
+
return __loglayer_shared.LogLevel;
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
Object.defineProperty(exports, 'LogLevelPriority', {
|
|
136
|
+
enumerable: true,
|
|
137
|
+
get: function () {
|
|
138
|
+
return __loglayer_shared.LogLevelPriority;
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
Object.defineProperty(exports, 'LogLevelPriorityToNames', {
|
|
142
|
+
enumerable: true,
|
|
143
|
+
get: function () {
|
|
144
|
+
return __loglayer_shared.LogLevelPriorityToNames;
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
exports.MockLogLevelManager = MockLogLevelManager;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { ILogLayer, ILogLevelManager, ILogLevelManager as ILogLevelManager$1, LogLevel, LogLevelPriority, LogLevelPriorityToNames, LogLevelType, LogLevelType as LogLevelType$1, OnChildLogLevelManagerCreatedParams, OnChildLogLevelManagerCreatedParams as OnChildLogLevelManagerCreatedParams$1 } from "@loglayer/shared";
|
|
2
|
+
|
|
3
|
+
//#region src/DefaultLogLevelManager.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The default log level manager used by LogLayer. Children inherit log level from parent,
|
|
7
|
+
* but changes from parent do not propagate down to existing children.
|
|
8
|
+
*
|
|
9
|
+
* @see {@link https://loglayer.dev/log-level-managers/default.html | Default Log Level Manager Docs}
|
|
10
|
+
*/
|
|
11
|
+
declare class DefaultLogLevelManager implements ILogLevelManager$1 {
|
|
12
|
+
private logLevelEnabledStatus;
|
|
13
|
+
/**
|
|
14
|
+
* Sets the minimum log level to be used by the logger. Only messages with
|
|
15
|
+
* this level or higher severity will be logged.
|
|
16
|
+
*/
|
|
17
|
+
setLevel(logLevel: LogLevelType$1): void;
|
|
18
|
+
/**
|
|
19
|
+
* Enables a specific log level
|
|
20
|
+
*/
|
|
21
|
+
enableIndividualLevel(logLevel: LogLevelType$1): void;
|
|
22
|
+
/**
|
|
23
|
+
* Disables a specific log level
|
|
24
|
+
*/
|
|
25
|
+
disableIndividualLevel(logLevel: LogLevelType$1): void;
|
|
26
|
+
/**
|
|
27
|
+
* Checks if a specific log level is enabled
|
|
28
|
+
*/
|
|
29
|
+
isLevelEnabled(logLevel: LogLevelType$1): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Enable sending logs to the logging library.
|
|
32
|
+
*/
|
|
33
|
+
enableLogging(): void;
|
|
34
|
+
/**
|
|
35
|
+
* All logging inputs are dropped and stops sending logs to the logging library.
|
|
36
|
+
*/
|
|
37
|
+
disableLogging(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Copies the parent log level status to the child log level manager.
|
|
40
|
+
* Children inherit log level from parent, but changes from parent do not propagate down.
|
|
41
|
+
*/
|
|
42
|
+
onChildLoggerCreated({
|
|
43
|
+
parentLogLevelManager,
|
|
44
|
+
childLogLevelManager
|
|
45
|
+
}: OnChildLogLevelManagerCreatedParams$1): void;
|
|
46
|
+
/**
|
|
47
|
+
* Creates a new instance of the log level manager with the same log level settings.
|
|
48
|
+
*/
|
|
49
|
+
clone(): ILogLevelManager$1;
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/MockLogLevelManager.d.ts
|
|
53
|
+
/**
|
|
54
|
+
* A mock log level manager for testing purposes.
|
|
55
|
+
* All log levels are enabled by default.
|
|
56
|
+
*/
|
|
57
|
+
declare class MockLogLevelManager implements ILogLevelManager$1 {
|
|
58
|
+
setLevel(_logLevel: LogLevelType$1): void;
|
|
59
|
+
enableIndividualLevel(_logLevel: LogLevelType$1): void;
|
|
60
|
+
disableIndividualLevel(_logLevel: LogLevelType$1): void;
|
|
61
|
+
isLevelEnabled(_logLevel: LogLevelType$1): boolean;
|
|
62
|
+
enableLogging(): void;
|
|
63
|
+
disableLogging(): void;
|
|
64
|
+
onChildLoggerCreated(_params: OnChildLogLevelManagerCreatedParams$1): void;
|
|
65
|
+
clone(): ILogLevelManager$1;
|
|
66
|
+
}
|
|
67
|
+
//#endregion
|
|
68
|
+
export { DefaultLogLevelManager, type ILogLayer, type ILogLevelManager, LogLevel, LogLevelPriority, LogLevelPriorityToNames, type LogLevelType, MockLogLevelManager, type OnChildLogLevelManagerCreatedParams };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { ILogLayer, ILogLevelManager, ILogLevelManager as ILogLevelManager$1, LogLevel, LogLevelPriority, LogLevelPriorityToNames, LogLevelType, LogLevelType as LogLevelType$1, OnChildLogLevelManagerCreatedParams, OnChildLogLevelManagerCreatedParams as OnChildLogLevelManagerCreatedParams$1 } from "@loglayer/shared";
|
|
2
|
+
|
|
3
|
+
//#region src/DefaultLogLevelManager.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The default log level manager used by LogLayer. Children inherit log level from parent,
|
|
7
|
+
* but changes from parent do not propagate down to existing children.
|
|
8
|
+
*
|
|
9
|
+
* @see {@link https://loglayer.dev/log-level-managers/default.html | Default Log Level Manager Docs}
|
|
10
|
+
*/
|
|
11
|
+
declare class DefaultLogLevelManager implements ILogLevelManager$1 {
|
|
12
|
+
private logLevelEnabledStatus;
|
|
13
|
+
/**
|
|
14
|
+
* Sets the minimum log level to be used by the logger. Only messages with
|
|
15
|
+
* this level or higher severity will be logged.
|
|
16
|
+
*/
|
|
17
|
+
setLevel(logLevel: LogLevelType$1): void;
|
|
18
|
+
/**
|
|
19
|
+
* Enables a specific log level
|
|
20
|
+
*/
|
|
21
|
+
enableIndividualLevel(logLevel: LogLevelType$1): void;
|
|
22
|
+
/**
|
|
23
|
+
* Disables a specific log level
|
|
24
|
+
*/
|
|
25
|
+
disableIndividualLevel(logLevel: LogLevelType$1): void;
|
|
26
|
+
/**
|
|
27
|
+
* Checks if a specific log level is enabled
|
|
28
|
+
*/
|
|
29
|
+
isLevelEnabled(logLevel: LogLevelType$1): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Enable sending logs to the logging library.
|
|
32
|
+
*/
|
|
33
|
+
enableLogging(): void;
|
|
34
|
+
/**
|
|
35
|
+
* All logging inputs are dropped and stops sending logs to the logging library.
|
|
36
|
+
*/
|
|
37
|
+
disableLogging(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Copies the parent log level status to the child log level manager.
|
|
40
|
+
* Children inherit log level from parent, but changes from parent do not propagate down.
|
|
41
|
+
*/
|
|
42
|
+
onChildLoggerCreated({
|
|
43
|
+
parentLogLevelManager,
|
|
44
|
+
childLogLevelManager
|
|
45
|
+
}: OnChildLogLevelManagerCreatedParams$1): void;
|
|
46
|
+
/**
|
|
47
|
+
* Creates a new instance of the log level manager with the same log level settings.
|
|
48
|
+
*/
|
|
49
|
+
clone(): ILogLevelManager$1;
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/MockLogLevelManager.d.ts
|
|
53
|
+
/**
|
|
54
|
+
* A mock log level manager for testing purposes.
|
|
55
|
+
* All log levels are enabled by default.
|
|
56
|
+
*/
|
|
57
|
+
declare class MockLogLevelManager implements ILogLevelManager$1 {
|
|
58
|
+
setLevel(_logLevel: LogLevelType$1): void;
|
|
59
|
+
enableIndividualLevel(_logLevel: LogLevelType$1): void;
|
|
60
|
+
disableIndividualLevel(_logLevel: LogLevelType$1): void;
|
|
61
|
+
isLevelEnabled(_logLevel: LogLevelType$1): boolean;
|
|
62
|
+
enableLogging(): void;
|
|
63
|
+
disableLogging(): void;
|
|
64
|
+
onChildLoggerCreated(_params: OnChildLogLevelManagerCreatedParams$1): void;
|
|
65
|
+
clone(): ILogLevelManager$1;
|
|
66
|
+
}
|
|
67
|
+
//#endregion
|
|
68
|
+
export { DefaultLogLevelManager, type ILogLayer, type ILogLevelManager, LogLevel, LogLevelPriority, LogLevelPriorityToNames, type LogLevelType, MockLogLevelManager, type OnChildLogLevelManagerCreatedParams };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { LogLevel, LogLevel as LogLevel$1, LogLevelPriority, LogLevelPriority as LogLevelPriority$1, LogLevelPriorityToNames } from "@loglayer/shared";
|
|
2
|
+
|
|
3
|
+
//#region src/DefaultLogLevelManager.ts
|
|
4
|
+
/**
|
|
5
|
+
* The default log level manager used by LogLayer. Children inherit log level from parent,
|
|
6
|
+
* but changes from parent do not propagate down to existing children.
|
|
7
|
+
*
|
|
8
|
+
* @see {@link https://loglayer.dev/log-level-managers/default.html | Default Log Level Manager Docs}
|
|
9
|
+
*/
|
|
10
|
+
var DefaultLogLevelManager = class DefaultLogLevelManager {
|
|
11
|
+
logLevelEnabledStatus = {
|
|
12
|
+
info: true,
|
|
13
|
+
warn: true,
|
|
14
|
+
error: true,
|
|
15
|
+
debug: true,
|
|
16
|
+
trace: true,
|
|
17
|
+
fatal: true
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Sets the minimum log level to be used by the logger. Only messages with
|
|
21
|
+
* this level or higher severity will be logged.
|
|
22
|
+
*/
|
|
23
|
+
setLevel(logLevel) {
|
|
24
|
+
const minLogValue = LogLevelPriority$1[logLevel];
|
|
25
|
+
for (const level of Object.values(LogLevel$1)) {
|
|
26
|
+
const levelKey = level;
|
|
27
|
+
const levelValue = LogLevelPriority$1[level];
|
|
28
|
+
this.logLevelEnabledStatus[levelKey] = levelValue >= minLogValue;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Enables a specific log level
|
|
33
|
+
*/
|
|
34
|
+
enableIndividualLevel(logLevel) {
|
|
35
|
+
const level = logLevel;
|
|
36
|
+
if (level in this.logLevelEnabledStatus) this.logLevelEnabledStatus[level] = true;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Disables a specific log level
|
|
40
|
+
*/
|
|
41
|
+
disableIndividualLevel(logLevel) {
|
|
42
|
+
const level = logLevel;
|
|
43
|
+
if (level in this.logLevelEnabledStatus) this.logLevelEnabledStatus[level] = false;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Checks if a specific log level is enabled
|
|
47
|
+
*/
|
|
48
|
+
isLevelEnabled(logLevel) {
|
|
49
|
+
const level = logLevel;
|
|
50
|
+
return this.logLevelEnabledStatus[level];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Enable sending logs to the logging library.
|
|
54
|
+
*/
|
|
55
|
+
enableLogging() {
|
|
56
|
+
for (const level of Object.keys(this.logLevelEnabledStatus)) this.logLevelEnabledStatus[level] = true;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* All logging inputs are dropped and stops sending logs to the logging library.
|
|
60
|
+
*/
|
|
61
|
+
disableLogging() {
|
|
62
|
+
for (const level of Object.keys(this.logLevelEnabledStatus)) this.logLevelEnabledStatus[level] = false;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Copies the parent log level status to the child log level manager.
|
|
66
|
+
* Children inherit log level from parent, but changes from parent do not propagate down.
|
|
67
|
+
*/
|
|
68
|
+
onChildLoggerCreated({ parentLogLevelManager, childLogLevelManager }) {
|
|
69
|
+
const parentStatus = parentLogLevelManager.logLevelEnabledStatus;
|
|
70
|
+
if (childLogLevelManager instanceof DefaultLogLevelManager) childLogLevelManager.logLevelEnabledStatus = { ...parentStatus };
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Creates a new instance of the log level manager with the same log level settings.
|
|
74
|
+
*/
|
|
75
|
+
clone() {
|
|
76
|
+
const clone = new DefaultLogLevelManager();
|
|
77
|
+
clone.logLevelEnabledStatus = { ...this.logLevelEnabledStatus };
|
|
78
|
+
return clone;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src/MockLogLevelManager.ts
|
|
84
|
+
/**
|
|
85
|
+
* A mock log level manager for testing purposes.
|
|
86
|
+
* All log levels are enabled by default.
|
|
87
|
+
*/
|
|
88
|
+
var MockLogLevelManager = class MockLogLevelManager {
|
|
89
|
+
setLevel(_logLevel) {}
|
|
90
|
+
enableIndividualLevel(_logLevel) {}
|
|
91
|
+
disableIndividualLevel(_logLevel) {}
|
|
92
|
+
isLevelEnabled(_logLevel) {
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
enableLogging() {}
|
|
96
|
+
disableLogging() {}
|
|
97
|
+
onChildLoggerCreated(_params) {}
|
|
98
|
+
clone() {
|
|
99
|
+
return new MockLogLevelManager();
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
//#endregion
|
|
104
|
+
export { DefaultLogLevelManager, LogLevel, LogLevelPriority, LogLevelPriorityToNames, MockLogLevelManager };
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@loglayer/log-level-manager",
|
|
3
|
+
"description": "Base log level manager used to implement log level managers for loglayer.",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
"import": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"require": {
|
|
14
|
+
"types": "./dist/index.d.cts",
|
|
15
|
+
"require": "./dist/index.cjs"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "https://github.com/loglayer/loglayer.git",
|
|
23
|
+
"directory": "packages/core/log-level-manager"
|
|
24
|
+
},
|
|
25
|
+
"author": "Theo Gravity <theo@suteki.nu>",
|
|
26
|
+
"keywords": [
|
|
27
|
+
"logging",
|
|
28
|
+
"log",
|
|
29
|
+
"loglayer",
|
|
30
|
+
"log level manager",
|
|
31
|
+
"log level",
|
|
32
|
+
"manager"
|
|
33
|
+
],
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@loglayer/shared": "3.0.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"serialize-error": "12.0.0",
|
|
39
|
+
"tsdown": "0.15.12",
|
|
40
|
+
"typescript": "5.9.3",
|
|
41
|
+
"vitest": "4.0.9",
|
|
42
|
+
"@internal/tsconfig": "2.1.0"
|
|
43
|
+
},
|
|
44
|
+
"bugs": "https://github.com/loglayer/loglayer/issues",
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=18"
|
|
47
|
+
},
|
|
48
|
+
"files": [
|
|
49
|
+
"dist"
|
|
50
|
+
],
|
|
51
|
+
"homepage": "https://loglayer.dev",
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "tsdown src/index.ts",
|
|
54
|
+
"test": "vitest --run",
|
|
55
|
+
"test:debug": "vitest --debug",
|
|
56
|
+
"clean": "rm -rf .turbo node_modules dist",
|
|
57
|
+
"lint": "biome check --no-errors-on-unmatched --write --unsafe src",
|
|
58
|
+
"lint:staged": "biome check --no-errors-on-unmatched --write --unsafe --staged src",
|
|
59
|
+
"verify-types": "tsc --noEmit"
|
|
60
|
+
}
|
|
61
|
+
}
|