@logtape/logtape 0.5.0-dev.44 → 0.5.0-dev.58
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 +30 -4
- package/esm/_dnt.shims.js +1 -5
- package/esm/filesink.node.js +16 -11
- package/esm/formatter.js +12 -6
- package/esm/fs.js +20 -0
- package/esm/logger.js +119 -7
- package/package.json +1 -1
- package/script/_dnt.shims.js +2 -7
- package/script/config.js +5 -5
- package/script/filesink.node.js +19 -14
- package/script/filter.js +2 -3
- package/script/formatter.js +37 -9
- package/script/fs.js +16 -0
- package/script/level.js +2 -3
- package/script/logger.js +124 -11
- package/script/sink.js +5 -6
- package/types/_dnt.shims.d.ts +1 -9
- package/types/_dnt.shims.d.ts.map +1 -1
- package/types/_dnt.test_shims.d.ts.map +1 -1
- package/types/filesink.node.d.ts +1 -2
- package/types/filesink.node.d.ts.map +1 -1
- package/types/formatter.d.ts.map +1 -1
- package/types/fs.d.ts +2 -0
- package/types/fs.d.ts.map +1 -0
- package/types/logger.d.ts +51 -1
- package/types/logger.d.ts.map +1 -1
- package/types/sink.d.ts +1 -5
- package/types/sink.d.ts.map +1 -1
package/README.md
CHANGED
|
@@ -8,10 +8,6 @@ LogTape
|
|
|
8
8
|
[![GitHub Actions][GitHub Actions badge]][GitHub Actions]
|
|
9
9
|
[![Codecov][Codecov badge]][Codecov]
|
|
10
10
|
|
|
11
|
-
> [!NOTE]
|
|
12
|
-
> LogTape is still in the early stage of development. The API is not stable
|
|
13
|
-
> yet. Please be careful when using it in production.
|
|
14
|
-
|
|
15
11
|
LogTape is a logging library for JavaScript and TypeScript. It provides a
|
|
16
12
|
simple and flexible logging system that is easy to use and easy to extend.
|
|
17
13
|
The highlights of LogTape are:
|
|
@@ -186,6 +182,36 @@ await configure({
|
|
|
186
182
|
~~~~
|
|
187
183
|
|
|
188
184
|
|
|
185
|
+
Contexts
|
|
186
|
+
--------
|
|
187
|
+
|
|
188
|
+
**Contexts are available since LogTape 0.5.0.**
|
|
189
|
+
|
|
190
|
+
LogTape provides a context system to reuse the same properties across log
|
|
191
|
+
messages. A context is a key-value map. You can set a context for a logger
|
|
192
|
+
and log messages with the context. Here's an example of setting a context
|
|
193
|
+
for a logger:
|
|
194
|
+
|
|
195
|
+
~~~~ typescript
|
|
196
|
+
const logger = getLogger(["my-app", "my-module"]);
|
|
197
|
+
const ctx = logger.with({ userId: 1234, requestId: "abc" });
|
|
198
|
+
ctx.info `This log message will have the context (userId & requestId).`;
|
|
199
|
+
ctx.warn("Context can be used inside message template: {userId}, {requestId}.");
|
|
200
|
+
~~~~
|
|
201
|
+
|
|
202
|
+
The context is inherited by child loggers. Here's an example of setting a
|
|
203
|
+
context for a parent logger and logging messages with a child logger:
|
|
204
|
+
|
|
205
|
+
~~~~ typescript
|
|
206
|
+
const logger = getLogger(["my-app"]);
|
|
207
|
+
const parentCtx = logger.with({ userId: 1234, requestId: "abc" });
|
|
208
|
+
const childCtx = parentCtx.getLogger(["my-module"]);
|
|
209
|
+
childCtx.debug("This log message will have the context: {userId} {requestId}.");
|
|
210
|
+
~~~~
|
|
211
|
+
|
|
212
|
+
Contexts are particularly useful when you want to do structured logging.
|
|
213
|
+
|
|
214
|
+
|
|
189
215
|
Sinks
|
|
190
216
|
-----
|
|
191
217
|
|
package/esm/_dnt.shims.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export { WritableStream } from "node:stream/web";
|
|
3
|
-
const dntGlobals = {
|
|
4
|
-
WritableStream,
|
|
5
|
-
};
|
|
1
|
+
const dntGlobals = {};
|
|
6
2
|
export const dntGlobalThis = createMergeProxy(globalThis, dntGlobals);
|
|
7
3
|
function createMergeProxy(baseObj, extObj) {
|
|
8
4
|
return new Proxy(baseObj, {
|
package/esm/filesink.node.js
CHANGED
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
import * as dntShim from "./_dnt.shims.js";
|
|
2
|
-
|
|
2
|
+
// @ts-ignore: a trick to avoid module resolution error on non-Node.js environ
|
|
3
|
+
import fsMod from "./fs.js";
|
|
3
4
|
import { webDriver } from "./filesink.web.js";
|
|
4
5
|
import { getFileSink as getBaseFileSink, getRotatingFileSink as getBaseRotatingFileSink, } from "./sink.js";
|
|
6
|
+
// @ts-ignore: a trick to avoid module resolution error on non-Node.js environ
|
|
7
|
+
const fs = fsMod;
|
|
5
8
|
/**
|
|
6
9
|
* A Node.js-specific file sink driver.
|
|
7
10
|
*/
|
|
8
|
-
export const nodeDriver =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
export const nodeDriver = fs == null
|
|
12
|
+
? webDriver
|
|
13
|
+
: {
|
|
14
|
+
openSync(path) {
|
|
15
|
+
return fs.openSync(path, "a");
|
|
16
|
+
},
|
|
17
|
+
writeSync: fs.writeSync,
|
|
18
|
+
flushSync: fs.fsyncSync,
|
|
19
|
+
closeSync: fs.closeSync,
|
|
20
|
+
statSync: fs.statSync,
|
|
21
|
+
renameSync: fs.renameSync,
|
|
22
|
+
};
|
|
18
23
|
/**
|
|
19
24
|
* Get a file sink.
|
|
20
25
|
*
|
package/esm/formatter.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as dntShim from "./_dnt.shims.js";
|
|
1
2
|
/**
|
|
2
3
|
* The severity level abbreviations.
|
|
3
4
|
*/
|
|
@@ -16,15 +17,20 @@ const levelAbbreviations = {
|
|
|
16
17
|
* @param value The value to inspect.
|
|
17
18
|
* @returns The string representation of the value.
|
|
18
19
|
*/
|
|
19
|
-
const inspect =
|
|
20
|
-
|
|
20
|
+
const inspect =
|
|
21
|
+
// @ts-ignore: Deno global
|
|
22
|
+
"Deno" in dntShim.dntGlobalThis && "inspect" in globalThis.Deno &&
|
|
23
|
+
// @ts-ignore: Deno global
|
|
21
24
|
typeof globalThis.Deno.inspect === "function"
|
|
25
|
+
// @ts-ignore: Deno global
|
|
22
26
|
? globalThis.Deno.inspect
|
|
23
|
-
:
|
|
27
|
+
// @ts-ignore: Node.js global
|
|
28
|
+
: "util" in dntShim.dntGlobalThis && "inspect" in globalThis.util &&
|
|
29
|
+
// @ts-ignore: Node.js global
|
|
24
30
|
globalThis.util.inspect === "function"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
// @ts-ignore: Node.js global
|
|
32
|
+
? globalThis.util.inspect
|
|
33
|
+
: JSON.stringify;
|
|
28
34
|
/**
|
|
29
35
|
* The default text formatter. This formatter formats log records as follows:
|
|
30
36
|
*
|
package/esm/fs.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
let fs = null;
|
|
2
|
+
if (
|
|
3
|
+
"process" in globalThis && "versions" in globalThis.process &&
|
|
4
|
+
"node" in globalThis.process.versions &&
|
|
5
|
+
typeof globalThis.caches === "undefined" &&
|
|
6
|
+
typeof globalThis.addEventListener !== "function" ||
|
|
7
|
+
"Bun" in globalThis
|
|
8
|
+
) {
|
|
9
|
+
try {
|
|
10
|
+
fs = await import("node" + ":fs");
|
|
11
|
+
} catch (e) {
|
|
12
|
+
if (e instanceof TypeError) {
|
|
13
|
+
fs = null;
|
|
14
|
+
} else {
|
|
15
|
+
throw e;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default fs;
|
package/esm/logger.js
CHANGED
|
@@ -77,10 +77,15 @@ export class LoggerImpl {
|
|
|
77
77
|
}
|
|
78
78
|
getChild(subcategory) {
|
|
79
79
|
const name = typeof subcategory === "string" ? subcategory : subcategory[0];
|
|
80
|
-
|
|
80
|
+
const childRef = this.children[name];
|
|
81
|
+
let child = childRef instanceof LoggerImpl
|
|
82
|
+
? childRef
|
|
83
|
+
: childRef?.deref();
|
|
81
84
|
if (child == null) {
|
|
82
85
|
child = new LoggerImpl(this, [...this.category, name]);
|
|
83
|
-
this.children[name] =
|
|
86
|
+
this.children[name] = "WeakRef" in dntShim.dntGlobalThis
|
|
87
|
+
? new WeakRef(child)
|
|
88
|
+
: child;
|
|
84
89
|
}
|
|
85
90
|
if (typeof subcategory === "string" || subcategory.length === 1) {
|
|
86
91
|
return child;
|
|
@@ -102,12 +107,15 @@ export class LoggerImpl {
|
|
|
102
107
|
*/
|
|
103
108
|
resetDescendants() {
|
|
104
109
|
for (const child of Object.values(this.children)) {
|
|
105
|
-
const logger = child.deref();
|
|
110
|
+
const logger = child instanceof LoggerImpl ? child : child.deref();
|
|
106
111
|
if (logger != null)
|
|
107
112
|
logger.resetDescendants();
|
|
108
113
|
}
|
|
109
114
|
this.reset();
|
|
110
115
|
}
|
|
116
|
+
with(properties) {
|
|
117
|
+
return new LoggerCtx(this, { ...properties });
|
|
118
|
+
}
|
|
111
119
|
filter(record) {
|
|
112
120
|
for (const filter of this.filters) {
|
|
113
121
|
if (!filter(record))
|
|
@@ -166,7 +174,7 @@ export class LoggerImpl {
|
|
|
166
174
|
};
|
|
167
175
|
this.emit(record, bypassSinks);
|
|
168
176
|
}
|
|
169
|
-
logLazily(level, callback) {
|
|
177
|
+
logLazily(level, callback, properties = {}) {
|
|
170
178
|
let msg = undefined;
|
|
171
179
|
this.emit({
|
|
172
180
|
category: this.category,
|
|
@@ -178,16 +186,16 @@ export class LoggerImpl {
|
|
|
178
186
|
return msg;
|
|
179
187
|
},
|
|
180
188
|
timestamp: Date.now(),
|
|
181
|
-
properties
|
|
189
|
+
properties,
|
|
182
190
|
});
|
|
183
191
|
}
|
|
184
|
-
logTemplate(level, messageTemplate, values) {
|
|
192
|
+
logTemplate(level, messageTemplate, values, properties = {}) {
|
|
185
193
|
this.emit({
|
|
186
194
|
category: this.category,
|
|
187
195
|
level,
|
|
188
196
|
message: renderMessage(messageTemplate, values),
|
|
189
197
|
timestamp: Date.now(),
|
|
190
|
-
properties
|
|
198
|
+
properties,
|
|
191
199
|
});
|
|
192
200
|
}
|
|
193
201
|
debug(message, ...values) {
|
|
@@ -246,6 +254,110 @@ export class LoggerImpl {
|
|
|
246
254
|
}
|
|
247
255
|
}
|
|
248
256
|
}
|
|
257
|
+
/**
|
|
258
|
+
* A logger implementation with contextual properties. Do not use this
|
|
259
|
+
* directly; use {@link Logger.with} instead. This class is exported
|
|
260
|
+
* for testing purposes.
|
|
261
|
+
*/
|
|
262
|
+
export class LoggerCtx {
|
|
263
|
+
constructor(logger, properties) {
|
|
264
|
+
Object.defineProperty(this, "logger", {
|
|
265
|
+
enumerable: true,
|
|
266
|
+
configurable: true,
|
|
267
|
+
writable: true,
|
|
268
|
+
value: void 0
|
|
269
|
+
});
|
|
270
|
+
Object.defineProperty(this, "properties", {
|
|
271
|
+
enumerable: true,
|
|
272
|
+
configurable: true,
|
|
273
|
+
writable: true,
|
|
274
|
+
value: void 0
|
|
275
|
+
});
|
|
276
|
+
this.logger = logger;
|
|
277
|
+
this.properties = properties;
|
|
278
|
+
}
|
|
279
|
+
get category() {
|
|
280
|
+
return this.logger.category;
|
|
281
|
+
}
|
|
282
|
+
get parent() {
|
|
283
|
+
return this.logger.parent;
|
|
284
|
+
}
|
|
285
|
+
getChild(subcategory) {
|
|
286
|
+
return this.logger.getChild(subcategory).with(this.properties);
|
|
287
|
+
}
|
|
288
|
+
with(properties) {
|
|
289
|
+
return new LoggerCtx(this.logger, { ...this.properties, ...properties });
|
|
290
|
+
}
|
|
291
|
+
log(level, message, properties, bypassSinks) {
|
|
292
|
+
this.logger.log(level, message, typeof properties === "function"
|
|
293
|
+
? () => ({
|
|
294
|
+
...this.properties,
|
|
295
|
+
...properties(),
|
|
296
|
+
})
|
|
297
|
+
: { ...this.properties, ...properties }, bypassSinks);
|
|
298
|
+
}
|
|
299
|
+
logLazily(level, callback) {
|
|
300
|
+
this.logger.logLazily(level, callback, this.properties);
|
|
301
|
+
}
|
|
302
|
+
logTemplate(level, messageTemplate, values) {
|
|
303
|
+
this.logger.logTemplate(level, messageTemplate, values, this.properties);
|
|
304
|
+
}
|
|
305
|
+
debug(message, ...values) {
|
|
306
|
+
if (typeof message === "string") {
|
|
307
|
+
this.log("debug", message, (values[0] ?? {}));
|
|
308
|
+
}
|
|
309
|
+
else if (typeof message === "function") {
|
|
310
|
+
this.logLazily("debug", message);
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
this.logTemplate("debug", message, values);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
info(message, ...values) {
|
|
317
|
+
if (typeof message === "string") {
|
|
318
|
+
this.log("info", message, (values[0] ?? {}));
|
|
319
|
+
}
|
|
320
|
+
else if (typeof message === "function") {
|
|
321
|
+
this.logLazily("info", message);
|
|
322
|
+
}
|
|
323
|
+
else {
|
|
324
|
+
this.logTemplate("info", message, values);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
warn(message, ...values) {
|
|
328
|
+
if (typeof message === "string") {
|
|
329
|
+
this.log("warning", message, (values[0] ?? {}));
|
|
330
|
+
}
|
|
331
|
+
else if (typeof message === "function") {
|
|
332
|
+
this.logLazily("warning", message);
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
335
|
+
this.logTemplate("warning", message, values);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
error(message, ...values) {
|
|
339
|
+
if (typeof message === "string") {
|
|
340
|
+
this.log("error", message, (values[0] ?? {}));
|
|
341
|
+
}
|
|
342
|
+
else if (typeof message === "function") {
|
|
343
|
+
this.logLazily("error", message);
|
|
344
|
+
}
|
|
345
|
+
else {
|
|
346
|
+
this.logTemplate("error", message, values);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
fatal(message, ...values) {
|
|
350
|
+
if (typeof message === "string") {
|
|
351
|
+
this.log("fatal", message, (values[0] ?? {}));
|
|
352
|
+
}
|
|
353
|
+
else if (typeof message === "function") {
|
|
354
|
+
this.logLazily("fatal", message);
|
|
355
|
+
}
|
|
356
|
+
else {
|
|
357
|
+
this.logTemplate("fatal", message, values);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
249
361
|
/**
|
|
250
362
|
* The meta logger. It is a logger with the category `["logtape", "meta"]`.
|
|
251
363
|
*/
|
package/package.json
CHANGED
package/script/_dnt.shims.js
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.dntGlobalThis =
|
|
4
|
-
const
|
|
5
|
-
var web_2 = require("node:stream/web");
|
|
6
|
-
Object.defineProperty(exports, "WritableStream", { enumerable: true, get: function () { return web_2.WritableStream; } });
|
|
7
|
-
const dntGlobals = {
|
|
8
|
-
WritableStream: web_1.WritableStream,
|
|
9
|
-
};
|
|
3
|
+
exports.dntGlobalThis = void 0;
|
|
4
|
+
const dntGlobals = {};
|
|
10
5
|
exports.dntGlobalThis = createMergeProxy(globalThis, dntGlobals);
|
|
11
6
|
function createMergeProxy(baseObj, extObj) {
|
|
12
7
|
return new Proxy(baseObj, {
|
package/script/config.js
CHANGED
|
@@ -23,7 +23,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.ConfigError =
|
|
26
|
+
exports.ConfigError = void 0;
|
|
27
|
+
exports.configure = configure;
|
|
28
|
+
exports.getConfig = getConfig;
|
|
29
|
+
exports.reset = reset;
|
|
30
|
+
exports.dispose = dispose;
|
|
27
31
|
const dntShim = __importStar(require("./_dnt.shims.js"));
|
|
28
32
|
const filter_js_1 = require("./filter.js");
|
|
29
33
|
const logger_js_1 = require("./logger.js");
|
|
@@ -156,7 +160,6 @@ async function configure(config) {
|
|
|
156
160
|
"misconfigured. To turn off this message, configure the meta logger " +
|
|
157
161
|
"with higher log levels than {dismissLevel}.", { metaLoggerCategory: ["logtape", "meta"], dismissLevel: "info" });
|
|
158
162
|
}
|
|
159
|
-
exports.configure = configure;
|
|
160
163
|
/**
|
|
161
164
|
* Get the current configuration, if any. Otherwise, `null`.
|
|
162
165
|
* @returns The current configuration, if any. Otherwise, `null`.
|
|
@@ -164,7 +167,6 @@ exports.configure = configure;
|
|
|
164
167
|
function getConfig() {
|
|
165
168
|
return currentConfig;
|
|
166
169
|
}
|
|
167
|
-
exports.getConfig = getConfig;
|
|
168
170
|
/**
|
|
169
171
|
* Reset the configuration. Mostly for testing purposes.
|
|
170
172
|
*/
|
|
@@ -174,7 +176,6 @@ async function reset() {
|
|
|
174
176
|
strongRefs.clear();
|
|
175
177
|
currentConfig = null;
|
|
176
178
|
}
|
|
177
|
-
exports.reset = reset;
|
|
178
179
|
/**
|
|
179
180
|
* Dispose of the disposables.
|
|
180
181
|
*/
|
|
@@ -189,7 +190,6 @@ async function dispose() {
|
|
|
189
190
|
}
|
|
190
191
|
await Promise.all(promises);
|
|
191
192
|
}
|
|
192
|
-
exports.dispose = dispose;
|
|
193
193
|
/**
|
|
194
194
|
* A configuration error.
|
|
195
195
|
*/
|
package/script/filesink.node.js
CHANGED
|
@@ -26,24 +26,31 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
29
|
+
exports.nodeDriver = void 0;
|
|
30
|
+
exports.getFileSink = getFileSink;
|
|
31
|
+
exports.getRotatingFileSink = getRotatingFileSink;
|
|
30
32
|
const dntShim = __importStar(require("./_dnt.shims.js"));
|
|
31
|
-
|
|
33
|
+
// @ts-ignore: a trick to avoid module resolution error on non-Node.js environ
|
|
34
|
+
const fs_js_1 = __importDefault(require("./fs.js"));
|
|
32
35
|
const filesink_web_js_1 = require("./filesink.web.js");
|
|
33
36
|
const sink_js_1 = require("./sink.js");
|
|
37
|
+
// @ts-ignore: a trick to avoid module resolution error on non-Node.js environ
|
|
38
|
+
const fs = fs_js_1.default;
|
|
34
39
|
/**
|
|
35
40
|
* A Node.js-specific file sink driver.
|
|
36
41
|
*/
|
|
37
|
-
exports.nodeDriver =
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
exports.nodeDriver = fs == null
|
|
43
|
+
? filesink_web_js_1.webDriver
|
|
44
|
+
: {
|
|
45
|
+
openSync(path) {
|
|
46
|
+
return fs.openSync(path, "a");
|
|
47
|
+
},
|
|
48
|
+
writeSync: fs.writeSync,
|
|
49
|
+
flushSync: fs.fsyncSync,
|
|
50
|
+
closeSync: fs.closeSync,
|
|
51
|
+
statSync: fs.statSync,
|
|
52
|
+
renameSync: fs.renameSync,
|
|
53
|
+
};
|
|
47
54
|
/**
|
|
48
55
|
* Get a file sink.
|
|
49
56
|
*
|
|
@@ -60,7 +67,6 @@ function getFileSink(path, options = {}) {
|
|
|
60
67
|
}
|
|
61
68
|
return (0, sink_js_1.getFileSink)(path, { ...options, ...exports.nodeDriver });
|
|
62
69
|
}
|
|
63
|
-
exports.getFileSink = getFileSink;
|
|
64
70
|
/**
|
|
65
71
|
* Get a rotating file sink.
|
|
66
72
|
*
|
|
@@ -82,5 +88,4 @@ function getRotatingFileSink(path, options = {}) {
|
|
|
82
88
|
}
|
|
83
89
|
return (0, sink_js_1.getRotatingFileSink)(path, { ...options, ...exports.nodeDriver });
|
|
84
90
|
}
|
|
85
|
-
exports.getRotatingFileSink = getRotatingFileSink;
|
|
86
91
|
// cSpell: ignore filesink
|
package/script/filter.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.toFilter = toFilter;
|
|
4
|
+
exports.getLevelFilter = getLevelFilter;
|
|
4
5
|
/**
|
|
5
6
|
* Converts a {@link FilterLike} value to an actual {@link Filter}.
|
|
6
7
|
*
|
|
@@ -12,7 +13,6 @@ function toFilter(filter) {
|
|
|
12
13
|
return filter;
|
|
13
14
|
return getLevelFilter(filter);
|
|
14
15
|
}
|
|
15
|
-
exports.toFilter = toFilter;
|
|
16
16
|
/**
|
|
17
17
|
* Returns a filter that accepts log records with the specified level.
|
|
18
18
|
*
|
|
@@ -44,4 +44,3 @@ function getLevelFilter(level) {
|
|
|
44
44
|
return () => true;
|
|
45
45
|
throw new TypeError(`Invalid log level: ${level}.`);
|
|
46
46
|
}
|
|
47
|
-
exports.getLevelFilter = getLevelFilter;
|
package/script/formatter.js
CHANGED
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
26
|
+
exports.defaultTextFormatter = defaultTextFormatter;
|
|
27
|
+
exports.defaultConsoleFormatter = defaultConsoleFormatter;
|
|
28
|
+
const dntShim = __importStar(require("./_dnt.shims.js"));
|
|
4
29
|
/**
|
|
5
30
|
* The severity level abbreviations.
|
|
6
31
|
*/
|
|
@@ -19,15 +44,20 @@ const levelAbbreviations = {
|
|
|
19
44
|
* @param value The value to inspect.
|
|
20
45
|
* @returns The string representation of the value.
|
|
21
46
|
*/
|
|
22
|
-
const inspect =
|
|
23
|
-
|
|
47
|
+
const inspect =
|
|
48
|
+
// @ts-ignore: Deno global
|
|
49
|
+
"Deno" in dntShim.dntGlobalThis && "inspect" in globalThis.Deno &&
|
|
50
|
+
// @ts-ignore: Deno global
|
|
24
51
|
typeof globalThis.Deno.inspect === "function"
|
|
52
|
+
// @ts-ignore: Deno global
|
|
25
53
|
? globalThis.Deno.inspect
|
|
26
|
-
:
|
|
54
|
+
// @ts-ignore: Node.js global
|
|
55
|
+
: "util" in dntShim.dntGlobalThis && "inspect" in globalThis.util &&
|
|
56
|
+
// @ts-ignore: Node.js global
|
|
27
57
|
globalThis.util.inspect === "function"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
58
|
+
// @ts-ignore: Node.js global
|
|
59
|
+
? globalThis.util.inspect
|
|
60
|
+
: JSON.stringify;
|
|
31
61
|
/**
|
|
32
62
|
* The default text formatter. This formatter formats log records as follows:
|
|
33
63
|
*
|
|
@@ -50,7 +80,6 @@ function defaultTextFormatter(record) {
|
|
|
50
80
|
const category = record.category.join("\xb7");
|
|
51
81
|
return `${ts.toISOString().replace("T", " ").replace("Z", " +00:00")} [${levelAbbreviations[record.level]}] ${category}: ${msg}\n`;
|
|
52
82
|
}
|
|
53
|
-
exports.defaultTextFormatter = defaultTextFormatter;
|
|
54
83
|
/**
|
|
55
84
|
* The styles for the log level in the console.
|
|
56
85
|
*/
|
|
@@ -91,4 +120,3 @@ function defaultConsoleFormatter(record) {
|
|
|
91
120
|
...values,
|
|
92
121
|
];
|
|
93
122
|
}
|
|
94
|
-
exports.defaultConsoleFormatter = defaultConsoleFormatter;
|
package/script/fs.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
let fs = null;
|
|
2
|
+
if (
|
|
3
|
+
"process" in globalThis && "versions" in globalThis.process &&
|
|
4
|
+
"node" in globalThis.process.versions &&
|
|
5
|
+
typeof globalThis.caches === "undefined" &&
|
|
6
|
+
typeof globalThis.addEventListener !== "function" ||
|
|
7
|
+
"Bun" in globalThis
|
|
8
|
+
) {
|
|
9
|
+
try {
|
|
10
|
+
fs = require("node" + ":fs");
|
|
11
|
+
} catch (_) {
|
|
12
|
+
fs = null;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
module.exports = fs;
|
package/script/level.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.parseLogLevel = parseLogLevel;
|
|
4
|
+
exports.isLogLevel = isLogLevel;
|
|
4
5
|
/**
|
|
5
6
|
* Parses a log level from a string.
|
|
6
7
|
*
|
|
@@ -21,7 +22,6 @@ function parseLogLevel(level) {
|
|
|
21
22
|
throw new TypeError(`Invalid log level: ${level}.`);
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
|
-
exports.parseLogLevel = parseLogLevel;
|
|
25
25
|
/**
|
|
26
26
|
* Checks if a string is a valid log level. This function can be used as
|
|
27
27
|
* as a type guard to narrow the type of a string to a {@link LogLevel}.
|
|
@@ -41,4 +41,3 @@ function isLogLevel(level) {
|
|
|
41
41
|
return false;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
exports.isLogLevel = isLogLevel;
|
package/script/logger.js
CHANGED
|
@@ -23,7 +23,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.LoggerCtx = exports.LoggerImpl = void 0;
|
|
27
|
+
exports.getLogger = getLogger;
|
|
28
|
+
exports.parseMessageTemplate = parseMessageTemplate;
|
|
29
|
+
exports.renderMessage = renderMessage;
|
|
27
30
|
const dntShim = __importStar(require("./_dnt.shims.js"));
|
|
28
31
|
/**
|
|
29
32
|
* Get a logger with the given category.
|
|
@@ -40,7 +43,6 @@ const dntShim = __importStar(require("./_dnt.shims.js"));
|
|
|
40
43
|
function getLogger(category = []) {
|
|
41
44
|
return LoggerImpl.getLogger(category);
|
|
42
45
|
}
|
|
43
|
-
exports.getLogger = getLogger;
|
|
44
46
|
/**
|
|
45
47
|
* The symbol for the global root logger.
|
|
46
48
|
*/
|
|
@@ -104,10 +106,15 @@ class LoggerImpl {
|
|
|
104
106
|
}
|
|
105
107
|
getChild(subcategory) {
|
|
106
108
|
const name = typeof subcategory === "string" ? subcategory : subcategory[0];
|
|
107
|
-
|
|
109
|
+
const childRef = this.children[name];
|
|
110
|
+
let child = childRef instanceof LoggerImpl
|
|
111
|
+
? childRef
|
|
112
|
+
: childRef?.deref();
|
|
108
113
|
if (child == null) {
|
|
109
114
|
child = new LoggerImpl(this, [...this.category, name]);
|
|
110
|
-
this.children[name] =
|
|
115
|
+
this.children[name] = "WeakRef" in dntShim.dntGlobalThis
|
|
116
|
+
? new WeakRef(child)
|
|
117
|
+
: child;
|
|
111
118
|
}
|
|
112
119
|
if (typeof subcategory === "string" || subcategory.length === 1) {
|
|
113
120
|
return child;
|
|
@@ -129,12 +136,15 @@ class LoggerImpl {
|
|
|
129
136
|
*/
|
|
130
137
|
resetDescendants() {
|
|
131
138
|
for (const child of Object.values(this.children)) {
|
|
132
|
-
const logger = child.deref();
|
|
139
|
+
const logger = child instanceof LoggerImpl ? child : child.deref();
|
|
133
140
|
if (logger != null)
|
|
134
141
|
logger.resetDescendants();
|
|
135
142
|
}
|
|
136
143
|
this.reset();
|
|
137
144
|
}
|
|
145
|
+
with(properties) {
|
|
146
|
+
return new LoggerCtx(this, { ...properties });
|
|
147
|
+
}
|
|
138
148
|
filter(record) {
|
|
139
149
|
for (const filter of this.filters) {
|
|
140
150
|
if (!filter(record))
|
|
@@ -193,7 +203,7 @@ class LoggerImpl {
|
|
|
193
203
|
};
|
|
194
204
|
this.emit(record, bypassSinks);
|
|
195
205
|
}
|
|
196
|
-
logLazily(level, callback) {
|
|
206
|
+
logLazily(level, callback, properties = {}) {
|
|
197
207
|
let msg = undefined;
|
|
198
208
|
this.emit({
|
|
199
209
|
category: this.category,
|
|
@@ -205,16 +215,16 @@ class LoggerImpl {
|
|
|
205
215
|
return msg;
|
|
206
216
|
},
|
|
207
217
|
timestamp: Date.now(),
|
|
208
|
-
properties
|
|
218
|
+
properties,
|
|
209
219
|
});
|
|
210
220
|
}
|
|
211
|
-
logTemplate(level, messageTemplate, values) {
|
|
221
|
+
logTemplate(level, messageTemplate, values, properties = {}) {
|
|
212
222
|
this.emit({
|
|
213
223
|
category: this.category,
|
|
214
224
|
level,
|
|
215
225
|
message: renderMessage(messageTemplate, values),
|
|
216
226
|
timestamp: Date.now(),
|
|
217
|
-
properties
|
|
227
|
+
properties,
|
|
218
228
|
});
|
|
219
229
|
}
|
|
220
230
|
debug(message, ...values) {
|
|
@@ -274,6 +284,111 @@ class LoggerImpl {
|
|
|
274
284
|
}
|
|
275
285
|
}
|
|
276
286
|
exports.LoggerImpl = LoggerImpl;
|
|
287
|
+
/**
|
|
288
|
+
* A logger implementation with contextual properties. Do not use this
|
|
289
|
+
* directly; use {@link Logger.with} instead. This class is exported
|
|
290
|
+
* for testing purposes.
|
|
291
|
+
*/
|
|
292
|
+
class LoggerCtx {
|
|
293
|
+
constructor(logger, properties) {
|
|
294
|
+
Object.defineProperty(this, "logger", {
|
|
295
|
+
enumerable: true,
|
|
296
|
+
configurable: true,
|
|
297
|
+
writable: true,
|
|
298
|
+
value: void 0
|
|
299
|
+
});
|
|
300
|
+
Object.defineProperty(this, "properties", {
|
|
301
|
+
enumerable: true,
|
|
302
|
+
configurable: true,
|
|
303
|
+
writable: true,
|
|
304
|
+
value: void 0
|
|
305
|
+
});
|
|
306
|
+
this.logger = logger;
|
|
307
|
+
this.properties = properties;
|
|
308
|
+
}
|
|
309
|
+
get category() {
|
|
310
|
+
return this.logger.category;
|
|
311
|
+
}
|
|
312
|
+
get parent() {
|
|
313
|
+
return this.logger.parent;
|
|
314
|
+
}
|
|
315
|
+
getChild(subcategory) {
|
|
316
|
+
return this.logger.getChild(subcategory).with(this.properties);
|
|
317
|
+
}
|
|
318
|
+
with(properties) {
|
|
319
|
+
return new LoggerCtx(this.logger, { ...this.properties, ...properties });
|
|
320
|
+
}
|
|
321
|
+
log(level, message, properties, bypassSinks) {
|
|
322
|
+
this.logger.log(level, message, typeof properties === "function"
|
|
323
|
+
? () => ({
|
|
324
|
+
...this.properties,
|
|
325
|
+
...properties(),
|
|
326
|
+
})
|
|
327
|
+
: { ...this.properties, ...properties }, bypassSinks);
|
|
328
|
+
}
|
|
329
|
+
logLazily(level, callback) {
|
|
330
|
+
this.logger.logLazily(level, callback, this.properties);
|
|
331
|
+
}
|
|
332
|
+
logTemplate(level, messageTemplate, values) {
|
|
333
|
+
this.logger.logTemplate(level, messageTemplate, values, this.properties);
|
|
334
|
+
}
|
|
335
|
+
debug(message, ...values) {
|
|
336
|
+
if (typeof message === "string") {
|
|
337
|
+
this.log("debug", message, (values[0] ?? {}));
|
|
338
|
+
}
|
|
339
|
+
else if (typeof message === "function") {
|
|
340
|
+
this.logLazily("debug", message);
|
|
341
|
+
}
|
|
342
|
+
else {
|
|
343
|
+
this.logTemplate("debug", message, values);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
info(message, ...values) {
|
|
347
|
+
if (typeof message === "string") {
|
|
348
|
+
this.log("info", message, (values[0] ?? {}));
|
|
349
|
+
}
|
|
350
|
+
else if (typeof message === "function") {
|
|
351
|
+
this.logLazily("info", message);
|
|
352
|
+
}
|
|
353
|
+
else {
|
|
354
|
+
this.logTemplate("info", message, values);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
warn(message, ...values) {
|
|
358
|
+
if (typeof message === "string") {
|
|
359
|
+
this.log("warning", message, (values[0] ?? {}));
|
|
360
|
+
}
|
|
361
|
+
else if (typeof message === "function") {
|
|
362
|
+
this.logLazily("warning", message);
|
|
363
|
+
}
|
|
364
|
+
else {
|
|
365
|
+
this.logTemplate("warning", message, values);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
error(message, ...values) {
|
|
369
|
+
if (typeof message === "string") {
|
|
370
|
+
this.log("error", message, (values[0] ?? {}));
|
|
371
|
+
}
|
|
372
|
+
else if (typeof message === "function") {
|
|
373
|
+
this.logLazily("error", message);
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
376
|
+
this.logTemplate("error", message, values);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
fatal(message, ...values) {
|
|
380
|
+
if (typeof message === "string") {
|
|
381
|
+
this.log("fatal", message, (values[0] ?? {}));
|
|
382
|
+
}
|
|
383
|
+
else if (typeof message === "function") {
|
|
384
|
+
this.logLazily("fatal", message);
|
|
385
|
+
}
|
|
386
|
+
else {
|
|
387
|
+
this.logTemplate("fatal", message, values);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
exports.LoggerCtx = LoggerCtx;
|
|
277
392
|
/**
|
|
278
393
|
* The meta logger. It is a logger with the category `["logtape", "meta"]`.
|
|
279
394
|
*/
|
|
@@ -318,7 +433,6 @@ function parseMessageTemplate(template, properties) {
|
|
|
318
433
|
message.push(part);
|
|
319
434
|
return message;
|
|
320
435
|
}
|
|
321
|
-
exports.parseMessageTemplate = parseMessageTemplate;
|
|
322
436
|
/**
|
|
323
437
|
* Render a message template with values.
|
|
324
438
|
* @param template The message template.
|
|
@@ -335,4 +449,3 @@ function renderMessage(template, values) {
|
|
|
335
449
|
}
|
|
336
450
|
return args;
|
|
337
451
|
}
|
|
338
|
-
exports.renderMessage = renderMessage;
|
package/script/sink.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.withFilter = withFilter;
|
|
4
|
+
exports.getStreamSink = getStreamSink;
|
|
5
|
+
exports.getConsoleSink = getConsoleSink;
|
|
6
|
+
exports.getFileSink = getFileSink;
|
|
7
|
+
exports.getRotatingFileSink = getRotatingFileSink;
|
|
4
8
|
const filter_js_1 = require("./filter.js");
|
|
5
9
|
const formatter_js_1 = require("./formatter.js");
|
|
6
10
|
/**
|
|
@@ -24,7 +28,6 @@ function withFilter(sink, filter) {
|
|
|
24
28
|
sink(record);
|
|
25
29
|
};
|
|
26
30
|
}
|
|
27
|
-
exports.withFilter = withFilter;
|
|
28
31
|
/**
|
|
29
32
|
* A factory that returns a sink that writes to a {@link WritableStream}.
|
|
30
33
|
*
|
|
@@ -66,7 +69,6 @@ function getStreamSink(stream, options = {}) {
|
|
|
66
69
|
};
|
|
67
70
|
return sink;
|
|
68
71
|
}
|
|
69
|
-
exports.getStreamSink = getStreamSink;
|
|
70
72
|
/**
|
|
71
73
|
* A console sink factory that returns a sink that logs to the console.
|
|
72
74
|
*
|
|
@@ -91,7 +93,6 @@ function getConsoleSink(options = {}) {
|
|
|
91
93
|
throw new TypeError(`Invalid log level: ${record.level}.`);
|
|
92
94
|
};
|
|
93
95
|
}
|
|
94
|
-
exports.getConsoleSink = getConsoleSink;
|
|
95
96
|
/**
|
|
96
97
|
* Get a platform-independent file sink.
|
|
97
98
|
*
|
|
@@ -112,7 +113,6 @@ function getFileSink(path, options) {
|
|
|
112
113
|
sink[Symbol.dispose] = () => options.closeSync(fd);
|
|
113
114
|
return sink;
|
|
114
115
|
}
|
|
115
|
-
exports.getFileSink = getFileSink;
|
|
116
116
|
/**
|
|
117
117
|
* Get a platform-independent rotating file sink.
|
|
118
118
|
*
|
|
@@ -163,4 +163,3 @@ function getRotatingFileSink(path, options) {
|
|
|
163
163
|
sink[Symbol.dispose] = () => options.closeSync(fd);
|
|
164
164
|
return sink;
|
|
165
165
|
}
|
|
166
|
-
exports.getRotatingFileSink = getRotatingFileSink;
|
package/types/_dnt.shims.d.ts
CHANGED
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { WritableStream } from "node:stream/web";
|
|
3
|
-
export { WritableStream } from "node:stream/web";
|
|
4
|
-
export declare const dntGlobalThis: Omit<typeof globalThis, "WritableStream"> & {
|
|
5
|
-
WritableStream: {
|
|
6
|
-
new <W = any>(underlyingSink?: import("stream/web").UnderlyingSink<W> | undefined, strategy?: import("stream/web").QueuingStrategy<W> | undefined): WritableStream<W>;
|
|
7
|
-
prototype: WritableStream<any>;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
1
|
+
export declare const dntGlobalThis: Omit<typeof globalThis, never>;
|
|
10
2
|
//# sourceMappingURL=_dnt.shims.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_dnt.shims.d.ts","sourceRoot":"","sources":["../src/_dnt.shims.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"_dnt.shims.d.ts","sourceRoot":"","sources":["../src/_dnt.shims.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,gCAA2C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_dnt.test_shims.d.ts","sourceRoot":"","sources":["../src/_dnt.test_shims.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"_dnt.test_shims.d.ts","sourceRoot":"","sources":["../src/_dnt.test_shims.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAKvC,eAAO,MAAM,aAAa;;CAA2C,CAAC"}
|
package/types/filesink.node.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { type FileSinkOptions, type RotatingFileSinkDriver, type RotatingFileSinkOptions, type Sink } from "./sink.js";
|
|
3
2
|
/**
|
|
4
3
|
* A Node.js-specific file sink driver.
|
|
5
4
|
*/
|
|
6
|
-
export declare const nodeDriver: RotatingFileSinkDriver<number>;
|
|
5
|
+
export declare const nodeDriver: RotatingFileSinkDriver<number | void>;
|
|
7
6
|
/**
|
|
8
7
|
* Get a file sink.
|
|
9
8
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filesink.node.d.ts","sourceRoot":"","sources":["../src/filesink.node.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"filesink.node.d.ts","sourceRoot":"","sources":["../src/filesink.node.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,eAAe,EAGpB,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,IAAI,EACV,MAAM,WAAW,CAAC;AAKnB;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,sBAAsB,CAAC,MAAM,GAAG,IAAI,CAW1D,CAAC;AAEJ;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,eAAoB,GAC5B,IAAI,GAAG,UAAU,CAKnB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,uBAA4B,GACpC,IAAI,GAAG,UAAU,CAKnB"}
|
package/types/formatter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../src/formatter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../src/formatter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,SAAS,KAAK,MAAM,CAAC;AAoC1D;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAW9D;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,SAAS,KAAK,SAAS,OAAO,EAAE,CAAC;AAazE;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,OAAO,EAAE,CA2B7E"}
|
package/types/fs.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../src/fs.js"],"names":[],"mappings":""}
|
package/types/logger.d.ts
CHANGED
|
@@ -44,6 +44,33 @@ export interface Logger {
|
|
|
44
44
|
* @returns The child logger.
|
|
45
45
|
*/
|
|
46
46
|
getChild(subcategory: string | readonly [string] | readonly [string, ...string[]]): Logger;
|
|
47
|
+
/**
|
|
48
|
+
* Get a logger with contextual properties. This is useful for
|
|
49
|
+
* log multiple messages with the shared set of properties.
|
|
50
|
+
*
|
|
51
|
+
* ```typescript
|
|
52
|
+
* const logger = getLogger("category");
|
|
53
|
+
* const ctx = logger.with({ foo: 123, bar: "abc" });
|
|
54
|
+
* ctx.info("A message with {foo} and {bar}.");
|
|
55
|
+
* ctx.warn("Another message with {foo}, {bar}, and {baz}.", { baz: true });
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* The above code is equivalent to:
|
|
59
|
+
*
|
|
60
|
+
* ```typescript
|
|
61
|
+
* const logger = getLogger("category");
|
|
62
|
+
* logger.info("A message with {foo} and {bar}.", { foo: 123, bar: "abc" });
|
|
63
|
+
* logger.warn(
|
|
64
|
+
* "Another message with {foo}, {bar}, and {baz}.",
|
|
65
|
+
* { foo: 123, bar: "abc", baz: true },
|
|
66
|
+
* );
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @param properties
|
|
70
|
+
* @returns
|
|
71
|
+
* @since 0.5.0
|
|
72
|
+
*/
|
|
73
|
+
with(properties: Record<string, unknown>): Logger;
|
|
47
74
|
/**
|
|
48
75
|
* Log a debug message. Use this as a template string prefix.
|
|
49
76
|
*
|
|
@@ -318,7 +345,7 @@ export declare function getLogger(category?: string | readonly string[]): Logger
|
|
|
318
345
|
*/
|
|
319
346
|
export declare class LoggerImpl implements Logger {
|
|
320
347
|
readonly parent: LoggerImpl | null;
|
|
321
|
-
readonly children: Record<string, WeakRef<LoggerImpl>>;
|
|
348
|
+
readonly children: Record<string, LoggerImpl | WeakRef<LoggerImpl>>;
|
|
322
349
|
readonly category: readonly string[];
|
|
323
350
|
readonly sinks: Sink[];
|
|
324
351
|
readonly filters: Filter[];
|
|
@@ -334,10 +361,33 @@ export declare class LoggerImpl implements Logger {
|
|
|
334
361
|
* filters from the logger and all its descendants.
|
|
335
362
|
*/
|
|
336
363
|
resetDescendants(): void;
|
|
364
|
+
with(properties: Record<string, unknown>): Logger;
|
|
337
365
|
filter(record: LogRecord): boolean;
|
|
338
366
|
getSinks(): Iterable<Sink>;
|
|
339
367
|
emit(record: LogRecord, bypassSinks?: Set<Sink>): void;
|
|
340
368
|
log(level: LogLevel, message: string, properties: Record<string, unknown> | (() => Record<string, unknown>), bypassSinks?: Set<Sink>): void;
|
|
369
|
+
logLazily(level: LogLevel, callback: LogCallback, properties?: Record<string, unknown>): void;
|
|
370
|
+
logTemplate(level: LogLevel, messageTemplate: TemplateStringsArray, values: unknown[], properties?: Record<string, unknown>): void;
|
|
371
|
+
debug(message: TemplateStringsArray | string | LogCallback, ...values: unknown[]): void;
|
|
372
|
+
info(message: TemplateStringsArray | string | LogCallback, ...values: unknown[]): void;
|
|
373
|
+
warn(message: TemplateStringsArray | string | LogCallback, ...values: unknown[]): void;
|
|
374
|
+
error(message: TemplateStringsArray | string | LogCallback, ...values: unknown[]): void;
|
|
375
|
+
fatal(message: TemplateStringsArray | string | LogCallback, ...values: unknown[]): void;
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* A logger implementation with contextual properties. Do not use this
|
|
379
|
+
* directly; use {@link Logger.with} instead. This class is exported
|
|
380
|
+
* for testing purposes.
|
|
381
|
+
*/
|
|
382
|
+
export declare class LoggerCtx implements Logger {
|
|
383
|
+
logger: LoggerImpl;
|
|
384
|
+
properties: Record<string, unknown>;
|
|
385
|
+
constructor(logger: LoggerImpl, properties: Record<string, unknown>);
|
|
386
|
+
get category(): readonly string[];
|
|
387
|
+
get parent(): Logger | null;
|
|
388
|
+
getChild(subcategory: string | readonly [string] | readonly [string, ...string[]]): Logger;
|
|
389
|
+
with(properties: Record<string, unknown>): Logger;
|
|
390
|
+
log(level: LogLevel, message: string, properties: Record<string, unknown> | (() => Record<string, unknown>), bypassSinks?: Set<Sink>): void;
|
|
341
391
|
logLazily(level: LogLevel, callback: LogCallback): void;
|
|
342
392
|
logTemplate(level: LogLevel, messageTemplate: TemplateStringsArray, values: unknown[]): void;
|
|
343
393
|
debug(message: TemplateStringsArray | string | LogCallback, ...values: unknown[]): void;
|
package/types/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtC;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,MAAM;IACrB;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAA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
|
|
3
|
-
/// <reference types="node" />
|
|
4
|
-
import * as dntShim from "./_dnt.shims.js";
|
|
5
1
|
import { type FilterLike } from "./filter.js";
|
|
6
2
|
import { type ConsoleFormatter, type TextFormatter } from "./formatter.js";
|
|
7
3
|
import type { LogRecord } from "./record.js";
|
|
@@ -69,7 +65,7 @@ export interface StreamSinkOptions {
|
|
|
69
65
|
* @param options The options for the sink.
|
|
70
66
|
* @returns A sink that writes to the stream.
|
|
71
67
|
*/
|
|
72
|
-
export declare function getStreamSink(stream:
|
|
68
|
+
export declare function getStreamSink(stream: WritableStream, options?: StreamSinkOptions): Sink & AsyncDisposable;
|
|
73
69
|
/**
|
|
74
70
|
* Options for the {@link getConsoleSink} function.
|
|
75
71
|
*/
|
package/types/sink.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sink.d.ts","sourceRoot":"","sources":["../src/sink.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sink.d.ts","sourceRoot":"","sources":["../src/sink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAY,MAAM,aAAa,CAAC;AACxD,OAAO,EACL,KAAK,gBAAgB,EAGrB,KAAK,aAAa,EACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;;;;;;;GAQG;AACH,MAAM,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,SAAS,KAAK,IAAI,CAAC;AAE/C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CAK/D;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,SAAS,CAAC,EAAE,aAAa,CAAC;IAE1B;;OAEG;IACH,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAA;KAAE,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