@logtape/logtape 0.5.0-dev.68 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/config.js +2 -2
- package/esm/formatter.js +43 -3
- package/esm/mod.js +1 -1
- package/esm/sink.js +26 -10
- package/package.json +1 -1
- package/script/config.js +2 -2
- package/script/formatter.js +45 -3
- package/script/mod.js +2 -1
- package/script/sink.js +26 -10
- package/types/config.d.ts +1 -1
- package/types/config.d.ts.map +1 -1
- package/types/formatter.d.ts +10 -0
- package/types/formatter.d.ts.map +1 -1
- package/types/mod.d.ts +1 -1
- package/types/mod.d.ts.map +1 -1
- package/types/sink.d.ts +3 -2
- package/types/sink.d.ts.map +1 -1
package/esm/config.js
CHANGED
|
@@ -86,7 +86,7 @@ export async function configure(config) {
|
|
|
86
86
|
if (cfg.level !== undefined)
|
|
87
87
|
logger.filters.push(toFilter(cfg.level));
|
|
88
88
|
for (const filterId of cfg.filters ?? []) {
|
|
89
|
-
const filter = config.filters[filterId];
|
|
89
|
+
const filter = config.filters?.[filterId];
|
|
90
90
|
if (filter === undefined) {
|
|
91
91
|
await reset();
|
|
92
92
|
throw new ConfigError(`Filter not found: ${filterId}.`);
|
|
@@ -102,7 +102,7 @@ export async function configure(config) {
|
|
|
102
102
|
if (Symbol.dispose in sink)
|
|
103
103
|
disposables.add(sink);
|
|
104
104
|
}
|
|
105
|
-
for (const filter of Object.values(config.filters)) {
|
|
105
|
+
for (const filter of Object.values(config.filters ?? {})) {
|
|
106
106
|
if (filter == null || typeof filter === "string")
|
|
107
107
|
continue;
|
|
108
108
|
if (Symbol.asyncDispose in filter) {
|
package/esm/formatter.js
CHANGED
|
@@ -11,10 +11,12 @@ const levelAbbreviations = {
|
|
|
11
11
|
};
|
|
12
12
|
/**
|
|
13
13
|
* A platform-specific inspect function. In Deno, this is {@link Deno.inspect},
|
|
14
|
-
* and in Node.js/Bun it is
|
|
14
|
+
* and in Node.js/Bun it is `util.inspect()`. If neither is available, it
|
|
15
15
|
* falls back to {@link JSON.stringify}.
|
|
16
16
|
*
|
|
17
17
|
* @param value The value to inspect.
|
|
18
|
+
* @param options The options for inspecting the value.
|
|
19
|
+
* If `colors` is `true`, the output will be ANSI-colored.
|
|
18
20
|
* @returns The string representation of the value.
|
|
19
21
|
*/
|
|
20
22
|
const inspect =
|
|
@@ -23,13 +25,13 @@ const inspect =
|
|
|
23
25
|
// @ts-ignore: Deno global
|
|
24
26
|
typeof globalThis.Deno.inspect === "function"
|
|
25
27
|
// @ts-ignore: Deno global
|
|
26
|
-
? globalThis.Deno.inspect
|
|
28
|
+
? globalThis.Deno.inspect.bind(globalThis.Deno)
|
|
27
29
|
// @ts-ignore: Node.js global
|
|
28
30
|
: "util" in dntShim.dntGlobalThis && "inspect" in globalThis.util &&
|
|
29
31
|
// @ts-ignore: Node.js global
|
|
30
32
|
globalThis.util.inspect === "function"
|
|
31
33
|
// @ts-ignore: Node.js global
|
|
32
|
-
? globalThis.util.inspect
|
|
34
|
+
? globalThis.util.inspect.bind(globalThis.util)
|
|
33
35
|
: JSON.stringify;
|
|
34
36
|
/**
|
|
35
37
|
* The default text formatter. This formatter formats log records as follows:
|
|
@@ -53,6 +55,44 @@ export function defaultTextFormatter(record) {
|
|
|
53
55
|
const category = record.category.join("\xb7");
|
|
54
56
|
return `${ts.toISOString().replace("T", " ").replace("Z", " +00:00")} [${levelAbbreviations[record.level]}] ${category}: ${msg}\n`;
|
|
55
57
|
}
|
|
58
|
+
const RESET = "\x1b[0m";
|
|
59
|
+
const BOLD = "\x1b[1m";
|
|
60
|
+
const DIM = "\x1b[2m";
|
|
61
|
+
const levelColors = {
|
|
62
|
+
debug: "\x1b[34m", // Blue
|
|
63
|
+
info: "\x1b[32m", // Green
|
|
64
|
+
warning: "\x1b[33m", // Yellow
|
|
65
|
+
error: "\x1b[31m", // Red
|
|
66
|
+
fatal: "\x1b[35m", // Magenta
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* A text formatter that uses ANSI colors to format log records.
|
|
70
|
+
*
|
|
71
|
+
* 
|
|
72
|
+
*
|
|
73
|
+
* @param record The log record to format.
|
|
74
|
+
* @returns The formatted log record.
|
|
75
|
+
* @since 0.5.0
|
|
76
|
+
*/
|
|
77
|
+
export const ansiColorFormatter = (record) => {
|
|
78
|
+
const ts = new Date(record.timestamp);
|
|
79
|
+
const timeString = ts.toISOString().replace("T", " ").replace("Z", " +00");
|
|
80
|
+
const category = record.category.join("·");
|
|
81
|
+
const levelColor = levelColors[record.level];
|
|
82
|
+
const levelAbbr = levelAbbreviations[record.level];
|
|
83
|
+
let message = "";
|
|
84
|
+
for (let i = 0; i < record.message.length; i++) {
|
|
85
|
+
if (i % 2 === 0) {
|
|
86
|
+
message += record.message[i];
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
message += inspect(record.message[i], { colors: true });
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return `${DIM}${timeString}${RESET} ` +
|
|
93
|
+
`${BOLD}${levelColor}${levelAbbr}${RESET} ` +
|
|
94
|
+
`${DIM}${category}:${RESET} ${message}\n`;
|
|
95
|
+
};
|
|
56
96
|
/**
|
|
57
97
|
* The styles for the log level in the console.
|
|
58
98
|
*/
|
package/esm/mod.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { ConfigError, configure, dispose, getConfig, reset, } from "./config.js";
|
|
2
2
|
export { getFileSink, getRotatingFileSink } from "./filesink.node.js";
|
|
3
3
|
export { getLevelFilter, toFilter, } from "./filter.js";
|
|
4
|
-
export { defaultConsoleFormatter, defaultTextFormatter, } from "./formatter.js";
|
|
4
|
+
export { ansiColorFormatter, defaultConsoleFormatter, defaultTextFormatter, } from "./formatter.js";
|
|
5
5
|
export { isLogLevel, parseLogLevel } from "./level.js";
|
|
6
6
|
export { getLogger } from "./logger.js";
|
|
7
7
|
export { getConsoleSink, getStreamSink, withFilter, } from "./sink.js";
|
package/esm/sink.js
CHANGED
|
@@ -73,17 +73,33 @@ export function getConsoleSink(options = {}) {
|
|
|
73
73
|
const console = options.console ?? globalThis.console;
|
|
74
74
|
return (record) => {
|
|
75
75
|
const args = formatter(record);
|
|
76
|
-
if (
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
76
|
+
if (typeof args === "string") {
|
|
77
|
+
const msg = args.replace(/\r?\n$/, "");
|
|
78
|
+
if (record.level === "debug")
|
|
79
|
+
console.debug(msg);
|
|
80
|
+
else if (record.level === "info")
|
|
81
|
+
console.info(msg);
|
|
82
|
+
else if (record.level === "warning")
|
|
83
|
+
console.warn(msg);
|
|
84
|
+
else if (record.level === "error" || record.level === "fatal") {
|
|
85
|
+
console.error(msg);
|
|
86
|
+
}
|
|
87
|
+
else
|
|
88
|
+
throw new TypeError(`Invalid log level: ${record.level}.`);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
if (record.level === "debug")
|
|
92
|
+
console.debug(...args);
|
|
93
|
+
else if (record.level === "info")
|
|
94
|
+
console.info(...args);
|
|
95
|
+
else if (record.level === "warning")
|
|
96
|
+
console.warn(...args);
|
|
97
|
+
else if (record.level === "error" || record.level === "fatal") {
|
|
98
|
+
console.error(...args);
|
|
99
|
+
}
|
|
100
|
+
else
|
|
101
|
+
throw new TypeError(`Invalid log level: ${record.level}.`);
|
|
84
102
|
}
|
|
85
|
-
else
|
|
86
|
-
throw new TypeError(`Invalid log level: ${record.level}.`);
|
|
87
103
|
};
|
|
88
104
|
}
|
|
89
105
|
/**
|
package/package.json
CHANGED
package/script/config.js
CHANGED
|
@@ -116,7 +116,7 @@ async function configure(config) {
|
|
|
116
116
|
if (cfg.level !== undefined)
|
|
117
117
|
logger.filters.push((0, filter_js_1.toFilter)(cfg.level));
|
|
118
118
|
for (const filterId of cfg.filters ?? []) {
|
|
119
|
-
const filter = config.filters[filterId];
|
|
119
|
+
const filter = config.filters?.[filterId];
|
|
120
120
|
if (filter === undefined) {
|
|
121
121
|
await reset();
|
|
122
122
|
throw new ConfigError(`Filter not found: ${filterId}.`);
|
|
@@ -132,7 +132,7 @@ async function configure(config) {
|
|
|
132
132
|
if (Symbol.dispose in sink)
|
|
133
133
|
disposables.add(sink);
|
|
134
134
|
}
|
|
135
|
-
for (const filter of Object.values(config.filters)) {
|
|
135
|
+
for (const filter of Object.values(config.filters ?? {})) {
|
|
136
136
|
if (filter == null || typeof filter === "string")
|
|
137
137
|
continue;
|
|
138
138
|
if (Symbol.asyncDispose in filter) {
|
package/script/formatter.js
CHANGED
|
@@ -23,6 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.ansiColorFormatter = void 0;
|
|
26
27
|
exports.defaultTextFormatter = defaultTextFormatter;
|
|
27
28
|
exports.defaultConsoleFormatter = defaultConsoleFormatter;
|
|
28
29
|
const dntShim = __importStar(require("./_dnt.shims.js"));
|
|
@@ -38,10 +39,12 @@ const levelAbbreviations = {
|
|
|
38
39
|
};
|
|
39
40
|
/**
|
|
40
41
|
* A platform-specific inspect function. In Deno, this is {@link Deno.inspect},
|
|
41
|
-
* and in Node.js/Bun it is
|
|
42
|
+
* and in Node.js/Bun it is `util.inspect()`. If neither is available, it
|
|
42
43
|
* falls back to {@link JSON.stringify}.
|
|
43
44
|
*
|
|
44
45
|
* @param value The value to inspect.
|
|
46
|
+
* @param options The options for inspecting the value.
|
|
47
|
+
* If `colors` is `true`, the output will be ANSI-colored.
|
|
45
48
|
* @returns The string representation of the value.
|
|
46
49
|
*/
|
|
47
50
|
const inspect =
|
|
@@ -50,13 +53,13 @@ const inspect =
|
|
|
50
53
|
// @ts-ignore: Deno global
|
|
51
54
|
typeof globalThis.Deno.inspect === "function"
|
|
52
55
|
// @ts-ignore: Deno global
|
|
53
|
-
? globalThis.Deno.inspect
|
|
56
|
+
? globalThis.Deno.inspect.bind(globalThis.Deno)
|
|
54
57
|
// @ts-ignore: Node.js global
|
|
55
58
|
: "util" in dntShim.dntGlobalThis && "inspect" in globalThis.util &&
|
|
56
59
|
// @ts-ignore: Node.js global
|
|
57
60
|
globalThis.util.inspect === "function"
|
|
58
61
|
// @ts-ignore: Node.js global
|
|
59
|
-
? globalThis.util.inspect
|
|
62
|
+
? globalThis.util.inspect.bind(globalThis.util)
|
|
60
63
|
: JSON.stringify;
|
|
61
64
|
/**
|
|
62
65
|
* The default text formatter. This formatter formats log records as follows:
|
|
@@ -80,6 +83,45 @@ function defaultTextFormatter(record) {
|
|
|
80
83
|
const category = record.category.join("\xb7");
|
|
81
84
|
return `${ts.toISOString().replace("T", " ").replace("Z", " +00:00")} [${levelAbbreviations[record.level]}] ${category}: ${msg}\n`;
|
|
82
85
|
}
|
|
86
|
+
const RESET = "\x1b[0m";
|
|
87
|
+
const BOLD = "\x1b[1m";
|
|
88
|
+
const DIM = "\x1b[2m";
|
|
89
|
+
const levelColors = {
|
|
90
|
+
debug: "\x1b[34m", // Blue
|
|
91
|
+
info: "\x1b[32m", // Green
|
|
92
|
+
warning: "\x1b[33m", // Yellow
|
|
93
|
+
error: "\x1b[31m", // Red
|
|
94
|
+
fatal: "\x1b[35m", // Magenta
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* A text formatter that uses ANSI colors to format log records.
|
|
98
|
+
*
|
|
99
|
+
* 
|
|
100
|
+
*
|
|
101
|
+
* @param record The log record to format.
|
|
102
|
+
* @returns The formatted log record.
|
|
103
|
+
* @since 0.5.0
|
|
104
|
+
*/
|
|
105
|
+
const ansiColorFormatter = (record) => {
|
|
106
|
+
const ts = new Date(record.timestamp);
|
|
107
|
+
const timeString = ts.toISOString().replace("T", " ").replace("Z", " +00");
|
|
108
|
+
const category = record.category.join("·");
|
|
109
|
+
const levelColor = levelColors[record.level];
|
|
110
|
+
const levelAbbr = levelAbbreviations[record.level];
|
|
111
|
+
let message = "";
|
|
112
|
+
for (let i = 0; i < record.message.length; i++) {
|
|
113
|
+
if (i % 2 === 0) {
|
|
114
|
+
message += record.message[i];
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
message += inspect(record.message[i], { colors: true });
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return `${DIM}${timeString}${RESET} ` +
|
|
121
|
+
`${BOLD}${levelColor}${levelAbbr}${RESET} ` +
|
|
122
|
+
`${DIM}${category}:${RESET} ${message}\n`;
|
|
123
|
+
};
|
|
124
|
+
exports.ansiColorFormatter = ansiColorFormatter;
|
|
83
125
|
/**
|
|
84
126
|
* The styles for the log level in the console.
|
|
85
127
|
*/
|
package/script/mod.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.withFilter = exports.getStreamSink = exports.getConsoleSink = exports.getLogger = exports.parseLogLevel = exports.isLogLevel = exports.defaultTextFormatter = exports.defaultConsoleFormatter = exports.toFilter = exports.getLevelFilter = exports.getRotatingFileSink = exports.getFileSink = exports.reset = exports.getConfig = exports.dispose = exports.configure = exports.ConfigError = void 0;
|
|
3
|
+
exports.withFilter = exports.getStreamSink = exports.getConsoleSink = exports.getLogger = exports.parseLogLevel = exports.isLogLevel = exports.defaultTextFormatter = exports.defaultConsoleFormatter = exports.ansiColorFormatter = exports.toFilter = exports.getLevelFilter = exports.getRotatingFileSink = exports.getFileSink = exports.reset = exports.getConfig = exports.dispose = 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; } });
|
|
@@ -14,6 +14,7 @@ var filter_js_1 = require("./filter.js");
|
|
|
14
14
|
Object.defineProperty(exports, "getLevelFilter", { enumerable: true, get: function () { return filter_js_1.getLevelFilter; } });
|
|
15
15
|
Object.defineProperty(exports, "toFilter", { enumerable: true, get: function () { return filter_js_1.toFilter; } });
|
|
16
16
|
var formatter_js_1 = require("./formatter.js");
|
|
17
|
+
Object.defineProperty(exports, "ansiColorFormatter", { enumerable: true, get: function () { return formatter_js_1.ansiColorFormatter; } });
|
|
17
18
|
Object.defineProperty(exports, "defaultConsoleFormatter", { enumerable: true, get: function () { return formatter_js_1.defaultConsoleFormatter; } });
|
|
18
19
|
Object.defineProperty(exports, "defaultTextFormatter", { enumerable: true, get: function () { return formatter_js_1.defaultTextFormatter; } });
|
|
19
20
|
var level_js_1 = require("./level.js");
|
package/script/sink.js
CHANGED
|
@@ -80,17 +80,33 @@ function getConsoleSink(options = {}) {
|
|
|
80
80
|
const console = options.console ?? globalThis.console;
|
|
81
81
|
return (record) => {
|
|
82
82
|
const args = formatter(record);
|
|
83
|
-
if (
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
83
|
+
if (typeof args === "string") {
|
|
84
|
+
const msg = args.replace(/\r?\n$/, "");
|
|
85
|
+
if (record.level === "debug")
|
|
86
|
+
console.debug(msg);
|
|
87
|
+
else if (record.level === "info")
|
|
88
|
+
console.info(msg);
|
|
89
|
+
else if (record.level === "warning")
|
|
90
|
+
console.warn(msg);
|
|
91
|
+
else if (record.level === "error" || record.level === "fatal") {
|
|
92
|
+
console.error(msg);
|
|
93
|
+
}
|
|
94
|
+
else
|
|
95
|
+
throw new TypeError(`Invalid log level: ${record.level}.`);
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
if (record.level === "debug")
|
|
99
|
+
console.debug(...args);
|
|
100
|
+
else if (record.level === "info")
|
|
101
|
+
console.info(...args);
|
|
102
|
+
else if (record.level === "warning")
|
|
103
|
+
console.warn(...args);
|
|
104
|
+
else if (record.level === "error" || record.level === "fatal") {
|
|
105
|
+
console.error(...args);
|
|
106
|
+
}
|
|
107
|
+
else
|
|
108
|
+
throw new TypeError(`Invalid log level: ${record.level}.`);
|
|
91
109
|
}
|
|
92
|
-
else
|
|
93
|
-
throw new TypeError(`Invalid log level: ${record.level}.`);
|
|
94
110
|
};
|
|
95
111
|
}
|
|
96
112
|
/**
|
package/types/config.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export interface Config<TSinkId extends string, TFilterId extends string> {
|
|
|
14
14
|
* The filters to use. The keys are the filter identifiers, and the values
|
|
15
15
|
* are either {@link Filter}s or {@link LogLevel}s.
|
|
16
16
|
*/
|
|
17
|
-
filters
|
|
17
|
+
filters?: Record<TFilterId, FilterLike>;
|
|
18
18
|
/**
|
|
19
19
|
* The loggers to configure.
|
|
20
20
|
*/
|
package/types/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAAY,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,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;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAAY,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,EAAkB,KAAK,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtD;;G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|
package/types/formatter.d.ts
CHANGED
|
@@ -18,6 +18,16 @@ export type TextFormatter = (record: LogRecord) => string;
|
|
|
18
18
|
* @returns The formatted log record.
|
|
19
19
|
*/
|
|
20
20
|
export declare function defaultTextFormatter(record: LogRecord): string;
|
|
21
|
+
/**
|
|
22
|
+
* A text formatter that uses ANSI colors to format log records.
|
|
23
|
+
*
|
|
24
|
+
* 
|
|
25
|
+
*
|
|
26
|
+
* @param record The log record to format.
|
|
27
|
+
* @returns The formatted log record.
|
|
28
|
+
* @since 0.5.0
|
|
29
|
+
*/
|
|
30
|
+
export declare const ansiColorFormatter: TextFormatter;
|
|
21
31
|
/**
|
|
22
32
|
* A console formatter is a function that accepts a log record and returns
|
|
23
33
|
* an array of arguments to pass to {@link console.log}.
|
package/types/formatter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AAsC1D;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAW9D;AAcD;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,EAAE,aAqBhC,CAAC;AAEF;;;;;;;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/mod.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { type Config, ConfigError, configure, dispose, getConfig, type LoggerConfig, reset, } from "./config.js";
|
|
2
2
|
export { getFileSink, getRotatingFileSink } from "./filesink.node.js";
|
|
3
3
|
export { type Filter, type FilterLike, getLevelFilter, toFilter, } from "./filter.js";
|
|
4
|
-
export { type ConsoleFormatter, defaultConsoleFormatter, defaultTextFormatter, type TextFormatter, } from "./formatter.js";
|
|
4
|
+
export { ansiColorFormatter, type ConsoleFormatter, defaultConsoleFormatter, defaultTextFormatter, type TextFormatter, } from "./formatter.js";
|
|
5
5
|
export { isLogLevel, type LogLevel, parseLogLevel } from "./level.js";
|
|
6
6
|
export { getLogger, type Logger } from "./logger.js";
|
|
7
7
|
export type { LogRecord } from "./record.js";
|
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,OAAO,EACP,SAAS,EACT,KAAK,YAAY,EACjB,KAAK,GACN,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACtE,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,UAAU,EAAE,KAAK,QAAQ,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AACrD,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,cAAc,EACd,aAAa,EACb,KAAK,uBAAuB,EAC5B,KAAK,IAAI,EACT,KAAK,iBAAiB,EACtB,UAAU,GACX,MAAM,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EACX,WAAW,EACX,SAAS,EACT,OAAO,EACP,SAAS,EACT,KAAK,YAAY,EACjB,KAAK,GACN,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EACL,KAAK,MAAM,EACX,KAAK,UAAU,EACf,cAAc,EACd,QAAQ,GACT,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,kBAAkB,EAClB,KAAK,gBAAgB,EACrB,uBAAuB,EACvB,oBAAoB,EACpB,KAAK,aAAa,GACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,KAAK,QAAQ,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AACrD,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,cAAc,EACd,aAAa,EACb,KAAK,uBAAuB,EAC5B,KAAK,IAAI,EACT,KAAK,iBAAiB,EACtB,UAAU,GACX,MAAM,WAAW,CAAC"}
|
package/types/sink.d.ts
CHANGED
|
@@ -71,9 +71,10 @@ export declare function getStreamSink(stream: WritableStream, options?: StreamSi
|
|
|
71
71
|
*/
|
|
72
72
|
export interface ConsoleSinkOptions {
|
|
73
73
|
/**
|
|
74
|
-
* The console formatter
|
|
74
|
+
* The console formatter or text formatter to use.
|
|
75
|
+
* Defaults to {@link defaultConsoleFormatter}.
|
|
75
76
|
*/
|
|
76
|
-
formatter?: ConsoleFormatter;
|
|
77
|
+
formatter?: ConsoleFormatter | TextFormatter;
|
|
77
78
|
/**
|
|
78
79
|
* The console to log to. Defaults to {@link console}.
|
|
79
80
|
*/
|
package/types/sink.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,CAAC;CAChD;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,cAAc,EACtB,OAAO,GAAE,iBAAsB,GAC9B,IAAI,GAAG,eAAe,CAgBxB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC
|
|
1
|
+
{"version":3,"file":"sink.d.ts","sourceRoot":"","sources":["../src/sink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAY,MA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