@logtape/logtape 0.2.1 → 0.2.2
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 +2 -5
- package/esm/config.js +8 -0
- package/package.json +1 -1
- package/script/config.js +8 -0
- package/types/config.d.ts.map +1 -1
package/README.md
CHANGED
|
@@ -27,9 +27,7 @@ The highlights of LogTape are:
|
|
|
27
27
|
and browsers. You can use LogTape in various environments without
|
|
28
28
|
changing the code.
|
|
29
29
|
|
|
30
|
-
- *Structured logging*:
|
|
31
|
-
messages with structured data. LogTape provides a simple and flexible
|
|
32
|
-
way to log structured data.
|
|
30
|
+
- *Structured logging*: You can log messages with structured data.
|
|
33
31
|
|
|
34
32
|
- *Hierarchical categories*: LogTape uses a hierarchical category system
|
|
35
33
|
to manage loggers. You can control the verbosity of log messages by
|
|
@@ -40,8 +38,7 @@ The highlights of LogTape are:
|
|
|
40
38
|
You can use template literals to log messages with placeholders and
|
|
41
39
|
values.
|
|
42
40
|
|
|
43
|
-
- *Dead simple sinks*:
|
|
44
|
-
sinks. You can easily add your own sinks to LogTape.
|
|
41
|
+
- *Dead simple sinks*: You can easily add your own sinks to LogTape.
|
|
45
42
|
|
|
46
43
|
Currently, LogTape provides only few sinks, but [you can easily add your own
|
|
47
44
|
sinks.](#sinks)
|
package/esm/config.js
CHANGED
|
@@ -6,6 +6,12 @@ import { getConsoleSink } from "./sink.js";
|
|
|
6
6
|
* Whether the loggers are configured.
|
|
7
7
|
*/
|
|
8
8
|
let configured = false;
|
|
9
|
+
/**
|
|
10
|
+
* Strong references to the loggers.
|
|
11
|
+
* This is to prevent the loggers from being garbage collected so that their
|
|
12
|
+
* sinks and filters are not removed.
|
|
13
|
+
*/
|
|
14
|
+
const strongRefs = new Set();
|
|
9
15
|
/**
|
|
10
16
|
* Disposables to dispose when resetting the configuration.
|
|
11
17
|
*/
|
|
@@ -87,6 +93,7 @@ export async function configure(config) {
|
|
|
87
93
|
}
|
|
88
94
|
logger.filters.push(toFilter(filter));
|
|
89
95
|
}
|
|
96
|
+
strongRefs.add(logger);
|
|
90
97
|
}
|
|
91
98
|
for (const sink of Object.values(config.sinks)) {
|
|
92
99
|
if (Symbol.asyncDispose in sink) {
|
|
@@ -129,6 +136,7 @@ export async function configure(config) {
|
|
|
129
136
|
export async function reset() {
|
|
130
137
|
await dispose();
|
|
131
138
|
LoggerImpl.getLogger([]).resetDescendants();
|
|
139
|
+
strongRefs.clear();
|
|
132
140
|
configured = false;
|
|
133
141
|
}
|
|
134
142
|
/**
|
package/package.json
CHANGED
package/script/config.js
CHANGED
|
@@ -32,6 +32,12 @@ const sink_js_1 = require("./sink.js");
|
|
|
32
32
|
* Whether the loggers are configured.
|
|
33
33
|
*/
|
|
34
34
|
let configured = false;
|
|
35
|
+
/**
|
|
36
|
+
* Strong references to the loggers.
|
|
37
|
+
* This is to prevent the loggers from being garbage collected so that their
|
|
38
|
+
* sinks and filters are not removed.
|
|
39
|
+
*/
|
|
40
|
+
const strongRefs = new Set();
|
|
35
41
|
/**
|
|
36
42
|
* Disposables to dispose when resetting the configuration.
|
|
37
43
|
*/
|
|
@@ -113,6 +119,7 @@ async function configure(config) {
|
|
|
113
119
|
}
|
|
114
120
|
logger.filters.push((0, filter_js_1.toFilter)(filter));
|
|
115
121
|
}
|
|
122
|
+
strongRefs.add(logger);
|
|
116
123
|
}
|
|
117
124
|
for (const sink of Object.values(config.sinks)) {
|
|
118
125
|
if (Symbol.asyncDispose in sink) {
|
|
@@ -156,6 +163,7 @@ exports.configure = configure;
|
|
|
156
163
|
async function reset() {
|
|
157
164
|
await dispose();
|
|
158
165
|
logger_js_1.LoggerImpl.getLogger([]).resetDescendants();
|
|
166
|
+
strongRefs.clear();
|
|
159
167
|
configured = false;
|
|
160
168
|
}
|
|
161
169
|
exports.reset = reset;
|
package/types/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.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