@visulima/pail 4.0.0-alpha.9 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +511 -0
- package/LICENSE.md +270 -166
- package/README.md +53 -24
- package/dist/error.d.ts +95 -96
- package/dist/error.js +5 -76
- package/dist/index.browser.d.ts +568 -47
- package/dist/index.browser.js +19 -1499
- package/dist/index.server.d.ts +749 -65
- package/dist/index.server.js +32 -3179
- package/dist/middleware/elysia.d.ts +66 -63
- package/dist/middleware/elysia.js +1 -70
- package/dist/middleware/express.d.ts +74 -71
- package/dist/middleware/express.js +1 -29
- package/dist/middleware/fastify.d.ts +70 -67
- package/dist/middleware/fastify.js +1 -46
- package/dist/middleware/hono.d.ts +75 -72
- package/dist/middleware/hono.js +1 -33
- package/dist/middleware/next/handler.d.ts +102 -34
- package/dist/middleware/next/handler.js +1 -53
- package/dist/middleware/sveltekit.d.ts +101 -98
- package/dist/middleware/sveltekit.js +1 -43
- package/dist/object-tree.d.ts +67 -70
- package/dist/object-tree.js +2 -89
- package/dist/packem_shared/AbstractJsonReporter-Bp_JCrMQ.js +1 -0
- package/dist/packem_shared/AbstractJsonReporter-w_bGGiD-.js +1 -0
- package/dist/packem_shared/JsonReporter-Sd_lJGS-.js +2 -0
- package/dist/packem_shared/JsonReporter-bmem9lcg.js +1 -0
- package/dist/packem_shared/PailError-CbU1Ogfa.js +5 -0
- package/dist/packem_shared/PrettyReporter-CcDdPQSt.js +44 -0
- package/dist/packem_shared/PrettyReporter-DsHfKOU7.js +5 -0
- package/dist/packem_shared/abstract-json-reporter.d-wfESoEa-.d.ts +62 -0
- package/dist/packem_shared/abstract-pretty-reporter-DrLBJ6ds.js +57 -0
- package/dist/packem_shared/addKnownErrorConstructor-C1OJTj2D-0FlJMfXz.js +25 -0
- package/dist/packem_shared/constants-DKfCaSUR.js +1 -0
- package/dist/packem_shared/constants-ep2nsfdy.js +1 -0
- package/dist/packem_shared/create-middleware-logger.d-B-JmQ1Sl.d.ts +47 -0
- package/dist/packem_shared/headers-DH0H2s8W.js +1 -0
- package/dist/packem_shared/index-Q1764hvO.js +1 -0
- package/dist/packem_shared/index.d-T71KjNAr.d.ts +16 -0
- package/dist/packem_shared/pailMiddleware-B5DJoBYl.js +1 -0
- package/dist/packem_shared/serializeError-C-NFvZ8_-D0CA_Qlx.js +1 -0
- package/dist/packem_shared/storage-DaXAlpiO.js +1 -0
- package/dist/packem_shared/types.d-Cz9S7jZh.d.ts +201 -0
- package/dist/packem_shared/types.d-bWnqHJKL.d.ts +211 -0
- package/dist/packem_shared/types.d-xxE3FOD3.d.ts +229 -0
- package/dist/packem_shared/useLogger-DB34CuU5.js +1 -0
- package/dist/packem_shared/wide-event.d-D3ATYpoK.d.ts +717 -0
- package/dist/packem_shared/write-console-log-based-on-level-BqjxV016.js +1 -0
- package/dist/packem_shared/write-stream-C7jxLxIT.js +1 -0
- package/dist/processor/caller/caller-processor.d.ts +50 -47
- package/dist/processor/caller/caller-processor.js +1 -59
- package/dist/processor/environment-processor.d.ts +114 -113
- package/dist/processor/environment-processor.js +1 -78
- package/dist/processor/message-formatter-processor.d.ts +59 -49
- package/dist/processor/message-formatter-processor.js +1 -713
- package/dist/processor/opentelemetry-processor.d.ts +70 -66
- package/dist/processor/opentelemetry-processor.js +1 -52
- package/dist/processor/redact-processor.d.ts +99 -41
- package/dist/processor/redact-processor.js +1 -30
- package/dist/processor/sampling-processor.d.ts +103 -101
- package/dist/processor/sampling-processor.js +1 -59
- package/dist/reporter/file/json-file-reporter.d.ts +109 -42
- package/dist/reporter/file/json-file-reporter.js +2 -136
- package/dist/reporter/http/abstract-http-reporter.d.ts +256 -211
- package/dist/reporter/http/abstract-http-reporter.js +2 -435
- package/dist/reporter/http/http-reporter.d.ts +41 -36
- package/dist/reporter/http/http-reporter.edge-light.d.ts +487 -39
- package/dist/reporter/http/http-reporter.edge-light.js +2 -733
- package/dist/reporter/http/http-reporter.js +1 -13
- package/dist/reporter/json/index.browser.d.ts +98 -3
- package/dist/reporter/json/index.browser.js +1 -2
- package/dist/reporter/json/index.d.ts +53 -3
- package/dist/reporter/json/index.js +1 -2
- package/dist/reporter/pretty/index.browser.d.ts +105 -2
- package/dist/reporter/pretty/index.browser.js +1 -1
- package/dist/reporter/pretty/index.d.ts +270 -2
- package/dist/reporter/pretty/index.js +1 -1
- package/dist/reporter/simple/simple-reporter.server.d.ts +215 -18
- package/dist/reporter/simple/simple-reporter.server.js +8 -182
- package/dist/wide-event.d.ts +6 -300
- package/dist/wide-event.js +1 -281
- package/package.json +22 -37
- package/dist/constants.d.ts +0 -37
- package/dist/interactive/index.d.ts +0 -2
- package/dist/interactive/index.js +0 -2
- package/dist/interactive/interactive-manager.d.ts +0 -108
- package/dist/interactive/interactive-stream-hook.d.ts +0 -68
- package/dist/middleware/next/middleware.d.ts +0 -59
- package/dist/middleware/next/storage.d.ts +0 -14
- package/dist/middleware/shared/create-middleware-logger.d.ts +0 -82
- package/dist/middleware/shared/headers.d.ts +0 -14
- package/dist/middleware/shared/routes.d.ts +0 -30
- package/dist/middleware/shared/storage.d.ts +0 -29
- package/dist/packem_shared/AbstractJsonReporter-CGKHS8_M.js +0 -286
- package/dist/packem_shared/AbstractJsonReporter-DDjDkciI.js +0 -286
- package/dist/packem_shared/InteractiveManager-Cd6A14ZK.js +0 -172
- package/dist/packem_shared/InteractiveStreamHook-ePIURL_U.js +0 -133
- package/dist/packem_shared/JsonReporter-B3XX8GHN.js +0 -58
- package/dist/packem_shared/JsonReporter-p_BXg6Sj.js +0 -28
- package/dist/packem_shared/PrettyReporter-BYL3NrdA.js +0 -214
- package/dist/packem_shared/PrettyReporter-CvBn-hxP.js +0 -1459
- package/dist/packem_shared/Spinner-DIdVcfWq.js +0 -2183
- package/dist/packem_shared/abstract-pretty-reporter-jU8WL_6c.js +0 -2602
- package/dist/packem_shared/constants-B1RjD_ps.js +0 -99
- package/dist/packem_shared/constants-omsTHUWB.js +0 -119
- package/dist/packem_shared/createPailError-B11aRfrT.js +0 -76
- package/dist/packem_shared/getBarChar-BWj1UrH3.js +0 -404
- package/dist/packem_shared/headers-Cp4uLtr4.js +0 -123
- package/dist/packem_shared/index-DnkF86LQ.js +0 -658
- package/dist/packem_shared/index-frijFf5m.js +0 -1252
- package/dist/packem_shared/pailMiddleware-Ci88geIF.js +0 -24
- package/dist/packem_shared/storage-D0vqz8OX.js +0 -36
- package/dist/packem_shared/useLogger-D0rU3lcX.js +0 -33
- package/dist/packem_shared/write-console-log-based-on-level-DBmRYXpj.js +0 -14
- package/dist/packem_shared/write-stream-BG8fhcs3.js +0 -6
- package/dist/pail.browser.d.ts +0 -412
- package/dist/pail.server.d.ts +0 -233
- package/dist/processor/caller/get-caller-filename.d.ts +0 -23
- package/dist/progress-bar.d.ts +0 -136
- package/dist/progress-bar.js +0 -404
- package/dist/reporter/file/utils/rotating-file-stream.d.ts +0 -48
- package/dist/reporter/http/utils/compression.d.ts +0 -7
- package/dist/reporter/http/utils/log-size-error.d.ts +0 -30
- package/dist/reporter/http/utils/retry.d.ts +0 -27
- package/dist/reporter/json/abstract-json-reporter.d.ts +0 -61
- package/dist/reporter/json/json-reporter.browser.d.ts +0 -40
- package/dist/reporter/json/json-reporter.server.d.ts +0 -50
- package/dist/reporter/pretty/abstract-pretty-reporter.d.ts +0 -83
- package/dist/reporter/pretty/pretty-reporter.browser.d.ts +0 -36
- package/dist/reporter/pretty/pretty-reporter.server.d.ts +0 -70
- package/dist/reporter/raw/raw-reporter.browser.d.ts +0 -5
- package/dist/reporter/raw/raw-reporter.server.d.ts +0 -13
- package/dist/reporter/utils/default-inspector-config.d.ts +0 -3
- package/dist/reporter/utils/format-label.d.ts +0 -3
- package/dist/spinner.d.ts +0 -220
- package/dist/spinner.js +0 -2183
- package/dist/types.d.ts +0 -241
- package/dist/utils/ansi-escapes.d.ts +0 -4
- package/dist/utils/arrayify.d.ts +0 -2
- package/dist/utils/get-longest-badge.d.ts +0 -4
- package/dist/utils/get-longest-label.d.ts +0 -4
- package/dist/utils/merge-types.d.ts +0 -4
- package/dist/utils/stream/safe-stream-handler.d.ts +0 -21
- package/dist/utils/write-console-log-based-on-level.d.ts +0 -4
- package/dist/utils/write-stream.d.ts +0 -2
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/pail",
|
|
3
|
-
"version": "4.0.0
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Highly configurable Logger for Node.js, Edge and Browser.",
|
|
5
5
|
"keywords": [
|
|
6
|
-
"ansi",
|
|
7
6
|
"anolilab",
|
|
7
|
+
"ansi",
|
|
8
8
|
"browser",
|
|
9
9
|
"browser-logger",
|
|
10
10
|
"callsite",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"json",
|
|
28
28
|
"json-logger",
|
|
29
29
|
"json-logging",
|
|
30
|
-
"log level",
|
|
31
30
|
"log",
|
|
31
|
+
"log level",
|
|
32
32
|
"log-cleaner",
|
|
33
33
|
"log-rotation",
|
|
34
34
|
"log4j",
|
|
@@ -37,11 +37,10 @@
|
|
|
37
37
|
"logger",
|
|
38
38
|
"logging",
|
|
39
39
|
"node",
|
|
40
|
-
"stream",
|
|
41
|
-
"pretty",
|
|
42
40
|
"node-logger",
|
|
43
41
|
"pail",
|
|
44
42
|
"pino",
|
|
43
|
+
"pretty",
|
|
45
44
|
"pretty-error",
|
|
46
45
|
"pretty-log",
|
|
47
46
|
"print",
|
|
@@ -49,6 +48,7 @@
|
|
|
49
48
|
"redact",
|
|
50
49
|
"rotating-log",
|
|
51
50
|
"show error",
|
|
51
|
+
"stream",
|
|
52
52
|
"timer",
|
|
53
53
|
"universal",
|
|
54
54
|
"visulima",
|
|
@@ -56,9 +56,7 @@
|
|
|
56
56
|
"winston"
|
|
57
57
|
],
|
|
58
58
|
"homepage": "https://visulima.com/packages/pail/",
|
|
59
|
-
"bugs":
|
|
60
|
-
"url": "https://github.com/visulima/visulima/issues"
|
|
61
|
-
},
|
|
59
|
+
"bugs": "https://github.com/visulima/visulima/issues",
|
|
62
60
|
"repository": {
|
|
63
61
|
"type": "git",
|
|
64
62
|
"url": "git+https://github.com/visulima/visulima.git",
|
|
@@ -84,11 +82,11 @@
|
|
|
84
82
|
"type": "module",
|
|
85
83
|
"exports": {
|
|
86
84
|
".": {
|
|
87
|
-
"browser": "./dist/index.browser.js",
|
|
88
85
|
"import": {
|
|
89
86
|
"types": "./dist/index.server.d.ts",
|
|
90
87
|
"default": "./dist/index.server.js"
|
|
91
|
-
}
|
|
88
|
+
},
|
|
89
|
+
"browser": "./dist/index.browser.js"
|
|
92
90
|
},
|
|
93
91
|
"./browser": {
|
|
94
92
|
"types": "./dist/index.browser.d.ts",
|
|
@@ -143,11 +141,11 @@
|
|
|
143
141
|
}
|
|
144
142
|
},
|
|
145
143
|
"./reporter/json": {
|
|
146
|
-
"browser": "./dist/reporter/json/index.browser.js",
|
|
147
144
|
"import": {
|
|
148
145
|
"types": "./dist/reporter/json/index.d.ts",
|
|
149
146
|
"default": "./dist/reporter/json/index.js"
|
|
150
|
-
}
|
|
147
|
+
},
|
|
148
|
+
"browser": "./dist/reporter/json/index.browser.js"
|
|
151
149
|
},
|
|
152
150
|
"./server/reporter/pretty": {
|
|
153
151
|
"import": {
|
|
@@ -162,11 +160,11 @@
|
|
|
162
160
|
}
|
|
163
161
|
},
|
|
164
162
|
"./reporter/pretty": {
|
|
165
|
-
"browser": "./dist/reporter/pretty/index.browser.js",
|
|
166
163
|
"import": {
|
|
167
164
|
"types": "./dist/reporter/pretty/index.d.ts",
|
|
168
165
|
"default": "./dist/reporter/pretty/index.js"
|
|
169
|
-
}
|
|
166
|
+
},
|
|
167
|
+
"browser": "./dist/reporter/pretty/index.browser.js"
|
|
170
168
|
},
|
|
171
169
|
"./reporter/simple": {
|
|
172
170
|
"types": "./dist/reporter/simple/simple-reporter.server.d.ts",
|
|
@@ -177,6 +175,10 @@
|
|
|
177
175
|
"default": "./dist/reporter/http/abstract-http-reporter.js"
|
|
178
176
|
},
|
|
179
177
|
"./reporter/http": {
|
|
178
|
+
"import": {
|
|
179
|
+
"types": "./dist/reporter/http/http-reporter.d.ts",
|
|
180
|
+
"default": "./dist/reporter/http/http-reporter.js"
|
|
181
|
+
},
|
|
180
182
|
"edge-light": {
|
|
181
183
|
"types": "./dist/reporter/http/http-reporter.edge-light.d.ts",
|
|
182
184
|
"default": "./dist/reporter/http/http-reporter.edge-light.js"
|
|
@@ -184,24 +186,8 @@
|
|
|
184
186
|
"browser": {
|
|
185
187
|
"types": "./dist/reporter/http/http-reporter.d.ts",
|
|
186
188
|
"default": "./dist/reporter/http/http-reporter.js"
|
|
187
|
-
},
|
|
188
|
-
"import": {
|
|
189
|
-
"types": "./dist/reporter/http/http-reporter.d.ts",
|
|
190
|
-
"default": "./dist/reporter/http/http-reporter.js"
|
|
191
189
|
}
|
|
192
190
|
},
|
|
193
|
-
"./progress-bar": {
|
|
194
|
-
"types": "./dist/progress-bar.d.ts",
|
|
195
|
-
"default": "./dist/progress-bar.js"
|
|
196
|
-
},
|
|
197
|
-
"./spinner": {
|
|
198
|
-
"types": "./dist/spinner.d.ts",
|
|
199
|
-
"default": "./dist/spinner.js"
|
|
200
|
-
},
|
|
201
|
-
"./interactive": {
|
|
202
|
-
"types": "./dist/interactive/index.d.ts",
|
|
203
|
-
"default": "./dist/interactive/index.js"
|
|
204
|
-
},
|
|
205
191
|
"./object-tree": {
|
|
206
192
|
"types": "./dist/object-tree.d.ts",
|
|
207
193
|
"default": "./dist/object-tree.js"
|
|
@@ -243,19 +229,19 @@
|
|
|
243
229
|
"LICENSE.md"
|
|
244
230
|
],
|
|
245
231
|
"dependencies": {
|
|
246
|
-
"@visulima/colorize": "2.0.0
|
|
247
|
-
"
|
|
232
|
+
"@visulima/colorize": "2.0.0",
|
|
233
|
+
"@visulima/interactive-manager": "1.0.0"
|
|
248
234
|
},
|
|
249
235
|
"peerDependencies": {
|
|
250
|
-
"@opentelemetry/api": "^1.9",
|
|
236
|
+
"@opentelemetry/api": "^1.9.1",
|
|
251
237
|
"@sveltejs/kit": ">=2.0",
|
|
252
|
-
"@visulima/redact": "3.0.0
|
|
238
|
+
"@visulima/redact": "3.0.0",
|
|
253
239
|
"elysia": ">=1.0",
|
|
254
240
|
"express": ">=4.0",
|
|
255
241
|
"fastify": ">=4.0",
|
|
256
242
|
"hono": ">=4.0",
|
|
257
243
|
"next": ">=14.0",
|
|
258
|
-
"rotating-file-stream": "3.2.9"
|
|
244
|
+
"rotating-file-stream": ">=3.2.9"
|
|
259
245
|
},
|
|
260
246
|
"peerDependenciesMeta": {
|
|
261
247
|
"@opentelemetry/api": {
|
|
@@ -286,9 +272,8 @@
|
|
|
286
272
|
"optional": true
|
|
287
273
|
}
|
|
288
274
|
},
|
|
289
|
-
"optionalDependencies": {},
|
|
290
275
|
"engines": {
|
|
291
|
-
"node": "
|
|
276
|
+
"node": "^22.14.0 || >=24.10.0"
|
|
292
277
|
},
|
|
293
278
|
"os": [
|
|
294
279
|
"darwin",
|
package/dist/constants.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { DefaultLoggerTypes } from "./types.d.ts";
|
|
2
|
-
/**
|
|
3
|
-
* Extended RFC 5424 Log Levels
|
|
4
|
-
*
|
|
5
|
-
* The log levels pail uses are those defined in the syslog protocol.
|
|
6
|
-
* Each level is assigned a numeric priority where lower numbers indicate higher priority.
|
|
7
|
-
* @see https://datatracker.ietf.org/doc/html/rfc5424#page-36
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* import { EXTENDED_RFC_5424_LOG_LEVELS } from "@visulima/pail";
|
|
11
|
-
*
|
|
12
|
-
* console.log(EXTENDED_RFC_5424_LOG_LEVELS.error); // 5
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
export declare const EXTENDED_RFC_5424_LOG_LEVELS: Record<string, number>;
|
|
16
|
-
/**
|
|
17
|
-
* Default Logger Types Configuration
|
|
18
|
-
*
|
|
19
|
-
* Predefined logger types with their associated colors, labels, and log levels.
|
|
20
|
-
* These types provide semantic meaning to different kinds of log messages.
|
|
21
|
-
* @example
|
|
22
|
-
* ```typescript
|
|
23
|
-
* import { LOG_TYPES } from "@visulima/pail";
|
|
24
|
-
*
|
|
25
|
-
* console.log(LOG_TYPES.error.color); // "red"
|
|
26
|
-
* console.log(LOG_TYPES.success.label); // "success"
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
export declare const LOG_TYPES: DefaultLoggerTypes;
|
|
30
|
-
/**
|
|
31
|
-
* Empty Symbol
|
|
32
|
-
*
|
|
33
|
-
* A unique symbol used internally to represent empty or undefined message values.
|
|
34
|
-
* This helps distinguish between intentional empty messages and undefined values.
|
|
35
|
-
* @internal
|
|
36
|
-
*/
|
|
37
|
-
export declare const EMPTY_SYMBOL: symbol;
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import type InteractiveStreamHook from "./interactive-stream-hook.d.ts";
|
|
2
|
-
/** Supported stream types for interactive output */
|
|
3
|
-
type StreamType = "stderr" | "stdout";
|
|
4
|
-
/**
|
|
5
|
-
* Interactive Manager.
|
|
6
|
-
*
|
|
7
|
-
* Manages interactive terminal output by coordinating stdout and stderr streams.
|
|
8
|
-
* Enables features like progress bars, spinners, and dynamic updates by temporarily
|
|
9
|
-
* capturing and controlling terminal output. Supports suspending and resuming
|
|
10
|
-
* interactive mode for external output.
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* const manager = new InteractiveManager(stdoutHook, stderrHook);
|
|
14
|
-
*
|
|
15
|
-
* // Start interactive mode
|
|
16
|
-
* manager.hook();
|
|
17
|
-
*
|
|
18
|
-
* // Update output dynamically
|
|
19
|
-
* manager.update("stdout", ["Processing...", "50% complete"]);
|
|
20
|
-
*
|
|
21
|
-
* // Temporarily suspend for external output
|
|
22
|
-
* manager.suspend("stdout");
|
|
23
|
-
* console.log("External message");
|
|
24
|
-
* manager.resume("stdout");
|
|
25
|
-
*
|
|
26
|
-
* // End interactive mode and show final output
|
|
27
|
-
* manager.unhook();
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
|
-
declare class InteractiveManager {
|
|
31
|
-
#private;
|
|
32
|
-
/**
|
|
33
|
-
* Creates a new InteractiveManager with the given stream hooks.
|
|
34
|
-
* @param stdout Hook for stdout stream
|
|
35
|
-
* @param stderr Hook for stderr stream
|
|
36
|
-
*/
|
|
37
|
-
constructor(stdout: InteractiveStreamHook, stderr: InteractiveStreamHook);
|
|
38
|
-
/**
|
|
39
|
-
* Last printed rows count.
|
|
40
|
-
*
|
|
41
|
-
* Tracks the number of rows that were last written to the terminal.
|
|
42
|
-
* Used internally for managing cursor positioning and output updates.
|
|
43
|
-
*/
|
|
44
|
-
get lastLength(): number;
|
|
45
|
-
/**
|
|
46
|
-
* Rows count outside editable area.
|
|
47
|
-
*
|
|
48
|
-
* Tracks the number of rows that extend beyond the current terminal height.
|
|
49
|
-
* Used for managing scrolling and ensuring all output remains visible.
|
|
50
|
-
*/
|
|
51
|
-
get outside(): number;
|
|
52
|
-
/**
|
|
53
|
-
* Hook activity status.
|
|
54
|
-
*
|
|
55
|
-
* Indicates whether the interactive hooks are currently active.
|
|
56
|
-
* When true, streams are being intercepted for interactive output.
|
|
57
|
-
*/
|
|
58
|
-
get isHooked(): boolean;
|
|
59
|
-
/**
|
|
60
|
-
* Suspend status for active hooks.
|
|
61
|
-
*
|
|
62
|
-
* Indicates whether interactive mode is temporarily suspended.
|
|
63
|
-
* When suspended, external output can be written without interference.
|
|
64
|
-
*/
|
|
65
|
-
get isSuspended(): boolean;
|
|
66
|
-
/**
|
|
67
|
-
* Removes lines from the terminal output.
|
|
68
|
-
*
|
|
69
|
-
* Erases the specified number of lines from the bottom of the output,
|
|
70
|
-
* moving the cursor up and clearing the lines. Useful for removing
|
|
71
|
-
* previous interactive output before displaying new content.
|
|
72
|
-
* @param stream The stream to erase lines from ("stdout" or "stderr")
|
|
73
|
-
* @param count Number of lines to remove (defaults to lastLength)
|
|
74
|
-
* @throws {TypeError} If the specified stream is not available
|
|
75
|
-
*/
|
|
76
|
-
erase(stream: StreamType, count?: number): void;
|
|
77
|
-
/**
|
|
78
|
-
* Hook stdout and stderr streams.
|
|
79
|
-
* @returns Success status
|
|
80
|
-
*/
|
|
81
|
-
hook(): boolean;
|
|
82
|
-
/**
|
|
83
|
-
* Resume suspend hooks.
|
|
84
|
-
* @param stream Stream to resume
|
|
85
|
-
* @param eraseRowCount erase output rows count
|
|
86
|
-
*/
|
|
87
|
-
resume(stream: StreamType, eraseRowCount?: number): void;
|
|
88
|
-
/**
|
|
89
|
-
* Suspend active hooks for external output.
|
|
90
|
-
* @param stream Stream to suspend
|
|
91
|
-
* @param erase erase output
|
|
92
|
-
*/
|
|
93
|
-
suspend(stream: StreamType, erase?: boolean): void;
|
|
94
|
-
/**
|
|
95
|
-
* Unhooks both stdout and stderr streams and print their story of logs.
|
|
96
|
-
* @param separateHistory If `true`, will add an empty line to the history output for individual recorded lines and console logs
|
|
97
|
-
* @returns Success status
|
|
98
|
-
*/
|
|
99
|
-
unhook(separateHistory?: boolean): boolean;
|
|
100
|
-
/**
|
|
101
|
-
* Update output.
|
|
102
|
-
* @param stream Stream to write to
|
|
103
|
-
* @param rows Text lines to write to standard output
|
|
104
|
-
* @param from Index of the line starting from which the contents of the terminal are being overwritten
|
|
105
|
-
*/
|
|
106
|
-
update(stream: StreamType, rows: string[], from?: number): void;
|
|
107
|
-
}
|
|
108
|
-
export default InteractiveManager;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Interactive Stream Hook.
|
|
3
|
-
*
|
|
4
|
-
* A utility class that hooks into Node.js WriteStreams to capture output
|
|
5
|
-
* for interactive terminal applications. It allows temporarily intercepting
|
|
6
|
-
* stream writes to enable features like progress bars and dynamic updates.
|
|
7
|
-
* @example
|
|
8
|
-
* ```typescript
|
|
9
|
-
* const hook = new InteractiveStreamHook(process.stdout);
|
|
10
|
-
* hook.active(); // Start capturing output
|
|
11
|
-
*
|
|
12
|
-
* // Output will be stored in history instead of being written to stdout
|
|
13
|
-
* console.log("This won't appear immediately");
|
|
14
|
-
*
|
|
15
|
-
* hook.inactive(); // Stop capturing and replay stored output
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
declare class InteractiveStreamHook {
|
|
19
|
-
#private;
|
|
20
|
-
/** Constant indicating the stream write operation was successful */
|
|
21
|
-
static readonly DRAIN = true;
|
|
22
|
-
/**
|
|
23
|
-
* Creates a new InteractiveStreamHook for the given stream.
|
|
24
|
-
* @param stream The Node.js WriteStream to hook into (usually stdout or stderr)
|
|
25
|
-
*/
|
|
26
|
-
constructor(stream: NodeJS.WriteStream);
|
|
27
|
-
/**
|
|
28
|
-
* Activates the stream hook.
|
|
29
|
-
*
|
|
30
|
-
* When active, all writes to the stream are captured in history instead of
|
|
31
|
-
* being written immediately. This allows for interactive features like
|
|
32
|
-
* progress bars that can update dynamically.
|
|
33
|
-
*/
|
|
34
|
-
active(): void;
|
|
35
|
-
/**
|
|
36
|
-
* Erases the specified number of lines from the terminal.
|
|
37
|
-
*
|
|
38
|
-
* Uses ANSI escape sequences to remove lines from the current cursor position
|
|
39
|
-
* upwards, which is useful for clearing previous output in interactive applications.
|
|
40
|
-
* @param count Number of lines to erase (including the current line)
|
|
41
|
-
*/
|
|
42
|
-
erase(count: number): void;
|
|
43
|
-
/**
|
|
44
|
-
* Deactivates the stream hook and replays captured output.
|
|
45
|
-
*
|
|
46
|
-
* Restores normal stream operation and outputs all captured history.
|
|
47
|
-
* Optionally adds a newline separator before replaying the history.
|
|
48
|
-
* @param separateHistory Whether to add a newline before replaying history
|
|
49
|
-
*/
|
|
50
|
-
inactive(separateHistory?: boolean): void;
|
|
51
|
-
/**
|
|
52
|
-
* Renews the stream hook state.
|
|
53
|
-
*
|
|
54
|
-
* Restores the original stream write method and shows the cursor.
|
|
55
|
-
* This is typically called when temporarily suspending interactive mode.
|
|
56
|
-
*/
|
|
57
|
-
renew(): void;
|
|
58
|
-
/**
|
|
59
|
-
* Writes a message directly to the underlying stream.
|
|
60
|
-
*
|
|
61
|
-
* Bypasses the hook mechanism and writes directly using the original
|
|
62
|
-
* stream write method. Useful for writing control sequences or
|
|
63
|
-
* messages that should not be captured in history.
|
|
64
|
-
* @param message The message to write to the stream
|
|
65
|
-
*/
|
|
66
|
-
write(message: string): void;
|
|
67
|
-
}
|
|
68
|
-
export default InteractiveStreamHook;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Minimal type definitions to avoid requiring next as a dependency.
|
|
3
|
-
*/
|
|
4
|
-
interface NextRequest {
|
|
5
|
-
headers: Headers;
|
|
6
|
-
nextUrl: {
|
|
7
|
-
pathname: string;
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
interface NextResponse {
|
|
11
|
-
headers: Headers;
|
|
12
|
-
}
|
|
13
|
-
interface NextResponseConstructor {
|
|
14
|
-
next: (options?: {
|
|
15
|
-
request?: {
|
|
16
|
-
headers?: Headers;
|
|
17
|
-
};
|
|
18
|
-
}) => NextResponse;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Options for the Next.js pail middleware.
|
|
22
|
-
*/
|
|
23
|
-
interface PailNextMiddlewareOptions {
|
|
24
|
-
/**
|
|
25
|
-
* Glob patterns for paths to exclude from logging.
|
|
26
|
-
* Excluded paths won't get request IDs or timing headers.
|
|
27
|
-
* @example ["/_next/**", "/favicon.ico"]
|
|
28
|
-
*/
|
|
29
|
-
exclude?: string[];
|
|
30
|
-
/**
|
|
31
|
-
* Glob patterns for paths to include in logging.
|
|
32
|
-
* If not set, all non-excluded paths are included.
|
|
33
|
-
*/
|
|
34
|
-
include?: string[];
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Create a Next.js edge middleware that sets `x-request-id` and `x-pail-start`
|
|
38
|
-
* headers on the request for downstream use by `withPail()`.
|
|
39
|
-
*
|
|
40
|
-
* This middleware runs at the edge and prepares request metadata.
|
|
41
|
-
* The actual wide event logging happens in `withPail()`.
|
|
42
|
-
* @param NextResponseClass The NextResponse class from "next/server.d.ts";
|
|
43
|
-
* @param options Middleware configuration
|
|
44
|
-
* @returns A middleware function
|
|
45
|
-
* @example
|
|
46
|
-
* ```typescript
|
|
47
|
-
* // middleware.ts
|
|
48
|
-
* import { NextResponse } from "next/server.d.ts";
|
|
49
|
-
* import { pailMiddleware } from "@visulima/pail/middleware/next";
|
|
50
|
-
*
|
|
51
|
-
* const middleware = pailMiddleware(NextResponse, {
|
|
52
|
-
* exclude: ["/_next/**", "/favicon.ico"],
|
|
53
|
-
* });
|
|
54
|
-
*
|
|
55
|
-
* export default middleware;
|
|
56
|
-
* ```
|
|
57
|
-
*/
|
|
58
|
-
export declare const pailMiddleware: (NextResponseClass: NextResponseConstructor, options?: PailNextMiddlewareOptions) => (request: NextRequest) => NextResponse;
|
|
59
|
-
export type { PailNextMiddlewareOptions };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
-
import type { WideEvent } from "../../wide-event.d.ts";
|
|
3
|
-
/**
|
|
4
|
-
* AsyncLocalStorage instance used to propagate the WideEvent logger
|
|
5
|
-
* through Next.js server actions, route handlers, and server components.
|
|
6
|
-
*/
|
|
7
|
-
export declare const pailStorage: AsyncLocalStorage<WideEvent>;
|
|
8
|
-
/**
|
|
9
|
-
* Retrieve the request-scoped WideEvent logger from AsyncLocalStorage.
|
|
10
|
-
* Must be called within a `withPail()` wrapped handler or server action.
|
|
11
|
-
* @returns The request-scoped WideEvent logger
|
|
12
|
-
* @throws Error if called outside of a withPail context
|
|
13
|
-
*/
|
|
14
|
-
export declare const useLogger: () => WideEvent;
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import type { PailBrowserImpl } from "../../pail.d.ts";
|
|
2
|
-
import type { DefaultLogTypes, LoggerFunction } from "../../types.d.ts";
|
|
3
|
-
import type { WideEventFinishOptions } from "../../wide-event.d.ts";
|
|
4
|
-
import { WideEvent } from "../../wide-event.d.ts";
|
|
5
|
-
import type { RouteConfig } from "./routes.d.ts";
|
|
6
|
-
/**
|
|
7
|
-
* A pail instance with dynamically generated log methods.
|
|
8
|
-
*/
|
|
9
|
-
type PailLike<T extends string = string> = PailBrowserImpl<T> & Record<DefaultLogTypes | T, LoggerFunction>;
|
|
10
|
-
/**
|
|
11
|
-
* Base options shared by all framework middleware adapters.
|
|
12
|
-
* @template T - Custom logger type names from the pail instance
|
|
13
|
-
*/
|
|
14
|
-
export interface PailMiddlewareOptions<T extends string = string> {
|
|
15
|
-
/**
|
|
16
|
-
* Glob patterns for paths to exclude from logging.
|
|
17
|
-
* Exclusions take precedence over inclusions.
|
|
18
|
-
* @example ["/health", "/api/_internal/**"]
|
|
19
|
-
*/
|
|
20
|
-
exclude?: string[];
|
|
21
|
-
/**
|
|
22
|
-
* Glob patterns for paths to include in logging.
|
|
23
|
-
* If not set, all non-excluded paths are logged.
|
|
24
|
-
* @example ["/api/**"]
|
|
25
|
-
*/
|
|
26
|
-
include?: string[];
|
|
27
|
-
/**
|
|
28
|
-
* The pail logger instance to use for wide event emission.
|
|
29
|
-
*/
|
|
30
|
-
pail: PailLike<T>;
|
|
31
|
-
/**
|
|
32
|
-
* Route-specific configuration. Maps glob patterns to config.
|
|
33
|
-
* First matching route wins.
|
|
34
|
-
* @example { "/api/auth/**": { service: "auth-service" } }
|
|
35
|
-
*/
|
|
36
|
-
routes?: Record<string, RouteConfig>;
|
|
37
|
-
/**
|
|
38
|
-
* Default service name for all wide events.
|
|
39
|
-
* Can be overridden per-route via `routes`.
|
|
40
|
-
*/
|
|
41
|
-
service?: string;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Result of creating a middleware logger for a request.
|
|
45
|
-
*/
|
|
46
|
-
export interface MiddlewareLoggerResult {
|
|
47
|
-
/**
|
|
48
|
-
* Finalize and emit the wide event. Sets status/error before emitting.
|
|
49
|
-
* Safe to call multiple times — only the first call emits.
|
|
50
|
-
*/
|
|
51
|
-
finish: (options?: WideEventFinishOptions) => void;
|
|
52
|
-
/**
|
|
53
|
-
* The request-scoped WideEvent logger.
|
|
54
|
-
* Use `set()`, `info()`, `warn()`, `error()`, `debug()` to accumulate context.
|
|
55
|
-
*/
|
|
56
|
-
logger: WideEvent;
|
|
57
|
-
/**
|
|
58
|
-
* Whether this request was skipped (excluded from logging).
|
|
59
|
-
* When true, `logger` and `finish` should not be used.
|
|
60
|
-
*/
|
|
61
|
-
skipped: boolean;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Core factory function used by all framework middleware adapters.
|
|
65
|
-
*
|
|
66
|
-
* Creates a WideEvent for the given request, checks route inclusion/exclusion,
|
|
67
|
-
* resolves the service name, and returns a logger + finish callback.
|
|
68
|
-
* @param options Middleware options including pail instance and route config
|
|
69
|
-
* @param request Request metadata for the current HTTP request
|
|
70
|
-
* @param request.headers Safe headers extracted from the request
|
|
71
|
-
* @param request.method The HTTP method (GET, POST, etc.)
|
|
72
|
-
* @param request.path The URL path of the request
|
|
73
|
-
* @param request.requestId A unique identifier for this request
|
|
74
|
-
* @returns A result object with logger, finish callback, and skipped flag
|
|
75
|
-
*/
|
|
76
|
-
export declare const createMiddlewareLogger: <T extends string = string>(options: PailMiddlewareOptions<T>, request: {
|
|
77
|
-
headers?: Record<string, string>;
|
|
78
|
-
method: string;
|
|
79
|
-
path: string;
|
|
80
|
-
requestId: string;
|
|
81
|
-
}) => MiddlewareLoggerResult;
|
|
82
|
-
export {};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Extract safe headers from a Web API Headers object, filtering out
|
|
3
|
-
* sensitive headers like Authorization, Cookie, and API keys.
|
|
4
|
-
* @param headers Web API Headers object
|
|
5
|
-
* @returns Plain object of safe header key-value pairs
|
|
6
|
-
*/
|
|
7
|
-
export declare const extractSafeHeaders: (headers: Headers) => Record<string, string>;
|
|
8
|
-
/**
|
|
9
|
-
* Extract safe headers from a Node.js IncomingHttpHeaders object,
|
|
10
|
-
* filtering out sensitive headers.
|
|
11
|
-
* @param headers Node.js IncomingHttpHeaders-like object
|
|
12
|
-
* @returns Plain object of safe header key-value pairs
|
|
13
|
-
*/
|
|
14
|
-
export declare const extractSafeNodeHeaders: (headers: Record<string, string | string[] | undefined>) => Record<string, string>;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Check if a path matches a glob pattern.
|
|
3
|
-
*/
|
|
4
|
-
export declare const matchesPattern: (path: string, pattern: string) => boolean;
|
|
5
|
-
/**
|
|
6
|
-
* Route configuration for a specific path pattern.
|
|
7
|
-
*/
|
|
8
|
-
export interface RouteConfig {
|
|
9
|
-
/** Override the service name for requests matching this route. */
|
|
10
|
-
service?: string;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Determine whether a request path should be logged based on include/exclude patterns.
|
|
14
|
-
*
|
|
15
|
-
* - Exclusions take precedence over inclusions.
|
|
16
|
-
* - If no include patterns are provided, all non-excluded paths are logged.
|
|
17
|
-
* @param path The request path
|
|
18
|
-
* @param include Glob patterns of paths to include
|
|
19
|
-
* @param exclude Glob patterns of paths to exclude
|
|
20
|
-
* @returns Whether the path should be logged
|
|
21
|
-
*/
|
|
22
|
-
export declare const shouldLog: (path: string, include?: string[], exclude?: string[]) => boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Get the service name override for a given path based on route configuration.
|
|
25
|
-
* Returns the first matching route's service name, or undefined if no match.
|
|
26
|
-
* @param path The request path
|
|
27
|
-
* @param routes Route configuration map (pattern → config)
|
|
28
|
-
* @returns The service name override, or undefined
|
|
29
|
-
*/
|
|
30
|
-
export declare const getServiceForPath: (path: string, routes?: Record<string, RouteConfig>) => string | undefined;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
-
import type { WideEvent } from "../../wide-event.d.ts";
|
|
3
|
-
/**
|
|
4
|
-
* Create an isolated AsyncLocalStorage instance and a `useLogger` accessor
|
|
5
|
-
* for retrieving the request-scoped WideEvent from anywhere in the call stack.
|
|
6
|
-
*
|
|
7
|
-
* Each framework adapter should call this once at module level to get its own
|
|
8
|
-
* isolated storage instance.
|
|
9
|
-
* @param contextHint A description of the expected context, used in the
|
|
10
|
-
* error message when `useLogger` is called outside of a request scope.
|
|
11
|
-
* @returns An object with `storage` and `useLogger`
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* const { storage, useLogger } = createLoggerStorage(
|
|
15
|
-
* "Express middleware context. Make sure evlog middleware is registered."
|
|
16
|
-
* );
|
|
17
|
-
*
|
|
18
|
-
* // In middleware:
|
|
19
|
-
* storage.run(wideEvent, () => next());
|
|
20
|
-
*
|
|
21
|
-
* // In handler:
|
|
22
|
-
* const log = useLogger();
|
|
23
|
-
* log.set({ user: { id: 1 } });
|
|
24
|
-
* ```
|
|
25
|
-
*/
|
|
26
|
-
export declare const createLoggerStorage: (contextHint: string) => {
|
|
27
|
-
storage: AsyncLocalStorage<WideEvent>;
|
|
28
|
-
useLogger: () => WideEvent;
|
|
29
|
-
};
|