@visulima/pail 4.0.2 → 4.1.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 +23 -0
- package/LICENSE.md +346 -0
- package/README.md +17 -0
- package/dist/error.d.ts +69 -69
- package/dist/index.browser.d.ts +446 -445
- package/dist/index.browser.js +17 -17
- package/dist/index.server.d.ts +582 -582
- package/dist/index.server.js +27 -27
- package/dist/middleware/elysia.d.ts +44 -42
- package/dist/middleware/elysia.js +1 -1
- package/dist/middleware/express.d.ts +58 -59
- package/dist/middleware/express.js +1 -1
- package/dist/middleware/fastify.d.ts +55 -56
- package/dist/middleware/fastify.js +1 -1
- package/dist/middleware/hono.d.ts +56 -57
- package/dist/middleware/hono.js +1 -1
- package/dist/middleware/next/handler.d.ts +67 -68
- package/dist/middleware/next/handler.js +1 -1
- package/dist/middleware/sveltekit.d.ts +72 -73
- package/dist/middleware/sveltekit.js +1 -1
- package/dist/object-tree.d.ts +44 -44
- package/dist/packem_shared/AbstractJsonReporter-BpWRnN0L.js +1 -0
- package/dist/packem_shared/AbstractJsonReporter-DxZwImm5.js +1 -0
- package/dist/packem_shared/JsonReporter-9IcELa1m.js +2 -0
- package/dist/packem_shared/JsonReporter-Dd3kuj8X.js +1 -0
- package/dist/packem_shared/{PrettyReporter-DsHfKOU7.js → PrettyReporter-BUWNEg3_.js} +1 -1
- package/dist/packem_shared/{PrettyReporter-CcDdPQSt.js → PrettyReporter-DbgD89ck.js} +56 -30
- package/dist/packem_shared/abstract-json-reporter.d-B6NoO-hG.d.ts +61 -0
- package/dist/packem_shared/{abstract-pretty-reporter-DrLBJ6ds.js → abstract-pretty-reporter-CyfTvmKf.js} +41 -39
- package/dist/packem_shared/create-middleware-logger.d-BRkkBMlk.d.ts +47 -0
- package/dist/packem_shared/headers-DI58djdG.js +1 -0
- package/dist/packem_shared/index-CbkPnylC.js +1 -0
- package/dist/packem_shared/serializeError-52C4oiKx-CrnRcq9R.js +1 -0
- package/dist/packem_shared/storage-DVcJumyk.js +1 -0
- package/dist/packem_shared/types.d-4ge_rME4.d.ts +246 -0
- package/dist/packem_shared/{types.d-Cz9S7jZh.d.ts → types.d-BW8kAXUv.d.ts} +95 -95
- package/dist/packem_shared/types.d-DGHeA2iJ.d.ts +194 -0
- package/dist/packem_shared/useLogger-7p55yvvc.js +1 -0
- package/dist/packem_shared/wide-event.d-BMLastMR.d.ts +716 -0
- package/dist/packem_shared/write-stream-ytl_vhg_.js +1 -0
- package/dist/processor/caller/caller-processor.d.ts +32 -33
- package/dist/processor/environment-processor.d.ts +83 -84
- package/dist/processor/message-formatter-processor.d.ts +40 -45
- package/dist/processor/message-formatter-processor.js +1 -1
- package/dist/processor/opentelemetry-processor.d.ts +51 -52
- package/dist/processor/redact-processor.d.ts +57 -65
- package/dist/processor/sampling-processor.d.ts +90 -91
- package/dist/reporter/file/json-file-reporter.d.ts +77 -78
- package/dist/reporter/file/json-file-reporter.js +1 -1
- package/dist/reporter/http/abstract-http-reporter.d.ts +125 -121
- package/dist/reporter/http/abstract-http-reporter.js +2 -2
- package/dist/reporter/http/http-reporter.d.ts +33 -34
- package/dist/reporter/http/http-reporter.edge-light.d.ts +235 -230
- package/dist/reporter/http/http-reporter.edge-light.js +2 -2
- package/dist/reporter/json/index.browser.d.ts +62 -61
- package/dist/reporter/json/index.browser.js +1 -1
- package/dist/reporter/json/index.d.ts +36 -37
- package/dist/reporter/json/index.js +1 -1
- package/dist/reporter/pretty/index.browser.d.ts +57 -56
- package/dist/reporter/pretty/index.browser.js +1 -1
- package/dist/reporter/pretty/index.d.ts +133 -133
- package/dist/reporter/pretty/index.js +1 -1
- package/dist/reporter/simple/simple-reporter.server.d.ts +91 -90
- package/dist/reporter/simple/simple-reporter.server.js +7 -7
- package/dist/wide-event.d.ts +2 -3
- package/dist/wide-event.js +1 -1
- package/package.json +58 -37
- package/dist/packem_shared/AbstractJsonReporter-Bp_JCrMQ.js +0 -1
- package/dist/packem_shared/AbstractJsonReporter-w_bGGiD-.js +0 -1
- package/dist/packem_shared/JsonReporter-Sd_lJGS-.js +0 -2
- package/dist/packem_shared/JsonReporter-bmem9lcg.js +0 -1
- package/dist/packem_shared/abstract-json-reporter.d-wfESoEa-.d.ts +0 -62
- package/dist/packem_shared/addKnownErrorConstructor-C1OJTj2D-0FlJMfXz.js +0 -25
- package/dist/packem_shared/create-middleware-logger.d-B-JmQ1Sl.d.ts +0 -47
- package/dist/packem_shared/headers-DH0H2s8W.js +0 -1
- package/dist/packem_shared/index-Q1764hvO.js +0 -1
- package/dist/packem_shared/serializeError-C-NFvZ8_-D0CA_Qlx.js +0 -1
- package/dist/packem_shared/storage-DaXAlpiO.js +0 -1
- package/dist/packem_shared/types.d-bWnqHJKL.d.ts +0 -211
- package/dist/packem_shared/types.d-xxE3FOD3.d.ts +0 -229
- package/dist/packem_shared/useLogger-DB34CuU5.js +0 -1
- package/dist/packem_shared/wide-event.d-D3ATYpoK.d.ts +0 -717
- package/dist/packem_shared/write-stream-C7jxLxIT.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
`,this.batchMode=
|
|
1
|
+
const D=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}}),E=e=>{if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.prototype||Object.getPrototypeOf(t)===null},p=new WeakSet,P=e=>{if(Object.hasOwn(e,"name")&&typeof e.name=="string"&&e.name!=="")return e.name;const t=e.constructor?.name;return typeof t=="string"&&t!==""?t:e.name},O=e=>{const t=Object.getOwnPropertyNames(e);for(const s of t){const r=Object.getOwnPropertyDescriptor(e,s);r&&(r.enumerable||Object.defineProperty(e,s,{...r,enumerable:!0}),r.value&&typeof r.value=="object"&&!Array.isArray(r.value)&&(Object.getPrototypeOf(r.value)===Object.prototype||Object.getPrototypeOf(r.value)===null)&&O(r.value))}},N=e=>{p.add(e);const t=e.toJSON();return p.delete(e),Object.isExtensible(t)&&O(t),t},d=(e,t,s,r,a=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 t.has(e)?"[Circular]":(s+=1,m(e,r,t,s));if(r.useToJSON&&e!==null&&typeof e=="object"&&"toJSON"in e&&typeof e.toJSON=="function")return e.toJSON();if(e instanceof Date)return e.toISOString();if(e instanceof RegExp)return e.toString();if(typeof URL<"u"&&e instanceof URL)return e.href;if(e instanceof Map){const i=[];for(const[n,o]of e.entries())i.push([d(n,t,s,r,a),d(o,t,s,r,a)]);return{__dataType:"Map",value:i}}if(e instanceof Set){const i=[];for(const n of e.values())i.push(d(n,t,s,r,a));return{__dataType:"Set",value:i}}if(typeof e=="function")return`[Function: ${e.name||"anonymous"}]`;if(typeof e=="bigint")return`${String(e)}n`;if(E(e)){if(a.has(e))return"[Circular]";if(r.maxDepth!==void 0&&r.maxDepth!==Number.POSITIVE_INFINITY&&s+1>=r.maxDepth)return{};s+=1,a.add(e);const i={};for(const n in e)i[n]=d(e[n],t,s,r,a);return a.delete(e),i}try{return e}catch{return"[Not Available]"}},m=(e,t,s,r)=>{if(s.add(e),t.maxDepth===0)return{};if(t.useToJSON&&typeof e.toJSON=="function"&&!p.has(e))return N(e);const a=Object.create(D);if(Object.defineProperty(a,"name",{configurable:!0,enumerable:!0,value:P(e),writable:!0}),Object.defineProperty(a,"message",{configurable:!0,enumerable:!0,value:e.message,writable:!0}),Object.defineProperty(a,"stack",{configurable:!0,enumerable:!0,value:e.stack,writable:!0}),Array.isArray(e.errors)){const n=[];for(const o of e.errors){if(!(o instanceof Error))throw new TypeError("All errors in the 'errors' property must be instances of Error");if(s.has(o))return Object.defineProperty(a,"errors",{configurable:!0,enumerable:!0,value:[],writable:!0}),a;n.push(m(o,t,s,r))}Object.defineProperty(a,"errors",{configurable:!0,enumerable:!0,value:n,writable:!0})}const i=e.cause;if(i!=null)if(i instanceof Error)s.has(i)?Object.defineProperty(a,"cause",{configurable:!0,enumerable:!0,value:"[Circular]",writable:!0}):Object.defineProperty(a,"cause",{configurable:!0,enumerable:!0,value:m(i,t,s,r),writable:!0});else{const n=d(i,s,r,t);Object.defineProperty(a,"cause",{configurable:!0,enumerable:!0,value:n,writable:!0})}for(const n in e){if(n==="name"||n==="message"||n==="stack"||n==="cause"||n==="errors")continue;const o=e[n],u=d(o,s,r,t);Object.defineProperty(a,n,{configurable:!0,enumerable:!0,value:u,writable:!0})}if(Array.isArray(t.exclude)&&t.exclude.length>0)for(const n of t.exclude)try{delete a[n]}catch{}return a},S=(e,t={})=>m(e,{exclude:t.exclude??[],maxDepth:t.maxDepth??Number.POSITIVE_INFINITY,useToJSON:t.useToJSON??!1},new Set,0),w=Symbol("EMPTY");class j{stringify;errorOptions;constructor(t={}){this.errorOptions=t.error??{}}setStringify(t){this.stringify=t}log(t){const{context:s,error:r,file:a,message:i,type:n,...o}=t;if(o.label&&(o.label=o.label.trim()),a&&(o.file=`${a.name??""}:${String(a.line)}${a.column?`:${String(a.column)}`:""}`),o.message=i===w?void 0:i,r&&(o.error=S(r,this.errorOptions)),s){const u=[];for(let h=0;h<s.length;h+=1){const c=s[h];c!==w&&(c instanceof Error?u.push(S(c,this.errorOptions)):u.push(c))}o.context=u}this._log(this.stringify(o),n.level)}}const R=async()=>{try{const{gzipSync:e}=await import("node:zlib");return typeof e=="function"?e:void 0}catch{return}},B=async e=>{const t=globalThis.CompressionStream;if(t){const r=new t("gzip"),a=r.writable.getWriter(),i=r.readable.getReader(),n=new TextEncoder,o=[];await a.write(n.encode(e)),await a.close();let u=!1;for(;!u;){const l=await i.read();u=l.done,l.value&&o.push(l.value)}const h=o.reduce((l,f)=>l+f.length,0),c=new Uint8Array(h);let b=0;for(let l=0;l<o.length;l+=1){const f=o[l];c.set(f,b),b+=f.length}return c}const s=await R();if(s===void 0)throw new Error("gzip compression is unavailable: this runtime provides neither CompressionStream nor node:zlib.");return s(e)};class Q extends Error{logData;actualSize;maxSize;constructor(t,s,r,a){super(t),this.name="LogSizeError",this.logData=s,this.actualSize=r,this.maxSize=a}}let v=class extends Error{};const y=(e,t)=>e*2**t,x=6e4,$=/^\d+$/,L=e=>{const t=e.trim();if($.test(t)){const a=Number.parseInt(t,10);return Math.min(Math.max(a,0)*1e3,x)}const s=Date.parse(t);if(Number.isNaN(s))return;const r=s-Date.now();return Math.min(Math.max(r,0),x)},z=e=>new Promise(t=>{setTimeout(t,e)}),M=e=>typeof e=="string"?e:new Uint8Array(e.buffer,e.byteOffset,e.byteLength),J=async(e,t,s,r,a,i,n)=>{const o={};e.headers.forEach((c,b)=>{o[b]=c});const u=await e.text(),h={req:{body:a,headers:r,method:s,url:t},res:{body:u,headers:o,status:e.status,statusText:e.statusText}};if(i&&i(h),e.ok)return!1;if(e.status<500&&e.status!==429){const c=new v(`HTTP ${String(e.status)}: ${e.statusText}`);throw n&&n(c),c}return!0},A=(e,t,s,r,a)=>{if(e.status===429&&t&&r<a){const i=e.headers.get("retry-after");return(i?L(i):void 0)??y(s,r)}},C=(e,t,s,r)=>{if(e.status>=500&&s<r)return y(t,s)},I=(e,t,s,r,a)=>{const i=A(e,t,s,r,a);return i!==void 0?i:C(e,s,r,a)},k=async(e,t,s,r,a)=>{if(t<s){const i=y(r,t);return await z(i),!0}return a&&a(e),!1},F=async(e,t)=>{const{body:s,headers:r,maxRetries:a,method:i,onDebugRequestResponse:n,onError:o,respectRateLimit:u,retryDelay:h,url:c}=e,b=M(s),l=await fetch(c,{body:b,headers:r,method:i});if(!await J(l,c,i,r,s,n,o))return{done:!0};const f=I(l,u,h,t,a);if(f!==void 0)return{retryInMs:f};if(!l.ok){const g=new Error(`HTTP ${String(l.status)}: ${l.statusText}`);throw o&&o(g),g}return{done:!0}},q=async(e,t,s,r,a,i,n,o,u)=>{const h={body:r,headers:s,maxRetries:a,method:t,onDebugRequestResponse:o,onError:u,respectRateLimit:n,retryDelay:i,url:e};let c=0;for(;c<=a;)try{const b=await F(h,c);if("retryInMs"in b)await z(b.retryInMs),c+=1;else return}catch(b){if(b instanceof v||!await k(b,c,a,i,u))throw b;c+=1}},_=e=>{let t=0;for(const s of e){const r=s.codePointAt(0);r<128?t+=1:r<2048?t+=2:r<65536?t+=3:t+=4}return t};let T;const U=e=>typeof TextEncoder=="function"?(T??=new TextEncoder,T.encode(e).length):_(e);class Y extends j{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=[];batchSizeQueue=[];batchTimeout;isProcessingBatch=!1;currentBatchSize=0;constructor(t){if(super(t),this.url=t.url,this.method=t.method??"POST",this.headers=t.headers??{},this.contentType=t.contentType??"application/json",this.batchContentType=t.batchContentType??"application/json",this.onError=t.onError,this.onDrop=t.onDrop,this.maxQueueSize=t.maxQueueSize??1e4,this.onDebug=t.onDebug,this.onDebugRequestResponse=t.onDebugRequestResponse,this.payloadTemplate=t.payloadTemplate??(s=>JSON.stringify(s)),this.compression=t.compression??!1,this.maxRetries=t.maxRetries??3,this.retryDelay=t.retryDelay??1e3,this.respectRateLimit=t.respectRateLimit??!0,this.enableBatchSend=t.enableBatchSend??!0,this.batchSize=t.batchSize??100,this.batchSendTimeout=t.batchSendTimeout??5e3,this.batchSendDelimiter=t.batchSendDelimiter??`
|
|
2
|
+
`,this.batchMode=t.batchMode??"delimiter",this.batchFieldName=t.batchFieldName,this.batchMode==="field"&&!this.batchFieldName)throw new Error("batchFieldName is required when batchMode is 'field'");this.maxLogSize=t.maxLogSize??1048576,this.maxPayloadSize=t.maxPayloadSize??5242880,this.edgeCompat=t.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(t=>setTimeout(t,0));continue}await this.processBatch()}}async close(){await this.flush()}async dispose(){await this.close()}_log(t,s){try{const r=JSON.parse(t),a=s,i=r.message,n={logLevel:a,message:i??""};if(r.data)n.data=r.data;else if(r.context)n.data=r.context;else{const h={...r};delete h.message,Object.keys(h).length>0&&(n.data=h)}const o=this.payloadTemplate(n);this.onDebug&&this.onDebug({data:n.data,logLevel:a,message:i});const u=U(o);if(u>this.maxLogSize){const h=new Q(`Log entry exceeds maximum size of ${String(this.maxLogSize)} bytes. Size: ${String(u)} bytes`,{data:n.data,logLevel:a,message:i},u,this.maxLogSize);this.onError&&this.onError(h);return}this.enableBatchSend?this.addToBatch(o,u):this.sendPayload(o).catch(h=>{this.onError&&this.onError(h)})}catch(r){this.onError&&this.onError(r)}}addToBatch(t,s){const r=this.currentBatchSize+s+this.batchSendDelimiter.length,a=this.maxPayloadSize*.9;if(r>a&&this.batchQueue.length>0&&this.processBatch(),this.batchQueue.push(t),this.batchSizeQueue.push(s),this.currentBatchSize+=s+this.batchSendDelimiter.length,this.batchQueue.length>this.maxQueueSize){const i=this.batchQueue.length-this.maxQueueSize,n=this.batchQueue.splice(0,i);this.batchSizeQueue.splice(0,i),this.currentBatchSize=this.#e(),this.onDrop&&this.onDrop(n.length)}this.batchTimeout??=setTimeout(()=>{this.processBatch()},this.batchSendTimeout),this.batchQueue.length>=this.batchSize&&this.processBatch()}#e(){let t=0;for(let s=0;s<this.batchSizeQueue.length;s+=1)t+=this.batchSizeQueue[s]+(s<this.batchSizeQueue.length-1?this.batchSendDelimiter.length:0);return t}async processBatch(){if(this.isProcessingBatch||this.batchQueue.length===0)return;this.isProcessingBatch=!0,this.batchTimeout&&(clearTimeout(this.batchTimeout),this.batchTimeout=void 0);const t=this.batchQueue.splice(0,this.batchSize);this.batchSizeQueue.splice(0,this.batchSize),this.currentBatchSize=this.#e();try{await this.sendBatch(t)}catch(s){this.onError&&this.onError(s)}finally{this.isProcessingBatch=!1,this.batchQueue.length>0&&this.processBatch()}}async sendBatch(t){let s;switch(this.batchMode){case"array":{const r=t.map(a=>JSON.parse(a));s=JSON.stringify(r);break}case"field":{const r=t.map(i=>JSON.parse(i)),a=this.batchFieldName?{[this.batchFieldName]:r}:{};s=JSON.stringify(a);break}default:{s=t.join(this.batchSendDelimiter);break}}await this.sendPayload(s,this.batchContentType)}async sendPayload(t,s){const r=typeof this.headers=="function"?this.headers():{...this.headers};r["content-type"]??=s??this.contentType;let a=t;if(this.compression&&!this.edgeCompat)try{a=await B(t),r["content-encoding"]="gzip"}catch(i){this.onError&&this.onError(new Error(`Compression failed: ${String(i)}`))}await q(this.url,this.method,r,a,this.maxRetries,this.retryDelay,this.respectRateLimit,this.onDebugRequestResponse,this.onError)}}class V extends Y{constructor(t){super({...t,edgeCompat:!0})}}export{V as default};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { s as stringify } from "../../packem_shared/index.d-T71KjNAr.js";
|
|
2
|
-
import {
|
|
2
|
+
import { LiteralUnion } from 'type-fest';
|
|
3
|
+
import { R as ReadonlyMeta, E as ExtendedRfc5424LogLevels, S as StringifyAwareReporter } from "../../packem_shared/types.d-DGHeA2iJ.js";
|
|
3
4
|
import '@visulima/colorize';
|
|
4
5
|
import '@visulima/interactive-manager';
|
|
5
6
|
/**
|
|
6
|
-
* Options for configuring JSON reporters.
|
|
7
|
-
*/
|
|
7
|
+
* Options for configuring JSON reporters.
|
|
8
|
+
*/
|
|
8
9
|
type AbstractJsonReporterOptions = {
|
|
9
10
|
/** Error serialization options */
|
|
10
11
|
error: Partial<{
|
|
@@ -17,82 +18,82 @@ type AbstractJsonReporterOptions = {
|
|
|
17
18
|
}>;
|
|
18
19
|
};
|
|
19
20
|
/**
|
|
20
|
-
* Abstract JSON Reporter.
|
|
21
|
-
*
|
|
22
|
-
* Base class for JSON-based reporters that provides common functionality
|
|
23
|
-
* for serializing log metadata to JSON format. Handles error serialization,
|
|
24
|
-
* context processing, and provides a template method for actual output.
|
|
25
|
-
* @template L - The log level type
|
|
26
|
-
* @example
|
|
27
|
-
* ```typescript
|
|
28
|
-
* class CustomJsonReporter extends AbstractJsonReporter {
|
|
29
|
-
* protected _log(message: string): void {
|
|
30
|
-
* console.log(message);
|
|
31
|
-
* }
|
|
32
|
-
* }
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
21
|
+
* Abstract JSON Reporter.
|
|
22
|
+
*
|
|
23
|
+
* Base class for JSON-based reporters that provides common functionality
|
|
24
|
+
* for serializing log metadata to JSON format. Handles error serialization,
|
|
25
|
+
* context processing, and provides a template method for actual output.
|
|
26
|
+
* @template L - The log level type
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* class CustomJsonReporter extends AbstractJsonReporter {
|
|
30
|
+
* protected _log(message: string): void {
|
|
31
|
+
* console.log(message);
|
|
32
|
+
* }
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
35
36
|
declare abstract class AbstractJsonReporter<L extends string = string> implements StringifyAwareReporter<L> {
|
|
36
37
|
/** Custom stringify function for object serialization */
|
|
37
38
|
protected stringify: typeof stringify | undefined;
|
|
38
39
|
/** Error serialization options */
|
|
39
40
|
protected errorOptions: AbstractJsonReporterOptions["error"];
|
|
40
41
|
/**
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
* Creates a new AbstractJsonReporter instance.
|
|
43
|
+
* @param options Configuration options for JSON formatting and error handling
|
|
44
|
+
*/
|
|
44
45
|
constructor(options?: Partial<AbstractJsonReporterOptions>);
|
|
45
46
|
/**
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
* Sets a custom stringify function for object serialization.
|
|
48
|
+
* @param function_ The stringify function to use for serialization
|
|
49
|
+
*/
|
|
49
50
|
setStringify(function_: typeof stringify): void;
|
|
50
51
|
log(meta: ReadonlyMeta<L>): void;
|
|
51
52
|
/**
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
53
|
+
* Template method for outputting the JSON log message.
|
|
54
|
+
*
|
|
55
|
+
* Subclasses must implement this method to define how the JSON message
|
|
56
|
+
* is actually written (to console, file, network, etc.).
|
|
57
|
+
* @param message The JSON-formatted log message
|
|
58
|
+
* @param logLevel The log level of the message
|
|
59
|
+
* @protected
|
|
60
|
+
* @abstract
|
|
61
|
+
*/
|
|
61
62
|
protected abstract _log(message: string, logLevel: LiteralUnion<ExtendedRfc5424LogLevels, L>): void;
|
|
62
63
|
}
|
|
63
64
|
/**
|
|
64
|
-
* Browser JSON Reporter.
|
|
65
|
-
*
|
|
66
|
-
* A JSON reporter for browser environments that outputs structured log data
|
|
67
|
-
* to the browser console. Uses appropriate console methods based on log level.
|
|
68
|
-
* @template L - The log level type
|
|
69
|
-
* @example
|
|
70
|
-
* ```typescript
|
|
71
|
-
* import { createPail } from "@visulima/pail";
|
|
72
|
-
*
|
|
73
|
-
* const logger = createPail({
|
|
74
|
-
* reporters: [new JsonReporter()]
|
|
75
|
-
* });
|
|
76
|
-
*
|
|
77
|
-
* logger.info("Application started", { version: "1.0.0" });
|
|
78
|
-
* // Outputs: {"level":"info","message":"Application started","context":[{"version":"1.0.0"}],...}
|
|
79
|
-
* ```
|
|
80
|
-
*/
|
|
65
|
+
* Browser JSON Reporter.
|
|
66
|
+
*
|
|
67
|
+
* A JSON reporter for browser environments that outputs structured log data
|
|
68
|
+
* to the browser console. Uses appropriate console methods based on log level.
|
|
69
|
+
* @template L - The log level type
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* import { createPail } from "@visulima/pail";
|
|
73
|
+
*
|
|
74
|
+
* const logger = createPail({
|
|
75
|
+
* reporters: [new JsonReporter()]
|
|
76
|
+
* });
|
|
77
|
+
*
|
|
78
|
+
* logger.info("Application started", { version: "1.0.0" });
|
|
79
|
+
* // Outputs: {"level":"info","message":"Application started","context":[{"version":"1.0.0"}],...}
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
81
82
|
declare class JsonReporter<L extends string = string> extends AbstractJsonReporter<L> {
|
|
82
83
|
/**
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
* Creates a new Browser JSON Reporter instance.
|
|
85
|
+
* @param options Configuration options for JSON formatting
|
|
86
|
+
*/
|
|
86
87
|
constructor(options?: Partial<AbstractJsonReporterOptions>);
|
|
87
88
|
/**
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
89
|
+
* Outputs the JSON message to the browser console.
|
|
90
|
+
*
|
|
91
|
+
* Uses the appropriate console method based on the log level
|
|
92
|
+
* (console.log, console.error, console.warn, etc.).
|
|
93
|
+
* @param message The JSON-formatted log message
|
|
94
|
+
* @param logLevel The log level determining which console method to use
|
|
95
|
+
* @protected
|
|
96
|
+
*/
|
|
96
97
|
protected override _log(message: string, logLevel: LiteralUnion<ExtendedRfc5424LogLevels, L>): void;
|
|
97
98
|
}
|
|
98
99
|
export { AbstractJsonReporter, type AbstractJsonReporterOptions, JsonReporter };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AbstractJsonReporter as e}from"../../packem_shared/AbstractJsonReporter-
|
|
1
|
+
import{AbstractJsonReporter as e}from"../../packem_shared/AbstractJsonReporter-BpWRnN0L.js";import{default as p}from"../../packem_shared/JsonReporter-Dd3kuj8X.js";export{e as AbstractJsonReporter,p as JsonReporter};
|
|
@@ -1,53 +1,52 @@
|
|
|
1
|
-
import { A as AbstractJsonReporterOptions, a as AbstractJsonReporter } from "../../packem_shared/abstract-json-reporter.d-
|
|
2
|
-
import { LiteralUnion } from
|
|
3
|
-
import { E as ExtendedRfc5424LogLevels, a as StreamAwareReporter } from "../../packem_shared/types.d-bWnqHJKL.js";
|
|
1
|
+
import { A as AbstractJsonReporterOptions, a as AbstractJsonReporter } from "../../packem_shared/abstract-json-reporter.d-B6NoO-hG.js";
|
|
2
|
+
import { E as ExtendedRfc5424LogLevels, L as LiteralUnion, a as StreamAwareReporter } from "../../packem_shared/types.d-4ge_rME4.js";
|
|
4
3
|
import "../../packem_shared/index.d-T71KjNAr.js";
|
|
5
4
|
import '@visulima/colorize';
|
|
6
5
|
import '@visulima/interactive-manager';
|
|
7
6
|
/**
|
|
8
|
-
* Server JSON Reporter.
|
|
9
|
-
*
|
|
10
|
-
* A JSON reporter for Node.js server environments that outputs structured log data
|
|
11
|
-
* to stdout/stderr streams. Routes error-level logs to stderr and others to stdout.
|
|
12
|
-
* @template L - The log level type
|
|
13
|
-
* @example
|
|
14
|
-
* ```typescript
|
|
15
|
-
* import { createPail } from "@visulima/pail";
|
|
16
|
-
*
|
|
17
|
-
* const logger = createPail({
|
|
18
|
-
* reporters: [new JsonReporter()]
|
|
19
|
-
* });
|
|
20
|
-
*
|
|
21
|
-
* logger.info("Server started", { port: 3000 });
|
|
22
|
-
* logger.error("Database connection failed", error);
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
7
|
+
* Server JSON Reporter.
|
|
8
|
+
*
|
|
9
|
+
* A JSON reporter for Node.js server environments that outputs structured log data
|
|
10
|
+
* to stdout/stderr streams. Routes error-level logs to stderr and others to stdout.
|
|
11
|
+
* @template L - The log level type
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { createPail } from "@visulima/pail";
|
|
15
|
+
*
|
|
16
|
+
* const logger = createPail({
|
|
17
|
+
* reporters: [new JsonReporter()]
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* logger.info("Server started", { port: 3000 });
|
|
21
|
+
* logger.error("Database connection failed", error);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
25
24
|
declare class JsonReporter<L extends string = string> extends AbstractJsonReporter<L> implements StreamAwareReporter<L> {
|
|
26
25
|
#private;
|
|
27
26
|
/**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
* Creates a new Server JSON Reporter instance.
|
|
28
|
+
* @param options Configuration options for JSON formatting
|
|
29
|
+
*/
|
|
31
30
|
constructor(options?: Partial<AbstractJsonReporterOptions>);
|
|
32
31
|
/**
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
* Sets the stdout stream for the reporter.
|
|
33
|
+
* @param stdout_ The writable stream to use for stdout output
|
|
34
|
+
*/
|
|
36
35
|
setStdout(stdout_: NodeJS.WriteStream): void;
|
|
37
36
|
/**
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
* Sets the stderr stream for the reporter.
|
|
38
|
+
* @param stderr_ The writable stream to use for stderr output
|
|
39
|
+
*/
|
|
41
40
|
setStderr(stderr_: NodeJS.WriteStream): void;
|
|
42
41
|
/**
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
42
|
+
* Outputs the JSON message to the appropriate stream.
|
|
43
|
+
*
|
|
44
|
+
* Routes high-severity RFC 5424 levels (warning/error/critical/alert/emergency/trace)
|
|
45
|
+
* to stderr, others to stdout.
|
|
46
|
+
* @param message The JSON-formatted log message
|
|
47
|
+
* @param logLevel The log level determining which stream to use
|
|
48
|
+
* @protected
|
|
49
|
+
*/
|
|
51
50
|
protected override _log(message: string, logLevel: LiteralUnion<ExtendedRfc5424LogLevels, L>): void;
|
|
52
51
|
}
|
|
53
52
|
export { AbstractJsonReporter, type AbstractJsonReporterOptions, JsonReporter };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{AbstractJsonReporter as e}from"../../packem_shared/AbstractJsonReporter-
|
|
1
|
+
import{AbstractJsonReporter as e}from"../../packem_shared/AbstractJsonReporter-DxZwImm5.js";import{default as p}from"../../packem_shared/JsonReporter-9IcELa1m.js";export{e as AbstractJsonReporter,p as JsonReporter};
|
|
@@ -1,50 +1,51 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LiteralUnion } from 'type-fest';
|
|
2
|
+
import { D as DefaultLogTypes, L as LoggerTypesConfig, R as ReadonlyMeta, a as LoggerTypesAwareReporter } from "../../packem_shared/types.d-DGHeA2iJ.js";
|
|
2
3
|
import '@visulima/colorize';
|
|
3
4
|
import '@visulima/interactive-manager';
|
|
4
5
|
/**
|
|
5
|
-
* Abstract Pretty Reporter.
|
|
6
|
-
*
|
|
7
|
-
* Base class for pretty-printing reporters that format log messages with colors,
|
|
8
|
-
* styles, and structured layout. Provides common functionality for styling options
|
|
9
|
-
* and logger type configuration.
|
|
10
|
-
* @template T - Custom logger type names
|
|
11
|
-
* @template L - Log level types
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* class CustomPrettyReporter extends AbstractPrettyReporter {
|
|
15
|
-
* public log(meta: ReadonlyMeta) {
|
|
16
|
-
* const formatted = this.formatMessage(meta);
|
|
17
|
-
* console.log(formatted);
|
|
18
|
-
* }
|
|
19
|
-
* }
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
6
|
+
* Abstract Pretty Reporter.
|
|
7
|
+
*
|
|
8
|
+
* Base class for pretty-printing reporters that format log messages with colors,
|
|
9
|
+
* styles, and structured layout. Provides common functionality for styling options
|
|
10
|
+
* and logger type configuration.
|
|
11
|
+
* @template T - Custom logger type names
|
|
12
|
+
* @template L - Log level types
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* class CustomPrettyReporter extends AbstractPrettyReporter {
|
|
16
|
+
* public log(meta: ReadonlyMeta) {
|
|
17
|
+
* const formatted = this.formatMessage(meta);
|
|
18
|
+
* console.log(formatted);
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
22
23
|
declare abstract class AbstractPrettyReporter<T extends string = string, L extends string = string> implements LoggerTypesAwareReporter<T, L> {
|
|
23
24
|
/** Styling options for pretty formatting */
|
|
24
25
|
protected readonly styles: PrettyStyleOptions;
|
|
25
26
|
/** Logger type configurations for styling */
|
|
26
27
|
protected loggerTypes: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>;
|
|
27
28
|
/**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
* Creates a new AbstractPrettyReporter instance.
|
|
30
|
+
* @param options Styling options for pretty formatting
|
|
31
|
+
* @protected
|
|
32
|
+
*/
|
|
32
33
|
protected constructor(options: Partial<PrettyStyleOptions>);
|
|
33
34
|
/**
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
* Sets the logger types configuration for styling.
|
|
36
|
+
* @param types Logger type configurations with colors and labels
|
|
37
|
+
*/
|
|
37
38
|
setLoggerTypes(types: LoggerTypesConfig<LiteralUnion<DefaultLogTypes, T>, L>): void;
|
|
38
39
|
/**
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
* Logs a message with pretty formatting.
|
|
41
|
+
* @param meta The log metadata to format and output
|
|
42
|
+
* @abstract
|
|
43
|
+
*/
|
|
43
44
|
abstract log(meta: ReadonlyMeta<L>): void;
|
|
44
45
|
}
|
|
45
46
|
/**
|
|
46
|
-
* Options for configuring pretty reporter styling.
|
|
47
|
-
*/
|
|
47
|
+
* Options for configuring pretty reporter styling.
|
|
48
|
+
*/
|
|
48
49
|
type PrettyStyleOptions = {
|
|
49
50
|
/** Bold styling options */
|
|
50
51
|
bold: {
|
|
@@ -71,34 +72,34 @@ type PrettyStyleOptions = {
|
|
|
71
72
|
};
|
|
72
73
|
};
|
|
73
74
|
/**
|
|
74
|
-
* Browser Pretty Reporter.
|
|
75
|
-
*
|
|
76
|
-
* A pretty-printing reporter for browser environments that formats log messages
|
|
77
|
-
* with colors and structured layout for console output. Uses browser-compatible
|
|
78
|
-
* color formatting and console APIs.
|
|
79
|
-
* @template T - Custom logger type names
|
|
80
|
-
* @template L - Log level types
|
|
81
|
-
* @example
|
|
82
|
-
* ```typescript
|
|
83
|
-
* import { createPail } from "@visulima/pail";
|
|
84
|
-
*
|
|
85
|
-
* const logger = createPail({
|
|
86
|
-
* reporters: [new PrettyReporter({
|
|
87
|
-
* bold: { label: true },
|
|
88
|
-
* uppercase: { label: true }
|
|
89
|
-
* })]
|
|
90
|
-
* });
|
|
91
|
-
*
|
|
92
|
-
* logger.info("Application started");
|
|
93
|
-
* logger.error("Something went wrong", error);
|
|
94
|
-
* ```
|
|
95
|
-
*/
|
|
75
|
+
* Browser Pretty Reporter.
|
|
76
|
+
*
|
|
77
|
+
* A pretty-printing reporter for browser environments that formats log messages
|
|
78
|
+
* with colors and structured layout for console output. Uses browser-compatible
|
|
79
|
+
* color formatting and console APIs.
|
|
80
|
+
* @template T - Custom logger type names
|
|
81
|
+
* @template L - Log level types
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* import { createPail } from "@visulima/pail";
|
|
85
|
+
*
|
|
86
|
+
* const logger = createPail({
|
|
87
|
+
* reporters: [new PrettyReporter({
|
|
88
|
+
* bold: { label: true },
|
|
89
|
+
* uppercase: { label: true }
|
|
90
|
+
* })]
|
|
91
|
+
* });
|
|
92
|
+
*
|
|
93
|
+
* logger.info("Application started");
|
|
94
|
+
* logger.error("Something went wrong", error);
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
96
97
|
declare class PrettyReporter<T extends string = string, L extends string = string> extends AbstractPrettyReporter<T, L> {
|
|
97
98
|
#private;
|
|
98
99
|
/**
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
* Creates a new Browser Pretty Reporter instance.
|
|
101
|
+
* @param options Styling options for pretty formatting
|
|
102
|
+
*/
|
|
102
103
|
constructor(options?: Partial<PrettyStyleOptions>);
|
|
103
104
|
log(meta: ReadonlyMeta<L>): void;
|
|
104
105
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{default as t}from"../../packem_shared/PrettyReporter-
|
|
1
|
+
import{default as t}from"../../packem_shared/PrettyReporter-BUWNEg3_.js";export{t as PrettyReporter};
|