@visulima/pail 4.0.0-alpha.9 → 4.0.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/CHANGELOG.md +519 -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 +43 -58
- 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
|
@@ -1,20 +1,217 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { LiteralUnion } from 'type-fest';
|
|
2
|
+
import { InteractiveManager } from '@visulima/interactive-manager';
|
|
3
|
+
import { D as DefaultLogTypes, L as LoggerTypesConfig, f as ReadonlyMeta, d as LoggerTypesAwareReporter, I as InteractiveStreamReporter } from "../../packem_shared/types.d-Cz9S7jZh.js";
|
|
4
|
+
import '@visulima/colorize';
|
|
5
|
+
type ColorizeMethod = (value: string) => string;
|
|
6
|
+
type CodeFrameOptions = {
|
|
7
|
+
color?: {
|
|
8
|
+
gutter?: ColorizeMethod;
|
|
9
|
+
marker?: ColorizeMethod;
|
|
10
|
+
message?: ColorizeMethod;
|
|
11
|
+
};
|
|
12
|
+
linesAbove?: number;
|
|
13
|
+
linesBelow?: number;
|
|
14
|
+
message?: string;
|
|
15
|
+
prefix?: string;
|
|
16
|
+
showGutter?: boolean;
|
|
17
|
+
showLineNumbers?: boolean;
|
|
18
|
+
tabWidth?: number | false;
|
|
10
19
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
log(meta: ReadonlyMeta<L>): void;
|
|
19
|
-
protected formatMessage(data: ReadonlyMeta<L>): string;
|
|
20
|
+
/**
|
|
21
|
+
* The compiled position of a stack frame handed to a {@link SourceMapResolver}.
|
|
22
|
+
*/
|
|
23
|
+
interface SourceMapLocation {
|
|
24
|
+
column?: number;
|
|
25
|
+
file: string;
|
|
26
|
+
line: number;
|
|
20
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* The resolved original position returned by a {@link SourceMapResolver}. Any omitted field falls
|
|
30
|
+
* back to the compiled value. `source`, when provided, is used directly as the code-frame content
|
|
31
|
+
* (e.g. from an inlined `sourcesContent`) instead of reading the resolved file from disk.
|
|
32
|
+
*/
|
|
33
|
+
interface ResolvedSourceLocation {
|
|
34
|
+
column?: number;
|
|
35
|
+
file?: string;
|
|
36
|
+
line?: number;
|
|
37
|
+
source?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Pluggable hook that maps a compiled `*.js:line:col` position back to its original source position
|
|
41
|
+
* (e.g. TS/JSX). Return `undefined` (or throw) to leave the frame untouched. Synchronous so it can
|
|
42
|
+
* be used by the synchronous `renderError`; resolve/inline your maps ahead of time.
|
|
43
|
+
*/
|
|
44
|
+
type SourceMapResolver = (location: SourceMapLocation) => ResolvedSourceLocation | undefined;
|
|
45
|
+
type Options$1 = {
|
|
46
|
+
/**
|
|
47
|
+
* Read source files for code frames from anywhere on disk, including absolute paths outside
|
|
48
|
+
* `cwd`. Defaults to `false`, in which case only files resolving inside `cwd` are read — this
|
|
49
|
+
* prevents local file disclosure when rendering errors whose stack came from untrusted input
|
|
50
|
+
* (e.g. a deserialized error). Enable only for trusted, locally-thrown errors.
|
|
51
|
+
* @default false
|
|
52
|
+
*/
|
|
53
|
+
allowAllFilePaths: boolean;
|
|
54
|
+
color: CodeFrameOptions["color"] & {
|
|
55
|
+
fileLine: ColorizeMethod;
|
|
56
|
+
hint: ColorizeMethod;
|
|
57
|
+
method: ColorizeMethod;
|
|
58
|
+
title: ColorizeMethod;
|
|
59
|
+
};
|
|
60
|
+
cwd: string;
|
|
61
|
+
displayShortPath: boolean;
|
|
62
|
+
filterStacktrace: ((line: string) => boolean) | undefined;
|
|
63
|
+
framesMaxLimit: number;
|
|
64
|
+
hideErrorCauseCodeView: boolean;
|
|
65
|
+
hideErrorCodeView: boolean;
|
|
66
|
+
hideErrorErrorsCodeView: boolean;
|
|
67
|
+
hideErrorTitle: boolean;
|
|
68
|
+
hideMessage: boolean;
|
|
69
|
+
indentation: number | " ";
|
|
70
|
+
prefix: string; /** Optional source-map resolver to map compiled frame positions back to original source. */
|
|
71
|
+
sourceMap?: SourceMapResolver;
|
|
72
|
+
} & Omit<CodeFrameOptions, "message | prefix">;
|
|
73
|
+
interface Options {
|
|
74
|
+
/**
|
|
75
|
+
* When `true`, honour custom inspectors: a value's
|
|
76
|
+
* `Symbol.for("nodejs.util.inspect.custom")` method (Node only),
|
|
77
|
+
* `Symbol.for("chai/inspect")` method, an `.inspect()` method, or a handler
|
|
78
|
+
* registered via `registerConstructor` / `registerStringTag`.
|
|
79
|
+
* @default true
|
|
80
|
+
*/
|
|
81
|
+
customInspect: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* The maximum nesting depth to traverse before collapsing a nested value to
|
|
84
|
+
* `[Object]` / `[Array]`. A value `<= 0` disables the limit.
|
|
85
|
+
* @default 5
|
|
86
|
+
*/
|
|
87
|
+
depth: number;
|
|
88
|
+
/**
|
|
89
|
+
* Pretty-print with indentation. `"\t"` indents with tabs, a positive integer
|
|
90
|
+
* indents with that many spaces, and `undefined` keeps everything on one line.
|
|
91
|
+
* @default undefined
|
|
92
|
+
*/
|
|
93
|
+
indent: number | " " | undefined;
|
|
94
|
+
/**
|
|
95
|
+
* The maximum number of array / typed-array / iterable elements to render
|
|
96
|
+
* before the remainder is replaced with an `… (N more)` marker. Use
|
|
97
|
+
* `Number.POSITIVE_INFINITY` to show every element.
|
|
98
|
+
* @default Number.POSITIVE_INFINITY
|
|
99
|
+
*/
|
|
100
|
+
maxArrayLength: number;
|
|
101
|
+
/**
|
|
102
|
+
* When `true`, render large numbers and bigints with `_` digit-group
|
|
103
|
+
* separators (e.g. `1_000_000`).
|
|
104
|
+
* @default true
|
|
105
|
+
*/
|
|
106
|
+
numericSeparator: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* The quote character used when rendering string values and complex object
|
|
109
|
+
* keys.
|
|
110
|
+
* @default "single"
|
|
111
|
+
*/
|
|
112
|
+
quoteStyle: "double" | "single";
|
|
113
|
+
/**
|
|
114
|
+
* When `true`, also render non-enumerable own properties of plain objects
|
|
115
|
+
* (mirrors `util.inspect`'s `showHidden`).
|
|
116
|
+
* @default false
|
|
117
|
+
*/
|
|
118
|
+
showHidden: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Colourize / decorate a rendered fragment. Receives the raw fragment and a
|
|
121
|
+
* style hint and must return the (optionally wrapped) string. Defaults to the
|
|
122
|
+
* identity function.
|
|
123
|
+
*/
|
|
124
|
+
stylize: (value: string, styleType: LiteralUnion<"bigint" | "boolean" | "date" | "null" | "number" | "regexp" | "special" | "string" | "symbol" | "undefined", string>) => string;
|
|
125
|
+
/**
|
|
126
|
+
* The maximum length (in characters) of a single rendered value before it is
|
|
127
|
+
* truncated with an ellipsis. Use `Number.POSITIVE_INFINITY` to disable
|
|
128
|
+
* truncation.
|
|
129
|
+
* @default Number.POSITIVE_INFINITY
|
|
130
|
+
*/
|
|
131
|
+
truncate: number;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Abstract Pretty Reporter.
|
|
135
|
+
*
|
|
136
|
+
* Base class for pretty-printing reporters that format log messages with colors,
|
|
137
|
+
* styles, and structured layout. Provides common functionality for styling options
|
|
138
|
+
* and logger type configuration.
|
|
139
|
+
* @template T - Custom logger type names
|
|
140
|
+
* @template L - Log level types
|
|
141
|
+
* @example
|
|
142
|
+
* ```typescript
|
|
143
|
+
* class CustomPrettyReporter extends AbstractPrettyReporter {
|
|
144
|
+
* public log(meta: ReadonlyMeta) {
|
|
145
|
+
* const formatted = this.formatMessage(meta);
|
|
146
|
+
* console.log(formatted);
|
|
147
|
+
* }
|
|
148
|
+
* }
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
declare abstract class AbstractPrettyReporter<T extends string = string, L extends string = string> implements LoggerTypesAwareReporter<T, L> {
|
|
152
|
+
/** Styling options for pretty formatting */
|
|
153
|
+
protected readonly styles: PrettyStyleOptions;
|
|
154
|
+
/** Logger type configurations for styling */
|
|
155
|
+
protected loggerTypes: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>;
|
|
156
|
+
/**
|
|
157
|
+
* Creates a new AbstractPrettyReporter instance.
|
|
158
|
+
* @param options Styling options for pretty formatting
|
|
159
|
+
* @protected
|
|
160
|
+
*/
|
|
161
|
+
protected constructor(options: Partial<PrettyStyleOptions>);
|
|
162
|
+
/**
|
|
163
|
+
* Sets the logger types configuration for styling.
|
|
164
|
+
* @param types Logger type configurations with colors and labels
|
|
165
|
+
*/
|
|
166
|
+
setLoggerTypes(types: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>): void;
|
|
167
|
+
/**
|
|
168
|
+
* Logs a message with pretty formatting.
|
|
169
|
+
* @param meta The log metadata to format and output
|
|
170
|
+
* @abstract
|
|
171
|
+
*/
|
|
172
|
+
abstract log(meta: ReadonlyMeta<L>): void;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Options for configuring pretty reporter styling.
|
|
176
|
+
*/
|
|
177
|
+
type PrettyStyleOptions = {
|
|
178
|
+
/** Bold styling options */
|
|
179
|
+
bold: {
|
|
180
|
+
/** Whether to bold the label text */
|
|
181
|
+
label: boolean;
|
|
182
|
+
};
|
|
183
|
+
/** Function to format dates in log output */
|
|
184
|
+
dateFormatter: (date: Date) => string;
|
|
185
|
+
/** Maximum length of message before line break (optional) */
|
|
186
|
+
messageLength: number | undefined;
|
|
187
|
+
/** Underline styling options */
|
|
188
|
+
underline: {
|
|
189
|
+
/** Whether to underline the label */
|
|
190
|
+
label: boolean;
|
|
191
|
+
/** Whether to underline prefixes */
|
|
192
|
+
prefix: boolean;
|
|
193
|
+
/** Whether to underline suffixes */
|
|
194
|
+
suffix: boolean;
|
|
195
|
+
};
|
|
196
|
+
/** Uppercase styling options */
|
|
197
|
+
uppercase: {
|
|
198
|
+
/** Whether to uppercase the label text */
|
|
199
|
+
label: boolean;
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
type SimpleReporterOptions = PrettyStyleOptions & {
|
|
203
|
+
error: Partial<Omit<Options$1, "color | prefix | indentation">>;
|
|
204
|
+
inspect: Partial<Options>;
|
|
205
|
+
};
|
|
206
|
+
declare class SimpleReporter<T extends string = string, L extends string = string> extends AbstractPrettyReporter<T, L> implements InteractiveStreamReporter<L> {
|
|
207
|
+
#private;
|
|
208
|
+
constructor(options?: Partial<SimpleReporterOptions>);
|
|
209
|
+
override setLoggerTypes(types: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>): void;
|
|
210
|
+
setStdout(stdout_: NodeJS.WriteStream): void;
|
|
211
|
+
setStderr(stderr_: NodeJS.WriteStream): void;
|
|
212
|
+
setInteractiveManager(manager?: InteractiveManager): void;
|
|
213
|
+
setIsInteractive(interactive: boolean): void;
|
|
214
|
+
log(meta: ReadonlyMeta<L>): void;
|
|
215
|
+
protected formatMessage(data: ReadonlyMeta<L>): string;
|
|
216
|
+
}
|
|
217
|
+
export { SimpleReporter, SimpleReporterOptions };
|
|
@@ -1,185 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import{createRequire as P}from"node:module";import L from"@visulima/colorize";import{A as z,c as B,r as D,b as O,d as F,g as G,e as H,f as c,h as K,a as Q,j as C,V as U,U as $,i as X}from"../../packem_shared/abstract-pretty-reporter-DrLBJ6ds.js";const ie=P(import.meta.url),V=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,{stdout:W,stderr:Y}=V,{bgGrey:Z,bold:E,cyan:J,green:N,greenBright:ee,grey:h,red:b,underline:I,white:te}=L,se=/[\\/]pail[\\/]dist/,x=T=>!se.test(T);class he extends z{#e;#r;#i;#h=!1;#o;#s;#t;#a=!1;#n="";#p="";constructor(t={}){const{error:o,inspect:n,...i}=t;super({uppercase:{label:!0,...i.uppercase},...i}),this.#o={...B,indent:void 0,...n},this.#s={...o,color:{fileLine:N,hint:J,marker:b,message:b,method:ee,title:b}},this.#e=W,this.#r=Y,this.#l()}setLoggerTypes(t){super.setLoggerTypes(t),this.#l()}setStdout(t){this.#e=t,this.#t=void 0,this.#a=!1}setStderr(t){this.#r=t}setInteractiveManager(t){this.#i=t}setIsInteractive(t){this.#h=t}log(t){const o=this.formatMessage(t),n=t.type.level,i=D(n)?"stderr":"stdout",a=i==="stderr"?this.#r:this.#e;this.#h&&this.#i!==void 0&&a.isTTY?this.#i.update(i,o.split(`
|
|
2
|
+
`),0):O(`${o}
|
|
3
|
+
`,a)}#l(){this.#n=F(this.loggerTypes),this.#p=G(this.loggerTypes)}#u(){return!this.#a&&typeof this.#e.on=="function"&&(this.#a=!0,this.#e.on("resize",()=>{this.#t=void 0})),this.#t===void 0&&(this.#t=H().columns),this.#t}formatMessage(t){let o=this.#u();typeof this.styles.messageLength=="number"&&(o=this.styles.messageLength);const{badge:n,context:i,date:a,error:S,file:l,groups:f,label:g,message:u,prefix:d,repeated:j,scope:m,suffix:y,traceError:_,type:R}=t,{color:M}=this.loggerTypes[R.name],v=M?L[M]:te,p=f.map(()=>" ").join(""),e=[];if(f.length>0&&e.push(`${p+h(`[${f.at(-1)??""}]`)} `),a&&e.push(`${h(this.styles.dateFormatter(typeof a=="string"?new Date(a):a))} `),n)e.push(E(v(n)));else{const s=this.#n;s.length>0&&e.push(h(" ".repeat(s.length)))}const A=this.#p,w=c(A);if(g){const s=c(g),r=Math.max(0,w-s);e.push(`${E(v(K(g,this.styles)))} `," ".repeat(r))}else e.push(" ".repeat(w+1));j&&e.push(`${Z.white(`[${String(j)}x]`)} `),Array.isArray(m)&&m.length>0&&e.push(`${h(`[${m.join(" > ")}]`)} `),d&&e.push(`${h(`[${this.styles.underline.prefix?I(d):d}]`)} `);const k=c(e.join(""));if(u!==Q){const s=typeof u=="string"?u:C(u,this.#o);e.push(p+U(s,{trim:!1,width:o-3,wrapMode:X.STRICT_WIDTH}))}if(i){let s=!1;e.push(...i.map(r=>{if(r instanceof Error)return s=!0,`
|
|
2
4
|
|
|
3
|
-
const
|
|
5
|
+
${$(r,{...this.#s,filterStacktrace:x,prefix:p})}`;if(typeof r=="object")return` ${C(r,this.#o)}`;const q=(s?`
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
`:" ")+String(r);return s=!1,q}))}if(S&&e.push($(S,{...this.#s,filterStacktrace:x,prefix:p})),_&&e.push(`
|
|
6
8
|
|
|
7
|
-
const {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} = __cjs_getProcess;
|
|
11
|
-
import colorize, { red, greenBright, cyan, green, grey, bold, bgGrey, underline, white } from '@visulima/colorize';
|
|
12
|
-
import { A as AbstractPrettyReporter, d as defaultInspectorConfig, b as writeStream, t as terminalSize, c as getLongestBadge, g as getLongestLabel, e as getStringWidth, f as formatLabel, a as EMPTY_SYMBOL, i as inspect, w as wordWrap, r as renderError, W as WrapMode } from '../../packem_shared/abstract-pretty-reporter-jU8WL_6c.js';
|
|
13
|
-
|
|
14
|
-
const PAIL_DIST_REGEX = /[\\/]pail[\\/]dist/;
|
|
15
|
-
const pailFileFilter = (line) => !PAIL_DIST_REGEX.test(line);
|
|
16
|
-
class SimpleReporter extends AbstractPrettyReporter {
|
|
17
|
-
#stdout;
|
|
18
|
-
#stderr;
|
|
19
|
-
#interactiveManager;
|
|
20
|
-
#interactive = false;
|
|
21
|
-
#inspectOptions;
|
|
22
|
-
#errorOptions;
|
|
23
|
-
constructor(options = {}) {
|
|
24
|
-
const { error: errorOptions, inspect: inspectOptions, ...rest } = options;
|
|
25
|
-
super({
|
|
26
|
-
uppercase: {
|
|
27
|
-
label: true,
|
|
28
|
-
...rest.uppercase
|
|
29
|
-
},
|
|
30
|
-
...rest
|
|
31
|
-
});
|
|
32
|
-
this.#inspectOptions = { ...defaultInspectorConfig, indent: void 0, ...inspectOptions };
|
|
33
|
-
this.#errorOptions = {
|
|
34
|
-
...errorOptions,
|
|
35
|
-
color: {
|
|
36
|
-
fileLine: green,
|
|
37
|
-
hint: cyan,
|
|
38
|
-
marker: red,
|
|
39
|
-
message: red,
|
|
40
|
-
method: greenBright,
|
|
41
|
-
title: red
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
this.#stdout = stdout;
|
|
45
|
-
this.#stderr = stderr;
|
|
46
|
-
}
|
|
47
|
-
setStdout(stdout_) {
|
|
48
|
-
this.#stdout = stdout_;
|
|
49
|
-
}
|
|
50
|
-
setStderr(stderr_) {
|
|
51
|
-
this.#stderr = stderr_;
|
|
52
|
-
}
|
|
53
|
-
setInteractiveManager(manager) {
|
|
54
|
-
this.#interactiveManager = manager;
|
|
55
|
-
}
|
|
56
|
-
setIsInteractive(interactive) {
|
|
57
|
-
this.#interactive = interactive;
|
|
58
|
-
}
|
|
59
|
-
log(meta) {
|
|
60
|
-
const message = this.formatMessage(meta);
|
|
61
|
-
const logLevel = meta.type.level;
|
|
62
|
-
const streamType = ["error", "trace", "warn"].includes(logLevel) ? "stderr" : "stdout";
|
|
63
|
-
const stream = streamType === "stderr" ? this.#stderr : this.#stdout;
|
|
64
|
-
if (this.#interactive && this.#interactiveManager !== void 0 && stream.isTTY) {
|
|
65
|
-
this.#interactiveManager.update(streamType, message.split("\n"), 0);
|
|
66
|
-
} else {
|
|
67
|
-
writeStream(`${message}
|
|
68
|
-
`, stream);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
72
|
-
formatMessage(data) {
|
|
73
|
-
const { columns } = terminalSize();
|
|
74
|
-
let size = columns;
|
|
75
|
-
if (typeof this.styles.messageLength === "number") {
|
|
76
|
-
size = this.styles.messageLength;
|
|
77
|
-
}
|
|
78
|
-
const { badge, context, date, error, file, groups, label, message, prefix, repeated, scope, suffix, traceError, type } = data;
|
|
79
|
-
const { color } = this.loggerTypes[type.name];
|
|
80
|
-
const colorized = color ? colorize[color] : white;
|
|
81
|
-
const groupSpaces = groups.map(() => " ").join("");
|
|
82
|
-
const items = [];
|
|
83
|
-
if (groups.length > 0) {
|
|
84
|
-
items.push(`${groupSpaces + grey(`[${groups.at(-1)}]`)} `);
|
|
85
|
-
}
|
|
86
|
-
if (date) {
|
|
87
|
-
items.push(`${grey(this.styles.dateFormatter(typeof date === "string" ? new Date(date) : date))} `);
|
|
88
|
-
}
|
|
89
|
-
if (badge) {
|
|
90
|
-
items.push(bold(colorized(badge)));
|
|
91
|
-
} else {
|
|
92
|
-
const longestBadge = getLongestBadge(this.loggerTypes);
|
|
93
|
-
if (longestBadge.length > 0) {
|
|
94
|
-
items.push(grey(" ".repeat(longestBadge.length)));
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
const longestLabel = getLongestLabel(this.loggerTypes);
|
|
98
|
-
const longestWidth = getStringWidth(longestLabel);
|
|
99
|
-
if (label) {
|
|
100
|
-
const labelWidth = getStringWidth(label);
|
|
101
|
-
const pad = Math.max(0, longestWidth - labelWidth);
|
|
102
|
-
items.push(`${bold(colorized(formatLabel(label, this.styles)))} `, " ".repeat(pad));
|
|
103
|
-
} else {
|
|
104
|
-
items.push(" ".repeat(longestWidth + 1));
|
|
105
|
-
}
|
|
106
|
-
if (repeated) {
|
|
107
|
-
items.push(`${bgGrey.white(`[${repeated}x]`)} `);
|
|
108
|
-
}
|
|
109
|
-
if (Array.isArray(scope) && scope.length > 0) {
|
|
110
|
-
items.push(`${grey(`[${scope.join(" > ")}]`)} `);
|
|
111
|
-
}
|
|
112
|
-
if (prefix) {
|
|
113
|
-
items.push(`${grey(`[${this.styles.underline.prefix ? underline(prefix) : prefix}]`)} `);
|
|
114
|
-
}
|
|
115
|
-
const titleSize = getStringWidth(items.join(""));
|
|
116
|
-
if (message !== EMPTY_SYMBOL) {
|
|
117
|
-
const formattedMessage = typeof message === "string" ? message : inspect(message, this.#inspectOptions);
|
|
118
|
-
items.push(
|
|
119
|
-
groupSpaces + wordWrap(formattedMessage, {
|
|
120
|
-
trim: false,
|
|
121
|
-
width: size - 3,
|
|
122
|
-
wrapMode: WrapMode.STRICT_WIDTH
|
|
123
|
-
})
|
|
124
|
-
);
|
|
125
|
-
}
|
|
126
|
-
if (context) {
|
|
127
|
-
let hasError = false;
|
|
128
|
-
items.push(
|
|
129
|
-
...context.map((value) => {
|
|
130
|
-
if (value instanceof Error) {
|
|
131
|
-
hasError = true;
|
|
132
|
-
return `
|
|
133
|
-
|
|
134
|
-
${renderError(value, {
|
|
135
|
-
...this.#errorOptions,
|
|
136
|
-
filterStacktrace: pailFileFilter,
|
|
137
|
-
prefix: groupSpaces
|
|
138
|
-
})}`;
|
|
139
|
-
}
|
|
140
|
-
if (typeof value === "object") {
|
|
141
|
-
return ` ${inspect(value, this.#inspectOptions)}`;
|
|
142
|
-
}
|
|
143
|
-
const newValue = (hasError ? "\n\n" : " ") + value;
|
|
144
|
-
hasError = false;
|
|
145
|
-
return newValue;
|
|
146
|
-
})
|
|
147
|
-
);
|
|
148
|
-
}
|
|
149
|
-
if (error) {
|
|
150
|
-
items.push(
|
|
151
|
-
renderError(error, {
|
|
152
|
-
...this.#errorOptions,
|
|
153
|
-
filterStacktrace: pailFileFilter,
|
|
154
|
-
prefix: groupSpaces
|
|
155
|
-
})
|
|
156
|
-
);
|
|
157
|
-
}
|
|
158
|
-
if (traceError) {
|
|
159
|
-
items.push(
|
|
160
|
-
`
|
|
161
|
-
|
|
162
|
-
${renderError(traceError, {
|
|
163
|
-
...this.#errorOptions,
|
|
164
|
-
filterStacktrace: pailFileFilter,
|
|
165
|
-
hideErrorCauseCodeView: true,
|
|
166
|
-
hideErrorCodeView: true,
|
|
167
|
-
hideErrorErrorsCodeView: true,
|
|
168
|
-
hideMessage: true,
|
|
169
|
-
prefix: groupSpaces
|
|
170
|
-
})}`
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
if (suffix) {
|
|
174
|
-
items.push(` ${groupSpaces}${grey(this.styles.underline.suffix ? underline(suffix) : suffix)}`);
|
|
175
|
-
}
|
|
176
|
-
if (file) {
|
|
177
|
-
const fileMessage = file.name + (file.line ? `:${file.line}` : "");
|
|
178
|
-
const callerPad = Math.max(0, titleSize - getStringWidth("Caller: "));
|
|
179
|
-
items.push("\n", grey("Caller: "), " ".repeat(callerPad), fileMessage, "\n");
|
|
180
|
-
}
|
|
181
|
-
return items.join("");
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
export { SimpleReporter };
|
|
9
|
+
${$(_,{...this.#s,filterStacktrace:x,hideErrorCauseCodeView:!0,hideErrorCodeView:!0,hideErrorErrorsCodeView:!0,hideMessage:!0,prefix:p})}`),y&&e.push(` ${p}${h(this.styles.underline.suffix?I(y):y)}`),l){const s=(l.name??"")+(l.line?`:${String(l.line)}`:""),r=Math.max(0,k-c("Caller: "));e.push(`
|
|
10
|
+
`,h("Caller: ")," ".repeat(r),s,`
|
|
11
|
+
`)}return e.join("")}}export{he as SimpleReporter};
|