@logtape/logtape 0.1.0-dev.9

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.
Files changed (59) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +18 -0
  3. package/esm/_dnt.shims.js +61 -0
  4. package/esm/config.js +108 -0
  5. package/esm/filter.js +42 -0
  6. package/esm/formatter.js +85 -0
  7. package/esm/logger.js +285 -0
  8. package/esm/mod.js +5 -0
  9. package/esm/package.json +3 -0
  10. package/esm/record.js +1 -0
  11. package/esm/sink.js +59 -0
  12. package/package.json +44 -0
  13. package/script/_dnt.shims.js +65 -0
  14. package/script/config.js +114 -0
  15. package/script/filter.js +47 -0
  16. package/script/formatter.js +90 -0
  17. package/script/logger.js +292 -0
  18. package/script/mod.js +15 -0
  19. package/script/package.json +3 -0
  20. package/script/record.js +2 -0
  21. package/script/sink.js +64 -0
  22. package/types/_dnt.shims.d.ts +10 -0
  23. package/types/_dnt.shims.d.ts.map +1 -0
  24. package/types/_dnt.test_shims.d.ts.map +1 -0
  25. package/types/config.d.ts +101 -0
  26. package/types/config.d.ts.map +1 -0
  27. package/types/config.test.d.ts.map +1 -0
  28. package/types/deps/jsr.io/@std/assert/0.222.1/_constants.d.ts.map +1 -0
  29. package/types/deps/jsr.io/@std/assert/0.222.1/_diff.d.ts.map +1 -0
  30. package/types/deps/jsr.io/@std/assert/0.222.1/_format.d.ts.map +1 -0
  31. package/types/deps/jsr.io/@std/assert/0.222.1/assert.d.ts.map +1 -0
  32. package/types/deps/jsr.io/@std/assert/0.222.1/assert_equals.d.ts.map +1 -0
  33. package/types/deps/jsr.io/@std/assert/0.222.1/assert_false.d.ts.map +1 -0
  34. package/types/deps/jsr.io/@std/assert/0.222.1/assert_greater_or_equal.d.ts.map +1 -0
  35. package/types/deps/jsr.io/@std/assert/0.222.1/assert_is_error.d.ts.map +1 -0
  36. package/types/deps/jsr.io/@std/assert/0.222.1/assert_less_or_equal.d.ts.map +1 -0
  37. package/types/deps/jsr.io/@std/assert/0.222.1/assert_strict_equals.d.ts.map +1 -0
  38. package/types/deps/jsr.io/@std/assert/0.222.1/assert_throws.d.ts.map +1 -0
  39. package/types/deps/jsr.io/@std/assert/0.222.1/assertion_error.d.ts.map +1 -0
  40. package/types/deps/jsr.io/@std/assert/0.222.1/equal.d.ts.map +1 -0
  41. package/types/deps/jsr.io/@std/async/0.222.1/delay.d.ts.map +1 -0
  42. package/types/deps/jsr.io/@std/fmt/0.222.1/colors.d.ts.map +1 -0
  43. package/types/filter.d.ts +30 -0
  44. package/types/filter.d.ts.map +1 -0
  45. package/types/filter.test.d.ts.map +1 -0
  46. package/types/fixtures.d.ts.map +1 -0
  47. package/types/formatter.d.ts +38 -0
  48. package/types/formatter.d.ts.map +1 -0
  49. package/types/formatter.test.d.ts.map +1 -0
  50. package/types/logger.d.ts +363 -0
  51. package/types/logger.d.ts.map +1 -0
  52. package/types/logger.test.d.ts.map +1 -0
  53. package/types/mod.d.ts +7 -0
  54. package/types/mod.d.ts.map +1 -0
  55. package/types/record.d.ts +33 -0
  56. package/types/record.d.ts.map +1 -0
  57. package/types/sink.d.ts +55 -0
  58. package/types/sink.d.ts.map +1 -0
  59. package/types/sink.test.d.ts.map +1 -0
