@logtape/file 0.9.0-dev.1
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/LICENSE +20 -0
- package/README.md +43 -0
- package/esm/_dnt.shims.js +57 -0
- package/esm/file/filesink.base.js +78 -0
- package/esm/file/filesink.node.js +47 -0
- package/esm/file/mod.js +1 -0
- package/esm/logtape/config.js +287 -0
- package/esm/logtape/context.js +23 -0
- package/esm/logtape/filter.js +42 -0
- package/esm/logtape/formatter.js +261 -0
- package/esm/logtape/level.js +59 -0
- package/esm/logtape/logger.js +480 -0
- package/esm/logtape/mod.js +8 -0
- package/esm/logtape/nodeUtil.js +2 -0
- package/esm/logtape/record.js +1 -0
- package/esm/logtape/sink.js +96 -0
- package/esm/package.json +3 -0
- package/package.json +55 -0
- package/script/_dnt.shims.js +60 -0
- package/script/file/filesink.base.js +82 -0
- package/script/file/filesink.node.js +55 -0
- package/script/file/mod.js +6 -0
- package/script/logtape/config.js +321 -0
- package/script/logtape/context.js +26 -0
- package/script/logtape/filter.js +46 -0
- package/script/logtape/formatter.js +270 -0
- package/script/logtape/level.js +64 -0
- package/script/logtape/logger.js +511 -0
- package/script/logtape/mod.js +34 -0
- package/script/logtape/nodeUtil.js +7 -0
- package/script/logtape/record.js +2 -0
- package/script/logtape/sink.js +101 -0
- package/script/package.json +3 -0
- package/types/_dnt.shims.d.ts +2 -0
- package/types/_dnt.shims.d.ts.map +1 -0
- package/types/_dnt.test_shims.d.ts.map +1 -0
- package/types/deps/jsr.io/@david/which-runtime/0.2.1/mod.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/assert/0.222.1/_constants.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/assert/0.222.1/_diff.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/assert/0.222.1/_format.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/assert/0.222.1/assert_equals.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/assert/0.222.1/assertion_error.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/assert/0.222.1/equal.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/fmt/0.222.1/colors.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/path/1.0.8/_common/assert_path.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/path/1.0.8/_common/constants.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/path/1.0.8/_common/normalize.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/path/1.0.8/_common/normalize_string.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/path/1.0.8/_os.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/path/1.0.8/join.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/path/1.0.8/posix/_util.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/path/1.0.8/posix/join.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/path/1.0.8/posix/normalize.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/path/1.0.8/windows/_util.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/path/1.0.8/windows/join.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/path/1.0.8/windows/normalize.d.ts.map +1 -0
- package/types/file/filesink.base.d.ts +89 -0
- package/types/file/filesink.base.d.ts.map +1 -0
- package/types/file/filesink.node.d.ts +34 -0
- package/types/file/filesink.node.d.ts.map +1 -0
- package/types/file/filesink.test.d.ts.map +1 -0
- package/types/file/mod.d.ts +3 -0
- package/types/file/mod.d.ts.map +1 -0
- package/types/logtape/config.d.ts +183 -0
- package/types/logtape/config.d.ts.map +1 -0
- package/types/logtape/context.d.ts +35 -0
- package/types/logtape/context.d.ts.map +1 -0
- package/types/logtape/filter.d.ts +31 -0
- package/types/logtape/filter.d.ts.map +1 -0
- package/types/logtape/fixtures.d.ts.map +1 -0
- package/types/logtape/formatter.d.ts +260 -0
- package/types/logtape/formatter.d.ts.map +1 -0
- package/types/logtape/level.d.ts +32 -0
- package/types/logtape/level.d.ts.map +1 -0
- package/types/logtape/logger.d.ts +423 -0
- package/types/logtape/logger.d.ts.map +1 -0
- package/types/logtape/mod.d.ts +9 -0
- package/types/logtape/mod.d.ts.map +1 -0
- package/types/logtape/nodeUtil.d.ts +3 -0
- package/types/logtape/nodeUtil.d.ts.map +1 -0
- package/types/logtape/record.d.ts +44 -0
- package/types/logtape/record.d.ts.map +1 -0
- package/types/logtape/sink.d.ts +108 -0
- package/types/logtape/sink.d.ts.map +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assert_equals.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/0.222.1/assert_equals.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAC5B,MAAM,EAAE,CAAC,EACT,QAAQ,EAAE,CAAC,EACX,GAAG,CAAC,EAAE,MAAM,EACZ,OAAO,GAAE;IAAE,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,CAAA;CAAO,QAuBzD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assertion_error.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/0.222.1/assertion_error.ts"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC,iCAAiC;gBACrB,OAAO,EAAE,MAAM;CAI5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"equal.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/assert/0.222.1/equal.ts"],"names":[],"mappings":"AAYA;;;;;;;;;;;;GAYG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CA8FrD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/j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KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,GAAG,GAAG,MAAM,CAuB9D;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,GAAG,GAAG,MAAM,CAuBhE;AAWD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEpD"}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { type Sink, type StreamSinkOptions } from "../logtape/mod.js";
|
|
2
|
+
/**
|
|
3
|
+
* Options for the {@link getBaseFileSink} function.
|
|
4
|
+
*/
|
|
5
|
+
export type FileSinkOptions = StreamSinkOptions;
|
|
6
|
+
/**
|
|
7
|
+
* A platform-specific file sink driver.
|
|
8
|
+
* @typeParam TFile The type of the file descriptor.
|
|
9
|
+
*/
|
|
10
|
+
export interface FileSinkDriver<TFile> {
|
|
11
|
+
/**
|
|
12
|
+
* Open a file for appending and return a file descriptor.
|
|
13
|
+
* @param path A path to the file to open.
|
|
14
|
+
*/
|
|
15
|
+
openSync(path: string): TFile;
|
|
16
|
+
/**
|
|
17
|
+
* Write a chunk of data to the file.
|
|
18
|
+
* @param fd The file descriptor.
|
|
19
|
+
* @param chunk The data to write.
|
|
20
|
+
*/
|
|
21
|
+
writeSync(fd: TFile, chunk: Uint8Array): void;
|
|
22
|
+
/**
|
|
23
|
+
* Flush the file to ensure that all data is written to the disk.
|
|
24
|
+
* @param fd The file descriptor.
|
|
25
|
+
*/
|
|
26
|
+
flushSync(fd: TFile): void;
|
|
27
|
+
/**
|
|
28
|
+
* Close the file.
|
|
29
|
+
* @param fd The file descriptor.
|
|
30
|
+
*/
|
|
31
|
+
closeSync(fd: TFile): void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Get a platform-independent file sink.
|
|
35
|
+
*
|
|
36
|
+
* @typeParam TFile The type of the file descriptor.
|
|
37
|
+
* @param path A path to the file to write to.
|
|
38
|
+
* @param options The options for the sink and the file driver.
|
|
39
|
+
* @returns A sink that writes to the file. The sink is also a disposable
|
|
40
|
+
* object that closes the file when disposed.
|
|
41
|
+
*/
|
|
42
|
+
export declare function getBaseFileSink<TFile>(path: string, options: FileSinkOptions & FileSinkDriver<TFile>): Sink & Disposable;
|
|
43
|
+
/**
|
|
44
|
+
* Options for the {@link getBaseRotatingFileSink} function.
|
|
45
|
+
*/
|
|
46
|
+
export interface RotatingFileSinkOptions extends FileSinkOptions {
|
|
47
|
+
/**
|
|
48
|
+
* The maximum bytes of the file before it is rotated. 1 MiB by default.
|
|
49
|
+
*/
|
|
50
|
+
maxSize?: number;
|
|
51
|
+
/**
|
|
52
|
+
* The maximum number of files to keep. 5 by default.
|
|
53
|
+
*/
|
|
54
|
+
maxFiles?: number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* A platform-specific rotating file sink driver.
|
|
58
|
+
*/
|
|
59
|
+
export interface RotatingFileSinkDriver<TFile> extends FileSinkDriver<TFile> {
|
|
60
|
+
/**
|
|
61
|
+
* Get the size of the file.
|
|
62
|
+
* @param path A path to the file.
|
|
63
|
+
* @returns The `size` of the file in bytes, in an object.
|
|
64
|
+
*/
|
|
65
|
+
statSync(path: string): {
|
|
66
|
+
size: number;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Rename a file.
|
|
70
|
+
* @param oldPath A path to the file to rename.
|
|
71
|
+
* @param newPath A path to be renamed to.
|
|
72
|
+
*/
|
|
73
|
+
renameSync(oldPath: string, newPath: string): void;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Get a platform-independent rotating file sink.
|
|
77
|
+
*
|
|
78
|
+
* This sink writes log records to a file, and rotates the file when it reaches
|
|
79
|
+
* the `maxSize`. The rotated files are named with the original file name
|
|
80
|
+
* followed by a dot and a number, starting from 1. The number is incremented
|
|
81
|
+
* for each rotation, and the maximum number of files to keep is `maxFiles`.
|
|
82
|
+
*
|
|
83
|
+
* @param path A path to the file to write to.
|
|
84
|
+
* @param options The options for the sink and the file driver.
|
|
85
|
+
* @returns A sink that writes to the file. The sink is also a disposable
|
|
86
|
+
* object that closes the file when disposed.
|
|
87
|
+
*/
|
|
88
|
+
export declare function getBaseRotatingFileSink<TFile>(path: string, options: RotatingFileSinkOptions & RotatingFileSinkDriver<TFile>): Sink & Disposable;
|
|
89
|
+
//# sourceMappingURL=filesink.base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filesink.base.d.ts","sourceRoot":"","sources":["../../src/file/filesink.base.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,IAAI,EACT,KAAK,iBAAiB,EACvB,MAAM,mBAAmB,CAAC;AAE3B;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,iBAAiB,CAAC;AAEhD;;;GAGG;AACH,MAAM,WAAW,cAAc,CAAC,KAAK;IACnC;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC;IAE9B;;;;OAIG;IACH,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;IAE9C;;;OAGG;IACH,SAAS,CAAC,EAAE,EAAE,KAAK,GAAG,IAAI,CAAC;IAE3B;;;OAGG;IACH,SAAS,CAAC,EAAE,EAAE,KAAK,GAAG,IAAI,CAAC;CAC5B;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,KAAK,EACnC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,eAAe,GAAG,cAAc,CAAC,KAAK,CAAC,GAC/C,IAAI,GAAG,UAAU,CAUnB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAwB,SAAQ,eAAe;IAC9D;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB,CAAC,KAAK,CAAE,SAAQ,cAAc,CAAC,KAAK,CAAC;IAC1E;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAEzC;;;;OAIG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACpD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAC3C,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,uBAAuB,GAAG,sBAAsB,CAAC,KAAK,CAAC,GAC/D,IAAI,GAAG,UAAU,CAwCnB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Sink } from "../logtape/mod.js";
|
|
2
|
+
import { type FileSinkOptions, type RotatingFileSinkDriver, type RotatingFileSinkOptions } from "./filesink.base.js";
|
|
3
|
+
/**
|
|
4
|
+
* A Node.js-specific file sink driver.
|
|
5
|
+
*/
|
|
6
|
+
export declare const nodeDriver: RotatingFileSinkDriver<number | void>;
|
|
7
|
+
/**
|
|
8
|
+
* Get a file sink.
|
|
9
|
+
*
|
|
10
|
+
* Note that this function is unavailable in the browser.
|
|
11
|
+
*
|
|
12
|
+
* @param path A path to the file to write to.
|
|
13
|
+
* @param options The options for the sink.
|
|
14
|
+
* @returns A sink that writes to the file. The sink is also a disposable
|
|
15
|
+
* object that closes the file when disposed.
|
|
16
|
+
*/
|
|
17
|
+
export declare function getFileSink(path: string, options?: FileSinkOptions): Sink & Disposable;
|
|
18
|
+
/**
|
|
19
|
+
* Get a rotating file sink.
|
|
20
|
+
*
|
|
21
|
+
* This sink writes log records to a file, and rotates the file when it reaches
|
|
22
|
+
* the `maxSize`. The rotated files are named with the original file name
|
|
23
|
+
* followed by a dot and a number, starting from 1. The number is incremented
|
|
24
|
+
* for each rotation, and the maximum number of files to keep is `maxFiles`.
|
|
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 and the file driver.
|
|
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 declare function getRotatingFileSink(path: string, options?: RotatingFileSinkOptions): Sink & Disposable;
|
|
34
|
+
//# sourceMappingURL=filesink.node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filesink.node.d.ts","sourceRoot":"","sources":["../../src/file/filesink.node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EACL,KAAK,eAAe,EAGpB,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC7B,MAAM,oBAAoB,CAAC;AAE5B;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,sBAAsB,CAAC,MAAM,GAAG,IAAI,CAS5D,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,eAAoB,GAC5B,IAAI,GAAG,UAAU,CAEnB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,uBAA4B,GACpC,IAAI,GAAG,UAAU,CAEnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filesink.test.d.ts","sourceRoot":"","sources":["../../src/file/filesink.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/file/mod.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,cAAc,EACd,eAAe,EACf,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import type { ContextLocalStorage } from "./context.js";
|
|
2
|
+
import { type FilterLike } from "./filter.js";
|
|
3
|
+
import type { LogLevel } from "./level.js";
|
|
4
|
+
import { type Sink } from "./sink.js";
|
|
5
|
+
/**
|
|
6
|
+
* A configuration for the loggers.
|
|
7
|
+
*/
|
|
8
|
+
export interface Config<TSinkId extends string, TFilterId extends string> {
|
|
9
|
+
/**
|
|
10
|
+
* The sinks to use. The keys are the sink identifiers, and the values are
|
|
11
|
+
* {@link Sink}s.
|
|
12
|
+
*/
|
|
13
|
+
sinks: Record<TSinkId, Sink>;
|
|
14
|
+
/**
|
|
15
|
+
* The filters to use. The keys are the filter identifiers, and the values
|
|
16
|
+
* are either {@link Filter}s or {@link LogLevel}s.
|
|
17
|
+
*/
|
|
18
|
+
filters?: Record<TFilterId, FilterLike>;
|
|
19
|
+
/**
|
|
20
|
+
* The loggers to configure.
|
|
21
|
+
*/
|
|
22
|
+
loggers: LoggerConfig<TSinkId, TFilterId>[];
|
|
23
|
+
/**
|
|
24
|
+
* The context-local storage to use for implicit contexts.
|
|
25
|
+
* @since 0.7.0
|
|
26
|
+
*/
|
|
27
|
+
contextLocalStorage?: ContextLocalStorage<Record<string, unknown>>;
|
|
28
|
+
/**
|
|
29
|
+
* Whether to reset the configuration before applying this one.
|
|
30
|
+
*/
|
|
31
|
+
reset?: boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A logger configuration.
|
|
35
|
+
*/
|
|
36
|
+
export interface LoggerConfig<TSinkId extends string, TFilterId extends string> {
|
|
37
|
+
/**
|
|
38
|
+
* The category of the logger. If a string, it is equivalent to an array
|
|
39
|
+
* with one element.
|
|
40
|
+
*/
|
|
41
|
+
category: string | string[];
|
|
42
|
+
/**
|
|
43
|
+
* The sink identifiers to use.
|
|
44
|
+
*/
|
|
45
|
+
sinks?: TSinkId[];
|
|
46
|
+
/**
|
|
47
|
+
* Whether to inherit the parent's sinks. If `inherit`, the parent's sinks
|
|
48
|
+
* are used along with the specified sinks. If `override`, the parent's
|
|
49
|
+
* sinks are not used, and only the specified sinks are used.
|
|
50
|
+
*
|
|
51
|
+
* The default is `inherit`.
|
|
52
|
+
* @default `"inherit"
|
|
53
|
+
* @since 0.6.0
|
|
54
|
+
*/
|
|
55
|
+
parentSinks?: "inherit" | "override";
|
|
56
|
+
/**
|
|
57
|
+
* The filter identifiers to use.
|
|
58
|
+
*/
|
|
59
|
+
filters?: TFilterId[];
|
|
60
|
+
/**
|
|
61
|
+
* The log level to filter by. If `null`, the logger will reject all
|
|
62
|
+
* records.
|
|
63
|
+
* @deprecated Use `filters` instead for backward compatibility, or use
|
|
64
|
+
* `lowestLevel` for less-misleading behavior.
|
|
65
|
+
*/
|
|
66
|
+
level?: LogLevel | null;
|
|
67
|
+
/**
|
|
68
|
+
* The lowest log level to accept. If `null`, the logger will reject all
|
|
69
|
+
* records.
|
|
70
|
+
* @since 0.8.0
|
|
71
|
+
*/
|
|
72
|
+
lowestLevel?: LogLevel | null;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Configure the loggers with the specified configuration.
|
|
76
|
+
*
|
|
77
|
+
* Note that if the given sinks or filters are disposable, they will be
|
|
78
|
+
* disposed when the configuration is reset, or when the process exits.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```typescript
|
|
82
|
+
* await configure({
|
|
83
|
+
* sinks: {
|
|
84
|
+
* console: getConsoleSink(),
|
|
85
|
+
* },
|
|
86
|
+
* filters: {
|
|
87
|
+
* slow: (log) =>
|
|
88
|
+
* "duration" in log.properties &&
|
|
89
|
+
* log.properties.duration as number > 1000,
|
|
90
|
+
* },
|
|
91
|
+
* loggers: [
|
|
92
|
+
* {
|
|
93
|
+
* category: "my-app",
|
|
94
|
+
* sinks: ["console"],
|
|
95
|
+
* level: "info",
|
|
96
|
+
* },
|
|
97
|
+
* {
|
|
98
|
+
* category: ["my-app", "sql"],
|
|
99
|
+
* filters: ["slow"],
|
|
100
|
+
* level: "debug",
|
|
101
|
+
* },
|
|
102
|
+
* {
|
|
103
|
+
* category: "logtape",
|
|
104
|
+
* sinks: ["console"],
|
|
105
|
+
* level: "error",
|
|
106
|
+
* },
|
|
107
|
+
* ],
|
|
108
|
+
* });
|
|
109
|
+
* ```
|
|
110
|
+
*
|
|
111
|
+
* @param config The configuration.
|
|
112
|
+
*/
|
|
113
|
+
export declare function configure<TSinkId extends string, TFilterId extends string>(config: Config<TSinkId, TFilterId>): Promise<void>;
|
|
114
|
+
/**
|
|
115
|
+
* Configure sync loggers with the specified configuration.
|
|
116
|
+
*
|
|
117
|
+
* Note that if the given sinks or filters are disposable, they will be
|
|
118
|
+
* disposed when the configuration is reset, or when the process exits.
|
|
119
|
+
*
|
|
120
|
+
* Also note that passing async sinks or filters will throw. If
|
|
121
|
+
* necessary use {@link resetSync} or {@link disposeSync}.
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```typescript
|
|
125
|
+
* configureSync({
|
|
126
|
+
* sinks: {
|
|
127
|
+
* console: getConsoleSink(),
|
|
128
|
+
* },
|
|
129
|
+
* loggers: [
|
|
130
|
+
* {
|
|
131
|
+
* category: "my-app",
|
|
132
|
+
* sinks: ["console"],
|
|
133
|
+
* level: "info",
|
|
134
|
+
* },
|
|
135
|
+
* {
|
|
136
|
+
* category: "logtape",
|
|
137
|
+
* sinks: ["console"],
|
|
138
|
+
* level: "error",
|
|
139
|
+
* },
|
|
140
|
+
* ],
|
|
141
|
+
* });
|
|
142
|
+
* ```
|
|
143
|
+
*
|
|
144
|
+
* @param config The configuration.
|
|
145
|
+
* @since 0.9.0
|
|
146
|
+
*/
|
|
147
|
+
export declare function configureSync<TSinkId extends string, TFilterId extends string>(config: Config<TSinkId, TFilterId>): void;
|
|
148
|
+
/**
|
|
149
|
+
* Get the current configuration, if any. Otherwise, `null`.
|
|
150
|
+
* @returns The current configuration, if any. Otherwise, `null`.
|
|
151
|
+
*/
|
|
152
|
+
export declare function getConfig(): Config<string, string> | null;
|
|
153
|
+
/**
|
|
154
|
+
* Reset the configuration. Mostly for testing purposes.
|
|
155
|
+
*/
|
|
156
|
+
export declare function reset(): Promise<void>;
|
|
157
|
+
/**
|
|
158
|
+
* Reset the configuration. Mostly for testing purposes. Will not clear async
|
|
159
|
+
* sinks, only use with sync sinks. Use {@link reset} if you have async sinks.
|
|
160
|
+
* @since 0.9.0
|
|
161
|
+
*/
|
|
162
|
+
export declare function resetSync(): void;
|
|
163
|
+
/**
|
|
164
|
+
* Dispose of the disposables.
|
|
165
|
+
*/
|
|
166
|
+
export declare function dispose(): Promise<void>;
|
|
167
|
+
/**
|
|
168
|
+
* Dispose of the sync disposables. Async disposables will be untouched,
|
|
169
|
+
* use {@link dispose} if you have async sinks.
|
|
170
|
+
* @since 0.9.0
|
|
171
|
+
*/
|
|
172
|
+
export declare function disposeSync(): void;
|
|
173
|
+
/**
|
|
174
|
+
* A configuration error.
|
|
175
|
+
*/
|
|
176
|
+
export declare class ConfigError extends Error {
|
|
177
|
+
/**
|
|
178
|
+
* Constructs a new configuration error.
|
|
179
|
+
* @param message The error message.
|
|
180
|
+
*/
|
|
181
|
+
constructor(message: string);
|
|
182
|
+
}
|
|
183
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/logtape/config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,KAAK,UAAU,EAAY,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,EAAkB,KAAK,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,MAAM,CAAC,OAAO,SAAS,MAAM,EAAE,SAAS,SAAS,MAAM;IACtE;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC7B;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAExC;;OAEG;IACH,OAAO,EAAE,YAAY,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,CAAC;IAE5C;;;OAGG;IACH,mBAAmB,CAAC,EAAE,mBAAmB,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAEnE;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY,CAC3B,OAAO,SAAS,MAAM,EACtB,SAAS,SAAS,MAAM;IAExB;;;OAGG;IACH,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAE5B;;OAEG;IACH,KAAK,CA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Storage} API from Node.js.
|
|
4
|
+
* @typeParam T The type of the context-local store.
|
|
5
|
+
* @since 0.7.0
|
|
6
|
+
*/
|
|
7
|
+
export interface ContextLocalStorage<T> {
|
|
8
|
+
/**
|
|
9
|
+
* Runs a callback with the given store as the context-local store.
|
|
10
|
+
* @param store The store to use as the context-local store.
|
|
11
|
+
* @param callback The callback to run.
|
|
12
|
+
* @returns The return value of the callback.
|
|
13
|
+
*/
|
|
14
|
+
run<R>(store: T, callback: () => R): R;
|
|
15
|
+
/**
|
|
16
|
+
* Returns the current context-local store.
|
|
17
|
+
* @returns The current context-local store, or `undefined` if there is no
|
|
18
|
+
* store.
|
|
19
|
+
*/
|
|
20
|
+
getStore(): T | undefined;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Runs a callback with the given implicit context. Every single log record
|
|
24
|
+
* in the callback will have the given context.
|
|
25
|
+
*
|
|
26
|
+
* If no `contextLocalStorage` is configured, this function does nothing and
|
|
27
|
+
* just returns the return value of the callback. It also logs a warning to
|
|
28
|
+
* the `["logtape", "meta"]` logger in this case.
|
|
29
|
+
* @param context The context to inject.
|
|
30
|
+
* @param callback The callback to run.
|
|
31
|
+
* @returns The return value of the callback.
|
|
32
|
+
* @since 0.7.0
|
|
33
|
+
*/
|
|
34
|
+
export declare function withContext<T>(context: Record<string, unknown>, callback: () => T): T;
|
|
35
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/logtape/context.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB,CAAC,CAAC;IACpC;;;;;OAKG;IACH,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IAEvC;;;;OAIG;IACH,QAAQ,IAAI,CAAC,GAAG,SAAS,CAAC;CAC3B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,QAAQ,EAAE,MAAM,CAAC,GAChB,CAAC,CAcH"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { LogLevel } from "./level.js";
|
|
2
|
+
import type { LogRecord } from "./record.js";
|
|
3
|
+
/**
|
|
4
|
+
* A filter is a function that accepts a log record and returns `true` if the
|
|
5
|
+
* record should be passed to the sink.
|
|
6
|
+
*
|
|
7
|
+
* @param record The log record to filter.
|
|
8
|
+
* @returns `true` if the record should be passed to the sink.
|
|
9
|
+
*/
|
|
10
|
+
export type Filter = (record: LogRecord) => boolean;
|
|
11
|
+
/**
|
|
12
|
+
* A filter-like value is either a {@link Filter} or a {@link LogLevel}.
|
|
13
|
+
* `null` is also allowed to represent a filter that rejects all records.
|
|
14
|
+
*/
|
|
15
|
+
export type FilterLike = Filter | LogLevel | null;
|
|
16
|
+
/**
|
|
17
|
+
* Converts a {@link FilterLike} value to an actual {@link Filter}.
|
|
18
|
+
*
|
|
19
|
+
* @param filter The filter-like value to convert.
|
|
20
|
+
* @returns The actual filter.
|
|
21
|
+
*/
|
|
22
|
+
export declare function toFilter(filter: FilterLike): Filter;
|
|
23
|
+
/**
|
|
24
|
+
* Returns a filter that accepts log records with the specified level.
|
|
25
|
+
*
|
|
26
|
+
* @param level The level to filter by. If `null`, the filter will reject all
|
|
27
|
+
* records.
|
|
28
|
+
* @returns The filter.
|
|
29
|
+
*/
|
|
30
|
+
export declare function getLevelFilter(level: LogLevel | null): Filter;
|
|
31
|
+
//# sourceMappingURL=filter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../src/logtape/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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../src/logtape/fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,eAAO,MAAM,IAAI,EAAE,SAOlB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,SAGnB,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,SAGrB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,SAGnB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,SAGnB,CAAC"}
|