@logtape/logtape 0.3.0-dev.24 → 0.3.0-dev.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -5
- package/esm/config.js +20 -5
- package/esm/level.js +39 -0
- package/esm/mod.js +2 -1
- package/package.json +1 -1
- package/script/config.js +22 -6
- package/script/level.js +44 -0
- package/script/mod.js +5 -1
- package/types/config.d.ts +6 -1
- package/types/config.d.ts.map +1 -1
- package/types/filter.d.ts +2 -1
- package/types/filter.d.ts.map +1 -1
- package/types/formatter.d.ts.map +1 -1
- package/types/level.d.ts +21 -0
- package/types/level.d.ts.map +1 -0
- package/types/level.test.d.ts.map +1 -0
- package/types/logger.d.ts +2 -1
- package/types/logger.d.ts.map +1 -1
- package/types/mod.d.ts +3 -2
- package/types/mod.d.ts.map +1 -1
- package/types/record.d.ts +1 -4
- package/types/record.d.ts.map +1 -1
package/README.md
CHANGED
|
@@ -27,9 +27,7 @@ The highlights of LogTape are:
|
|
|
27
27
|
and browsers. You can use LogTape in various environments without
|
|
28
28
|
changing the code.
|
|
29
29
|
|
|
30
|
-
- *Structured logging*:
|
|
31
|
-
messages with structured data. LogTape provides a simple and flexible
|
|
32
|
-
way to log structured data.
|
|
30
|
+
- *Structured logging*: You can log messages with structured data.
|
|
33
31
|
|
|
34
32
|
- *Hierarchical categories*: LogTape uses a hierarchical category system
|
|
35
33
|
to manage loggers. You can control the verbosity of log messages by
|
|
@@ -40,8 +38,7 @@ The highlights of LogTape are:
|
|
|
40
38
|
You can use template literals to log messages with placeholders and
|
|
41
39
|
values.
|
|
42
40
|
|
|
43
|
-
- *Dead simple sinks*:
|
|
44
|
-
sinks. You can easily add your own sinks to LogTape.
|
|
41
|
+
- *Dead simple sinks*: You can easily add your own sinks to LogTape.
|
|
45
42
|
|
|
46
43
|
Currently, LogTape provides only few sinks, but [you can easily add your own
|
|
47
44
|
sinks.](#sinks)
|
package/esm/config.js
CHANGED
|
@@ -3,9 +3,15 @@ import { toFilter } from "./filter.js";
|
|
|
3
3
|
import { LoggerImpl } from "./logger.js";
|
|
4
4
|
import { getConsoleSink } from "./sink.js";
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* The current configuration, if any. Otherwise, `null`.
|
|
7
7
|
*/
|
|
8
|
-
let
|
|
8
|
+
let currentConfig = null;
|
|
9
|
+
/**
|
|
10
|
+
* Strong references to the loggers.
|
|
11
|
+
* This is to prevent the loggers from being garbage collected so that their
|
|
12
|
+
* sinks and filters are not removed.
|
|
13
|
+
*/
|
|
14
|
+
const strongRefs = new Set();
|
|
9
15
|
/**
|
|
10
16
|
* Disposables to dispose when resetting the configuration.
|
|
11
17
|
*/
|
|
@@ -54,11 +60,11 @@ const asyncDisposables = new Set();
|
|
|
54
60
|
* @param config The configuration.
|
|
55
61
|
*/
|
|
56
62
|
export async function configure(config) {
|
|
57
|
-
if (
|
|
63
|
+
if (currentConfig != null && !config.reset) {
|
|
58
64
|
throw new ConfigError("Already configured; if you want to reset, turn on the reset flag.");
|
|
59
65
|
}
|
|
60
66
|
await reset();
|
|
61
|
-
|
|
67
|
+
currentConfig = config;
|
|
62
68
|
let metaConfigured = false;
|
|
63
69
|
for (const cfg of config.loggers) {
|
|
64
70
|
if (cfg.category.length === 0 ||
|
|
@@ -87,6 +93,7 @@ export async function configure(config) {
|
|
|
87
93
|
}
|
|
88
94
|
logger.filters.push(toFilter(filter));
|
|
89
95
|
}
|
|
96
|
+
strongRefs.add(logger);
|
|
90
97
|
}
|
|
91
98
|
for (const sink of Object.values(config.sinks)) {
|
|
92
99
|
if (Symbol.asyncDispose in sink) {
|
|
@@ -123,13 +130,21 @@ export async function configure(config) {
|
|
|
123
130
|
"misconfigured. To turn off this message, configure the meta logger " +
|
|
124
131
|
"with higher log levels than {dismissLevel}.", { metaLoggerCategory: ["logtape", "meta"], dismissLevel: "info" });
|
|
125
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* Get the current configuration, if any. Otherwise, `null`.
|
|
135
|
+
* @returns The current configuration, if any. Otherwise, `null`.
|
|
136
|
+
*/
|
|
137
|
+
export function getConfig() {
|
|
138
|
+
return currentConfig;
|
|
139
|
+
}
|
|
126
140
|
/**
|
|
127
141
|
* Reset the configuration. Mostly for testing purposes.
|
|
128
142
|
*/
|
|
129
143
|
export async function reset() {
|
|
130
144
|
await dispose();
|
|
131
145
|
LoggerImpl.getLogger([]).resetDescendants();
|
|
132
|
-
|
|
146
|
+
strongRefs.clear();
|
|
147
|
+
currentConfig = null;
|
|
133
148
|
}
|
|
134
149
|
/**
|
|
135
150
|
* Dispose of the disposables.
|
package/esm/level.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses a log level from a string.
|
|
3
|
+
*
|
|
4
|
+
* @param level The log level as a string. This is case-insensitive.
|
|
5
|
+
* @returns The log level.
|
|
6
|
+
* @throws {TypeError} If the log level is invalid.
|
|
7
|
+
*/
|
|
8
|
+
export function parseLogLevel(level) {
|
|
9
|
+
level = level.toLowerCase();
|
|
10
|
+
switch (level) {
|
|
11
|
+
case "debug":
|
|
12
|
+
case "info":
|
|
13
|
+
case "warning":
|
|
14
|
+
case "error":
|
|
15
|
+
case "fatal":
|
|
16
|
+
return level;
|
|
17
|
+
default:
|
|
18
|
+
throw new TypeError(`Invalid log level: ${level}.`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Checks if a string is a valid log level. This function can be used as
|
|
23
|
+
* as a type guard to narrow the type of a string to a {@link LogLevel}.
|
|
24
|
+
*
|
|
25
|
+
* @param level The log level as a string. This is case-sensitive.
|
|
26
|
+
* @returns `true` if the string is a valid log level.
|
|
27
|
+
*/
|
|
28
|
+
export function isLogLevel(level) {
|
|
29
|
+
switch (level) {
|
|
30
|
+
case "debug":
|
|
31
|
+
case "info":
|
|
32
|
+
case "warning":
|
|
33
|
+
case "error":
|
|
34
|
+
case "fatal":
|
|
35
|
+
return true;
|
|
36
|
+
default:
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}
|
package/esm/mod.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export { ConfigError, configure, dispose, reset, } from "./config.js";
|
|
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
4
|
export { defaultConsoleFormatter, defaultTextFormatter, } from "./formatter.js";
|
|
5
|
+
export { isLogLevel, parseLogLevel } from "./level.js";
|
|
5
6
|
export { getLogger } from "./logger.js";
|
|
6
7
|
export { getConsoleSink, getStreamSink, } from "./sink.js";
|
|
7
8
|
// cSpell: ignore filesink
|
package/package.json
CHANGED
package/script/config.js
CHANGED
|
@@ -23,15 +23,21 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.ConfigError = exports.dispose = exports.reset = exports.configure = void 0;
|
|
26
|
+
exports.ConfigError = exports.dispose = exports.reset = exports.getConfig = exports.configure = void 0;
|
|
27
27
|
const dntShim = __importStar(require("./_dnt.shims.js"));
|
|
28
28
|
const filter_js_1 = require("./filter.js");
|
|
29
29
|
const logger_js_1 = require("./logger.js");
|
|
30
30
|
const sink_js_1 = require("./sink.js");
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
32
|
+
* The current configuration, if any. Otherwise, `null`.
|
|
33
33
|
*/
|
|
34
|
-
let
|
|
34
|
+
let currentConfig = null;
|
|
35
|
+
/**
|
|
36
|
+
* Strong references to the loggers.
|
|
37
|
+
* This is to prevent the loggers from being garbage collected so that their
|
|
38
|
+
* sinks and filters are not removed.
|
|
39
|
+
*/
|
|
40
|
+
const strongRefs = new Set();
|
|
35
41
|
/**
|
|
36
42
|
* Disposables to dispose when resetting the configuration.
|
|
37
43
|
*/
|
|
@@ -80,11 +86,11 @@ const asyncDisposables = new Set();
|
|
|
80
86
|
* @param config The configuration.
|
|
81
87
|
*/
|
|
82
88
|
async function configure(config) {
|
|
83
|
-
if (
|
|
89
|
+
if (currentConfig != null && !config.reset) {
|
|
84
90
|
throw new ConfigError("Already configured; if you want to reset, turn on the reset flag.");
|
|
85
91
|
}
|
|
86
92
|
await reset();
|
|
87
|
-
|
|
93
|
+
currentConfig = config;
|
|
88
94
|
let metaConfigured = false;
|
|
89
95
|
for (const cfg of config.loggers) {
|
|
90
96
|
if (cfg.category.length === 0 ||
|
|
@@ -113,6 +119,7 @@ async function configure(config) {
|
|
|
113
119
|
}
|
|
114
120
|
logger.filters.push((0, filter_js_1.toFilter)(filter));
|
|
115
121
|
}
|
|
122
|
+
strongRefs.add(logger);
|
|
116
123
|
}
|
|
117
124
|
for (const sink of Object.values(config.sinks)) {
|
|
118
125
|
if (Symbol.asyncDispose in sink) {
|
|
@@ -150,13 +157,22 @@ async function configure(config) {
|
|
|
150
157
|
"with higher log levels than {dismissLevel}.", { metaLoggerCategory: ["logtape", "meta"], dismissLevel: "info" });
|
|
151
158
|
}
|
|
152
159
|
exports.configure = configure;
|
|
160
|
+
/**
|
|
161
|
+
* Get the current configuration, if any. Otherwise, `null`.
|
|
162
|
+
* @returns The current configuration, if any. Otherwise, `null`.
|
|
163
|
+
*/
|
|
164
|
+
function getConfig() {
|
|
165
|
+
return currentConfig;
|
|
166
|
+
}
|
|
167
|
+
exports.getConfig = getConfig;
|
|
153
168
|
/**
|
|
154
169
|
* Reset the configuration. Mostly for testing purposes.
|
|
155
170
|
*/
|
|
156
171
|
async function reset() {
|
|
157
172
|
await dispose();
|
|
158
173
|
logger_js_1.LoggerImpl.getLogger([]).resetDescendants();
|
|
159
|
-
|
|
174
|
+
strongRefs.clear();
|
|
175
|
+
currentConfig = null;
|
|
160
176
|
}
|
|
161
177
|
exports.reset = reset;
|
|
162
178
|
/**
|
package/script/level.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isLogLevel = exports.parseLogLevel = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Parses a log level from a string.
|
|
6
|
+
*
|
|
7
|
+
* @param level The log level as a string. This is case-insensitive.
|
|
8
|
+
* @returns The log level.
|
|
9
|
+
* @throws {TypeError} If the log level is invalid.
|
|
10
|
+
*/
|
|
11
|
+
function parseLogLevel(level) {
|
|
12
|
+
level = level.toLowerCase();
|
|
13
|
+
switch (level) {
|
|
14
|
+
case "debug":
|
|
15
|
+
case "info":
|
|
16
|
+
case "warning":
|
|
17
|
+
case "error":
|
|
18
|
+
case "fatal":
|
|
19
|
+
return level;
|
|
20
|
+
default:
|
|
21
|
+
throw new TypeError(`Invalid log level: ${level}.`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.parseLogLevel = parseLogLevel;
|
|
25
|
+
/**
|
|
26
|
+
* Checks if a string is a valid log level. This function can be used as
|
|
27
|
+
* as a type guard to narrow the type of a string to a {@link LogLevel}.
|
|
28
|
+
*
|
|
29
|
+
* @param level The log level as a string. This is case-sensitive.
|
|
30
|
+
* @returns `true` if the string is a valid log level.
|
|
31
|
+
*/
|
|
32
|
+
function isLogLevel(level) {
|
|
33
|
+
switch (level) {
|
|
34
|
+
case "debug":
|
|
35
|
+
case "info":
|
|
36
|
+
case "warning":
|
|
37
|
+
case "error":
|
|
38
|
+
case "fatal":
|
|
39
|
+
return true;
|
|
40
|
+
default:
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.isLogLevel = isLogLevel;
|
package/script/mod.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getStreamSink = exports.getConsoleSink = exports.getLogger = exports.defaultTextFormatter = exports.defaultConsoleFormatter = exports.toFilter = exports.getLevelFilter = exports.getRotatingFileSink = exports.getFileSink = exports.reset = exports.dispose = exports.configure = exports.ConfigError = void 0;
|
|
3
|
+
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;
|
|
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
7
|
Object.defineProperty(exports, "dispose", { enumerable: true, get: function () { return config_js_1.dispose; } });
|
|
8
|
+
Object.defineProperty(exports, "getConfig", { enumerable: true, get: function () { return config_js_1.getConfig; } });
|
|
8
9
|
Object.defineProperty(exports, "reset", { enumerable: true, get: function () { return config_js_1.reset; } });
|
|
9
10
|
var filesink_node_js_1 = require("./filesink.node.js");
|
|
10
11
|
Object.defineProperty(exports, "getFileSink", { enumerable: true, get: function () { return filesink_node_js_1.getFileSink; } });
|
|
@@ -15,6 +16,9 @@ Object.defineProperty(exports, "toFilter", { enumerable: true, get: function ()
|
|
|
15
16
|
var formatter_js_1 = require("./formatter.js");
|
|
16
17
|
Object.defineProperty(exports, "defaultConsoleFormatter", { enumerable: true, get: function () { return formatter_js_1.defaultConsoleFormatter; } });
|
|
17
18
|
Object.defineProperty(exports, "defaultTextFormatter", { enumerable: true, get: function () { return formatter_js_1.defaultTextFormatter; } });
|
|
19
|
+
var level_js_1 = require("./level.js");
|
|
20
|
+
Object.defineProperty(exports, "isLogLevel", { enumerable: true, get: function () { return level_js_1.isLogLevel; } });
|
|
21
|
+
Object.defineProperty(exports, "parseLogLevel", { enumerable: true, get: function () { return level_js_1.parseLogLevel; } });
|
|
18
22
|
var logger_js_1 = require("./logger.js");
|
|
19
23
|
Object.defineProperty(exports, "getLogger", { enumerable: true, get: function () { return logger_js_1.getLogger; } });
|
|
20
24
|
var sink_js_1 = require("./sink.js");
|
package/types/config.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type FilterLike } from "./filter.js";
|
|
2
|
-
import type { LogLevel } from "./
|
|
2
|
+
import type { LogLevel } from "./level.js";
|
|
3
3
|
import { type Sink } from "./sink.js";
|
|
4
4
|
/**
|
|
5
5
|
* A configuration for the loggers.
|
|
@@ -87,6 +87,11 @@ export interface LoggerConfig<TSinkId extends string, TFilterId extends string>
|
|
|
87
87
|
* @param config The configuration.
|
|
88
88
|
*/
|
|
89
89
|
export declare function configure<TSinkId extends string, TFilterId extends string>(config: Config<TSinkId, TFilterId>): Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Get the current configuration, if any. Otherwise, `null`.
|
|
92
|
+
* @returns The current configuration, if any. Otherwise, `null`.
|
|
93
|
+
*/
|
|
94
|
+
export declare function getConfig(): Config<string, string> | null;
|
|
90
95
|
/**
|
|
91
96
|
* Reset the configuration. Mostly for testing purposes.
|
|
92
97
|
*/
|
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;
|
|
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;I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
import type { LogLevel } from "./level.js";
|
|
2
|
+
import type { LogRecord } from "./record.js";
|
|
2
3
|
/**
|
|
3
4
|
* A filter is a function that accepts a log record and returns `true` if the
|
|
4
5
|
* record should be passed to the sink.
|
package/types/filter.d.ts.map
CHANGED
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../src/filter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;;;;;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"}
|
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":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;;;;;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,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/level.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The severity level of a {@link LogRecord}.
|
|
3
|
+
*/
|
|
4
|
+
export type LogLevel = "debug" | "info" | "warning" | "error" | "fatal";
|
|
5
|
+
/**
|
|
6
|
+
* Parses a log level from a string.
|
|
7
|
+
*
|
|
8
|
+
* @param level The log level as a string. This is case-insensitive.
|
|
9
|
+
* @returns The log level.
|
|
10
|
+
* @throws {TypeError} If the log level is invalid.
|
|
11
|
+
*/
|
|
12
|
+
export declare function parseLogLevel(level: string): LogLevel;
|
|
13
|
+
/**
|
|
14
|
+
* Checks if a string is a valid log level. This function can be used as
|
|
15
|
+
* as a type guard to narrow the type of a string to a {@link LogLevel}.
|
|
16
|
+
*
|
|
17
|
+
* @param level The log level as a string. This is case-sensitive.
|
|
18
|
+
* @returns `true` if the string is a valid log level.
|
|
19
|
+
*/
|
|
20
|
+
export declare function isLogLevel(level: string): level is LogLevel;
|
|
21
|
+
//# sourceMappingURL=level.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"level.d.ts","sourceRoot":"","sources":["../src/level.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CAAC;AAExE;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAYrD;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,QAAQ,CAW3D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"level.test.d.ts","sourceRoot":"","sources":["../src/level.test.ts"],"names":[],"mappings":""}
|
package/types/logger.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Filter } from "./filter.js";
|
|
2
|
-
import type { LogLevel
|
|
2
|
+
import type { LogLevel } from "./level.js";
|
|
3
|
+
import type { LogRecord } from "./record.js";
|
|
3
4
|
import type { Sink } from "./sink.js";
|
|
4
5
|
/**
|
|
5
6
|
* A logger interface. It provides methods to log messages at different
|
package/types/logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,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,CAAC;IAErC;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAE/B;;;;;;;;;;;;;;;;;OAiBG;IACH,QAAQ,CACN,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,G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,EAAE,GAChB,IAAI;IAUP,KAAK,CACH,OAAO,EAAE,oBAAoB,GAAG,MAAM,GAAG,WAAW,EACpD,GAAG,MAAM,EAAE,OAAO,EAAE,GACnB,IAAI;IAUP,IAAI,CACF,OAAO,EAAE,oBAAoB,GAAG,MAAM,GAAG,WAAW,EACpD,GAAG,MAAM,EAAE,OAAO,EAAE,GACnB,IAAI;IAUP,IAAI,CACF,OAAO,EAAE,oBAAoB,GAAG,MAAM,GAAG,WAAW,EACpD,GAAG,MAAM,EAAE,OAAO,EAAE,GACnB,IAAI;IAcP,KAAK,CACH,OAAO,EAAE,oBAAoB,GAAG,MAAM,GAAG,WAAW,EACpD,GAAG,MAAM,EAAE,OAAO,EAAE,GACnB,IAAI;IAUP,KAAK,CACH,OAAO,EAAE,oBAAoB,GAAG,MAAM,GAAG,WAAW,EACpD,GAAG,MAAM,EAAE,OAAO,EAAE,GACnB,IAAI;CASR;AASD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAClC,SAAS,OAAO,EAAE,CAepB;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,oBAAoB,EAC9B,MAAM,EAAE,SAAS,OAAO,EAAE,GACzB,OAAO,EAAE,CAOX"}
|
package/types/mod.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export { type Config, ConfigError, configure, dispose, type LoggerConfig, reset, } from "./config.js";
|
|
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
4
|
export { type ConsoleFormatter, defaultConsoleFormatter, defaultTextFormatter, type TextFormatter, } from "./formatter.js";
|
|
5
|
+
export { isLogLevel, type LogLevel, parseLogLevel } from "./level.js";
|
|
5
6
|
export { getLogger, type Logger } from "./logger.js";
|
|
6
|
-
export type {
|
|
7
|
+
export type { LogRecord } from "./record.js";
|
|
7
8
|
export { type ConsoleSinkOptions, type FileSinkOptions, getConsoleSink, getStreamSink, type RotatingFileSinkOptions, type Sink, type StreamSinkOptions, } from "./sink.js";
|
|
8
9
|
//# 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,OAAO,EACP,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,SAAS,EAAE,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AACrD,YAAY,EAAE,
|
|
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,GACvB,MAAM,WAAW,CAAC"}
|
package/types/record.d.ts
CHANGED
package/types/record.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../src/record.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../src/record.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IAErC;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IAEzB;;;;;OAKG;IACH,QAAQ,CAAC,OAAO,EAAE,SAAS,OAAO,EAAE,CAAC;IAErC;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC9C"}
|