package/script/sink.js ADDED
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getConsoleSink = exports.getStreamSink = void 0;
4
+ const formatter_js_1 = require("./formatter.js");
5
+ /**
6
+ * A factory that returns a sink that writes to a {@link WritableStream}.
7
+ *
8
+ * Note that the `stream` is of Web Streams API, which is different from
9
+ * Node.js streams. You can convert a Node.js stream to a Web Streams API
10
+ * stream using [`stream.Writable.toWeb()`] method.
11
+ *
12
+ * [`stream.Writable.toWeb()`]: https://nodejs.org/api/stream.html#streamwritabletowebstreamwritable
13
+ *
14
+ * @example Sink to the standard error in Deno
15
+ * ```typescript
16
+ * const stderrSink = getStreamSink(Deno.stderr.writable);
17
+ * ```
18
+ *
19
+ * @example Sink to the standard error in Node.js
20
+ * ```typescript
21
+ * import stream from "node:stream";
22
+ * const stderrSink = getStreamSink(stream.Writable.toWeb(process.stderr));
23
+ * ```
24
+ *
25
+ * @param stream The stream to write to.
26
+ * @param formatter The text formatter to use. Defaults to
27
+ * {@link defaultTextFormatter}.
28
+ * @param encoder The text encoder to use. Defaults to an instance of
29
+ * {@link TextEncoder}.
30
+ * @returns A sink that writes to the stream.
31
+ */
32
+ function getStreamSink(stream, formatter = formatter_js_1.defaultTextFormatter, encoder = new TextEncoder()) {
33
+ const writer = stream.getWriter();
34
+ return (record) => {
35
+ const bytes = encoder.encode(formatter(record));
36
+ writer.ready.then(() => writer.write(bytes));
37
+ };
38
+ }
39
+ exports.getStreamSink = getStreamSink;
40
+ /**
41
+ * A console sink factory that returns a sink that logs to the console.
42
+ *
43
+ * @param formatter A console formatter. Defaults to
44
+ * {@link defaultConsoleFormatter}.
45
+ * @param console The console to log to. Defaults to {@link console}.
46
+ * @returns A sink that logs to the console.
47
+ */
48
+ function getConsoleSink(formatter = formatter_js_1.defaultConsoleFormatter, console = globalThis.console) {
49
+ return (record) => {
50
+ const args = formatter(record);
51
+ if (record.level === "debug")
52
+ console.debug(...args);
53
+ else if (record.level === "info")
54
+ console.info(...args);
55
+ else if (record.level === "warning")
56
+ console.warn(...args);
57
+ else if (record.level === "error" || record.level === "fatal") {
58
+ console.error(...args);
59
+ }
60
+ else
61
+ throw new TypeError(`Invalid log level: ${record.level}.`);
62
+ };
63
+ }
64
+ exports.getConsoleSink = getConsoleSink;
@@ -0,0 +1,10 @@
1
+ /// <reference types="node" />
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
+ };
10
+ //# sourceMappingURL=_dnt.shims.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_dnt.shims.d.ts","sourceRoot":"","sources":["../src/_dnt.shims.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAKjD,eAAO,MAAM,aAAa;;;;;CAA2C,CAAC"}
@@ -0,0 +1 @@
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;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAMjD,eAAO,MAAM,aAAa;;;;;;CAA2C,CAAC"}
@@ -0,0 +1,101 @@
1
+ import { type FilterLike } from "./filter.js";
2
+ import type { LogLevel } from "./record.js";
3
+ import { type Sink } from "./sink.js";
4
+ /**
5
+ * A configuration for the loggers.
6
+ */
7
+ export interface Config<TSinkId extends string, TFilterId extends string> {
8
+ /**
9
+ * The sinks to use. The keys are the sink identifiers, and the values are
10
+ * {@link Sink}s.
11
+ */
12
+ sinks: Record<TSinkId, Sink>;
13
+ /**
14
+ * The filters to use. The keys are the filter identifiers, and the values
15
+ * are either {@link Filter}s or {@link LogLevel}s.
16
+ */
17
+ filters: Record<TFilterId, FilterLike>;
18
+ /**
19
+ * The loggers to configure.
20
+ */
21
+ loggers: LoggerConfig<TSinkId, TFilterId>[];
22
+ /**
23
+ * Whether to reset the configuration before applying this one.
24
+ */
25
+ reset?: boolean;
26
+ }
27
+ /**
28
+ * A logger configuration.
29
+ */
30
+ export interface LoggerConfig<TSinkId extends string, TFilterId extends string> {
31
+ /**
32
+ * The category of the logger. If a string, it is equivalent to an array
33
+ * with one element.
34
+ */
35
+ category: string | string[];
36
+ /**
37
+ * The sink identifiers to use.
38
+ */
39
+ sinks?: TSinkId[];
40
+ /**
41
+ * The filter identifiers to use.
42
+ */
43
+ filters?: TFilterId[];
44
+ /**
45
+ * The log level to filter by. If `null`, the logger will reject all
46
+ * records.
47
+ */
48
+ level?: LogLevel | null;
49
+ }
50
+ /**
51
+ * Configure the loggers with the specified configuration.
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * configure({
56
+ * sinks: {
57
+ * console: getConsoleSink(),
58
+ * },
59
+ * filters: {
60
+ * slow: (log) =>
61
+ * "duration" in log.properties &&
62
+ * log.properties.duration as number > 1000,
63
+ * },
64
+ * loggers: [
65
+ * {
66
+ * category: "my-app",
67
+ * sinks: ["console"],
68
+ * level: "info",
69
+ * },
70
+ * {
71
+ * category: ["my-app", "sql"],
72
+ * filters: ["slow"],
73
+ * level: "debug",
74
+ * },
75
+ * {
76
+ * category: "logtape",
77
+ * sinks: ["console"],
78
+ * level: "error",
79
+ * },
80
+ * ],
81
+ * });
82
+ * ```
83
+ *
84
+ * @param config The configuration.
85
+ */
86
+ export declare function configure<TSinkId extends string, TFilterId extends string>(config: Config<TSinkId, TFilterId>): void;
87
+ /**
88
+ * Reset the configuration. Mostly for testing purposes.
89
+ */
90
+ export declare function reset(): void;
91
+ /**
92
+ * A configuration error.
93
+ */
94
+ export declare class ConfigError extends Error {
95
+ /**
96
+ * Constructs a new configuration error.
97
+ * @param message The error message.
98
+ */
99
+ constructor(message: string);
100
+ }
101
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,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;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,SAAS,CAAC,OAAO,SAAS,MAAM,EAAE,SAAS,SAAS,MAAM,EACxE,MAAM,EAAE,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,QA0DnC;AAED;;GAEG;AACH,wBAAgB,KAAK,SAGpB;AAED;;GAEG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACpC;;;OAGG;gBACS,OAAO,EAAE,MAAM;CAI5B"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.test.d.ts","sourceRoot":"","sources":["../src/config.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_constants.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/0.222.1/_constants.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,eAAe,qBAAqB,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_diff.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/0.222.1/_diff.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,QAAQ;;;;CAIX,CAAC;AAEX,MAAM,MAAM,QAAQ,GAAG,MAAM,OAAO,QAAQ,CAAC;AAE7C,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,CAAC,CAAC;IACT,OAAO,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;CAChC;AA4BD;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CA+L5D;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,wBAsI3C;AAwCD,wBAAgB,YAAY,CAC1B,UAAU,EAAE,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAC7C,EAAE,UAAkB,EAAE;;CAAK,GAC1B,MAAM,EAAE,CAyBV"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_format.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/0.222.1/_format.ts"],"names":[],"mappings":"AAYA,wBAAgB,MAAM,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,CAezC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/0.222.1/assert.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;GAUG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,SAAK,GAAG,OAAO,CAAC,IAAI,CAI5D"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assert_equals.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/0.222.1/assert_equals.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAC5B,MAAM,EAAE,CAAC,EACT,QAAQ,EAAE,CAAC,EACX,GAAG,CAAC,EAAE,MAAM,EACZ,OAAO,GAAE;IAAE,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,CAAA;CAAO,QAuBzD"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assert_false.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/0.222.1/assert_false.ts"],"names":[],"mappings":"AAIA,uDAAuD;AACvD,MAAM,MAAM,KAAK,GAAG,KAAK,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC;AAE3D;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,SAAK,GAAG,OAAO,CAAC,IAAI,IAAI,KAAK,CAI1E"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assert_greater_or_equal.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/0.222.1/assert_greater_or_equal.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EACpC,MAAM,EAAE,CAAC,EACT,QAAQ,EAAE,CAAC,EACX,GAAG,CAAC,EAAE,MAAM,QASb"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assert_is_error.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/0.222.1/assert_is_error.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,KAAK,GAAG,KAAK,EACnD,KAAK,EAAE,OAAO,EAEd,UAAU,CAAC,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,EACtC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,EAC5B,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,KAAK,IAAI,CAAC,CAmCpB"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assert_less_or_equal.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/0.222.1/assert_less_or_equal.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,MAAM,EAAE,CAAC,EACT,QAAQ,EAAE,CAAC,EACX,GAAG,CAAC,EAAE,MAAM,QASb"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assert_strict_equals.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/0.222.1/assert_strict_equals.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,MAAM,EAAE,OAAO,EACf,QAAQ,EAAE,CAAC,EACX,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,IAAI,CAAC,CAmCrB"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assert_throws.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/0.222.1/assert_throws.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,YAAY,CAC1B,EAAE,EAAE,MAAM,OAAO,EACjB,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC;AACX;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,KAAK,GAAG,KAAK,EAClD,EAAE,EAAE,MAAM,OAAO,EAEjB,UAAU,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,EACrC,WAAW,CAAC,EAAE,MAAM,EACpB,GAAG,CAAC,EAAE,MAAM,GACX,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assertion_error.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/0.222.1/assertion_error.ts"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC,iCAAiC;gBACrB,OAAO,EAAE,MAAM;CAI5B"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"equal.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/0.222.1/equal.ts"],"names":[],"mappings":"AAYA;;;;;;;;;;;;GAYG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CA8FrD"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delay.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/async/0.222.1/delay.ts"],"names":[],"mappings":";AAMA,MAAM,WAAW,YAAY;IAC3B,sCAAsC;IACtC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CA0B3E"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/fmt/0.222.1/colors.ts"],"names":[],"mappings":"AAkEA,qEAAqE;AACrE,MAAM,WAAW,GAAG;IAClB,0BAA0B;IAC1B,CAAC,EAAE,MAAM,CAAC;IACV,4BAA4B;IAC5B,CAAC,EAAE,MAAM,CAAC;IACV,2BAA2B;IAC3B,CAAC,EAAE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,CAuBhE;AAWD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEpD"}
@@ -0,0 +1,30 @@
1
+ import type { LogLevel, LogRecord } from "./record.js";
2
+ /**
3
+ * A filter is a function that accepts a log record and returns `true` if the
4
+ * record should be passed to the sink.
5
+ *
6
+ * @param record The log record to filter.
7
+ * @returns `true` if the record should be passed to the sink.
8
+ */
9
+ export type Filter = (record: LogRecord) => boolean;
10
+ /**
11
+ * A filter-like value is either a {@link Filter} or a {@link LogLevel}.
12
+ * `null` is also allowed to represent a filter that rejects all records.
13
+ */
14
+ export type FilterLike = Filter | LogLevel | null;
15
+ /**
16
+ * Converts a {@link FilterLike} value to an actual {@link Filter}.
17
+ *
18
+ * @param filter The filter-like value to convert.
19
+ * @returns The actual filter.
20
+ */
21
+ export declare function toFilter(filter: FilterLike): Filter;
22
+ /**
23
+ * Returns a filter that accepts log records with the specified level.
24
+ *
25
+ * @param level The level to filter by. If `null`, the filter will reject all
26
+ * records.
27
+ * @returns The filter.
28
+ */
29
+ export declare function getLevelFilter(level: LogLevel | null): Filter;
30
+ //# sourceMappingURL=filter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../src/filter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEvD;;;;;;GAMG;AACH,MAAM,MAAM,MAAM,GAAG,CAAC,MAAM,EAAE,SAAS,KAAK,OAAO,CAAC;AAEpD;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,IAAI,CAAC;AAElD;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAGnD;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI,GAAG,MAAM,CAoB7D"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter.test.d.ts","sourceRoot":"","sources":["../src/filter.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../src/fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,eAAO,MAAM,IAAI,EAAE,SAMlB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,SAGnB,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,SAGrB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,SAGnB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,SAGnB,CAAC"}
@@ -0,0 +1,38 @@
1
+ import type { LogRecord } from "./record.js";
2
+ /**
3
+ * A text formatter is a function that accepts a log record and returns
4
+ * a string.
5
+ *
6
+ * @param record The log record to format.
7
+ * @returns The formatted log record.
8
+ */
9
+ export type TextFormatter = (record: LogRecord) => string;
10
+ /**
11
+ * The default text formatter. This formatter formats log records as follows:
12
+ *
13
+ * ```
14
+ * 2023-11-14 22:13:20.000 +00:00 [INF] Hello, world!
15
+ * ```
16
+ *
17
+ * @param record The log record to format.
18
+ * @returns The formatted log record.
19
+ */
20
+ export declare function defaultTextFormatter(record: LogRecord): string;
21
+ /**
22
+ * A console formatter is a function that accepts a log record and returns
23
+ * an array of arguments to pass to {@link console.log}.
24
+ *
25
+ * @param record The log record to format.
26
+ * @returns The formatted log record, as an array of arguments for
27
+ * {@link console.log}.
28
+ */
29
+ export type ConsoleFormatter = (record: LogRecord) => readonly unknown[];
30
+ /**
31
+ * The default console formatter.
32
+ *
33
+ * @param record The log record to format.
34
+ * @returns The formatted log record, as an array of arguments for
35
+ * {@link console.log}.
36
+ */
37
+ export declare function defaultConsoleFormatter(record: LogRecord): readonly unknown[];
38
+ //# sourceMappingURL=formatter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../src/formatter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAY,SAAS,EAAE,MAAM,aAAa,CAAC;AAEvD;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,SAAS,KAAK,MAAM,CAAC;AA+B1D;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAU9D;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,CAoB7E"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatter.test.d.ts","sourceRoot":"","sources":["../src/formatter.test.ts"],"names":[],"mappings":""}