@logtape/logtape 0.1.0-dev.14 → 0.1.0-dev.16
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 +64 -17
- package/esm/config.js +35 -1
- package/esm/mod.js +3 -3
- package/esm/sink.js +6 -3
- package/package.json +1 -1
- package/script/config.js +60 -2
- package/script/mod.js +5 -1
- package/script/sink.js +6 -3
- package/types/config.d.ts +7 -0
- package/types/config.d.ts.map +1 -1
- package/types/mod.d.ts +3 -3
- package/types/mod.d.ts.map +1 -1
- package/types/sink.d.ts +5 -5
- package/types/sink.d.ts.map +1 -1
package/README.md
CHANGED
|
@@ -301,43 +301,90 @@ See also [`getFileSink()`] function, [`FileSinkOptions`] interface, and
|
|
|
301
301
|
[`FileSinkOptions`]: https://jsr.io/@logtape/logtape/doc/~/FileSinkOptions
|
|
302
302
|
[`FileSinkDriver`]: https://jsr.io/@logtape/logtape/doc/~/FileSinkDriver
|
|
303
303
|
|
|
304
|
-
###
|
|
304
|
+
### Text formatter
|
|
305
305
|
|
|
306
|
-
|
|
307
|
-
|
|
306
|
+
A stream sink and a file sink write log messages in a plain text format.
|
|
307
|
+
You can customize the format by providing a text formatter. The type of a
|
|
308
|
+
text formatter is:
|
|
308
309
|
|
|
309
310
|
~~~~ typescript
|
|
310
|
-
|
|
311
|
+
export type TextFormatter = (record: LogRecord) => string;
|
|
312
|
+
~~~~
|
|
311
313
|
|
|
312
|
-
|
|
314
|
+
Here's an example of a text formatter that writes log messages in a JSON format:
|
|
313
315
|
|
|
316
|
+
~~~~ typescript
|
|
314
317
|
configure({
|
|
315
318
|
sinks: {
|
|
316
|
-
|
|
319
|
+
stream: getStreamSink(Deno.stderr.writable, {
|
|
320
|
+
formatter: JSON.stringify,
|
|
321
|
+
}),
|
|
317
322
|
},
|
|
318
323
|
// Omitted for brevity
|
|
319
|
-
})
|
|
324
|
+
})
|
|
320
325
|
~~~~
|
|
321
326
|
|
|
322
|
-
###
|
|
327
|
+
### Disposable sink
|
|
323
328
|
|
|
324
|
-
A
|
|
325
|
-
|
|
326
|
-
|
|
329
|
+
A disposable sink is a sink that can be disposed of. They are automatically
|
|
330
|
+
disposed of when the configuration is reset or the program exits. The type
|
|
331
|
+
of a disposable sink is: `Sink & Disposable`. You can create a disposable
|
|
332
|
+
sink by defining a `[Symbol.dispose]` method:
|
|
327
333
|
|
|
328
334
|
~~~~ typescript
|
|
329
|
-
|
|
335
|
+
const disposableSink: Sink & Disposable = (record: LogRecord) => {
|
|
336
|
+
console.log(record.message);
|
|
337
|
+
};
|
|
338
|
+
disposableSink[Symbol.dispose] = () => {
|
|
339
|
+
console.log("Disposed!");
|
|
340
|
+
};
|
|
330
341
|
~~~~
|
|
331
342
|
|
|
332
|
-
|
|
343
|
+
|
|
344
|
+
Testing
|
|
345
|
+
-------
|
|
346
|
+
|
|
347
|
+
Here are some tips for testing your application or library with LogTape.
|
|
348
|
+
|
|
349
|
+
### Reset configuration
|
|
350
|
+
|
|
351
|
+
You can reset the configuration of LogTape to its initial state. This is
|
|
352
|
+
useful when you want to reset the configuration between tests. For example,
|
|
353
|
+
the following code shows how to reset the configuration after a test
|
|
354
|
+
(regardless of whether the test passes or fails) in Deno:
|
|
355
|
+
|
|
356
|
+
~~~~ typescript
|
|
357
|
+
import { configure, reset } from "@logtape/logtape";
|
|
358
|
+
|
|
359
|
+
Deno.test("my test", async (t) => {
|
|
360
|
+
await t.step("set up", () => {
|
|
361
|
+
configure({ /* ... */ });
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
await t.step("run test", () => {
|
|
365
|
+
// Run the test
|
|
366
|
+
});
|
|
367
|
+
|
|
368
|
+
await t.step("tear down", () => {
|
|
369
|
+
reset();
|
|
370
|
+
});
|
|
371
|
+
});
|
|
372
|
+
~~~~
|
|
373
|
+
|
|
374
|
+
### Buffer sink
|
|
375
|
+
|
|
376
|
+
For testing purposes, you may want to collect log messages in memory. Although
|
|
377
|
+
LogTape does not provide a built-in buffer sink, you can easily implement it:
|
|
333
378
|
|
|
334
379
|
~~~~ typescript
|
|
380
|
+
import { type LogRecord, configure } from "@logtape/logtape";
|
|
381
|
+
|
|
382
|
+
const buffer: LogRecord[] = [];
|
|
383
|
+
|
|
335
384
|
configure({
|
|
336
385
|
sinks: {
|
|
337
|
-
|
|
338
|
-
formatter: JSON.stringify,
|
|
339
|
-
}),
|
|
386
|
+
buffer: buffer.push.bind(buffer),
|
|
340
387
|
},
|
|
341
388
|
// Omitted for brevity
|
|
342
|
-
})
|
|
389
|
+
});
|
|
343
390
|
~~~~
|
package/esm/config.js
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
|
+
import * as dntShim from "./_dnt.shims.js";
|
|
1
2
|
import { toFilter } from "./filter.js";
|
|
2
3
|
import { LoggerImpl } from "./logger.js";
|
|
3
4
|
import { getConsoleSink } from "./sink.js";
|
|
5
|
+
/**
|
|
6
|
+
* Whether the loggers are configured.
|
|
7
|
+
*/
|
|
4
8
|
let configured = false;
|
|
9
|
+
/**
|
|
10
|
+
* Disposables to dispose when resetting the configuration.
|
|
11
|
+
*/
|
|
12
|
+
const disposables = new Set();
|
|
5
13
|
/**
|
|
6
14
|
* Configure the loggers with the specified configuration.
|
|
7
15
|
*
|
|
16
|
+
* Note that if the given sinks or filters are disposable, they will be
|
|
17
|
+
* disposed when the configuration is reset, or when the process exits.
|
|
18
|
+
*
|
|
8
19
|
* @example
|
|
9
20
|
* ```typescript
|
|
10
21
|
* configure({
|
|
@@ -42,8 +53,8 @@ export function configure(config) {
|
|
|
42
53
|
if (configured && !config.reset) {
|
|
43
54
|
throw new ConfigError("Already configured; if you want to reset, turn on the reset flag.");
|
|
44
55
|
}
|
|
56
|
+
reset();
|
|
45
57
|
configured = true;
|
|
46
|
-
LoggerImpl.getLogger([]).resetDescendants();
|
|
47
58
|
let metaConfigured = false;
|
|
48
59
|
for (const cfg of config.loggers) {
|
|
49
60
|
if (cfg.category.length === 0 ||
|
|
@@ -73,6 +84,20 @@ export function configure(config) {
|
|
|
73
84
|
logger.filters.push(toFilter(filter));
|
|
74
85
|
}
|
|
75
86
|
}
|
|
87
|
+
for (const sink of Object.values(config.sinks)) {
|
|
88
|
+
if (Symbol.dispose in sink)
|
|
89
|
+
disposables.add(sink);
|
|
90
|
+
}
|
|
91
|
+
for (const filter of Object.values(config.filters)) {
|
|
92
|
+
if (filter != null && typeof filter !== "string" && Symbol.dispose in filter)
|
|
93
|
+
disposables.add(filter);
|
|
94
|
+
}
|
|
95
|
+
if ("process" in dntShim.dntGlobalThis) { // @ts-ignore: It's fine to use process in Node
|
|
96
|
+
process.on("exit", dispose);
|
|
97
|
+
}
|
|
98
|
+
else { // @ts-ignore: It's fine to addEventListener() on the browser/Deno
|
|
99
|
+
addEventListener("unload", dispose);
|
|
100
|
+
}
|
|
76
101
|
const meta = LoggerImpl.getLogger(["logtape", "meta"]);
|
|
77
102
|
if (!metaConfigured) {
|
|
78
103
|
meta.sinks.push(getConsoleSink());
|
|
@@ -90,9 +115,18 @@ export function configure(config) {
|
|
|
90
115
|
* Reset the configuration. Mostly for testing purposes.
|
|
91
116
|
*/
|
|
92
117
|
export function reset() {
|
|
118
|
+
dispose();
|
|
93
119
|
LoggerImpl.getLogger([]).resetDescendants();
|
|
94
120
|
configured = false;
|
|
95
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* Dispose of the disposables.
|
|
124
|
+
*/
|
|
125
|
+
export function dispose() {
|
|
126
|
+
for (const disposable of disposables)
|
|
127
|
+
disposable[Symbol.dispose]();
|
|
128
|
+
disposables.clear();
|
|
129
|
+
}
|
|
96
130
|
/**
|
|
97
131
|
* A configuration error.
|
|
98
132
|
*/
|
package/esm/mod.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { ConfigError, configure, } from "./config.js";
|
|
1
|
+
export { ConfigError, configure, reset, } from "./config.js";
|
|
2
2
|
export { getLevelFilter, toFilter, } from "./filter.js";
|
|
3
|
-
export { defaultConsoleFormatter, } from "./formatter.js";
|
|
3
|
+
export { defaultConsoleFormatter, defaultTextFormatter, } from "./formatter.js";
|
|
4
4
|
export { getLogger } from "./logger.js";
|
|
5
|
-
export { getConsoleSink } from "./sink.js";
|
|
5
|
+
export { getConsoleSink, getFileSink, getStreamSink, } from "./sink.js";
|
package/esm/sink.js
CHANGED
|
@@ -27,10 +27,12 @@ export function getStreamSink(stream, options = {}) {
|
|
|
27
27
|
const formatter = options.formatter ?? defaultTextFormatter;
|
|
28
28
|
const encoder = options.encoder ?? new TextEncoder();
|
|
29
29
|
const writer = stream.getWriter();
|
|
30
|
-
|
|
30
|
+
const sink = (record) => {
|
|
31
31
|
const bytes = encoder.encode(formatter(record));
|
|
32
32
|
writer.ready.then(() => writer.write(bytes));
|
|
33
33
|
};
|
|
34
|
+
sink[Symbol.dispose] = () => writer.close();
|
|
35
|
+
return sink;
|
|
34
36
|
}
|
|
35
37
|
/**
|
|
36
38
|
* A console sink factory that returns a sink that logs to the console.
|
|
@@ -61,7 +63,8 @@ export function getConsoleSink(options = {}) {
|
|
|
61
63
|
* @typeParam TFile The type of the file descriptor.
|
|
62
64
|
* @param path A path to the file to write to.
|
|
63
65
|
* @param options The options for the sink and the file driver.
|
|
64
|
-
* @returns A sink that writes to the file.
|
|
66
|
+
* @returns A sink that writes to the file. The sink is also a disposable
|
|
67
|
+
* object that closes the file when disposed.
|
|
65
68
|
*/
|
|
66
69
|
export function getFileSink(path, options) {
|
|
67
70
|
const formatter = options.formatter ?? defaultTextFormatter;
|
|
@@ -71,6 +74,6 @@ export function getFileSink(path, options) {
|
|
|
71
74
|
options.writeSync(fd, encoder.encode(formatter(record)));
|
|
72
75
|
options.flushSync(fd);
|
|
73
76
|
};
|
|
74
|
-
sink.
|
|
77
|
+
sink[Symbol.dispose] = () => options.closeSync(fd);
|
|
75
78
|
return sink;
|
|
76
79
|
}
|
package/package.json
CHANGED
package/script/config.js
CHANGED
|
@@ -1,13 +1,47 @@
|
|
|
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.ConfigError = exports.reset = exports.configure = void 0;
|
|
26
|
+
exports.ConfigError = exports.dispose = exports.reset = exports.configure = void 0;
|
|
27
|
+
const dntShim = __importStar(require("./_dnt.shims.js"));
|
|
4
28
|
const filter_js_1 = require("./filter.js");
|
|
5
29
|
const logger_js_1 = require("./logger.js");
|
|
6
30
|
const sink_js_1 = require("./sink.js");
|
|
31
|
+
/**
|
|
32
|
+
* Whether the loggers are configured.
|
|
33
|
+
*/
|
|
7
34
|
let configured = false;
|
|
35
|
+
/**
|
|
36
|
+
* Disposables to dispose when resetting the configuration.
|
|
37
|
+
*/
|
|
38
|
+
const disposables = new Set();
|
|
8
39
|
/**
|
|
9
40
|
* Configure the loggers with the specified configuration.
|
|
10
41
|
*
|
|
42
|
+
* Note that if the given sinks or filters are disposable, they will be
|
|
43
|
+
* disposed when the configuration is reset, or when the process exits.
|
|
44
|
+
*
|
|
11
45
|
* @example
|
|
12
46
|
* ```typescript
|
|
13
47
|
* configure({
|
|
@@ -45,8 +79,8 @@ function configure(config) {
|
|
|
45
79
|
if (configured && !config.reset) {
|
|
46
80
|
throw new ConfigError("Already configured; if you want to reset, turn on the reset flag.");
|
|
47
81
|
}
|
|
82
|
+
reset();
|
|
48
83
|
configured = true;
|
|
49
|
-
logger_js_1.LoggerImpl.getLogger([]).resetDescendants();
|
|
50
84
|
let metaConfigured = false;
|
|
51
85
|
for (const cfg of config.loggers) {
|
|
52
86
|
if (cfg.category.length === 0 ||
|
|
@@ -76,6 +110,20 @@ function configure(config) {
|
|
|
76
110
|
logger.filters.push((0, filter_js_1.toFilter)(filter));
|
|
77
111
|
}
|
|
78
112
|
}
|
|
113
|
+
for (const sink of Object.values(config.sinks)) {
|
|
114
|
+
if (Symbol.dispose in sink)
|
|
115
|
+
disposables.add(sink);
|
|
116
|
+
}
|
|
117
|
+
for (const filter of Object.values(config.filters)) {
|
|
118
|
+
if (filter != null && typeof filter !== "string" && Symbol.dispose in filter)
|
|
119
|
+
disposables.add(filter);
|
|
120
|
+
}
|
|
121
|
+
if ("process" in dntShim.dntGlobalThis) { // @ts-ignore: It's fine to use process in Node
|
|
122
|
+
process.on("exit", dispose);
|
|
123
|
+
}
|
|
124
|
+
else { // @ts-ignore: It's fine to addEventListener() on the browser/Deno
|
|
125
|
+
addEventListener("unload", dispose);
|
|
126
|
+
}
|
|
79
127
|
const meta = logger_js_1.LoggerImpl.getLogger(["logtape", "meta"]);
|
|
80
128
|
if (!metaConfigured) {
|
|
81
129
|
meta.sinks.push((0, sink_js_1.getConsoleSink)());
|
|
@@ -94,10 +142,20 @@ exports.configure = configure;
|
|
|
94
142
|
* Reset the configuration. Mostly for testing purposes.
|
|
95
143
|
*/
|
|
96
144
|
function reset() {
|
|
145
|
+
dispose();
|
|
97
146
|
logger_js_1.LoggerImpl.getLogger([]).resetDescendants();
|
|
98
147
|
configured = false;
|
|
99
148
|
}
|
|
100
149
|
exports.reset = reset;
|
|
150
|
+
/**
|
|
151
|
+
* Dispose of the disposables.
|
|
152
|
+
*/
|
|
153
|
+
function dispose() {
|
|
154
|
+
for (const disposable of disposables)
|
|
155
|
+
disposable[Symbol.dispose]();
|
|
156
|
+
disposables.clear();
|
|
157
|
+
}
|
|
158
|
+
exports.dispose = dispose;
|
|
101
159
|
/**
|
|
102
160
|
* A configuration error.
|
|
103
161
|
*/
|
package/script/mod.js
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getConsoleSink = exports.getLogger = exports.defaultConsoleFormatter = exports.toFilter = exports.getLevelFilter = exports.configure = exports.ConfigError = void 0;
|
|
3
|
+
exports.getStreamSink = exports.getFileSink = exports.getConsoleSink = exports.getLogger = exports.defaultTextFormatter = exports.defaultConsoleFormatter = exports.toFilter = exports.getLevelFilter = exports.reset = exports.configure = exports.ConfigError = void 0;
|
|
4
4
|
var config_js_1 = require("./config.js");
|
|
5
5
|
Object.defineProperty(exports, "ConfigError", { enumerable: true, get: function () { return config_js_1.ConfigError; } });
|
|
6
6
|
Object.defineProperty(exports, "configure", { enumerable: true, get: function () { return config_js_1.configure; } });
|
|
7
|
+
Object.defineProperty(exports, "reset", { enumerable: true, get: function () { return config_js_1.reset; } });
|
|
7
8
|
var filter_js_1 = require("./filter.js");
|
|
8
9
|
Object.defineProperty(exports, "getLevelFilter", { enumerable: true, get: function () { return filter_js_1.getLevelFilter; } });
|
|
9
10
|
Object.defineProperty(exports, "toFilter", { enumerable: true, get: function () { return filter_js_1.toFilter; } });
|
|
10
11
|
var formatter_js_1 = require("./formatter.js");
|
|
11
12
|
Object.defineProperty(exports, "defaultConsoleFormatter", { enumerable: true, get: function () { return formatter_js_1.defaultConsoleFormatter; } });
|
|
13
|
+
Object.defineProperty(exports, "defaultTextFormatter", { enumerable: true, get: function () { return formatter_js_1.defaultTextFormatter; } });
|
|
12
14
|
var logger_js_1 = require("./logger.js");
|
|
13
15
|
Object.defineProperty(exports, "getLogger", { enumerable: true, get: function () { return logger_js_1.getLogger; } });
|
|
14
16
|
var sink_js_1 = require("./sink.js");
|
|
15
17
|
Object.defineProperty(exports, "getConsoleSink", { enumerable: true, get: function () { return sink_js_1.getConsoleSink; } });
|
|
18
|
+
Object.defineProperty(exports, "getFileSink", { enumerable: true, get: function () { return sink_js_1.getFileSink; } });
|
|
19
|
+
Object.defineProperty(exports, "getStreamSink", { enumerable: true, get: function () { return sink_js_1.getStreamSink; } });
|
package/script/sink.js
CHANGED
|
@@ -30,10 +30,12 @@ function getStreamSink(stream, options = {}) {
|
|
|
30
30
|
const formatter = options.formatter ?? formatter_js_1.defaultTextFormatter;
|
|
31
31
|
const encoder = options.encoder ?? new TextEncoder();
|
|
32
32
|
const writer = stream.getWriter();
|
|
33
|
-
|
|
33
|
+
const sink = (record) => {
|
|
34
34
|
const bytes = encoder.encode(formatter(record));
|
|
35
35
|
writer.ready.then(() => writer.write(bytes));
|
|
36
36
|
};
|
|
37
|
+
sink[Symbol.dispose] = () => writer.close();
|
|
38
|
+
return sink;
|
|
37
39
|
}
|
|
38
40
|
exports.getStreamSink = getStreamSink;
|
|
39
41
|
/**
|
|
@@ -66,7 +68,8 @@ exports.getConsoleSink = getConsoleSink;
|
|
|
66
68
|
* @typeParam TFile The type of the file descriptor.
|
|
67
69
|
* @param path A path to the file to write to.
|
|
68
70
|
* @param options The options for the sink and the file driver.
|
|
69
|
-
* @returns A sink that writes to the file.
|
|
71
|
+
* @returns A sink that writes to the file. The sink is also a disposable
|
|
72
|
+
* object that closes the file when disposed.
|
|
70
73
|
*/
|
|
71
74
|
function getFileSink(path, options) {
|
|
72
75
|
const formatter = options.formatter ?? formatter_js_1.defaultTextFormatter;
|
|
@@ -76,7 +79,7 @@ function getFileSink(path, options) {
|
|
|
76
79
|
options.writeSync(fd, encoder.encode(formatter(record)));
|
|
77
80
|
options.flushSync(fd);
|
|
78
81
|
};
|
|
79
|
-
sink.
|
|
82
|
+
sink[Symbol.dispose] = () => options.closeSync(fd);
|
|
80
83
|
return sink;
|
|
81
84
|
}
|
|
82
85
|
exports.getFileSink = getFileSink;
|
package/types/config.d.ts
CHANGED
|
@@ -50,6 +50,9 @@ export interface LoggerConfig<TSinkId extends string, TFilterId extends string>
|
|
|
50
50
|
/**
|
|
51
51
|
* Configure the loggers with the specified configuration.
|
|
52
52
|
*
|
|
53
|
+
* Note that if the given sinks or filters are disposable, they will be
|
|
54
|
+
* disposed when the configuration is reset, or when the process exits.
|
|
55
|
+
*
|
|
53
56
|
* @example
|
|
54
57
|
* ```typescript
|
|
55
58
|
* configure({
|
|
@@ -88,6 +91,10 @@ export declare function configure<TSinkId extends string, TFilterId extends stri
|
|
|
88
91
|
* Reset the configuration. Mostly for testing purposes.
|
|
89
92
|
*/
|
|
90
93
|
export declare function reset(): void;
|
|
94
|
+
/**
|
|
95
|
+
* Dispose of the disposables.
|
|
96
|
+
*/
|
|
97
|
+
export declare function dispose(): void;
|
|
91
98
|
/**
|
|
92
99
|
* A configuration error.
|
|
93
100
|
*/
|
package/types/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAAY,MAAM,aAAa,CAAC;AAExD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAkB,KAAK,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,MAAM,CAAC,OAAO,SAAS,MAAM,EAAE,SAAS,SAAS,MAAM;IACtE;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC7B;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAEvC;;OAEG;IACH,OAAO,EAAE,YAAY,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,CAAC;IAE5C;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY,CAC3B,OAAO,SAAS,MAAM,EACtB,SAAS,SAAS,MAAM;IAExB;;;OAGG;IACH,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAE5B;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC;IAElB;;OAEG;IACH,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC;IAEtB;;;OAGG;IACH,KAAK,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;CACzB;AAYD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,SAAS,CAAC,OAAO,SAAS,MAAM,EAAE,SAAS,SAAS,MAAM,EACxE,MAAM,EAAE,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,QA0EnC;AAED;;GAEG;AACH,wBAAgB,KAAK,SAIpB;AAED;;GAEG;AACH,wBAAgB,OAAO,SAGtB;AAED;;GAEG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACpC;;;OAGG;gBACS,OAAO,EAAE,MAAM;CAI5B"}
|
package/types/mod.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { type Config, ConfigError, configure, type LoggerConfig, } from "./config.js";
|
|
1
|
+
export { type Config, ConfigError, configure, type LoggerConfig, reset, } from "./config.js";
|
|
2
2
|
export { type Filter, type FilterLike, getLevelFilter, toFilter, } from "./filter.js";
|
|
3
|
-
export { type ConsoleFormatter, defaultConsoleFormatter, type TextFormatter, } from "./formatter.js";
|
|
3
|
+
export { type ConsoleFormatter, defaultConsoleFormatter, defaultTextFormatter, type TextFormatter, } from "./formatter.js";
|
|
4
4
|
export { getLogger, type Logger } from "./logger.js";
|
|
5
5
|
export type { LogLevel, LogRecord } from "./record.js";
|
|
6
|
-
export { getConsoleSink, type Sink } from "./sink.js";
|
|
6
|
+
export { type ConsoleSinkOptions, type FileSinkDriver, type FileSinkOptions, getConsoleSink, getFileSink, getStreamSink, type Sink, type StreamSinkOptions, } from "./sink.js";
|
|
7
7
|
//# sourceMappingURL=mod.d.ts.map
|
package/types/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EACX,WAAW,EACX,SAAS,EACT,KAAK,YAAY,
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EACX,WAAW,EACX,SAAS,EACT,KAAK,YAAY,EACjB,KAAK,GACN,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,KAAK,MAAM,EACX,KAAK,UAAU,EACf,cAAc,EACd,QAAQ,GACT,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,KAAK,gBAAgB,EACrB,uBAAuB,EACvB,oBAAoB,EACpB,KAAK,aAAa,GACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AACrD,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,cAAc,EACd,WAAW,EACX,aAAa,EACb,KAAK,IAAI,EACT,KAAK,iBAAiB,GACvB,MAAM,WAAW,CAAC"}
|
package/types/sink.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
3
4
|
import * as dntShim from "./_dnt.shims.js";
|
|
4
5
|
import { type ConsoleFormatter, type TextFormatter } from "./formatter.js";
|
|
5
6
|
import type { LogRecord } from "./record.js";
|
|
@@ -52,7 +53,7 @@ export interface StreamSinkOptions {
|
|
|
52
53
|
* @param options The options for the sink.
|
|
53
54
|
* @returns A sink that writes to the stream.
|
|
54
55
|
*/
|
|
55
|
-
export declare function getStreamSink(stream: dntShim.WritableStream, options?: StreamSinkOptions): Sink;
|
|
56
|
+
export declare function getStreamSink(stream: dntShim.WritableStream, options?: StreamSinkOptions): Sink & Disposable;
|
|
56
57
|
/**
|
|
57
58
|
* Options for the {@link getConsoleSink} function.
|
|
58
59
|
*/
|
|
@@ -109,9 +110,8 @@ export interface FileSinkDriver<TFile> {
|
|
|
109
110
|
* @typeParam TFile The type of the file descriptor.
|
|
110
111
|
* @param path A path to the file to write to.
|
|
111
112
|
* @param options The options for the sink and the file driver.
|
|
112
|
-
* @returns A sink that writes to the file.
|
|
113
|
+
* @returns A sink that writes to the file. The sink is also a disposable
|
|
114
|
+
* object that closes the file when disposed.
|
|
113
115
|
*/
|
|
114
|
-
export declare function getFileSink<TFile>(path: string, options: FileSinkOptions & FileSinkDriver<TFile>): Sink &
|
|
115
|
-
close: () => void;
|
|
116
|
-
};
|
|
116
|
+
export declare function getFileSink<TFile>(path: string, options: FileSinkOptions & FileSinkDriver<TFile>): Sink & Disposable;
|
|
117
117
|
//# sourceMappingURL=sink.d.ts.map
|
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,KAAK,OAAO,MAAM,iBAAiB,CAAC;AAC3C,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;;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,CAAC;CAChD;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,OAAO,CAAC,cAAc,EAC9B,OAAO,GAAE,iBAAsB,GAC9B,IAAI,GAAG,UAAU,CAUnB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAE7B;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,OAAO,GAAE,kBAAuB,GAAG,IAAI,CAYrE;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,iBAAiB,CAAC;AAEhD;;;GAGG;AACH,MAAM,WAAW,cAAc,CAAC,KAAK;IACnC;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC;IAE9B;;;;OAIG;IACH,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;IAE9C;;;OAGG;IACH,SAAS,CAAC,EAAE,EAAE,KAAK,GAAG,IAAI,CAAC;IAE3B;;;OAGG;IACH,SAAS,CAAC,EAAE,EAAE,KAAK,GAAG,IAAI,CAAC;CAC5B;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAC/B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,eAAe,GAAG,cAAc,CAAC,KAAK,CAAC,GAC/C,IAAI,GAAG,UAAU,CAUnB"}
|