@visulima/pail 4.0.0-alpha.21 → 4.0.0-alpha.23
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 +74 -0
- package/LICENSE.md +841 -6
- package/README.md +53 -24
- package/dist/index.browser.d.ts +16 -5
- package/dist/index.browser.js +19 -19
- package/dist/index.server.d.ts +30 -5
- package/dist/index.server.js +28 -27
- package/dist/middleware/elysia.d.ts +5 -4
- package/dist/middleware/elysia.js +1 -1
- package/dist/middleware/express.d.ts +5 -4
- package/dist/middleware/express.js +1 -1
- package/dist/middleware/fastify.d.ts +5 -4
- package/dist/middleware/fastify.js +1 -1
- package/dist/middleware/hono.d.ts +5 -4
- package/dist/middleware/hono.js +1 -1
- package/dist/middleware/next/handler.d.ts +5 -4
- package/dist/middleware/next/handler.js +1 -1
- package/dist/middleware/sveltekit.d.ts +5 -4
- package/dist/middleware/sveltekit.js +1 -1
- package/dist/packem_shared/AbstractJsonReporter-Bp_JCrMQ.js +1 -0
- package/dist/packem_shared/AbstractJsonReporter-C6iu_u9-.js +1 -0
- package/dist/packem_shared/JsonReporter-BXktpC__.js +2 -0
- package/dist/packem_shared/JsonReporter-bmem9lcg.js +1 -0
- package/dist/packem_shared/{PrettyReporter-D75CJT0C.js → PrettyReporter-DsHfKOU7.js} +3 -3
- package/dist/packem_shared/PrettyReporter-LXeSlx8P.js +44 -0
- package/dist/packem_shared/{abstract-json-reporter.d-Boj5w068.d.ts → abstract-json-reporter.d-wfESoEa-.d.ts} +3 -2
- package/dist/packem_shared/abstract-pretty-reporter-eLxhddj0.js +57 -0
- package/dist/packem_shared/addKnownErrorConstructor-C1OJTj2D-f9no2VNI.js +25 -0
- package/dist/packem_shared/{create-middleware-logger.d-MK7moe4r.d.ts → create-middleware-logger.d-B-JmQ1Sl.d.ts} +2 -2
- package/dist/packem_shared/{headers-D-K_EnkH.js → headers-DH0H2s8W.js} +1 -1
- package/dist/packem_shared/index-Q1764hvO.js +1 -0
- package/dist/packem_shared/index.d-T71KjNAr.d.ts +16 -0
- package/dist/packem_shared/serializeError-C-NFvZ8_-D0CA_Qlx.js +1 -0
- package/dist/packem_shared/{types.d-Ck_RSjLg.d.ts → types.d-bWnqHJKL.d.ts} +2 -37
- package/dist/packem_shared/{wide-event.d-DkYD7YVK.d.ts → wide-event.d-D3ATYpoK.d.ts} +17 -5
- 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 +2 -1
- package/dist/processor/environment-processor.d.ts +2 -1
- package/dist/processor/message-formatter-processor.d.ts +9 -1
- package/dist/processor/message-formatter-processor.js +1 -1
- package/dist/processor/opentelemetry-processor.d.ts +2 -1
- package/dist/processor/redact-processor.d.ts +41 -2
- package/dist/processor/sampling-processor.d.ts +2 -1
- package/dist/reporter/file/json-file-reporter.d.ts +21 -3
- package/dist/reporter/file/json-file-reporter.js +1 -1
- package/dist/reporter/http/abstract-http-reporter.d.ts +46 -3
- package/dist/reporter/http/abstract-http-reporter.js +2 -2
- package/dist/reporter/http/http-reporter.d.ts +4 -3
- package/dist/reporter/http/http-reporter.edge-light.d.ts +57 -1
- package/dist/reporter/http/http-reporter.edge-light.js +2 -2
- package/dist/reporter/json/index.browser.d.ts +1 -1
- package/dist/reporter/json/index.browser.js +1 -1
- package/dist/reporter/json/index.d.ts +6 -4
- package/dist/reporter/json/index.js +1 -1
- package/dist/reporter/pretty/index.browser.js +1 -1
- package/dist/reporter/pretty/index.d.ts +58 -38
- package/dist/reporter/pretty/index.js +1 -1
- package/dist/reporter/simple/simple-reporter.server.d.ts +87 -5
- package/dist/reporter/simple/simple-reporter.server.js +8 -8
- package/dist/wide-event.d.ts +4 -3
- package/dist/wide-event.js +1 -1
- package/package.json +5 -5
- package/dist/packem_shared/AbstractJsonReporter-CF0KKdQS.js +0 -1
- package/dist/packem_shared/AbstractJsonReporter-CVwjgboT.js +0 -1
- package/dist/packem_shared/JsonReporter-BJFnahby.js +0 -1
- package/dist/packem_shared/JsonReporter-CnLM-d0U.js +0 -2
- package/dist/packem_shared/PrettyReporter-D9aBMmxI.js +0 -45
- package/dist/packem_shared/abstract-pretty-reporter-zijeSUgy.js +0 -34
- package/dist/packem_shared/index-COQEZODZ.js +0 -1
- package/dist/packem_shared/write-console-log-based-on-level-DDSKGBKj.js +0 -1
- package/dist/packem_shared/write-stream-B6BXco86.js +0 -1
- /package/dist/packem_shared/{createPailError-CbU1Ogfa.js → PailError-CbU1Ogfa.js} +0 -0
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { AbstractHttpReporterOptions, AbstractHttpReporter } from "./abstract-http-reporter.js";
|
|
2
|
-
import
|
|
2
|
+
import 'type-fest';
|
|
3
|
+
import "../../packem_shared/types.d-bWnqHJKL.js";
|
|
3
4
|
import '@visulima/colorize';
|
|
4
5
|
import '@visulima/interactive-manager';
|
|
5
|
-
import "../../packem_shared/abstract-json-reporter.d-
|
|
6
|
-
import
|
|
6
|
+
import "../../packem_shared/abstract-json-reporter.d-wfESoEa-.js";
|
|
7
|
+
import "../../packem_shared/index.d-T71KjNAr.js";
|
|
7
8
|
/**
|
|
8
9
|
* HTTP Reporter.
|
|
9
10
|
*
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import '@visulima/colorize';
|
|
2
2
|
import '@visulima/interactive-manager';
|
|
3
|
-
import { stringify } from 'safe-stable-stringify';
|
|
4
3
|
/**
|
|
5
4
|
Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
|
|
6
5
|
|
|
@@ -123,6 +122,21 @@ interface StringifyAwareReporter<L extends string> extends Reporter<L> {
|
|
|
123
122
|
/** Set the stringify function for object serialization */
|
|
124
123
|
setStringify: (stringify: any) => void;
|
|
125
124
|
}
|
|
125
|
+
type Replacer = (number | string)[] | null | undefined | ((key: string, value: unknown) => string | number | boolean | null | object);
|
|
126
|
+
declare function stringify(value: undefined | symbol | ((...args: unknown[]) => unknown), replacer?: Replacer, space?: string | number): undefined;
|
|
127
|
+
declare function stringify(value: string | number | unknown[] | null | boolean | object, replacer?: Replacer, space?: string | number): string;
|
|
128
|
+
declare function stringify(value: unknown, replacer?: ((key: string, value: unknown) => unknown) | (number | string)[] | null | undefined, space?: string | number): string | undefined;
|
|
129
|
+
declare namespace stringify {
|
|
130
|
+
export function configure(options: StringifyOptions): typeof stringify;
|
|
131
|
+
}
|
|
132
|
+
interface StringifyOptions {
|
|
133
|
+
bigint?: boolean;
|
|
134
|
+
circularValue?: string | null | TypeErrorConstructor | ErrorConstructor;
|
|
135
|
+
deterministic?: boolean | ((a: string, b: string) => number);
|
|
136
|
+
maximumBreadth?: number;
|
|
137
|
+
maximumDepth?: number;
|
|
138
|
+
strict?: boolean;
|
|
139
|
+
}
|
|
126
140
|
/**
|
|
127
141
|
* Options for configuring JSON reporters.
|
|
128
142
|
*/
|
|
@@ -254,6 +268,13 @@ type AbstractHttpReporterOptions = AbstractJsonReporterOptions & {
|
|
|
254
268
|
*/
|
|
255
269
|
maxPayloadSize?: number;
|
|
256
270
|
/**
|
|
271
|
+
* Maximum number of entries to keep queued while the endpoint is unavailable.
|
|
272
|
+
* When the queue exceeds this limit, the oldest entries are dropped (drop-oldest)
|
|
273
|
+
* so a sustained outage cannot grow memory without bound.
|
|
274
|
+
* @default 10000
|
|
275
|
+
*/
|
|
276
|
+
maxQueueSize?: number;
|
|
277
|
+
/**
|
|
257
278
|
* Number of retry attempts before giving up
|
|
258
279
|
* @default 3
|
|
259
280
|
*/
|
|
@@ -285,6 +306,11 @@ type AbstractHttpReporterOptions = AbstractJsonReporterOptions & {
|
|
|
285
306
|
};
|
|
286
307
|
}) => void;
|
|
287
308
|
/**
|
|
309
|
+
* Optional callback invoked when queued log entries are dropped because the queue
|
|
310
|
+
* exceeded `maxQueueSize`. Receives the number of dropped entries.
|
|
311
|
+
*/
|
|
312
|
+
onDrop?: (droppedCount: number) => void;
|
|
313
|
+
/**
|
|
288
314
|
* Optional callback for error handling
|
|
289
315
|
*/
|
|
290
316
|
onError?: (error: Error) => void;
|
|
@@ -320,12 +346,15 @@ type AbstractHttpReporterOptions = AbstractJsonReporterOptions & {
|
|
|
320
346
|
* @template L - The log level type
|
|
321
347
|
*/
|
|
322
348
|
declare abstract class AbstractHttpReporter<L extends string = string> extends AbstractJsonReporter<L> implements StringifyAwareReporter<L> {
|
|
349
|
+
#private;
|
|
323
350
|
protected url: string;
|
|
324
351
|
protected method: string;
|
|
325
352
|
protected headers: Record<string, string> | (() => Record<string, string>);
|
|
326
353
|
protected contentType: string;
|
|
327
354
|
protected batchContentType: string;
|
|
328
355
|
protected onError?: (error: Error) => void;
|
|
356
|
+
protected onDrop?: (droppedCount: number) => void;
|
|
357
|
+
protected maxQueueSize: number;
|
|
329
358
|
protected onDebug?: (entry: Record<string, unknown>) => void;
|
|
330
359
|
protected onDebugRequestResponse?: (requestResponse: {
|
|
331
360
|
req: {
|
|
@@ -369,6 +398,33 @@ declare abstract class AbstractHttpReporter<L extends string = string> extends A
|
|
|
369
398
|
*/
|
|
370
399
|
constructor(config: AbstractHttpReporterOptions);
|
|
371
400
|
/**
|
|
401
|
+
* Flushes all queued log entries to the HTTP endpoint immediately.
|
|
402
|
+
*
|
|
403
|
+
* Returns a promise that resolves once the queue has been drained (or rejects
|
|
404
|
+
* if a batch send fails terminally). Use this before a serverless function or
|
|
405
|
+
* short-lived process exits so the tail of the batch is not lost.
|
|
406
|
+
* @example
|
|
407
|
+
* ```typescript
|
|
408
|
+
* await reporter.flush();
|
|
409
|
+
* ```
|
|
410
|
+
*/
|
|
411
|
+
flush(): Promise<void>;
|
|
412
|
+
/**
|
|
413
|
+
* Flushes any remaining queued entries and clears pending timers.
|
|
414
|
+
*
|
|
415
|
+
* Counterpart to a transport lifecycle `end`/`dispose`. After calling `close()`
|
|
416
|
+
* the reporter can still be used, but any pending batch timeout is cleared.
|
|
417
|
+
* @example
|
|
418
|
+
* ```typescript
|
|
419
|
+
* process.on("beforeExit", () => reporter.close());
|
|
420
|
+
* ```
|
|
421
|
+
*/
|
|
422
|
+
close(): Promise<void>;
|
|
423
|
+
/**
|
|
424
|
+
* Alias for {@link close} to match common transport `dispose` conventions.
|
|
425
|
+
*/
|
|
426
|
+
dispose(): Promise<void>;
|
|
427
|
+
/**
|
|
372
428
|
* Processes and ships log entries to the HTTP endpoint.
|
|
373
429
|
* @param message The JSON-formatted log message
|
|
374
430
|
* @param logLevel The log level of the message
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createRequire as
|
|
2
|
-
`,this.batchMode=
|
|
1
|
+
import{createRequire as N}from"node:module";const z=N(import.meta.url),d=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,S=t=>{if(typeof d<"u"&&d.versions&&d.versions.node){const[e,r]=d.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return d.getBuiltinModule(t)}return z(t)},{Buffer:E}=S("node:buffer"),{createRequire:P}=S("node:module"),{gzipSync:B}=S("node:zlib"),R=P(import.meta.url),p=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_=t=>{if(typeof p<"u"&&p.versions&&p.versions.node){const[e,r]=p.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return p.getBuiltinModule(t)}return R(t)};_("node:util");const L=P(import.meta.url),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,T=t=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[e,r]=m.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return m.getBuiltinModule(t)}return L(t)};T("node:fs");T("node:path");T("node:url");const M=new Map([["Error",Error],["EvalError",EvalError],["RangeError",RangeError],["ReferenceError",ReferenceError],["SyntaxError",SyntaxError],["TypeError",TypeError],["URIError",URIError]]);typeof AggregateError<"u"&&M.set("AggregateError",AggregateError);const $=Object.create({},{cause:{enumerable:!1,value:void 0,writable:!0},code:{enumerable:!0,value:void 0,writable:!0},errors:{enumerable:!1,value:void 0,writable:!0},message:{enumerable:!1,value:void 0,writable:!0},name:{enumerable:!1,value:void 0,writable:!0},stack:{enumerable:!1,value:void 0,writable:!0}}),Q=t=>{if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return e===null||e===Object.prototype||Object.getPrototypeOf(e)===null},y=new WeakSet,j=t=>{const e=Object.getOwnPropertyNames(t);for(const r of e){const s=Object.getOwnPropertyDescriptor(t,r);s&&(s.enumerable||Object.defineProperty(t,r,{...s,enumerable:!0}),s.value&&typeof s.value=="object"&&!Array.isArray(s.value)&&(Object.getPrototypeOf(s.value)===Object.prototype||Object.getPrototypeOf(s.value)===null)&&j(s.value))}},A=t=>{y.add(t);const e=t.toJSON();return y.delete(t),Object.isExtensible(e)&&j(e),e},b=(t,e,r,s,o=new Set)=>{if(t&&t instanceof Uint8Array&&t.constructor.name==="Buffer")return"[object Buffer]";if(t!==null&&typeof t=="object"&&"pipe"in t&&typeof t.pipe=="function")return"[object Stream]";if(t instanceof Error)return e.has(t)?"[Circular]":(r+=1,g(t,s,e,r));if(s.useToJSON&&t!==null&&typeof t=="object"&&"toJSON"in t&&typeof t.toJSON=="function")return t.toJSON();if(t instanceof Date)return t.toISOString();if(t instanceof RegExp)return t.toString();if(typeof URL<"u"&&t instanceof URL)return t.href;if(t instanceof Map){const i=[];for(const[a,n]of t.entries())i.push([b(a,e,r,s,o),b(n,e,r,s,o)]);return{__dataType:"Map",value:i}}if(t instanceof Set){const i=[];for(const a of t.values())i.push(b(a,e,r,s,o));return{__dataType:"Set",value:i}}if(typeof t=="function")return`[Function: ${t.name||"anonymous"}]`;if(typeof t=="bigint")return`${String(t)}n`;if(Q(t)){if(o.has(t))return"[Circular]";if(s.maxDepth!==void 0&&s.maxDepth!==Number.POSITIVE_INFINITY&&r+1>=s.maxDepth)return{};r+=1,o.add(t);const i={};for(const a in t)i[a]=b(t[a],e,r,s,o);return o.delete(t),i}try{return t}catch{return"[Not Available]"}},g=(t,e,r,s)=>{if(r.add(t),e.maxDepth===0)return{};if(e.useToJSON&&typeof t.toJSON=="function"&&!y.has(t))return A(t);const o=Object.create($);if(Object.defineProperty(o,"name",{configurable:!0,enumerable:!0,value:Object.prototype.toString.call(t.constructor)==="[object Function]"?t.constructor.name:t.name,writable:!0}),Object.defineProperty(o,"message",{configurable:!0,enumerable:!0,value:t.message,writable:!0}),Object.defineProperty(o,"stack",{configurable:!0,enumerable:!0,value:t.stack,writable:!0}),Array.isArray(t.errors)){const a=[];for(const n of t.errors){if(!(n instanceof Error))throw new TypeError("All errors in the 'errors' property must be instances of Error");if(r.has(n))return Object.defineProperty(o,"errors",{configurable:!0,enumerable:!0,value:[],writable:!0}),o;a.push(g(n,e,r,s))}Object.defineProperty(o,"errors",{configurable:!0,enumerable:!0,value:a,writable:!0})}const i=t.cause;if(i!=null)if(i instanceof Error)r.has(i)?Object.defineProperty(o,"cause",{configurable:!0,enumerable:!0,value:"[Circular]",writable:!0}):Object.defineProperty(o,"cause",{configurable:!0,enumerable:!0,value:g(i,e,r,s),writable:!0});else{const a=b(i,r,s,e);Object.defineProperty(o,"cause",{configurable:!0,enumerable:!0,value:a,writable:!0})}for(const a in t){if(a==="name"||a==="message"||a==="stack"||a==="cause"||a==="errors")continue;const n=t[a],u=b(n,r,s,e);Object.defineProperty(o,a,{configurable:!0,enumerable:!0,value:u,writable:!0})}if(Array.isArray(e.exclude)&&e.exclude.length>0)for(const a of e.exclude)try{delete o[a]}catch{}return o},v=(t,e={})=>g(t,{exclude:e.exclude??[],maxDepth:e.maxDepth??Number.POSITIVE_INFINITY,useToJSON:e.useToJSON??!1},new Set,0),O=Symbol("EMPTY");class C{stringify;errorOptions;constructor(e={}){this.errorOptions=e.error??{}}setStringify(e){this.stringify=e}log(e){const{context:r,error:s,file:o,message:i,type:a,...n}=e;if(n.label&&(n.label=n.label.trim()),o&&(n.file=`${o.name??""}:${String(o.line)}${o.column?`:${String(o.column)}`:""}`),n.message=i===O?void 0:i,s&&(n.error=v(s,this.errorOptions)),r){const u=[];for(let c=0;c<r.length;c+=1){const h=r[c];h!==O&&(h instanceof Error?u.push(v(h,this.errorOptions)):u.push(h))}n.context=u}this._log(this.stringify(n),a.level)}}const J=async t=>{const e=globalThis.CompressionStream;if(e){const r=new e("gzip"),s=r.writable.getWriter(),o=r.readable.getReader(),i=new TextEncoder,a=[];await s.write(i.encode(t)),await s.close();let n=!1;for(;!n;){const l=await o.read();n=l.done,l.value&&a.push(l.value)}const u=a.reduce((l,f)=>l+f.length,0),c=new Uint8Array(u);let h=0;for(let l=0;l<a.length;l+=1){const f=a[l];c.set(f,h),h+=f.length}return c}return B(t)};class I extends Error{logData;actualSize;maxSize;constructor(e,r,s,o){super(e),this.name="LogSizeError",this.logData=r,this.actualSize=s,this.maxSize=o}}const w=(t,e)=>t*2**e,k=/^\d+$/,F=t=>{const e=t.trim();if(k.test(e)){const o=Number.parseInt(e,10);return Math.min(Math.max(o,0)*1e3,6e4)}const r=Date.parse(e);if(Number.isNaN(r))return;const s=r-Date.now();return Math.min(Math.max(s,0),6e4)},D=t=>new Promise(e=>{setTimeout(e,t)}),q=t=>typeof t=="string"?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),U=async(t,e,r,s,o,i,a)=>{const n={};t.headers.forEach((h,l)=>{n[l]=h});const u=await t.text(),c={req:{body:o,headers:s,method:r,url:e},res:{body:u,headers:n,status:t.status,statusText:t.statusText}};if(i&&i(c),t.ok)return!1;if(t.status<500&&t.status!==429){const h=new Error(`HTTP ${String(t.status)}: ${t.statusText}`);throw a&&a(h),h}return!0},Y=(t,e,r,s,o)=>{if(t.status===429&&e&&s<o){const i=t.headers.get("retry-after");return(i?F(i):void 0)??w(r,s)}},H=(t,e,r,s)=>{if(t.status>=500&&r<s)return w(e,r)},V=(t,e,r,s,o)=>{const i=Y(t,e,r,s,o);return i!==void 0?i:H(t,r,s,o)},W=async(t,e,r,s,o)=>{if(e<r){const i=w(s,e);return await D(i),!0}return o&&o(t),!1},G=async(t,e,r,s,o,i,a,n,u)=>{let c=0;for(;c<=o;)try{const h=q(s),l=await fetch(t,{body:h,headers:r,method:e});if(!await U(l,t,e,r,s,n,u))return;const f=V(l,a,i,c,o);if(f!==void 0){await D(f),c+=1;continue}if(!l.ok){const x=new Error(`HTTP ${String(l.status)}: ${l.statusText}`);throw u&&u(x),x}return}catch(h){if(await W(h,c,o,i,u)){c+=1;continue}throw h}};class K extends C{url;method;headers;contentType;batchContentType;onError;onDrop;maxQueueSize;onDebug;onDebugRequestResponse;payloadTemplate;compression;maxRetries;retryDelay;respectRateLimit;enableBatchSend;batchSize;batchSendTimeout;batchSendDelimiter;batchMode;batchFieldName;maxLogSize;maxPayloadSize;edgeCompat;batchQueue=[];batchTimeout;isProcessingBatch=!1;currentBatchSize=0;constructor(e){if(super(e),this.url=e.url,this.method=e.method??"POST",this.headers=e.headers??{},this.contentType=e.contentType??"application/json",this.batchContentType=e.batchContentType??"application/json",this.onError=e.onError,this.onDrop=e.onDrop,this.maxQueueSize=e.maxQueueSize??1e4,this.onDebug=e.onDebug,this.onDebugRequestResponse=e.onDebugRequestResponse,this.payloadTemplate=e.payloadTemplate??(r=>JSON.stringify(r)),this.compression=e.compression??!1,this.maxRetries=e.maxRetries??3,this.retryDelay=e.retryDelay??1e3,this.respectRateLimit=e.respectRateLimit??!0,this.enableBatchSend=e.enableBatchSend??!0,this.batchSize=e.batchSize??100,this.batchSendTimeout=e.batchSendTimeout??5e3,this.batchSendDelimiter=e.batchSendDelimiter??`
|
|
2
|
+
`,this.batchMode=e.batchMode??"delimiter",this.batchFieldName=e.batchFieldName,this.batchMode==="field"&&!this.batchFieldName)throw new Error("batchFieldName is required when batchMode is 'field'");this.maxLogSize=e.maxLogSize??1048576,this.maxPayloadSize=e.maxPayloadSize??5242880,this.edgeCompat=e.edgeCompat??!1}async flush(){for(this.batchTimeout&&(clearTimeout(this.batchTimeout),this.batchTimeout=void 0);this.batchQueue.length>0||this.isProcessingBatch;){if(this.isProcessingBatch){await new Promise(e=>setTimeout(e,0));continue}await this.processBatch()}}async close(){await this.flush()}async dispose(){await this.close()}_log(e,r){try{const s=JSON.parse(e),o=r,i=s.message,a={logLevel:o,message:i??""};if(s.data)a.data=s.data;else if(s.context)a.data=s.context;else{const c={...s};delete c.message,Object.keys(c).length>0&&(a.data=c)}const n=this.payloadTemplate(a);this.onDebug&&this.onDebug({data:a.data,logLevel:o,message:i});const u=this.edgeCompat||typeof TextEncoder>"u"?E.byteLength(n,"utf8"):new TextEncoder().encode(n).length;if(u>this.maxLogSize){const c=new I(`Log entry exceeds maximum size of ${String(this.maxLogSize)} bytes. Size: ${String(u)} bytes`,{data:a.data,logLevel:o,message:i},u,this.maxLogSize);this.onError&&this.onError(c);return}this.enableBatchSend?this.addToBatch(n,u):this.sendPayload(n).catch(c=>{this.onError&&this.onError(c)})}catch(s){this.onError&&this.onError(s)}}addToBatch(e,r){const s=this.currentBatchSize+r+this.batchSendDelimiter.length,o=this.maxPayloadSize*.9;if(s>o&&this.batchQueue.length>0&&this.processBatch(),this.batchQueue.push(e),this.currentBatchSize+=r+this.batchSendDelimiter.length,this.batchQueue.length>this.maxQueueSize){const i=this.batchQueue.splice(0,this.batchQueue.length-this.maxQueueSize);this.currentBatchSize=this.#e(),this.onDrop&&this.onDrop(i.length)}this.batchTimeout??=setTimeout(()=>{this.processBatch()},this.batchSendTimeout),this.batchQueue.length>=this.batchSize&&this.processBatch()}#e(){let e=0;for(let r=0;r<this.batchQueue.length;r+=1){const s=this.batchQueue[r],o=this.edgeCompat||typeof TextEncoder>"u"?E.byteLength(s,"utf8"):new TextEncoder().encode(s).length;e+=o+(r<this.batchQueue.length-1?this.batchSendDelimiter.length:0)}return e}async processBatch(){if(this.isProcessingBatch||this.batchQueue.length===0)return;this.isProcessingBatch=!0,this.batchTimeout&&(clearTimeout(this.batchTimeout),this.batchTimeout=void 0);const e=this.batchQueue.splice(0,this.batchSize);this.currentBatchSize=this.#e();try{await this.sendBatch(e)}catch(r){this.onError&&this.onError(r)}finally{this.isProcessingBatch=!1,this.batchQueue.length>0&&this.processBatch()}}async sendBatch(e){let r;switch(this.batchMode){case"array":{const s=e.map(o=>JSON.parse(o));r=JSON.stringify(s);break}case"field":{const s=e.map(i=>JSON.parse(i)),o=this.batchFieldName?{[this.batchFieldName]:s}:{};r=JSON.stringify(o);break}default:{r=e.join(this.batchSendDelimiter);break}}await this.sendPayload(r,this.batchContentType)}async sendPayload(e,r){const s=typeof this.headers=="function"?this.headers():{...this.headers};s["content-type"]??=r??this.contentType;let o=e;if(this.compression&&!this.edgeCompat)try{o=await J(e),s["content-encoding"]="gzip"}catch(i){this.onError&&this.onError(new Error(`Compression failed: ${String(i)}`))}await G(this.url,this.method,s,o,this.maxRetries,this.retryDelay,this.respectRateLimit,this.onDebugRequestResponse,this.onError)}}class Z extends K{constructor(e){super({...e,edgeCompat:!0})}}export{Z as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { stringify } from
|
|
1
|
+
import { s as stringify } from "../../packem_shared/index.d-T71KjNAr.js";
|
|
2
2
|
import { R as ReadonlyMeta, E as ExtendedRfc5424LogLevels, L as LiteralUnion, S as StringifyAwareReporter } from "../../packem_shared/types.d-xxE3FOD3.js";
|
|
3
3
|
import '@visulima/colorize';
|
|
4
4
|
import '@visulima/interactive-manager';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AbstractJsonReporter as e}from"../../packem_shared/AbstractJsonReporter-
|
|
1
|
+
import{AbstractJsonReporter as e}from"../../packem_shared/AbstractJsonReporter-Bp_JCrMQ.js";import{default as p}from"../../packem_shared/JsonReporter-bmem9lcg.js";export{e as AbstractJsonReporter,p as JsonReporter};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { A as AbstractJsonReporterOptions, a as AbstractJsonReporter } from "../../packem_shared/abstract-json-reporter.d-
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { A as AbstractJsonReporterOptions, a as AbstractJsonReporter } from "../../packem_shared/abstract-json-reporter.d-wfESoEa-.js";
|
|
2
|
+
import { LiteralUnion } from 'type-fest';
|
|
3
|
+
import { E as ExtendedRfc5424LogLevels, a as StreamAwareReporter } from "../../packem_shared/types.d-bWnqHJKL.js";
|
|
4
|
+
import "../../packem_shared/index.d-T71KjNAr.js";
|
|
4
5
|
import '@visulima/colorize';
|
|
5
6
|
import '@visulima/interactive-manager';
|
|
6
7
|
/**
|
|
@@ -41,7 +42,8 @@ declare class JsonReporter<L extends string = string> extends AbstractJsonReport
|
|
|
41
42
|
/**
|
|
42
43
|
* Outputs the JSON message to the appropriate stream.
|
|
43
44
|
*
|
|
44
|
-
* Routes
|
|
45
|
+
* Routes high-severity RFC 5424 levels (warning/error/critical/alert/emergency/trace)
|
|
46
|
+
* to stderr, others to stdout.
|
|
45
47
|
* @param message The JSON-formatted log message
|
|
46
48
|
* @param logLevel The log level determining which stream to use
|
|
47
49
|
* @protected
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AbstractJsonReporter as e}from"../../packem_shared/AbstractJsonReporter-
|
|
1
|
+
import{AbstractJsonReporter as e}from"../../packem_shared/AbstractJsonReporter-C6iu_u9-.js";import{default as p}from"../../packem_shared/JsonReporter-BXktpC__.js";export{e as AbstractJsonReporter,p as JsonReporter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as t}from"../../packem_shared/PrettyReporter-
|
|
1
|
+
import{default as t}from"../../packem_shared/PrettyReporter-DsHfKOU7.js";export{t as PrettyReporter};
|
|
@@ -1,51 +1,66 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RenderErrorOptions } from '@visulima/error/error';
|
|
2
|
+
import { LiteralUnion } from 'type-fest';
|
|
2
3
|
import { InteractiveManager } from '@visulima/interactive-manager';
|
|
4
|
+
import { D as DefaultLogTypes, c as LoggerTypesConfig, R as ReadonlyMeta, e as LoggerTypesAwareReporter, E as ExtendedRfc5424LogLevels, I as InteractiveStreamReporter } from "../../packem_shared/types.d-bWnqHJKL.js";
|
|
3
5
|
import '@visulima/colorize';
|
|
4
|
-
type ColorizeMethod = (value: string) => string;
|
|
5
|
-
type CodeFrameOptions = {
|
|
6
|
-
color?: {
|
|
7
|
-
gutter?: ColorizeMethod;
|
|
8
|
-
marker?: ColorizeMethod;
|
|
9
|
-
message?: ColorizeMethod;
|
|
10
|
-
};
|
|
11
|
-
linesAbove?: number;
|
|
12
|
-
linesBelow?: number;
|
|
13
|
-
message?: string;
|
|
14
|
-
prefix?: string;
|
|
15
|
-
showGutter?: boolean;
|
|
16
|
-
showLineNumbers?: boolean;
|
|
17
|
-
tabWidth?: number | false;
|
|
18
|
-
};
|
|
19
|
-
type Options$1 = Omit<CodeFrameOptions, "message | prefix"> & {
|
|
20
|
-
color: CodeFrameOptions["color"] & {
|
|
21
|
-
fileLine: ColorizeMethod;
|
|
22
|
-
hint: ColorizeMethod;
|
|
23
|
-
method: ColorizeMethod;
|
|
24
|
-
title: ColorizeMethod;
|
|
25
|
-
};
|
|
26
|
-
cwd: string;
|
|
27
|
-
displayShortPath: boolean;
|
|
28
|
-
filterStacktrace: ((line: string) => boolean) | undefined;
|
|
29
|
-
framesMaxLimit: number;
|
|
30
|
-
hideErrorCauseCodeView: boolean;
|
|
31
|
-
hideErrorCodeView: boolean;
|
|
32
|
-
hideErrorErrorsCodeView: boolean;
|
|
33
|
-
hideErrorTitle: boolean;
|
|
34
|
-
hideMessage: boolean;
|
|
35
|
-
indentation: number | " ";
|
|
36
|
-
prefix: string;
|
|
37
|
-
};
|
|
38
6
|
interface Options {
|
|
39
|
-
|
|
7
|
+
/**
|
|
8
|
+
* When `true`, honour custom inspectors: a value's
|
|
9
|
+
* `Symbol.for("nodejs.util.inspect.custom")` method (Node only),
|
|
10
|
+
* `Symbol.for("chai/inspect")` method, an `.inspect()` method, or a handler
|
|
11
|
+
* registered via `registerConstructor` / `registerStringTag`.
|
|
12
|
+
* @default true
|
|
13
|
+
*/
|
|
40
14
|
customInspect: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The maximum nesting depth to traverse before collapsing a nested value to
|
|
17
|
+
* `[Object]` / `[Array]`. A value `<= 0` disables the limit.
|
|
18
|
+
* @default 5
|
|
19
|
+
*/
|
|
41
20
|
depth: number;
|
|
21
|
+
/**
|
|
22
|
+
* Pretty-print with indentation. `"\t"` indents with tabs, a positive integer
|
|
23
|
+
* indents with that many spaces, and `undefined` keeps everything on one line.
|
|
24
|
+
* @default undefined
|
|
25
|
+
*/
|
|
42
26
|
indent: number | " " | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* The maximum number of array / typed-array / iterable elements to render
|
|
29
|
+
* before the remainder is replaced with an `… (N more)` marker. Use
|
|
30
|
+
* `Number.POSITIVE_INFINITY` to show every element.
|
|
31
|
+
* @default Number.POSITIVE_INFINITY
|
|
32
|
+
*/
|
|
43
33
|
maxArrayLength: number;
|
|
34
|
+
/**
|
|
35
|
+
* When `true`, render large numbers and bigints with `_` digit-group
|
|
36
|
+
* separators (e.g. `1_000_000`).
|
|
37
|
+
* @default true
|
|
38
|
+
*/
|
|
44
39
|
numericSeparator: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* The quote character used when rendering string values and complex object
|
|
42
|
+
* keys.
|
|
43
|
+
* @default "single"
|
|
44
|
+
*/
|
|
45
45
|
quoteStyle: "double" | "single";
|
|
46
|
+
/**
|
|
47
|
+
* When `true`, also render non-enumerable own properties of plain objects
|
|
48
|
+
* (mirrors `util.inspect`'s `showHidden`).
|
|
49
|
+
* @default false
|
|
50
|
+
*/
|
|
46
51
|
showHidden: boolean;
|
|
47
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Colourize / decorate a rendered fragment. Receives the raw fragment and a
|
|
54
|
+
* style hint and must return the (optionally wrapped) string. Defaults to the
|
|
55
|
+
* identity function.
|
|
56
|
+
*/
|
|
48
57
|
stylize: (value: string, styleType: LiteralUnion<"bigint" | "boolean" | "date" | "null" | "number" | "regexp" | "special" | "string" | "symbol" | "undefined", string>) => string;
|
|
58
|
+
/**
|
|
59
|
+
* The maximum length (in characters) of a single rendered value before it is
|
|
60
|
+
* truncated with an ellipsis. Use `Number.POSITIVE_INFINITY` to disable
|
|
61
|
+
* truncation.
|
|
62
|
+
* @default Number.POSITIVE_INFINITY
|
|
63
|
+
*/
|
|
49
64
|
truncate: number;
|
|
50
65
|
}
|
|
51
66
|
/**
|
|
@@ -122,7 +137,7 @@ type PrettyStyleOptions = {
|
|
|
122
137
|
*/
|
|
123
138
|
type PrettyReporterOptions = PrettyStyleOptions & {
|
|
124
139
|
/** Error rendering options */
|
|
125
|
-
error: Partial<Omit<
|
|
140
|
+
error: Partial<Omit<RenderErrorOptions, "color" | "prefix" | "indentation">>;
|
|
126
141
|
/** Object inspection options */
|
|
127
142
|
inspect: Partial<Options>;
|
|
128
143
|
};
|
|
@@ -157,6 +172,11 @@ declare class PrettyReporter<T extends string = string, L extends string = strin
|
|
|
157
172
|
*/
|
|
158
173
|
constructor(options?: Partial<PrettyReporterOptions>);
|
|
159
174
|
/**
|
|
175
|
+
* Sets the logger types configuration and refreshes cached badge/label widths.
|
|
176
|
+
* @param types Logger type configurations with colors and labels
|
|
177
|
+
*/
|
|
178
|
+
override setLoggerTypes(types: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>): void;
|
|
179
|
+
/**
|
|
160
180
|
* Sets the stdout stream for the reporter.
|
|
161
181
|
* @param stdout_ The writable stream to use for standard output
|
|
162
182
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{PrettyReporter as t}from"../../packem_shared/PrettyReporter-
|
|
1
|
+
import{PrettyReporter as t}from"../../packem_shared/PrettyReporter-LXeSlx8P.js";export{t as PrettyReporter};
|
|
@@ -17,7 +17,40 @@ type CodeFrameOptions = {
|
|
|
17
17
|
showLineNumbers?: boolean;
|
|
18
18
|
tabWidth?: number | false;
|
|
19
19
|
};
|
|
20
|
-
|
|
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;
|
|
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;
|
|
21
54
|
color: CodeFrameOptions["color"] & {
|
|
22
55
|
fileLine: ColorizeMethod;
|
|
23
56
|
hint: ColorizeMethod;
|
|
@@ -34,19 +67,67 @@ type Options$1 = Omit<CodeFrameOptions, "message | prefix"> & {
|
|
|
34
67
|
hideErrorTitle: boolean;
|
|
35
68
|
hideMessage: boolean;
|
|
36
69
|
indentation: number | " ";
|
|
37
|
-
prefix: string;
|
|
38
|
-
|
|
70
|
+
prefix: string; /** Optional source-map resolver to map compiled frame positions back to original source. */
|
|
71
|
+
sourceMap?: SourceMapResolver;
|
|
72
|
+
} & Omit<CodeFrameOptions, "message | prefix">;
|
|
39
73
|
interface Options {
|
|
40
|
-
|
|
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
|
+
*/
|
|
41
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
|
+
*/
|
|
42
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
|
+
*/
|
|
43
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
|
+
*/
|
|
44
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
|
+
*/
|
|
45
106
|
numericSeparator: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* The quote character used when rendering string values and complex object
|
|
109
|
+
* keys.
|
|
110
|
+
* @default "single"
|
|
111
|
+
*/
|
|
46
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
|
+
*/
|
|
47
118
|
showHidden: boolean;
|
|
48
|
-
|
|
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
|
+
*/
|
|
49
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
|
+
*/
|
|
50
131
|
truncate: number;
|
|
51
132
|
}
|
|
52
133
|
/**
|
|
@@ -125,6 +206,7 @@ type SimpleReporterOptions = PrettyStyleOptions & {
|
|
|
125
206
|
declare class SimpleReporter<T extends string = string, L extends string = string> extends AbstractPrettyReporter<T, L> implements InteractiveStreamReporter<L> {
|
|
126
207
|
#private;
|
|
127
208
|
constructor(options?: Partial<SimpleReporterOptions>);
|
|
209
|
+
override setLoggerTypes(types: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>): void;
|
|
128
210
|
setStdout(stdout_: NodeJS.WriteStream): void;
|
|
129
211
|
setStderr(stderr_: NodeJS.WriteStream): void;
|
|
130
212
|
setInteractiveManager(manager?: InteractiveManager): void;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import{createRequire as
|
|
2
|
-
`),0):
|
|
3
|
-
`,p)}
|
|
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-eLxhddj0.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,`
|
|
4
4
|
|
|
5
|
-
${
|
|
5
|
+
${$(r,{...this.#s,filterStacktrace:x,prefix:p})}`;if(typeof r=="object")return` ${C(r,this.#o)}`;const q=(s?`
|
|
6
6
|
|
|
7
|
-
`:" ")+String(r);return s=!1,
|
|
7
|
+
`:" ")+String(r);return s=!1,q}))}if(S&&e.push($(S,{...this.#s,filterStacktrace:x,prefix:p})),_&&e.push(`
|
|
8
8
|
|
|
9
|
-
${
|
|
10
|
-
`,
|
|
11
|
-
`)}return e.join("")}}export{
|
|
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};
|
package/dist/wide-event.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export { R as RequestLogEntry, S as SerializedError, W as WideEvent, a as WideEventFinishOptions, b as WideEventLevel, c as WideEventOptions, d as createWideEvent } from "./packem_shared/wide-event.d-
|
|
2
|
-
import "./packem_shared/types.d-
|
|
3
|
-
import
|
|
1
|
+
export { R as RequestLogEntry, S as SerializedError, W as WideEvent, a as WideEventFinishOptions, b as WideEventLevel, c as WideEventOptions, d as createWideEvent } from "./packem_shared/wide-event.d-D3ATYpoK.js";
|
|
2
|
+
import "./packem_shared/types.d-bWnqHJKL.js";
|
|
3
|
+
import "./packem_shared/index.d-T71KjNAr.js";
|
|
4
|
+
import 'type-fest';
|
|
4
5
|
import '@visulima/colorize';
|
|
5
6
|
import '@visulima/interactive-manager';
|
package/dist/wide-event.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const h={debug:0,error:3,info:1,warn:2},
|
|
1
|
+
import"./packem_shared/addKnownErrorConstructor-C1OJTj2D-f9no2VNI.js";import{O as c}from"./packem_shared/serializeError-C-NFvZ8_-D0CA_Qlx.js";const m=8,h={debug:0,error:3,info:1,warn:2},l={debug:"debug",error:"error",info:"info",warn:"warn"},u=(s,t)=>{const e={...s},r=Object.keys(t);for(let i=0;i<r.length;i+=1){const a=r[i],o=t[a],n=e[a];o!==null&&typeof o=="object"&&!Array.isArray(o)&&n!==null&&typeof n=="object"&&!Array.isArray(n)?e[a]=u(n,o):e[a]=o}return e},g=s=>s<1e3?`${String(s)}ms`:`${(s/1e3).toFixed(2)}s`,d=(s,t)=>{const e={message:typeof s.message=="string"?s.message:"",name:typeof s.name=="string"?s.name:"Error"};if(s.stack&&(e.stack=s.stack),s.status!==void 0?e.status=s.status:s.statusCode!==void 0&&(e.status=s.statusCode),s.data!==void 0&&(e.data=s.data),t.cause instanceof Error){const{cause:r}=s;r==="[Circular]"?e.cause="[Circular]":r!==null&&typeof r=="object"&&(e.cause=d(r,t.cause))}return e},p=s=>d(c(s,{maxDepth:m}),s);class v{name;autoEmit;data;emitted;attachedError;level;pail;requestLogs;service;startTime;status;timestamp;_type;constructor(t){this.name=t.name,this.pail=t.pail,this.data={},this.startTime=performance.now(),this.timestamp=new Date().toISOString(),this.emitted=!1,this.autoEmit=t.autoEmit??!0,this._type=t.type??"info",this.level="info",this.requestLogs=[],this.service=t.service}debug(t,e){return this.addLogEntry("debug",t,e)}emit(t){if(this.emitted)return;this.emitted=!0;const e=Math.round(performance.now()-this.startTime),r=this.attachedError?"error":this.level,i=t??l[r],a={duration:g(e),duration_ms:e,event:this.name,timestamp:this.timestamp,...this.data};this.service&&(a.service=this.service),this.status!==void 0&&(a.status=this.status),this.attachedError&&(a.error=p(this.attachedError)),this.requestLogs.length>0&&(a.requestLogs=this.requestLogs);const o=this.pail[i];o({message:a})}error(t,e,r){return e&&(this.attachedError=e),this.addLogEntry("error",t,r)}finish(t){t?.status!==void 0&&(this.status=t.status),t?.error&&(this.attachedError=t.error),this.emit()}getData(){return this.data}getLevel(){return this.attachedError?"error":this.level}getRequestLogs(){return this.requestLogs}info(t,e){return this.addLogEntry("info",t,e)}set(t){return this.data=u(this.data,t),this}setError(t){return this.attachedError=t,this}setStatus(t){return this.status=t,this}warn(t,e){return this.addLogEntry("warn",t,e)}[Symbol.dispose](){this.autoEmit&&!this.emitted&&this.emit()}addLogEntry(t,e,r){const i={level:t,message:e,timestamp:new Date().toISOString()};return r&&(i.context=r),this.requestLogs.push(i),this.escalateLevel(t),this}escalateLevel(t){(h[t]??0)>(h[this.level]??0)&&(this.level=t)}}const y=s=>new v(s);export{v as WideEvent,y as createWideEvent};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/pail",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.23",
|
|
4
4
|
"description": "Highly configurable Logger for Node.js, Edge and Browser.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"anolilab",
|
|
@@ -229,19 +229,19 @@
|
|
|
229
229
|
"LICENSE.md"
|
|
230
230
|
],
|
|
231
231
|
"dependencies": {
|
|
232
|
-
"@visulima/colorize": "2.0.0-alpha.
|
|
233
|
-
"@visulima/interactive-manager": "1.0.0-alpha.
|
|
232
|
+
"@visulima/colorize": "2.0.0-alpha.15",
|
|
233
|
+
"@visulima/interactive-manager": "1.0.0-alpha.5"
|
|
234
234
|
},
|
|
235
235
|
"peerDependencies": {
|
|
236
236
|
"@opentelemetry/api": "^1.9.1",
|
|
237
237
|
"@sveltejs/kit": ">=2.0",
|
|
238
|
-
"@visulima/redact": "3.0.0-alpha.
|
|
238
|
+
"@visulima/redact": "3.0.0-alpha.14",
|
|
239
239
|
"elysia": ">=1.0",
|
|
240
240
|
"express": ">=4.0",
|
|
241
241
|
"fastify": ">=4.0",
|
|
242
242
|
"hono": ">=4.0",
|
|
243
243
|
"next": ">=14.0",
|
|
244
|
-
"rotating-file-stream": "3.2.9"
|
|
244
|
+
"rotating-file-stream": ">=3.2.9"
|
|
245
245
|
},
|
|
246
246
|
"peerDependenciesMeta": {
|
|
247
247
|
"@opentelemetry/api": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{E as O}from"./constants-ep2nsfdy.js";var d=Object.defineProperty,v=(e,r)=>d(e,"name",{value:r,configurable:!0});const j=Object.create({},{cause:{enumerable:!1,value:void 0,writable:!0},code:{enumerable:!0,value:void 0,writable:!0},errors:{enumerable:!1,value:void 0,writable:!0},message:{enumerable:!1,value:void 0,writable:!0},name:{enumerable:!1,value:void 0,writable:!0},stack:{enumerable:!1,value:void 0,writable:!0}});var h=Object.defineProperty,l=v((e,r)=>h(e,"name",{value:r,configurable:!0}),"i");const S=l(e=>{if(typeof e!="object"||e===null)return!1;const r=Object.getPrototypeOf(e);return r===null||r===Object.prototype||Object.getPrototypeOf(r)===null},"isPlainObject"),p=new WeakSet,g=l(e=>{const r=Object.getOwnPropertyNames(e);for(const n of r){const t=Object.getOwnPropertyDescriptor(e,n);t&&(t.enumerable||Object.defineProperty(e,n,{...t,enumerable:!0}),t.value&&typeof t.value=="object"&&!Array.isArray(t.value)&&(Object.getPrototypeOf(t.value)===Object.prototype||Object.getPrototypeOf(t.value)===null)&&g(t.value))}},"makePropertiesEnumerable"),P=l(e=>{p.add(e);const r=e.toJSON();return p.delete(e),Object.isExtensible(r)&&g(r),r},"toJSON"),m=l((e,r,n,t,o=new Set)=>{if(e&&e instanceof Uint8Array&&e.constructor.name==="Buffer")return"[object Buffer]";if(e!==null&&typeof e=="object"&&"pipe"in e&&typeof e.pipe=="function")return"[object Stream]";if(e instanceof Error)return r.has(e)?"[Circular]":(n+=1,f(e,t,r,n));if(t.useToJSON&&e!==null&&typeof e=="object"&&"toJSON"in e&&typeof e.toJSON=="function")return e.toJSON();if(e instanceof Date)return e.toISOString();if(typeof e=="function")return`[Function: ${e.name||"anonymous"}]`;if(typeof e=="bigint")return`${String(e)}n`;if(S(e)){if(o.has(e))return"[Circular]";if(t.maxDepth!==void 0&&t.maxDepth!==Number.POSITIVE_INFINITY&&n+1>=t.maxDepth)return{};n+=1,o.add(e);const i={};for(const u in e)i[u]=m(e[u],r,n,t,o);return o.delete(e),i}try{return e}catch{return"[Not Available]"}},"serializeValue"),f=l((e,r,n,t)=>{if(n.add(e),r.maxDepth===0)return{};if(r.useToJSON&&typeof e.toJSON=="function"&&!p.has(e))return P(e);const o=Object.create(j);if(Object.defineProperty(o,"name",{configurable:!0,enumerable:!0,value:Object.prototype.toString.call(e.constructor)==="[object Function]"?e.constructor.name:e.name,writable:!0}),Object.defineProperty(o,"message",{configurable:!0,enumerable:!0,value:e.message,writable:!0}),Object.defineProperty(o,"stack",{configurable:!0,enumerable:!0,value:e.stack,writable:!0}),Array.isArray(e.errors)){const u=[];for(const a of e.errors){if(!(a instanceof Error))throw new TypeError("All errors in the 'errors' property must be instances of Error");if(n.has(a))return Object.defineProperty(o,"errors",{configurable:!0,enumerable:!0,value:[],writable:!0}),o;u.push(f(a,r,n,t))}Object.defineProperty(o,"errors",{configurable:!0,enumerable:!0,value:u,writable:!0})}const i=e.cause;if(i!=null)if(i instanceof Error)n.has(i)?Object.defineProperty(o,"cause",{configurable:!0,enumerable:!0,value:"[Circular]",writable:!0}):Object.defineProperty(o,"cause",{configurable:!0,enumerable:!0,value:f(i,r,n,t),writable:!0});else{const u=m(i,n,t,r);Object.defineProperty(o,"cause",{configurable:!0,enumerable:!0,value:u,writable:!0})}for(const u in e){if(u==="name"||u==="message"||u==="stack"||u==="cause"||u==="errors")continue;const a=e[u],c=m(a,n,t,r);Object.defineProperty(o,u,{configurable:!0,enumerable:!0,value:c,writable:!0})}if(Array.isArray(r.exclude)&&r.exclude.length>0)for(const u of r.exclude)try{delete o[u]}catch{}return o},"_serialize"),y=l((e,r={})=>f(e,{exclude:r.exclude??[],maxDepth:r.maxDepth??Number.POSITIVE_INFINITY,useToJSON:r.useToJSON??!1},new Set,0),"serialize");class N{stringify;errorOptions;constructor(r={}){this.errorOptions=r.error??{}}setStringify(r){this.stringify=r}log(r){const{context:n,error:t,file:o,message:i,type:u,...a}=r;if(a.label&&(a.label=a.label.trim()),o&&(a.file=`${o.name??""}:${String(o.line)}${o.column?`:${String(o.column)}`:""}`),a.message=i===O?void 0:i,t&&(a.error=y(t,this.errorOptions)),n){const c=[];for(let b=0;b<n.length;b+=1){const s=n[b];s!==O&&(s instanceof Error?c.push(y(s,this.errorOptions)):c.push(s))}a.context=c}this._log(this.stringify(a),u.level)}}export{N as AbstractJsonReporter};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{E as O}from"./constants-DKfCaSUR.js";var d=Object.defineProperty,v=(e,r)=>d(e,"name",{value:r,configurable:!0});const j=Object.create({},{cause:{enumerable:!1,value:void 0,writable:!0},code:{enumerable:!0,value:void 0,writable:!0},errors:{enumerable:!1,value:void 0,writable:!0},message:{enumerable:!1,value:void 0,writable:!0},name:{enumerable:!1,value:void 0,writable:!0},stack:{enumerable:!1,value:void 0,writable:!0}});var h=Object.defineProperty,l=v((e,r)=>h(e,"name",{value:r,configurable:!0}),"i");const S=l(e=>{if(typeof e!="object"||e===null)return!1;const r=Object.getPrototypeOf(e);return r===null||r===Object.prototype||Object.getPrototypeOf(r)===null},"isPlainObject"),p=new WeakSet,g=l(e=>{const r=Object.getOwnPropertyNames(e);for(const n of r){const t=Object.getOwnPropertyDescriptor(e,n);t&&(t.enumerable||Object.defineProperty(e,n,{...t,enumerable:!0}),t.value&&typeof t.value=="object"&&!Array.isArray(t.value)&&(Object.getPrototypeOf(t.value)===Object.prototype||Object.getPrototypeOf(t.value)===null)&&g(t.value))}},"makePropertiesEnumerable"),P=l(e=>{p.add(e);const r=e.toJSON();return p.delete(e),Object.isExtensible(r)&&g(r),r},"toJSON"),m=l((e,r,n,t,o=new Set)=>{if(e&&e instanceof Uint8Array&&e.constructor.name==="Buffer")return"[object Buffer]";if(e!==null&&typeof e=="object"&&"pipe"in e&&typeof e.pipe=="function")return"[object Stream]";if(e instanceof Error)return r.has(e)?"[Circular]":(n+=1,f(e,t,r,n));if(t.useToJSON&&e!==null&&typeof e=="object"&&"toJSON"in e&&typeof e.toJSON=="function")return e.toJSON();if(e instanceof Date)return e.toISOString();if(typeof e=="function")return`[Function: ${e.name||"anonymous"}]`;if(typeof e=="bigint")return`${String(e)}n`;if(S(e)){if(o.has(e))return"[Circular]";if(t.maxDepth!==void 0&&t.maxDepth!==Number.POSITIVE_INFINITY&&n+1>=t.maxDepth)return{};n+=1,o.add(e);const i={};for(const u in e)i[u]=m(e[u],r,n,t,o);return o.delete(e),i}try{return e}catch{return"[Not Available]"}},"serializeValue"),f=l((e,r,n,t)=>{if(n.add(e),r.maxDepth===0)return{};if(r.useToJSON&&typeof e.toJSON=="function"&&!p.has(e))return P(e);const o=Object.create(j);if(Object.defineProperty(o,"name",{configurable:!0,enumerable:!0,value:Object.prototype.toString.call(e.constructor)==="[object Function]"?e.constructor.name:e.name,writable:!0}),Object.defineProperty(o,"message",{configurable:!0,enumerable:!0,value:e.message,writable:!0}),Object.defineProperty(o,"stack",{configurable:!0,enumerable:!0,value:e.stack,writable:!0}),Array.isArray(e.errors)){const u=[];for(const a of e.errors){if(!(a instanceof Error))throw new TypeError("All errors in the 'errors' property must be instances of Error");if(n.has(a))return Object.defineProperty(o,"errors",{configurable:!0,enumerable:!0,value:[],writable:!0}),o;u.push(f(a,r,n,t))}Object.defineProperty(o,"errors",{configurable:!0,enumerable:!0,value:u,writable:!0})}const i=e.cause;if(i!=null)if(i instanceof Error)n.has(i)?Object.defineProperty(o,"cause",{configurable:!0,enumerable:!0,value:"[Circular]",writable:!0}):Object.defineProperty(o,"cause",{configurable:!0,enumerable:!0,value:f(i,r,n,t),writable:!0});else{const u=m(i,n,t,r);Object.defineProperty(o,"cause",{configurable:!0,enumerable:!0,value:u,writable:!0})}for(const u in e){if(u==="name"||u==="message"||u==="stack"||u==="cause"||u==="errors")continue;const a=e[u],c=m(a,n,t,r);Object.defineProperty(o,u,{configurable:!0,enumerable:!0,value:c,writable:!0})}if(Array.isArray(r.exclude)&&r.exclude.length>0)for(const u of r.exclude)try{delete o[u]}catch{}return o},"_serialize"),y=l((e,r={})=>f(e,{exclude:r.exclude??[],maxDepth:r.maxDepth??Number.POSITIVE_INFINITY,useToJSON:r.useToJSON??!1},new Set,0),"serialize");class N{stringify;errorOptions;constructor(r={}){this.errorOptions=r.error??{}}setStringify(r){this.stringify=r}log(r){const{context:n,error:t,file:o,message:i,type:u,...a}=r;if(a.label&&(a.label=a.label.trim()),o&&(a.file=`${o.name??""}:${String(o.line)}${o.column?`:${String(o.column)}`:""}`),a.message=i===O?void 0:i,t&&(a.error=y(t,this.errorOptions)),n){const c=[];for(let b=0;b<n.length;b+=1){const s=n[b];s!==O&&(s instanceof Error?c.push(y(s,this.errorOptions)):c.push(s))}a.context=c}this._log(this.stringify(a),u.level)}}export{N as AbstractJsonReporter};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{AbstractJsonReporter as t}from"./AbstractJsonReporter-CVwjgboT.js";import{o as s}from"./write-console-log-based-on-level-DDSKGBKj.js";class c extends t{constructor(o={}){super(o)}_log(o,r){s(r)(o)}}export{c as default};
|