@logtape/file 1.0.0-dev.241 → 1.0.0-dev.246
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/deno.json +1 -1
- package/dist/filesink.base.cjs +52 -347
- package/dist/filesink.base.d.cts +3 -65
- package/dist/filesink.base.d.cts.map +1 -1
- package/dist/filesink.base.d.ts +3 -65
- package/dist/filesink.base.d.ts.map +1 -1
- package/dist/filesink.base.js +52 -347
- package/dist/filesink.base.js.map +1 -1
- package/dist/filesink.deno.cjs +23 -26
- package/dist/filesink.deno.d.cts +4 -17
- package/dist/filesink.deno.d.cts.map +1 -1
- package/dist/filesink.deno.d.ts +4 -17
- package/dist/filesink.deno.d.ts.map +1 -1
- package/dist/filesink.deno.js +24 -26
- package/dist/filesink.deno.js.map +1 -1
- package/dist/filesink.node.cjs +23 -33
- package/dist/filesink.node.d.cts +4 -17
- package/dist/filesink.node.d.cts.map +1 -1
- package/dist/filesink.node.d.ts +4 -17
- package/dist/filesink.node.d.ts.map +1 -1
- package/dist/filesink.node.js +24 -33
- package/dist/filesink.node.js.map +1 -1
- package/dist/mod.cjs +1 -3
- package/dist/mod.d.cts +1 -2
- package/dist/mod.d.ts +1 -2
- package/dist/mod.js +1 -2
- package/filesink.base.ts +37 -618
- package/filesink.deno.ts +4 -57
- package/filesink.jsr.ts +7 -32
- package/filesink.node.ts +4 -58
- package/filesink.test.ts +0 -120
- package/mod.ts +0 -2
- package/package.json +12 -7
- package/tsdown.config.ts +2 -2
- package/dist/streamfilesink.cjs +0 -84
- package/dist/streamfilesink.d.cts +0 -95
- package/dist/streamfilesink.d.cts.map +0 -1
- package/dist/streamfilesink.d.ts +0 -95
- package/dist/streamfilesink.d.ts.map +0 -1
- package/dist/streamfilesink.js +0 -84
- package/dist/streamfilesink.js.map +0 -1
- package/streamfilesink.test.ts +0 -336
- package/streamfilesink.ts +0 -136
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filesink.deno.d.cts","names":[],"sources":["../filesink.deno.ts"],"sourcesContent":[],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"filesink.deno.d.cts","names":[],"sources":["../filesink.deno.ts"],"sourcesContent":[],"mappings":";;;;;;;AAYA;AAeC,cAfY,UAeZ,EAfwB,sBAexB,CAf+C,IAAA,CAAK,MAepD,CAAA;;;AAf8C;AA2B/C;;;;;AAGoB;AAmBpB;AAAmC,iBAtBnB,WAAA,CAsBmB,IAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EApBxB,eAoBwB,CAAA,EAnBhC,IAmBgC,GAnBzB,UAmByB;;;;AAGf;;;;;;;;;;;;iBAHJ,mBAAA,yBAEL,0BACR,OAAO"}
|
package/dist/filesink.deno.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FileSinkOptions, RotatingFileSinkDriver, RotatingFileSinkOptions } from "./filesink.base.js";
|
|
2
2
|
import { Sink } from "@logtape/logtape";
|
|
3
3
|
|
|
4
4
|
//#region filesink.deno.d.ts
|
|
@@ -7,11 +7,6 @@ import { Sink } from "@logtape/logtape";
|
|
|
7
7
|
* A Deno-specific file sink driver.
|
|
8
8
|
*/
|
|
9
9
|
declare const denoDriver: RotatingFileSinkDriver<Deno.FsFile>;
|
|
10
|
-
/**
|
|
11
|
-
* A Deno-specific async file sink driver.
|
|
12
|
-
* @since 1.0.0
|
|
13
|
-
*/
|
|
14
|
-
declare const denoAsyncDriver: AsyncRotatingFileSinkDriver<Deno.FsFile>;
|
|
15
10
|
/**
|
|
16
11
|
* Get a file sink.
|
|
17
12
|
*
|
|
@@ -20,13 +15,9 @@ declare const denoAsyncDriver: AsyncRotatingFileSinkDriver<Deno.FsFile>;
|
|
|
20
15
|
* @param path A path to the file to write to.
|
|
21
16
|
* @param options The options for the sink.
|
|
22
17
|
* @returns A sink that writes to the file. The sink is also a disposable
|
|
23
|
-
* object that closes the file when disposed.
|
|
24
|
-
* returns a sink that also implements {@link AsyncDisposable}.
|
|
18
|
+
* object that closes the file when disposed.
|
|
25
19
|
*/
|
|
26
20
|
declare function getFileSink(path: string, options?: FileSinkOptions): Sink & Disposable;
|
|
27
|
-
declare function getFileSink(path: string, options: FileSinkOptions & {
|
|
28
|
-
nonBlocking: true;
|
|
29
|
-
}): Sink & AsyncDisposable;
|
|
30
21
|
/**
|
|
31
22
|
* Get a rotating file sink.
|
|
32
23
|
*
|
|
@@ -40,14 +31,10 @@ declare function getFileSink(path: string, options: FileSinkOptions & {
|
|
|
40
31
|
* @param path A path to the file to write to.
|
|
41
32
|
* @param options The options for the sink and the file driver.
|
|
42
33
|
* @returns A sink that writes to the file. The sink is also a disposable
|
|
43
|
-
* object that closes the file when disposed.
|
|
44
|
-
* returns a sink that also implements {@link AsyncDisposable}.
|
|
34
|
+
* object that closes the file when disposed.
|
|
45
35
|
*/
|
|
46
36
|
declare function getRotatingFileSink(path: string, options?: RotatingFileSinkOptions): Sink & Disposable;
|
|
47
|
-
declare function getRotatingFileSink(path: string, options: RotatingFileSinkOptions & {
|
|
48
|
-
nonBlocking: true;
|
|
49
|
-
}): Sink & AsyncDisposable;
|
|
50
37
|
//# sourceMappingURL=filesink.deno.d.ts.map
|
|
51
38
|
//#endregion
|
|
52
|
-
export {
|
|
39
|
+
export { denoDriver, getFileSink, getRotatingFileSink };
|
|
53
40
|
//# sourceMappingURL=filesink.deno.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filesink.deno.d.ts","names":[],"sources":["../filesink.deno.ts"],"sourcesContent":[],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"filesink.deno.d.ts","names":[],"sources":["../filesink.deno.ts"],"sourcesContent":[],"mappings":";;;;;;;AAYA;AAeC,cAfY,UAeZ,EAfwB,sBAexB,CAf+C,IAAA,CAAK,MAepD,CAAA;;;AAf8C;AA2B/C;;;;;AAGoB;AAmBpB;AAAmC,iBAtBnB,WAAA,CAsBmB,IAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EApBxB,eAoBwB,CAAA,EAnBhC,IAmBgC,GAnBzB,UAmByB;;;;AAGf;;;;;;;;;;;;iBAHJ,mBAAA,yBAEL,0BACR,OAAO"}
|
package/dist/filesink.deno.js
CHANGED
|
@@ -14,9 +14,6 @@ const denoDriver = {
|
|
|
14
14
|
writeSync(fd, chunk) {
|
|
15
15
|
fd.writeSync(chunk);
|
|
16
16
|
},
|
|
17
|
-
writeManySync(fd, chunks) {
|
|
18
|
-
for (const chunk of chunks) fd.writeSync(chunk);
|
|
19
|
-
},
|
|
20
17
|
flushSync(fd) {
|
|
21
18
|
fd.syncSync();
|
|
22
19
|
},
|
|
@@ -27,36 +24,37 @@ const denoDriver = {
|
|
|
27
24
|
renameSync: globalThis?.Deno.renameSync
|
|
28
25
|
};
|
|
29
26
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
27
|
+
* Get a file sink.
|
|
28
|
+
*
|
|
29
|
+
* Note that this function is unavailable in the browser.
|
|
30
|
+
*
|
|
31
|
+
* @param path A path to the file to write to.
|
|
32
|
+
* @param options The options for the sink.
|
|
33
|
+
* @returns A sink that writes to the file. The sink is also a disposable
|
|
34
|
+
* object that closes the file when disposed.
|
|
32
35
|
*/
|
|
33
|
-
const denoAsyncDriver = {
|
|
34
|
-
...denoDriver,
|
|
35
|
-
async writeMany(fd, chunks) {
|
|
36
|
-
for (const chunk of chunks) await fd.write(chunk);
|
|
37
|
-
},
|
|
38
|
-
async flush(fd) {
|
|
39
|
-
await fd.sync();
|
|
40
|
-
},
|
|
41
|
-
close(fd) {
|
|
42
|
-
return Promise.resolve(fd.close());
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
36
|
function getFileSink(path, options = {}) {
|
|
46
|
-
if (options.nonBlocking) return getBaseFileSink(path, {
|
|
47
|
-
...options,
|
|
48
|
-
...denoAsyncDriver
|
|
49
|
-
});
|
|
50
37
|
return getBaseFileSink(path, {
|
|
51
38
|
...options,
|
|
52
39
|
...denoDriver
|
|
53
40
|
});
|
|
54
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Get a rotating file sink.
|
|
44
|
+
*
|
|
45
|
+
* This sink writes log records to a file, and rotates the file when it reaches
|
|
46
|
+
* the `maxSize`. The rotated files are named with the original file name
|
|
47
|
+
* followed by a dot and a number, starting from 1. The number is incremented
|
|
48
|
+
* for each rotation, and the maximum number of files to keep is `maxFiles`.
|
|
49
|
+
*
|
|
50
|
+
* Note that this function is unavailable in the browser.
|
|
51
|
+
*
|
|
52
|
+
* @param path A path to the file to write to.
|
|
53
|
+
* @param options The options for the sink and the file driver.
|
|
54
|
+
* @returns A sink that writes to the file. The sink is also a disposable
|
|
55
|
+
* object that closes the file when disposed.
|
|
56
|
+
*/
|
|
55
57
|
function getRotatingFileSink(path, options = {}) {
|
|
56
|
-
if (options.nonBlocking) return getBaseRotatingFileSink(path, {
|
|
57
|
-
...options,
|
|
58
|
-
...denoAsyncDriver
|
|
59
|
-
});
|
|
60
58
|
return getBaseRotatingFileSink(path, {
|
|
61
59
|
...options,
|
|
62
60
|
...denoDriver
|
|
@@ -64,5 +62,5 @@ function getRotatingFileSink(path, options = {}) {
|
|
|
64
62
|
}
|
|
65
63
|
|
|
66
64
|
//#endregion
|
|
67
|
-
export {
|
|
65
|
+
export { denoDriver, getFileSink, getRotatingFileSink };
|
|
68
66
|
//# sourceMappingURL=filesink.deno.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filesink.deno.js","names":["denoDriver: RotatingFileSinkDriver<Deno.FsFile>","path: string","
|
|
1
|
+
{"version":3,"file":"filesink.deno.js","names":["denoDriver: RotatingFileSinkDriver<Deno.FsFile>","path: string","options: FileSinkOptions","options: RotatingFileSinkOptions"],"sources":["../filesink.deno.ts"],"sourcesContent":["import type { Sink } from \"@logtape/logtape\";\nimport {\n type FileSinkOptions,\n getBaseFileSink,\n getBaseRotatingFileSink,\n type RotatingFileSinkDriver,\n type RotatingFileSinkOptions,\n} from \"./filesink.base.ts\";\n\n/**\n * A Deno-specific file sink driver.\n */\nexport const denoDriver: RotatingFileSinkDriver<Deno.FsFile> = {\n openSync(path: string) {\n return Deno.openSync(path, { create: true, append: true });\n },\n writeSync(fd, chunk) {\n fd.writeSync(chunk);\n },\n flushSync(fd) {\n fd.syncSync();\n },\n closeSync(fd) {\n fd.close();\n },\n statSync: globalThis?.Deno.statSync,\n renameSync: globalThis?.Deno.renameSync,\n};\n\n/**\n * Get a file sink.\n *\n * Note that this function is unavailable in the browser.\n *\n * @param path A path to the file to write to.\n * @param options The options for the sink.\n * @returns A sink that writes to the file. The sink is also a disposable\n * object that closes the file when disposed.\n */\nexport function getFileSink(\n path: string,\n options: FileSinkOptions = {},\n): Sink & Disposable {\n return getBaseFileSink(path, { ...options, ...denoDriver });\n}\n\n/**\n * Get a rotating file sink.\n *\n * This sink writes log records to a file, and rotates the file when it reaches\n * the `maxSize`. The rotated files are named with the original file name\n * followed by a dot and a number, starting from 1. The number is incremented\n * for each rotation, and the maximum number of files to keep is `maxFiles`.\n *\n * Note that this function is unavailable in the browser.\n *\n * @param path A path to the file to write to.\n * @param options The options for the sink and the file driver.\n * @returns A sink that writes to the file. The sink is also a disposable\n * object that closes the file when disposed.\n */\nexport function getRotatingFileSink(\n path: string,\n options: RotatingFileSinkOptions = {},\n): Sink & Disposable {\n return getBaseRotatingFileSink(path, { ...options, ...denoDriver });\n}\n\n// cSpell: ignore filesink\n"],"mappings":";;;;;;AAYA,MAAaA,aAAkD;CAC7D,SAASC,MAAc;AACrB,SAAO,KAAK,SAAS,MAAM;GAAE,QAAQ;GAAM,QAAQ;EAAM,EAAC;CAC3D;CACD,UAAU,IAAI,OAAO;AACnB,KAAG,UAAU,MAAM;CACpB;CACD,UAAU,IAAI;AACZ,KAAG,UAAU;CACd;CACD,UAAU,IAAI;AACZ,KAAG,OAAO;CACX;CACD,UAAU,YAAY,KAAK;CAC3B,YAAY,YAAY,KAAK;AAC9B;;;;;;;;;;;AAYD,SAAgB,YACdA,MACAC,UAA2B,CAAE,GACV;AACnB,QAAO,gBAAgB,MAAM;EAAE,GAAG;EAAS,GAAG;CAAY,EAAC;AAC5D;;;;;;;;;;;;;;;;AAiBD,SAAgB,oBACdD,MACAE,UAAmC,CAAE,GAClB;AACnB,QAAO,wBAAwB,MAAM;EAAE,GAAG;EAAS,GAAG;CAAY,EAAC;AACpE"}
|
package/dist/filesink.node.cjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_filesink_base = require('./filesink.base.cjs');
|
|
3
3
|
const node_fs = require_rolldown_runtime.__toESM(require("node:fs"));
|
|
4
|
-
const node_util = require_rolldown_runtime.__toESM(require("node:util"));
|
|
5
4
|
|
|
6
5
|
//#region filesink.node.ts
|
|
7
6
|
/**
|
|
@@ -12,51 +11,43 @@ const nodeDriver = {
|
|
|
12
11
|
return node_fs.default.openSync(path, "a");
|
|
13
12
|
},
|
|
14
13
|
writeSync: node_fs.default.writeSync,
|
|
15
|
-
writeManySync(fd, chunks) {
|
|
16
|
-
if (chunks.length === 0) return;
|
|
17
|
-
if (chunks.length === 1) {
|
|
18
|
-
node_fs.default.writeSync(fd, chunks[0]);
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
node_fs.default.writevSync(fd, chunks);
|
|
22
|
-
},
|
|
23
14
|
flushSync: node_fs.default.fsyncSync,
|
|
24
15
|
closeSync: node_fs.default.closeSync,
|
|
25
16
|
statSync: node_fs.default.statSync,
|
|
26
17
|
renameSync: node_fs.default.renameSync
|
|
27
18
|
};
|
|
28
19
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
20
|
+
* Get a file sink.
|
|
21
|
+
*
|
|
22
|
+
* Note that this function is unavailable in the browser.
|
|
23
|
+
*
|
|
24
|
+
* @param path A path to the file to write to.
|
|
25
|
+
* @param options The options for the sink.
|
|
26
|
+
* @returns A sink that writes to the file. The sink is also a disposable
|
|
27
|
+
* object that closes the file when disposed.
|
|
31
28
|
*/
|
|
32
|
-
const nodeAsyncDriver = {
|
|
33
|
-
...nodeDriver,
|
|
34
|
-
async writeMany(fd, chunks) {
|
|
35
|
-
if (chunks.length === 0) return;
|
|
36
|
-
if (chunks.length === 1) {
|
|
37
|
-
await (0, node_util.promisify)(node_fs.default.write)(fd, chunks[0]);
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
await (0, node_util.promisify)(node_fs.default.writev)(fd, chunks);
|
|
41
|
-
},
|
|
42
|
-
flush: (0, node_util.promisify)(node_fs.default.fsync),
|
|
43
|
-
close: (0, node_util.promisify)(node_fs.default.close)
|
|
44
|
-
};
|
|
45
29
|
function getFileSink(path, options = {}) {
|
|
46
|
-
if (options.nonBlocking) return require_filesink_base.getBaseFileSink(path, {
|
|
47
|
-
...options,
|
|
48
|
-
...nodeAsyncDriver
|
|
49
|
-
});
|
|
50
30
|
return require_filesink_base.getBaseFileSink(path, {
|
|
51
31
|
...options,
|
|
52
32
|
...nodeDriver
|
|
53
33
|
});
|
|
54
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Get a rotating file sink.
|
|
37
|
+
*
|
|
38
|
+
* This sink writes log records to a file, and rotates the file when it reaches
|
|
39
|
+
* the `maxSize`. The rotated files are named with the original file name
|
|
40
|
+
* followed by a dot and a number, starting from 1. The number is incremented
|
|
41
|
+
* for each rotation, and the maximum number of files to keep is `maxFiles`.
|
|
42
|
+
*
|
|
43
|
+
* Note that this function is unavailable in the browser.
|
|
44
|
+
*
|
|
45
|
+
* @param path A path to the file to write to.
|
|
46
|
+
* @param options The options for the sink and the file driver.
|
|
47
|
+
* @returns A sink that writes to the file. The sink is also a disposable
|
|
48
|
+
* object that closes the file when disposed.
|
|
49
|
+
*/
|
|
55
50
|
function getRotatingFileSink(path, options = {}) {
|
|
56
|
-
if (options.nonBlocking) return require_filesink_base.getBaseRotatingFileSink(path, {
|
|
57
|
-
...options,
|
|
58
|
-
...nodeAsyncDriver
|
|
59
|
-
});
|
|
60
51
|
return require_filesink_base.getBaseRotatingFileSink(path, {
|
|
61
52
|
...options,
|
|
62
53
|
...nodeDriver
|
|
@@ -66,5 +57,4 @@ function getRotatingFileSink(path, options = {}) {
|
|
|
66
57
|
//#endregion
|
|
67
58
|
exports.getFileSink = getFileSink;
|
|
68
59
|
exports.getRotatingFileSink = getRotatingFileSink;
|
|
69
|
-
exports.nodeAsyncDriver = nodeAsyncDriver;
|
|
70
60
|
exports.nodeDriver = nodeDriver;
|
package/dist/filesink.node.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FileSinkOptions, RotatingFileSinkDriver, RotatingFileSinkOptions } from "./filesink.base.cjs";
|
|
2
2
|
import { Sink } from "@logtape/logtape";
|
|
3
3
|
|
|
4
4
|
//#region filesink.node.d.ts
|
|
@@ -7,11 +7,6 @@ import { Sink } from "@logtape/logtape";
|
|
|
7
7
|
* A Node.js-specific file sink driver.
|
|
8
8
|
*/
|
|
9
9
|
declare const nodeDriver: RotatingFileSinkDriver<number | void>;
|
|
10
|
-
/**
|
|
11
|
-
* A Node.js-specific async file sink driver.
|
|
12
|
-
* @since 1.0.0
|
|
13
|
-
*/
|
|
14
|
-
declare const nodeAsyncDriver: AsyncRotatingFileSinkDriver<number | void>;
|
|
15
10
|
/**
|
|
16
11
|
* Get a file sink.
|
|
17
12
|
*
|
|
@@ -20,13 +15,9 @@ declare const nodeAsyncDriver: AsyncRotatingFileSinkDriver<number | void>;
|
|
|
20
15
|
* @param path A path to the file to write to.
|
|
21
16
|
* @param options The options for the sink.
|
|
22
17
|
* @returns A sink that writes to the file. The sink is also a disposable
|
|
23
|
-
* object that closes the file when disposed.
|
|
24
|
-
* returns a sink that also implements {@link AsyncDisposable}.
|
|
18
|
+
* object that closes the file when disposed.
|
|
25
19
|
*/
|
|
26
20
|
declare function getFileSink(path: string, options?: FileSinkOptions): Sink & Disposable;
|
|
27
|
-
declare function getFileSink(path: string, options: FileSinkOptions & {
|
|
28
|
-
nonBlocking: true;
|
|
29
|
-
}): Sink & AsyncDisposable;
|
|
30
21
|
/**
|
|
31
22
|
* Get a rotating file sink.
|
|
32
23
|
*
|
|
@@ -40,14 +31,10 @@ declare function getFileSink(path: string, options: FileSinkOptions & {
|
|
|
40
31
|
* @param path A path to the file to write to.
|
|
41
32
|
* @param options The options for the sink and the file driver.
|
|
42
33
|
* @returns A sink that writes to the file. The sink is also a disposable
|
|
43
|
-
* object that closes the file when disposed.
|
|
44
|
-
* returns a sink that also implements {@link AsyncDisposable}.
|
|
34
|
+
* object that closes the file when disposed.
|
|
45
35
|
*/
|
|
46
36
|
declare function getRotatingFileSink(path: string, options?: RotatingFileSinkOptions): Sink & Disposable;
|
|
47
|
-
declare function getRotatingFileSink(path: string, options: RotatingFileSinkOptions & {
|
|
48
|
-
nonBlocking: true;
|
|
49
|
-
}): Sink & AsyncDisposable;
|
|
50
37
|
//# sourceMappingURL=filesink.node.d.ts.map
|
|
51
38
|
//#endregion
|
|
52
|
-
export { getFileSink, getRotatingFileSink,
|
|
39
|
+
export { getFileSink, getRotatingFileSink, nodeDriver };
|
|
53
40
|
//# sourceMappingURL=filesink.node.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filesink.node.d.cts","names":[],"sources":["../filesink.node.ts"],"sourcesContent":[],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"filesink.node.d.cts","names":[],"sources":["../filesink.node.ts"],"sourcesContent":[],"mappings":";;;;;;;AAaA;AAqBgB,cArBH,UAqBc,EArBF,sBAqBE,CAAA,MAAA,GAAA,IAAA,CAAA;;;;;AAGP;AAmBpB;;;;;AAGoB,iBAzBJ,WAAA,CAyBI,IAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EAvBT,eAuBS,CAAA,EAtBjB,IAsBiB,GAtBV,UAsBU;;;;;;;;;;;;;;;;iBAHJ,mBAAA,yBAEL,0BACR,OAAO"}
|
package/dist/filesink.node.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FileSinkOptions, RotatingFileSinkDriver, RotatingFileSinkOptions } from "./filesink.base.js";
|
|
2
2
|
import { Sink } from "@logtape/logtape";
|
|
3
3
|
|
|
4
4
|
//#region filesink.node.d.ts
|
|
@@ -7,11 +7,6 @@ import { Sink } from "@logtape/logtape";
|
|
|
7
7
|
* A Node.js-specific file sink driver.
|
|
8
8
|
*/
|
|
9
9
|
declare const nodeDriver: RotatingFileSinkDriver<number | void>;
|
|
10
|
-
/**
|
|
11
|
-
* A Node.js-specific async file sink driver.
|
|
12
|
-
* @since 1.0.0
|
|
13
|
-
*/
|
|
14
|
-
declare const nodeAsyncDriver: AsyncRotatingFileSinkDriver<number | void>;
|
|
15
10
|
/**
|
|
16
11
|
* Get a file sink.
|
|
17
12
|
*
|
|
@@ -20,13 +15,9 @@ declare const nodeAsyncDriver: AsyncRotatingFileSinkDriver<number | void>;
|
|
|
20
15
|
* @param path A path to the file to write to.
|
|
21
16
|
* @param options The options for the sink.
|
|
22
17
|
* @returns A sink that writes to the file. The sink is also a disposable
|
|
23
|
-
* object that closes the file when disposed.
|
|
24
|
-
* returns a sink that also implements {@link AsyncDisposable}.
|
|
18
|
+
* object that closes the file when disposed.
|
|
25
19
|
*/
|
|
26
20
|
declare function getFileSink(path: string, options?: FileSinkOptions): Sink & Disposable;
|
|
27
|
-
declare function getFileSink(path: string, options: FileSinkOptions & {
|
|
28
|
-
nonBlocking: true;
|
|
29
|
-
}): Sink & AsyncDisposable;
|
|
30
21
|
/**
|
|
31
22
|
* Get a rotating file sink.
|
|
32
23
|
*
|
|
@@ -40,14 +31,10 @@ declare function getFileSink(path: string, options: FileSinkOptions & {
|
|
|
40
31
|
* @param path A path to the file to write to.
|
|
41
32
|
* @param options The options for the sink and the file driver.
|
|
42
33
|
* @returns A sink that writes to the file. The sink is also a disposable
|
|
43
|
-
* object that closes the file when disposed.
|
|
44
|
-
* returns a sink that also implements {@link AsyncDisposable}.
|
|
34
|
+
* object that closes the file when disposed.
|
|
45
35
|
*/
|
|
46
36
|
declare function getRotatingFileSink(path: string, options?: RotatingFileSinkOptions): Sink & Disposable;
|
|
47
|
-
declare function getRotatingFileSink(path: string, options: RotatingFileSinkOptions & {
|
|
48
|
-
nonBlocking: true;
|
|
49
|
-
}): Sink & AsyncDisposable;
|
|
50
37
|
//# sourceMappingURL=filesink.node.d.ts.map
|
|
51
38
|
//#endregion
|
|
52
|
-
export { getFileSink, getRotatingFileSink,
|
|
39
|
+
export { getFileSink, getRotatingFileSink, nodeDriver };
|
|
53
40
|
//# sourceMappingURL=filesink.node.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filesink.node.d.ts","names":[],"sources":["../filesink.node.ts"],"sourcesContent":[],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"filesink.node.d.ts","names":[],"sources":["../filesink.node.ts"],"sourcesContent":[],"mappings":";;;;;;;AAaA;AAqBgB,cArBH,UAqBc,EArBF,sBAqBE,CAAA,MAAA,GAAA,IAAA,CAAA;;;;;AAGP;AAmBpB;;;;;AAGoB,iBAzBJ,WAAA,CAyBI,IAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EAvBT,eAuBS,CAAA,EAtBjB,IAsBiB,GAtBV,UAsBU;;;;;;;;;;;;;;;;iBAHJ,mBAAA,yBAEL,0BACR,OAAO"}
|
package/dist/filesink.node.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { getBaseFileSink, getBaseRotatingFileSink } from "./filesink.base.js";
|
|
2
2
|
import fs from "node:fs";
|
|
3
|
-
import { promisify } from "node:util";
|
|
4
3
|
|
|
5
4
|
//#region filesink.node.ts
|
|
6
5
|
/**
|
|
@@ -11,51 +10,43 @@ const nodeDriver = {
|
|
|
11
10
|
return fs.openSync(path, "a");
|
|
12
11
|
},
|
|
13
12
|
writeSync: fs.writeSync,
|
|
14
|
-
writeManySync(fd, chunks) {
|
|
15
|
-
if (chunks.length === 0) return;
|
|
16
|
-
if (chunks.length === 1) {
|
|
17
|
-
fs.writeSync(fd, chunks[0]);
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
fs.writevSync(fd, chunks);
|
|
21
|
-
},
|
|
22
13
|
flushSync: fs.fsyncSync,
|
|
23
14
|
closeSync: fs.closeSync,
|
|
24
15
|
statSync: fs.statSync,
|
|
25
16
|
renameSync: fs.renameSync
|
|
26
17
|
};
|
|
27
18
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
19
|
+
* Get a file sink.
|
|
20
|
+
*
|
|
21
|
+
* Note that this function is unavailable in the browser.
|
|
22
|
+
*
|
|
23
|
+
* @param path A path to the file to write to.
|
|
24
|
+
* @param options The options for the sink.
|
|
25
|
+
* @returns A sink that writes to the file. The sink is also a disposable
|
|
26
|
+
* object that closes the file when disposed.
|
|
30
27
|
*/
|
|
31
|
-
const nodeAsyncDriver = {
|
|
32
|
-
...nodeDriver,
|
|
33
|
-
async writeMany(fd, chunks) {
|
|
34
|
-
if (chunks.length === 0) return;
|
|
35
|
-
if (chunks.length === 1) {
|
|
36
|
-
await promisify(fs.write)(fd, chunks[0]);
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
await promisify(fs.writev)(fd, chunks);
|
|
40
|
-
},
|
|
41
|
-
flush: promisify(fs.fsync),
|
|
42
|
-
close: promisify(fs.close)
|
|
43
|
-
};
|
|
44
28
|
function getFileSink(path, options = {}) {
|
|
45
|
-
if (options.nonBlocking) return getBaseFileSink(path, {
|
|
46
|
-
...options,
|
|
47
|
-
...nodeAsyncDriver
|
|
48
|
-
});
|
|
49
29
|
return getBaseFileSink(path, {
|
|
50
30
|
...options,
|
|
51
31
|
...nodeDriver
|
|
52
32
|
});
|
|
53
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Get a rotating file sink.
|
|
36
|
+
*
|
|
37
|
+
* This sink writes log records to a file, and rotates the file when it reaches
|
|
38
|
+
* the `maxSize`. The rotated files are named with the original file name
|
|
39
|
+
* followed by a dot and a number, starting from 1. The number is incremented
|
|
40
|
+
* for each rotation, and the maximum number of files to keep is `maxFiles`.
|
|
41
|
+
*
|
|
42
|
+
* Note that this function is unavailable in the browser.
|
|
43
|
+
*
|
|
44
|
+
* @param path A path to the file to write to.
|
|
45
|
+
* @param options The options for the sink and the file driver.
|
|
46
|
+
* @returns A sink that writes to the file. The sink is also a disposable
|
|
47
|
+
* object that closes the file when disposed.
|
|
48
|
+
*/
|
|
54
49
|
function getRotatingFileSink(path, options = {}) {
|
|
55
|
-
if (options.nonBlocking) return getBaseRotatingFileSink(path, {
|
|
56
|
-
...options,
|
|
57
|
-
...nodeAsyncDriver
|
|
58
|
-
});
|
|
59
50
|
return getBaseRotatingFileSink(path, {
|
|
60
51
|
...options,
|
|
61
52
|
...nodeDriver
|
|
@@ -63,5 +54,5 @@ function getRotatingFileSink(path, options = {}) {
|
|
|
63
54
|
}
|
|
64
55
|
|
|
65
56
|
//#endregion
|
|
66
|
-
export { getFileSink, getRotatingFileSink,
|
|
57
|
+
export { getFileSink, getRotatingFileSink, nodeDriver };
|
|
67
58
|
//# sourceMappingURL=filesink.node.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filesink.node.js","names":["nodeDriver: RotatingFileSinkDriver<number | void>","path: string","
|
|
1
|
+
{"version":3,"file":"filesink.node.js","names":["nodeDriver: RotatingFileSinkDriver<number | void>","path: string","options: FileSinkOptions","options: RotatingFileSinkOptions"],"sources":["../filesink.node.ts"],"sourcesContent":["import type { Sink } from \"@logtape/logtape\";\nimport fs from \"node:fs\";\nimport {\n type FileSinkOptions,\n getBaseFileSink,\n getBaseRotatingFileSink,\n type RotatingFileSinkDriver,\n type RotatingFileSinkOptions,\n} from \"./filesink.base.ts\";\n\n/**\n * A Node.js-specific file sink driver.\n */\nexport const nodeDriver: RotatingFileSinkDriver<number | void> = {\n openSync(path: string) {\n return fs.openSync(path, \"a\");\n },\n writeSync: fs.writeSync,\n flushSync: fs.fsyncSync,\n closeSync: fs.closeSync,\n statSync: fs.statSync,\n renameSync: fs.renameSync,\n};\n\n/**\n * Get a file sink.\n *\n * Note that this function is unavailable in the browser.\n *\n * @param path A path to the file to write to.\n * @param options The options for the sink.\n * @returns A sink that writes to the file. The sink is also a disposable\n * object that closes the file when disposed.\n */\nexport function getFileSink(\n path: string,\n options: FileSinkOptions = {},\n): Sink & Disposable {\n return getBaseFileSink(path, { ...options, ...nodeDriver });\n}\n\n/**\n * Get a rotating file sink.\n *\n * This sink writes log records to a file, and rotates the file when it reaches\n * the `maxSize`. The rotated files are named with the original file name\n * followed by a dot and a number, starting from 1. The number is incremented\n * for each rotation, and the maximum number of files to keep is `maxFiles`.\n *\n * Note that this function is unavailable in the browser.\n *\n * @param path A path to the file to write to.\n * @param options The options for the sink and the file driver.\n * @returns A sink that writes to the file. The sink is also a disposable\n * object that closes the file when disposed.\n */\nexport function getRotatingFileSink(\n path: string,\n options: RotatingFileSinkOptions = {},\n): Sink & Disposable {\n return getBaseRotatingFileSink(path, { ...options, ...nodeDriver });\n}\n\n// cSpell: ignore filesink\n"],"mappings":";;;;;;;AAaA,MAAaA,aAAoD;CAC/D,SAASC,MAAc;AACrB,SAAO,GAAG,SAAS,MAAM,IAAI;CAC9B;CACD,WAAW,GAAG;CACd,WAAW,GAAG;CACd,WAAW,GAAG;CACd,UAAU,GAAG;CACb,YAAY,GAAG;AAChB;;;;;;;;;;;AAYD,SAAgB,YACdA,MACAC,UAA2B,CAAE,GACV;AACnB,QAAO,gBAAgB,MAAM;EAAE,GAAG;EAAS,GAAG;CAAY,EAAC;AAC5D;;;;;;;;;;;;;;;;AAiBD,SAAgB,oBACdD,MACAE,UAAmC,CAAE,GAClB;AACnB,QAAO,wBAAwB,MAAM;EAAE,GAAG;EAAS,GAAG;CAAY,EAAC;AACpE"}
|
package/dist/mod.cjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_streamfilesink = require('./streamfilesink.cjs');
|
|
3
2
|
const __filesink = require_rolldown_runtime.__toESM(require("#filesink"));
|
|
4
3
|
|
|
5
4
|
Object.defineProperty(exports, 'getFileSink', {
|
|
@@ -13,5 +12,4 @@ Object.defineProperty(exports, 'getRotatingFileSink', {
|
|
|
13
12
|
get: function () {
|
|
14
13
|
return __filesink.getRotatingFileSink;
|
|
15
14
|
}
|
|
16
|
-
});
|
|
17
|
-
exports.getStreamFileSink = require_streamfilesink.getStreamFileSink;
|
|
15
|
+
});
|
package/dist/mod.d.cts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { FileSinkDriver, FileSinkOptions, RotatingFileSinkDriver, RotatingFileSinkOptions } from "./filesink.base.cjs";
|
|
2
|
-
import { StreamFileSinkOptions, getStreamFileSink } from "./streamfilesink.cjs";
|
|
3
2
|
import { getFileSink, getRotatingFileSink } from "#filesink";
|
|
4
|
-
export { FileSinkDriver, FileSinkOptions, RotatingFileSinkDriver, RotatingFileSinkOptions,
|
|
3
|
+
export { FileSinkDriver, FileSinkOptions, RotatingFileSinkDriver, RotatingFileSinkOptions, getFileSink, getRotatingFileSink };
|
package/dist/mod.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { FileSinkDriver, FileSinkOptions, RotatingFileSinkDriver, RotatingFileSinkOptions } from "./filesink.base.js";
|
|
2
|
-
import { StreamFileSinkOptions, getStreamFileSink } from "./streamfilesink.js";
|
|
3
2
|
import { getFileSink, getRotatingFileSink } from "#filesink";
|
|
4
|
-
export { FileSinkDriver, FileSinkOptions, RotatingFileSinkDriver, RotatingFileSinkOptions,
|
|
3
|
+
export { FileSinkDriver, FileSinkOptions, RotatingFileSinkDriver, RotatingFileSinkOptions, getFileSink, getRotatingFileSink };
|
package/dist/mod.js
CHANGED