@logtape/logtape 0.9.0-dev.128 → 0.9.0-dev.132
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 +1 -1
- package/esm/mod.js +0 -1
- package/esm/sink.js +14 -99
- package/package.json +3 -2
- package/script/config.js +1 -1
- package/script/mod.js +1 -4
- package/script/sink.js +14 -101
- package/types/mod.d.ts +1 -2
- package/types/mod.d.ts.map +1 -1
- package/types/sink.d.ts +18 -87
- package/types/sink.d.ts.map +1 -1
- package/esm/filesink.node.js +0 -60
- package/esm/filesink.web.js +0 -14
- package/esm/fs.cjs +0 -20
- package/esm/fs.js +0 -2
- package/script/filesink.node.js +0 -91
- package/script/filesink.web.js +0 -17
- package/script/fs.js +0 -20
- package/types/deps/deno.land/x/which_runtime@0.2.0/mod.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/path/1.0.8/_common/assert_path.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/path/1.0.8/_common/constants.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/path/1.0.8/_common/normalize.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/path/1.0.8/_common/normalize_string.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/path/1.0.8/_os.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/path/1.0.8/join.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/path/1.0.8/posix/_util.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/path/1.0.8/posix/join.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/path/1.0.8/posix/normalize.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/path/1.0.8/windows/_util.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/path/1.0.8/windows/join.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/path/1.0.8/windows/normalize.d.ts.map +0 -1
- package/types/filesink.node.d.ts +0 -33
- package/types/filesink.node.d.ts.map +0 -1
- package/types/filesink.test.d.ts.map +0 -1
- package/types/filesink.web.d.ts +0 -6
- package/types/filesink.web.d.ts.map +0 -1
- package/types/fs.d.ts +0 -2
- package/types/fs.d.ts.map +0 -1
package/esm/config.js
CHANGED
|
@@ -208,7 +208,7 @@ function configureInternal(config, allowAsync) {
|
|
|
208
208
|
meta.info("LogTape loggers are configured. Note that LogTape itself uses the meta " +
|
|
209
209
|
"logger, which has category {metaLoggerCategory}. The meta logger " +
|
|
210
210
|
"purposes to log internal errors such as sink exceptions. If you " +
|
|
211
|
-
"are seeing this message, the meta logger is
|
|
211
|
+
"are seeing this message, the meta logger is automatically configured. " +
|
|
212
212
|
"It's recommended to configure the meta logger with a separate sink " +
|
|
213
213
|
"so that you can easily notice if logging itself fails or is " +
|
|
214
214
|
"misconfigured. To turn off this message, configure the meta logger " +
|
package/esm/mod.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { ConfigError, configure, configureSync, dispose, disposeSync, getConfig, reset, resetSync, } from "./config.js";
|
|
2
2
|
export { withContext } from "./context.js";
|
|
3
|
-
export { getFileSink, getRotatingFileSink } from "./filesink.node.js";
|
|
4
3
|
export { getLevelFilter, toFilter, } from "./filter.js";
|
|
5
4
|
export { ansiColorFormatter, defaultConsoleFormatter, defaultTextFormatter, getAnsiColorFormatter, getTextFormatter, } from "./formatter.js";
|
|
6
5
|
export { compareLogLevel, isLogLevel, parseLogLevel, } from "./level.js";
|
package/esm/sink.js
CHANGED
|
@@ -70,112 +70,27 @@ export function getStreamSink(stream, options = {}) {
|
|
|
70
70
|
*/
|
|
71
71
|
export function getConsoleSink(options = {}) {
|
|
72
72
|
const formatter = options.formatter ?? defaultConsoleFormatter;
|
|
73
|
+
const levelMap = {
|
|
74
|
+
debug: "debug",
|
|
75
|
+
info: "info",
|
|
76
|
+
warning: "warn",
|
|
77
|
+
error: "error",
|
|
78
|
+
fatal: "error",
|
|
79
|
+
...(options.levelMap ?? {}),
|
|
80
|
+
};
|
|
73
81
|
const console = options.console ?? globalThis.console;
|
|
74
82
|
return (record) => {
|
|
75
83
|
const args = formatter(record);
|
|
84
|
+
const method = levelMap[record.level];
|
|
85
|
+
if (method === undefined) {
|
|
86
|
+
throw new TypeError(`Invalid log level: ${record.level}.`);
|
|
87
|
+
}
|
|
76
88
|
if (typeof args === "string") {
|
|
77
89
|
const msg = args.replace(/\r?\n$/, "");
|
|
78
|
-
|
|
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}.`);
|
|
90
|
+
console[method](msg);
|
|
89
91
|
}
|
|
90
92
|
else {
|
|
91
|
-
|
|
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}.`);
|
|
93
|
+
console[method](...args);
|
|
102
94
|
}
|
|
103
95
|
};
|
|
104
96
|
}
|
|
105
|
-
/**
|
|
106
|
-
* Get a platform-independent file sink.
|
|
107
|
-
*
|
|
108
|
-
* @typeParam TFile The type of the file descriptor.
|
|
109
|
-
* @param path A path to the file to write to.
|
|
110
|
-
* @param options The options for the sink and the file driver.
|
|
111
|
-
* @returns A sink that writes to the file. The sink is also a disposable
|
|
112
|
-
* object that closes the file when disposed.
|
|
113
|
-
*/
|
|
114
|
-
export function getFileSink(path, options) {
|
|
115
|
-
const formatter = options.formatter ?? defaultTextFormatter;
|
|
116
|
-
const encoder = options.encoder ?? new TextEncoder();
|
|
117
|
-
const fd = options.openSync(path);
|
|
118
|
-
const sink = (record) => {
|
|
119
|
-
options.writeSync(fd, encoder.encode(formatter(record)));
|
|
120
|
-
options.flushSync(fd);
|
|
121
|
-
};
|
|
122
|
-
sink[Symbol.dispose] = () => options.closeSync(fd);
|
|
123
|
-
return sink;
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Get a platform-independent rotating file sink.
|
|
127
|
-
*
|
|
128
|
-
* This sink writes log records to a file, and rotates the file when it reaches
|
|
129
|
-
* the `maxSize`. The rotated files are named with the original file name
|
|
130
|
-
* followed by a dot and a number, starting from 1. The number is incremented
|
|
131
|
-
* for each rotation, and the maximum number of files to keep is `maxFiles`.
|
|
132
|
-
*
|
|
133
|
-
* @param path A path to the file to write to.
|
|
134
|
-
* @param options The options for the sink and the file driver.
|
|
135
|
-
* @returns A sink that writes to the file. The sink is also a disposable
|
|
136
|
-
* object that closes the file when disposed.
|
|
137
|
-
*/
|
|
138
|
-
export function getRotatingFileSink(path, options) {
|
|
139
|
-
const formatter = options.formatter ?? defaultTextFormatter;
|
|
140
|
-
const encoder = options.encoder ?? new TextEncoder();
|
|
141
|
-
const maxSize = options.maxSize ?? 1024 * 1024;
|
|
142
|
-
const maxFiles = options.maxFiles ?? 5;
|
|
143
|
-
let offset = 0;
|
|
144
|
-
try {
|
|
145
|
-
const stat = options.statSync(path);
|
|
146
|
-
offset = stat.size;
|
|
147
|
-
}
|
|
148
|
-
catch {
|
|
149
|
-
// Continue as the offset is already 0.
|
|
150
|
-
}
|
|
151
|
-
let fd = options.openSync(path);
|
|
152
|
-
function shouldRollover(bytes) {
|
|
153
|
-
return offset + bytes.length > maxSize;
|
|
154
|
-
}
|
|
155
|
-
function performRollover() {
|
|
156
|
-
options.closeSync(fd);
|
|
157
|
-
for (let i = maxFiles - 1; i > 0; i--) {
|
|
158
|
-
const oldPath = `${path}.${i}`;
|
|
159
|
-
const newPath = `${path}.${i + 1}`;
|
|
160
|
-
try {
|
|
161
|
-
options.renameSync(oldPath, newPath);
|
|
162
|
-
}
|
|
163
|
-
catch (_) {
|
|
164
|
-
// Continue if the file does not exist.
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
options.renameSync(path, `${path}.1`);
|
|
168
|
-
offset = 0;
|
|
169
|
-
fd = options.openSync(path);
|
|
170
|
-
}
|
|
171
|
-
const sink = (record) => {
|
|
172
|
-
const bytes = encoder.encode(formatter(record));
|
|
173
|
-
if (shouldRollover(bytes))
|
|
174
|
-
performRollover();
|
|
175
|
-
options.writeSync(fd, bytes);
|
|
176
|
-
options.flushSync(fd);
|
|
177
|
-
offset += bytes.length;
|
|
178
|
-
};
|
|
179
|
-
sink[Symbol.dispose] = () => options.closeSync(fd);
|
|
180
|
-
return sink;
|
|
181
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logtape/logtape",
|
|
3
|
-
"version": "0.9.0-dev.
|
|
3
|
+
"version": "0.9.0-dev.132+7c6dd185",
|
|
4
4
|
"description": "Simple logging library with zero dependencies for Deno/Node.js/Bun/browsers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"logging",
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
"homepage": "https://logtape.org/",
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
18
|
-
"url": "git+https://github.com/dahlia/logtape.git"
|
|
18
|
+
"url": "git+https://github.com/dahlia/logtape.git",
|
|
19
|
+
"directory": "logtape/"
|
|
19
20
|
},
|
|
20
21
|
"license": "MIT",
|
|
21
22
|
"bugs": {
|
package/script/config.js
CHANGED
|
@@ -241,7 +241,7 @@ function configureInternal(config, allowAsync) {
|
|
|
241
241
|
meta.info("LogTape loggers are configured. Note that LogTape itself uses the meta " +
|
|
242
242
|
"logger, which has category {metaLoggerCategory}. The meta logger " +
|
|
243
243
|
"purposes to log internal errors such as sink exceptions. If you " +
|
|
244
|
-
"are seeing this message, the meta logger is
|
|
244
|
+
"are seeing this message, the meta logger is automatically configured. " +
|
|
245
245
|
"It's recommended to configure the meta logger with a separate sink " +
|
|
246
246
|
"so that you can easily notice if logging itself fails or is " +
|
|
247
247
|
"misconfigured. To turn off this message, configure the meta logger " +
|
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.compareLogLevel = exports.getTextFormatter = exports.getAnsiColorFormatter = exports.defaultTextFormatter = exports.defaultConsoleFormatter = exports.ansiColorFormatter = exports.toFilter = exports.getLevelFilter = exports.
|
|
3
|
+
exports.withFilter = exports.getStreamSink = exports.getConsoleSink = exports.getLogger = exports.parseLogLevel = exports.isLogLevel = exports.compareLogLevel = exports.getTextFormatter = exports.getAnsiColorFormatter = exports.defaultTextFormatter = exports.defaultConsoleFormatter = exports.ansiColorFormatter = exports.toFilter = exports.getLevelFilter = exports.withContext = exports.resetSync = exports.reset = exports.getConfig = exports.disposeSync = exports.dispose = exports.configureSync = 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; } });
|
|
@@ -12,9 +12,6 @@ Object.defineProperty(exports, "reset", { enumerable: true, get: function () { r
|
|
|
12
12
|
Object.defineProperty(exports, "resetSync", { enumerable: true, get: function () { return config_js_1.resetSync; } });
|
|
13
13
|
var context_js_1 = require("./context.js");
|
|
14
14
|
Object.defineProperty(exports, "withContext", { enumerable: true, get: function () { return context_js_1.withContext; } });
|
|
15
|
-
var filesink_node_js_1 = require("./filesink.node.js");
|
|
16
|
-
Object.defineProperty(exports, "getFileSink", { enumerable: true, get: function () { return filesink_node_js_1.getFileSink; } });
|
|
17
|
-
Object.defineProperty(exports, "getRotatingFileSink", { enumerable: true, get: function () { return filesink_node_js_1.getRotatingFileSink; } });
|
|
18
15
|
var filter_js_1 = require("./filter.js");
|
|
19
16
|
Object.defineProperty(exports, "getLevelFilter", { enumerable: true, get: function () { return filter_js_1.getLevelFilter; } });
|
|
20
17
|
Object.defineProperty(exports, "toFilter", { enumerable: true, get: function () { return filter_js_1.toFilter; } });
|
package/script/sink.js
CHANGED
|
@@ -3,8 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.withFilter = withFilter;
|
|
4
4
|
exports.getStreamSink = getStreamSink;
|
|
5
5
|
exports.getConsoleSink = getConsoleSink;
|
|
6
|
-
exports.getFileSink = getFileSink;
|
|
7
|
-
exports.getRotatingFileSink = getRotatingFileSink;
|
|
8
6
|
const filter_js_1 = require("./filter.js");
|
|
9
7
|
const formatter_js_1 = require("./formatter.js");
|
|
10
8
|
/**
|
|
@@ -77,112 +75,27 @@ function getStreamSink(stream, options = {}) {
|
|
|
77
75
|
*/
|
|
78
76
|
function getConsoleSink(options = {}) {
|
|
79
77
|
const formatter = options.formatter ?? formatter_js_1.defaultConsoleFormatter;
|
|
78
|
+
const levelMap = {
|
|
79
|
+
debug: "debug",
|
|
80
|
+
info: "info",
|
|
81
|
+
warning: "warn",
|
|
82
|
+
error: "error",
|
|
83
|
+
fatal: "error",
|
|
84
|
+
...(options.levelMap ?? {}),
|
|
85
|
+
};
|
|
80
86
|
const console = options.console ?? globalThis.console;
|
|
81
87
|
return (record) => {
|
|
82
88
|
const args = formatter(record);
|
|
89
|
+
const method = levelMap[record.level];
|
|
90
|
+
if (method === undefined) {
|
|
91
|
+
throw new TypeError(`Invalid log level: ${record.level}.`);
|
|
92
|
+
}
|
|
83
93
|
if (typeof args === "string") {
|
|
84
94
|
const msg = args.replace(/\r?\n$/, "");
|
|
85
|
-
|
|
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}.`);
|
|
95
|
+
console[method](msg);
|
|
96
96
|
}
|
|
97
97
|
else {
|
|
98
|
-
|
|
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}.`);
|
|
98
|
+
console[method](...args);
|
|
109
99
|
}
|
|
110
100
|
};
|
|
111
101
|
}
|
|
112
|
-
/**
|
|
113
|
-
* Get a platform-independent file sink.
|
|
114
|
-
*
|
|
115
|
-
* @typeParam TFile The type of the file descriptor.
|
|
116
|
-
* @param path A path to the file to write to.
|
|
117
|
-
* @param options The options for the sink and the file driver.
|
|
118
|
-
* @returns A sink that writes to the file. The sink is also a disposable
|
|
119
|
-
* object that closes the file when disposed.
|
|
120
|
-
*/
|
|
121
|
-
function getFileSink(path, options) {
|
|
122
|
-
const formatter = options.formatter ?? formatter_js_1.defaultTextFormatter;
|
|
123
|
-
const encoder = options.encoder ?? new TextEncoder();
|
|
124
|
-
const fd = options.openSync(path);
|
|
125
|
-
const sink = (record) => {
|
|
126
|
-
options.writeSync(fd, encoder.encode(formatter(record)));
|
|
127
|
-
options.flushSync(fd);
|
|
128
|
-
};
|
|
129
|
-
sink[Symbol.dispose] = () => options.closeSync(fd);
|
|
130
|
-
return sink;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Get a platform-independent rotating file sink.
|
|
134
|
-
*
|
|
135
|
-
* This sink writes log records to a file, and rotates the file when it reaches
|
|
136
|
-
* the `maxSize`. The rotated files are named with the original file name
|
|
137
|
-
* followed by a dot and a number, starting from 1. The number is incremented
|
|
138
|
-
* for each rotation, and the maximum number of files to keep is `maxFiles`.
|
|
139
|
-
*
|
|
140
|
-
* @param path A path to the file to write to.
|
|
141
|
-
* @param options The options for the sink and the file driver.
|
|
142
|
-
* @returns A sink that writes to the file. The sink is also a disposable
|
|
143
|
-
* object that closes the file when disposed.
|
|
144
|
-
*/
|
|
145
|
-
function getRotatingFileSink(path, options) {
|
|
146
|
-
const formatter = options.formatter ?? formatter_js_1.defaultTextFormatter;
|
|
147
|
-
const encoder = options.encoder ?? new TextEncoder();
|
|
148
|
-
const maxSize = options.maxSize ?? 1024 * 1024;
|
|
149
|
-
const maxFiles = options.maxFiles ?? 5;
|
|
150
|
-
let offset = 0;
|
|
151
|
-
try {
|
|
152
|
-
const stat = options.statSync(path);
|
|
153
|
-
offset = stat.size;
|
|
154
|
-
}
|
|
155
|
-
catch {
|
|
156
|
-
// Continue as the offset is already 0.
|
|
157
|
-
}
|
|
158
|
-
let fd = options.openSync(path);
|
|
159
|
-
function shouldRollover(bytes) {
|
|
160
|
-
return offset + bytes.length > maxSize;
|
|
161
|
-
}
|
|
162
|
-
function performRollover() {
|
|
163
|
-
options.closeSync(fd);
|
|
164
|
-
for (let i = maxFiles - 1; i > 0; i--) {
|
|
165
|
-
const oldPath = `${path}.${i}`;
|
|
166
|
-
const newPath = `${path}.${i + 1}`;
|
|
167
|
-
try {
|
|
168
|
-
options.renameSync(oldPath, newPath);
|
|
169
|
-
}
|
|
170
|
-
catch (_) {
|
|
171
|
-
// Continue if the file does not exist.
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
options.renameSync(path, `${path}.1`);
|
|
175
|
-
offset = 0;
|
|
176
|
-
fd = options.openSync(path);
|
|
177
|
-
}
|
|
178
|
-
const sink = (record) => {
|
|
179
|
-
const bytes = encoder.encode(formatter(record));
|
|
180
|
-
if (shouldRollover(bytes))
|
|
181
|
-
performRollover();
|
|
182
|
-
options.writeSync(fd, bytes);
|
|
183
|
-
options.flushSync(fd);
|
|
184
|
-
offset += bytes.length;
|
|
185
|
-
};
|
|
186
|
-
sink[Symbol.dispose] = () => options.closeSync(fd);
|
|
187
|
-
return sink;
|
|
188
|
-
}
|
package/types/mod.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
export { type Config, ConfigError, configure, configureSync, dispose, disposeSync, getConfig, type LoggerConfig, reset, resetSync, } from "./config.js";
|
|
2
2
|
export { type ContextLocalStorage, withContext } from "./context.js";
|
|
3
|
-
export { getFileSink, getRotatingFileSink } from "./filesink.node.js";
|
|
4
3
|
export { type Filter, type FilterLike, getLevelFilter, toFilter, } from "./filter.js";
|
|
5
4
|
export { type AnsiColor, ansiColorFormatter, type AnsiColorFormatterOptions, type AnsiStyle, type ConsoleFormatter, defaultConsoleFormatter, defaultTextFormatter, type FormattedValues, getAnsiColorFormatter, getTextFormatter, type TextFormatter, type TextFormatterOptions, } from "./formatter.js";
|
|
6
5
|
export { compareLogLevel, isLogLevel, type LogLevel, parseLogLevel, } from "./level.js";
|
|
7
6
|
export { getLogger, type Logger } from "./logger.js";
|
|
8
7
|
export type { LogRecord } from "./record.js";
|
|
9
|
-
export { type ConsoleSinkOptions,
|
|
8
|
+
export { type ConsoleSinkOptions, getConsoleSink, getStreamSink, type Sink, type StreamSinkOptions, withFilter, } from "./sink.js";
|
|
10
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,aAAa,EACb,OAAO,EACP,WAAW,EACX,SAAS,EACT,KAAK,YAAY,EACjB,KAAK,EACL,SAAS,GACV,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,KAAK,mBAAmB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EACX,WAAW,EACX,SAAS,EACT,aAAa,EACb,OAAO,EACP,WAAW,EACX,SAAS,EACT,KAAK,YAAY,EACjB,KAAK,EACL,SAAS,GACV,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,KAAK,mBAAmB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,EACL,KAAK,MAAM,EACX,KAAK,UAAU,EACf,cAAc,EACd,QAAQ,GACT,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,KAAK,SAAS,EACd,kBAAkB,EAClB,KAAK,yBAAyB,EAC9B,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,uBAAuB,EACvB,oBAAoB,EACpB,KAAK,eAAe,EACpB,qBAAqB,EACrB,gBAAgB,EAChB,KAAK,aAAa,EAClB,KAAK,oBAAoB,GAC1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,eAAe,EACf,UAAU,EACV,KAAK,QAAQ,EACb,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,KAAK,MAAM,EAAE,MAAM,aAAa,CAAC;AACrD,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EACL,KAAK,kBAAkB,EACvB,cAAc,EACd,aAAa,EACb,KAAK,IAAI,EACT,KAAK,iBAAiB,EACtB,UAAU,GACX,MAAM,WAAW,CAAC"}
|
package/types/sink.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type FilterLike } from "./filter.js";
|
|
2
2
|
import { type ConsoleFormatter, type TextFormatter } from "./formatter.js";
|
|
3
|
+
import type { LogLevel } from "./level.js";
|
|
3
4
|
import type { LogRecord } from "./record.js";
|
|
4
5
|
/**
|
|
5
6
|
* A sink is a function that accepts a log record and prints it somewhere.
|
|
@@ -66,6 +67,7 @@ export interface StreamSinkOptions {
|
|
|
66
67
|
* @returns A sink that writes to the stream.
|
|
67
68
|
*/
|
|
68
69
|
export declare function getStreamSink(stream: WritableStream, options?: StreamSinkOptions): Sink & AsyncDisposable;
|
|
70
|
+
type ConsoleMethod = "debug" | "info" | "log" | "warn" | "error";
|
|
69
71
|
/**
|
|
70
72
|
* Options for the {@link getConsoleSink} function.
|
|
71
73
|
*/
|
|
@@ -75,6 +77,21 @@ export interface ConsoleSinkOptions {
|
|
|
75
77
|
* Defaults to {@link defaultConsoleFormatter}.
|
|
76
78
|
*/
|
|
77
79
|
formatter?: ConsoleFormatter | TextFormatter;
|
|
80
|
+
/**
|
|
81
|
+
* The mapping from log levels to console methods. Defaults to:
|
|
82
|
+
*
|
|
83
|
+
* ```typescript
|
|
84
|
+
* {
|
|
85
|
+
* debug: "debug",
|
|
86
|
+
* info: "info",
|
|
87
|
+
* warning: "warn",
|
|
88
|
+
* error: "error",
|
|
89
|
+
* fatal: "error",
|
|
90
|
+
* }
|
|
91
|
+
* ```
|
|
92
|
+
* @since 0.9.0
|
|
93
|
+
*/
|
|
94
|
+
levelMap?: Record<LogLevel, ConsoleMethod>;
|
|
78
95
|
/**
|
|
79
96
|
* The console to log to. Defaults to {@link console}.
|
|
80
97
|
*/
|
|
@@ -87,91 +104,5 @@ export interface ConsoleSinkOptions {
|
|
|
87
104
|
* @returns A sink that logs to the console.
|
|
88
105
|
*/
|
|
89
106
|
export declare function getConsoleSink(options?: ConsoleSinkOptions): Sink;
|
|
90
|
-
|
|
91
|
-
* Options for the {@link getFileSink} function.
|
|
92
|
-
*/
|
|
93
|
-
export type FileSinkOptions = StreamSinkOptions;
|
|
94
|
-
/**
|
|
95
|
-
* A platform-specific file sink driver.
|
|
96
|
-
* @typeParam TFile The type of the file descriptor.
|
|
97
|
-
*/
|
|
98
|
-
export interface FileSinkDriver<TFile> {
|
|
99
|
-
/**
|
|
100
|
-
* Open a file for appending and return a file descriptor.
|
|
101
|
-
* @param path A path to the file to open.
|
|
102
|
-
*/
|
|
103
|
-
openSync(path: string): TFile;
|
|
104
|
-
/**
|
|
105
|
-
* Write a chunk of data to the file.
|
|
106
|
-
* @param fd The file descriptor.
|
|
107
|
-
* @param chunk The data to write.
|
|
108
|
-
*/
|
|
109
|
-
writeSync(fd: TFile, chunk: Uint8Array): void;
|
|
110
|
-
/**
|
|
111
|
-
* Flush the file to ensure that all data is written to the disk.
|
|
112
|
-
* @param fd The file descriptor.
|
|
113
|
-
*/
|
|
114
|
-
flushSync(fd: TFile): void;
|
|
115
|
-
/**
|
|
116
|
-
* Close the file.
|
|
117
|
-
* @param fd The file descriptor.
|
|
118
|
-
*/
|
|
119
|
-
closeSync(fd: TFile): void;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Get a platform-independent file sink.
|
|
123
|
-
*
|
|
124
|
-
* @typeParam TFile The type of the file descriptor.
|
|
125
|
-
* @param path A path to the file to write to.
|
|
126
|
-
* @param options The options for the sink and the file driver.
|
|
127
|
-
* @returns A sink that writes to the file. The sink is also a disposable
|
|
128
|
-
* object that closes the file when disposed.
|
|
129
|
-
*/
|
|
130
|
-
export declare function getFileSink<TFile>(path: string, options: FileSinkOptions & FileSinkDriver<TFile>): Sink & Disposable;
|
|
131
|
-
/**
|
|
132
|
-
* Options for the {@link getRotatingFileSink} function.
|
|
133
|
-
*/
|
|
134
|
-
export interface RotatingFileSinkOptions extends FileSinkOptions {
|
|
135
|
-
/**
|
|
136
|
-
* The maximum bytes of the file before it is rotated. 1 MiB by default.
|
|
137
|
-
*/
|
|
138
|
-
maxSize?: number;
|
|
139
|
-
/**
|
|
140
|
-
* The maximum number of files to keep. 5 by default.
|
|
141
|
-
*/
|
|
142
|
-
maxFiles?: number;
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* A platform-specific rotating file sink driver.
|
|
146
|
-
*/
|
|
147
|
-
export interface RotatingFileSinkDriver<TFile> extends FileSinkDriver<TFile> {
|
|
148
|
-
/**
|
|
149
|
-
* Get the size of the file.
|
|
150
|
-
* @param path A path to the file.
|
|
151
|
-
* @returns The `size` of the file in bytes, in an object.
|
|
152
|
-
*/
|
|
153
|
-
statSync(path: string): {
|
|
154
|
-
size: number;
|
|
155
|
-
};
|
|
156
|
-
/**
|
|
157
|
-
* Rename a file.
|
|
158
|
-
* @param oldPath A path to the file to rename.
|
|
159
|
-
* @param newPath A path to be renamed to.
|
|
160
|
-
*/
|
|
161
|
-
renameSync(oldPath: string, newPath: string): void;
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Get a platform-independent rotating file sink.
|
|
165
|
-
*
|
|
166
|
-
* This sink writes log records to a file, and rotates the file when it reaches
|
|
167
|
-
* the `maxSize`. The rotated files are named with the original file name
|
|
168
|
-
* followed by a dot and a number, starting from 1. The number is incremented
|
|
169
|
-
* for each rotation, and the maximum number of files to keep is `maxFiles`.
|
|
170
|
-
*
|
|
171
|
-
* @param path A path to the file to write to.
|
|
172
|
-
* @param options The options for the sink and the file driver.
|
|
173
|
-
* @returns A sink that writes to the file. The sink is also a disposable
|
|
174
|
-
* object that closes the file when disposed.
|
|
175
|
-
*/
|
|
176
|
-
export declare function getRotatingFileSink<TFile>(path: string, options: RotatingFileSinkOptions & RotatingFileSinkDriver<TFile>): Sink & Disposable;
|
|
107
|
+
export {};
|
|
177
108
|
//# 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":"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
|
|
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,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,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,KAAK,aAAa,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC;AAEjE;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,SAAS,CAAC,EAAE,gBAAgB,GAAG,aAAa,CAAC;IAE7C;;;;;;;;;;;;;OAaG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;IAE3C;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,OAAO,GAAE,kBAAuB,GAAG,IAAI,CAwBrE"}
|
package/esm/filesink.node.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import * as dntShim from "./_dnt.shims.js";
|
|
2
|
-
// @ts-ignore: a trick to avoid module resolution error on non-Node.js environ
|
|
3
|
-
import fsMod from "./fs.js";
|
|
4
|
-
import { webDriver } from "./filesink.web.js";
|
|
5
|
-
import { getFileSink as getBaseFileSink, getRotatingFileSink as getBaseRotatingFileSink, } from "./sink.js";
|
|
6
|
-
// @ts-ignore: a trick to avoid module resolution error on non-Node.js environ
|
|
7
|
-
const fs = fsMod;
|
|
8
|
-
/**
|
|
9
|
-
* A Node.js-specific file sink driver.
|
|
10
|
-
*/
|
|
11
|
-
export const nodeDriver = fs == null
|
|
12
|
-
? webDriver
|
|
13
|
-
: {
|
|
14
|
-
openSync(path) {
|
|
15
|
-
return fs.openSync(path, "a");
|
|
16
|
-
},
|
|
17
|
-
writeSync: fs.writeSync,
|
|
18
|
-
flushSync: fs.fsyncSync,
|
|
19
|
-
closeSync: fs.closeSync,
|
|
20
|
-
statSync: fs.statSync,
|
|
21
|
-
renameSync: fs.renameSync,
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Get a file sink.
|
|
25
|
-
*
|
|
26
|
-
* Note that this function is unavailable in the browser.
|
|
27
|
-
*
|
|
28
|
-
* @param path A path to the file to write to.
|
|
29
|
-
* @param options The options for the sink.
|
|
30
|
-
* @returns A sink that writes to the file. The sink is also a disposable
|
|
31
|
-
* object that closes the file when disposed.
|
|
32
|
-
*/
|
|
33
|
-
export function getFileSink(path, options = {}) {
|
|
34
|
-
if ("document" in dntShim.dntGlobalThis) {
|
|
35
|
-
return getBaseFileSink(path, { ...options, ...webDriver });
|
|
36
|
-
}
|
|
37
|
-
return getBaseFileSink(path, { ...options, ...nodeDriver });
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Get a rotating file sink.
|
|
41
|
-
*
|
|
42
|
-
* This sink writes log records to a file, and rotates the file when it reaches
|
|
43
|
-
* the `maxSize`. The rotated files are named with the original file name
|
|
44
|
-
* followed by a dot and a number, starting from 1. The number is incremented
|
|
45
|
-
* for each rotation, and the maximum number of files to keep is `maxFiles`.
|
|
46
|
-
*
|
|
47
|
-
* Note that this function is unavailable in the browser.
|
|
48
|
-
*
|
|
49
|
-
* @param path A path to the file to write to.
|
|
50
|
-
* @param options The options for the sink and the file driver.
|
|
51
|
-
* @returns A sink that writes to the file. The sink is also a disposable
|
|
52
|
-
* object that closes the file when disposed.
|
|
53
|
-
*/
|
|
54
|
-
export function getRotatingFileSink(path, options = {}) {
|
|
55
|
-
if ("document" in dntShim.dntGlobalThis) {
|
|
56
|
-
return getBaseRotatingFileSink(path, { ...options, ...webDriver });
|
|
57
|
-
}
|
|
58
|
-
return getBaseRotatingFileSink(path, { ...options, ...nodeDriver });
|
|
59
|
-
}
|
|
60
|
-
// cSpell: ignore filesink
|
package/esm/filesink.web.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
function notImplemented() {
|
|
2
|
-
throw new Error("File sink is not available in the browser.");
|
|
3
|
-
}
|
|
4
|
-
/**
|
|
5
|
-
* A browser-specific file sink driver. All methods throw an error.
|
|
6
|
-
*/
|
|
7
|
-
export const webDriver = {
|
|
8
|
-
openSync: notImplemented,
|
|
9
|
-
writeSync: notImplemented,
|
|
10
|
-
flushSync: notImplemented,
|
|
11
|
-
closeSync: notImplemented,
|
|
12
|
-
statSync: notImplemented,
|
|
13
|
-
renameSync: notImplemented,
|
|
14
|
-
};
|
package/esm/fs.cjs
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
let fs = null;
|
|
2
|
-
if (
|
|
3
|
-
typeof window === "undefined" && (
|
|
4
|
-
"process" in globalThis && "versions" in globalThis.process &&
|
|
5
|
-
"node" in globalThis.process.versions &&
|
|
6
|
-
typeof globalThis.caches === "undefined" &&
|
|
7
|
-
typeof globalThis.addEventListener !== "function" ||
|
|
8
|
-
"Bun" in globalThis
|
|
9
|
-
)
|
|
10
|
-
) {
|
|
11
|
-
try {
|
|
12
|
-
// Intentionally confuse static analysis of bundlers:
|
|
13
|
-
const $require = [require];
|
|
14
|
-
fs = $require[0](`${["node", "fs"].join(":")}`);
|
|
15
|
-
} catch {
|
|
16
|
-
fs = null;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
module.exports = fs;
|
package/esm/fs.js
DELETED
package/script/filesink.node.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
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
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.nodeDriver = void 0;
|
|
30
|
-
exports.getFileSink = getFileSink;
|
|
31
|
-
exports.getRotatingFileSink = getRotatingFileSink;
|
|
32
|
-
const dntShim = __importStar(require("./_dnt.shims.js"));
|
|
33
|
-
// @ts-ignore: a trick to avoid module resolution error on non-Node.js environ
|
|
34
|
-
const fs_js_1 = __importDefault(require("./fs.js"));
|
|
35
|
-
const filesink_web_js_1 = require("./filesink.web.js");
|
|
36
|
-
const sink_js_1 = require("./sink.js");
|
|
37
|
-
// @ts-ignore: a trick to avoid module resolution error on non-Node.js environ
|
|
38
|
-
const fs = fs_js_1.default;
|
|
39
|
-
/**
|
|
40
|
-
* A Node.js-specific file sink driver.
|
|
41
|
-
*/
|
|
42
|
-
exports.nodeDriver = fs == null
|
|
43
|
-
? filesink_web_js_1.webDriver
|
|
44
|
-
: {
|
|
45
|
-
openSync(path) {
|
|
46
|
-
return fs.openSync(path, "a");
|
|
47
|
-
},
|
|
48
|
-
writeSync: fs.writeSync,
|
|
49
|
-
flushSync: fs.fsyncSync,
|
|
50
|
-
closeSync: fs.closeSync,
|
|
51
|
-
statSync: fs.statSync,
|
|
52
|
-
renameSync: fs.renameSync,
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* Get a file sink.
|
|
56
|
-
*
|
|
57
|
-
* Note that this function is unavailable in the browser.
|
|
58
|
-
*
|
|
59
|
-
* @param path A path to the file to write to.
|
|
60
|
-
* @param options The options for the sink.
|
|
61
|
-
* @returns A sink that writes to the file. The sink is also a disposable
|
|
62
|
-
* object that closes the file when disposed.
|
|
63
|
-
*/
|
|
64
|
-
function getFileSink(path, options = {}) {
|
|
65
|
-
if ("document" in dntShim.dntGlobalThis) {
|
|
66
|
-
return (0, sink_js_1.getFileSink)(path, { ...options, ...filesink_web_js_1.webDriver });
|
|
67
|
-
}
|
|
68
|
-
return (0, sink_js_1.getFileSink)(path, { ...options, ...exports.nodeDriver });
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Get a rotating file sink.
|
|
72
|
-
*
|
|
73
|
-
* This sink writes log records to a file, and rotates the file when it reaches
|
|
74
|
-
* the `maxSize`. The rotated files are named with the original file name
|
|
75
|
-
* followed by a dot and a number, starting from 1. The number is incremented
|
|
76
|
-
* for each rotation, and the maximum number of files to keep is `maxFiles`.
|
|
77
|
-
*
|
|
78
|
-
* Note that this function is unavailable in the browser.
|
|
79
|
-
*
|
|
80
|
-
* @param path A path to the file to write to.
|
|
81
|
-
* @param options The options for the sink and the file driver.
|
|
82
|
-
* @returns A sink that writes to the file. The sink is also a disposable
|
|
83
|
-
* object that closes the file when disposed.
|
|
84
|
-
*/
|
|
85
|
-
function getRotatingFileSink(path, options = {}) {
|
|
86
|
-
if ("document" in dntShim.dntGlobalThis) {
|
|
87
|
-
return (0, sink_js_1.getRotatingFileSink)(path, { ...options, ...filesink_web_js_1.webDriver });
|
|
88
|
-
}
|
|
89
|
-
return (0, sink_js_1.getRotatingFileSink)(path, { ...options, ...exports.nodeDriver });
|
|
90
|
-
}
|
|
91
|
-
// cSpell: ignore filesink
|
package/script/filesink.web.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.webDriver = void 0;
|
|
4
|
-
function notImplemented() {
|
|
5
|
-
throw new Error("File sink is not available in the browser.");
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* A browser-specific file sink driver. All methods throw an error.
|
|
9
|
-
*/
|
|
10
|
-
exports.webDriver = {
|
|
11
|
-
openSync: notImplemented,
|
|
12
|
-
writeSync: notImplemented,
|
|
13
|
-
flushSync: notImplemented,
|
|
14
|
-
closeSync: notImplemented,
|
|
15
|
-
statSync: notImplemented,
|
|
16
|
-
renameSync: notImplemented,
|
|
17
|
-
};
|
package/script/fs.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
let fs = null;
|
|
2
|
-
if (
|
|
3
|
-
typeof window === "undefined" && (
|
|
4
|
-
"process" in globalThis && "versions" in globalThis.process &&
|
|
5
|
-
"node" in globalThis.process.versions &&
|
|
6
|
-
typeof globalThis.caches === "undefined" &&
|
|
7
|
-
typeof globalThis.addEventListener !== "function" ||
|
|
8
|
-
"Bun" in globalThis
|
|
9
|
-
)
|
|
10
|
-
) {
|
|
11
|
-
try {
|
|
12
|
-
// Intentionally confuse static analysis of bundlers:
|
|
13
|
-
const $require = [require];
|
|
14
|
-
fs = $require[0](`${["node", "fs"].join(":")}`);
|
|
15
|
-
} catch {
|
|
16
|
-
fs = null;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
module.exports = fs;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../../../src/deps/deno.land/x/which_runtime@0.2.0/mod.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,MAAM,SAAgC,CAAC;AACpD,eAAO,MAAM,MAAM,SAA0B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"assert_path.d.ts","sourceRoot":"","sources":["../../../../../../../src/deps/jsr.io/@std/path/1.0.8/_common/assert_path.ts"],"names":[],"mappings":"AAGA,wBAAgB,UAAU,CAAC,IAAI,CAAC,EAAE,MAAM,QAMvC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../../../src/deps/jsr.io/@std/path/1.0.8/_common/constants.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,gBAAgB,KAAK,CAAC;AACnC,eAAO,MAAM,gBAAgB,KAAK,CAAC;AACnC,eAAO,MAAM,gBAAgB,KAAK,CAAC;AACnC,eAAO,MAAM,gBAAgB,MAAM,CAAC;AAGpC,eAAO,MAAM,QAAQ,KAAK,CAAC;AAC3B,eAAO,MAAM,kBAAkB,KAAK,CAAC;AACrC,eAAO,MAAM,mBAAmB,KAAK,CAAC;AACtC,eAAO,MAAM,kBAAkB,MAAM,CAAC;AACtC,eAAO,MAAM,UAAU,KAAK,CAAC;AAC7B,eAAO,MAAM,kBAAkB,KAAK,CAAC;AACrC,eAAO,MAAM,eAAe,KAAK,CAAC;AAClC,eAAO,MAAM,cAAc,KAAK,CAAC;AACjC,eAAO,MAAM,oBAAoB,KAAK,CAAC;AACvC,eAAO,MAAM,QAAQ,IAAI,CAAC;AAC1B,eAAO,MAAM,cAAc,KAAK,CAAC;AACjC,eAAO,MAAM,qBAAqB,KAAK,CAAC;AACxC,eAAO,MAAM,SAAS,KAAK,CAAC;AAC5B,eAAO,MAAM,UAAU,KAAK,CAAC;AAC7B,eAAO,MAAM,mBAAmB,MAAM,CAAC;AACvC,eAAO,MAAM,6BAA6B,QAAQ,CAAC;AACnD,eAAO,MAAM,wBAAwB,KAAK,CAAC;AAC3C,eAAO,MAAM,yBAAyB,KAAK,CAAC;AAC5C,eAAO,MAAM,uBAAuB,KAAK,CAAC;AAC1C,eAAO,MAAM,wBAAwB,KAAK,CAAC;AAC3C,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAC3C,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAC5C,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,SAAS,KAAK,CAAC;AAC5B,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,YAAY,KAAK,CAAC;AAC/B,eAAO,MAAM,cAAc,KAAK,CAAC;AACjC,eAAO,MAAM,sBAAsB,KAAK,CAAC;AACzC,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,OAAO,KAAK,CAAC;AAC1B,eAAO,MAAM,cAAc,KAAK,CAAC;AACjC,eAAO,MAAM,UAAU,KAAK,CAAC;AAG7B,eAAO,MAAM,MAAM,KAAK,CAAC;AACzB,eAAO,MAAM,MAAM,KAAK,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../../../../../../src/deps/jsr.io/@std/path/1.0.8/_common/normalize.ts"],"names":[],"mappings":"AAKA,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,mBAGrC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"normalize_string.d.ts","sourceRoot":"","sources":["../../../../../../../src/deps/jsr.io/@std/path/1.0.8/_common/normalize_string.ts"],"names":[],"mappings":"AAQA,wBAAgB,eAAe,CAC7B,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,OAAO,EACvB,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,GACzC,MAAM,CA4DR"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_os.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/path/1.0.8/_os.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,SAAS,EAAE,OAIjB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"join.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/path/1.0.8/join.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,IAAI,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAE/C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_util.d.ts","sourceRoot":"","sources":["../../../../../../../src/deps/jsr.io/@std/path/1.0.8/posix/_util.ts"],"names":[],"mappings":"AAOA,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE1D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"join.d.ts","sourceRoot":"","sources":["../../../../../../../src/deps/jsr.io/@std/path/1.0.8/posix/join.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,IAAI,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAK/C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../../../../../../src/deps/jsr.io/@std/path/1.0.8/posix/normalize.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAgB9C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_util.d.ts","sourceRoot":"","sources":["../../../../../../../src/deps/jsr.io/@std/path/1.0.8/windows/_util.ts"],"names":[],"mappings":"AAcA,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAErD;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAKzD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"join.d.ts","sourceRoot":"","sources":["../../../../../../../src/deps/jsr.io/@std/path/1.0.8/windows/join.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,IAAI,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAiD/C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../../../../../../src/deps/jsr.io/@std/path/1.0.8/windows/normalize.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CA0G9C"}
|
package/types/filesink.node.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { type FileSinkOptions, type RotatingFileSinkDriver, type RotatingFileSinkOptions, type Sink } from "./sink.js";
|
|
2
|
-
/**
|
|
3
|
-
* A Node.js-specific file sink driver.
|
|
4
|
-
*/
|
|
5
|
-
export declare const nodeDriver: RotatingFileSinkDriver<number | void>;
|
|
6
|
-
/**
|
|
7
|
-
* Get a file sink.
|
|
8
|
-
*
|
|
9
|
-
* Note that this function is unavailable in the browser.
|
|
10
|
-
*
|
|
11
|
-
* @param path A path to the file to write to.
|
|
12
|
-
* @param options The options for the sink.
|
|
13
|
-
* @returns A sink that writes to the file. The sink is also a disposable
|
|
14
|
-
* object that closes the file when disposed.
|
|
15
|
-
*/
|
|
16
|
-
export declare function getFileSink(path: string, options?: FileSinkOptions): Sink & Disposable;
|
|
17
|
-
/**
|
|
18
|
-
* Get a rotating file sink.
|
|
19
|
-
*
|
|
20
|
-
* This sink writes log records to a file, and rotates the file when it reaches
|
|
21
|
-
* the `maxSize`. The rotated files are named with the original file name
|
|
22
|
-
* followed by a dot and a number, starting from 1. The number is incremented
|
|
23
|
-
* for each rotation, and the maximum number of files to keep is `maxFiles`.
|
|
24
|
-
*
|
|
25
|
-
* Note that this function is unavailable in the browser.
|
|
26
|
-
*
|
|
27
|
-
* @param path A path to the file to write to.
|
|
28
|
-
* @param options The options for the sink and the file driver.
|
|
29
|
-
* @returns A sink that writes to the file. The sink is also a disposable
|
|
30
|
-
* object that closes the file when disposed.
|
|
31
|
-
*/
|
|
32
|
-
export declare function getRotatingFileSink(path: string, options?: RotatingFileSinkOptions): Sink & Disposable;
|
|
33
|
-
//# sourceMappingURL=filesink.node.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"filesink.node.d.ts","sourceRoot":"","sources":["../src/filesink.node.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,eAAe,EAGpB,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,IAAI,EACV,MAAM,WAAW,CAAC;AAKnB;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,sBAAsB,CAAC,MAAM,GAAG,IAAI,CAW1D,CAAC;AAEJ;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,eAAoB,GAC5B,IAAI,GAAG,UAAU,CAKnB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,uBAA4B,GACpC,IAAI,GAAG,UAAU,CAKnB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"filesink.test.d.ts","sourceRoot":"","sources":["../src/filesink.test.ts"],"names":[],"mappings":""}
|
package/types/filesink.web.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"filesink.web.d.ts","sourceRoot":"","sources":["../src/filesink.web.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAMxD;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,sBAAsB,CAAC,IAAI,CAOlD,CAAC"}
|
package/types/fs.d.ts
DELETED
package/types/fs.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../src/fs.js"],"names":[],"mappings":""}
|