vedatrace 0.1.6 → 0.1.8

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/dist/index.cjs CHANGED
@@ -59,7 +59,11 @@ class VedaTraceBatcher {
59
59
  const combinedError = new Error(
60
60
  `Failed to send logs after ${this.config.maxRetries} retries: ${errors.map((e) => e.message).join(", ")}`
61
61
  );
62
- this.onError?.(combinedError);
62
+ if (this.onError) {
63
+ this.onError(combinedError);
64
+ } else {
65
+ console.error("[VedaTrace]", combinedError.message);
66
+ }
63
67
  return;
64
68
  }
65
69
  this.onSuccess?.();
@@ -71,10 +75,21 @@ class VedaTraceBatcher {
71
75
  }
72
76
  this.flushTimer = setInterval(() => {
73
77
  if (this.queue.length > 0) {
74
- this.flush();
78
+ this.flush().catch((error) => {
79
+ if (this.onError) {
80
+ this.onError(
81
+ error instanceof Error ? error : new Error(String(error))
82
+ );
83
+ } else {
84
+ console.error(
85
+ "[VedaTrace] Flush error:",
86
+ error instanceof Error ? error.message : String(error)
87
+ );
88
+ }
89
+ });
75
90
  }
76
91
  }, this.config.flushInterval);
77
- if (this.config.unrefTimer !== false) {
92
+ if (this.config.unrefTimer === true) {
78
93
  this.flushTimer.unref();
79
94
  }
80
95
  }
@@ -114,7 +129,8 @@ class VedaTraceLogger {
114
129
  onError: config.onError,
115
130
  onSuccess: config.onSuccess,
116
131
  debug: config.debug ?? false,
117
- immediateFlush: config.immediateFlush ?? false
132
+ immediateFlush: config.immediateFlush ?? false,
133
+ unrefTimer: config.unrefTimer
118
134
  };
119
135
  if (!config.disabled) {
120
136
  this.initializeBatcher(config);
@@ -131,7 +147,8 @@ class VedaTraceLogger {
131
147
  batchSize: this.config.batchSize,
132
148
  flushInterval: this.config.flushInterval,
133
149
  maxRetries: this.config.maxRetries,
134
- retryDelay: this.config.retryDelay
150
+ retryDelay: this.config.retryDelay,
151
+ unrefTimer: this.config.unrefTimer
135
152
  },
136
153
  this.config.onError,
137
154
  this.config.onSuccess,
@@ -319,7 +336,8 @@ function vedatrace(config = {}) {
319
336
  batchSize: config.batchSize ?? 100,
320
337
  flushInterval: config.flushInterval ?? 1e3,
321
338
  maxRetries: config.maxRetries ?? 3,
322
- retryDelay: config.retryDelay ?? 1e3
339
+ retryDelay: config.retryDelay ?? 1e3,
340
+ unrefTimer: config.unrefTimer
323
341
  },
324
342
  config.onError,
325
343
  config.onSuccess
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { b as VedaTraceTransport, B as BatcherConfig, I as InternalLogEntry, V as VedaTraceLoggerInterface, a as VedaTraceConfig, L as LogMetadata, R as RedactionConfig } from './types-CGtcllp9.cjs';
2
- export { c as VedaTraceLevel, d as VedaTraceLog } from './types-CGtcllp9.cjs';
1
+ import { b as VedaTraceTransport, B as BatcherConfig, I as InternalLogEntry, V as VedaTraceLoggerInterface, a as VedaTraceConfig, L as LogMetadata, R as RedactionConfig } from './types-CcdFb-vY.cjs';
2
+ export { c as VedaTraceLevel, d as VedaTraceLog } from './types-CcdFb-vY.cjs';
3
3
  export { ConsoleFormat, ConsoleTransportConfig, HttpTransportConfig, VedaTraceConsoleTransport, VedaTraceHttpTransport } from './transports/index.cjs';
4
4
 
5
5
  /**
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { b as VedaTraceTransport, B as BatcherConfig, I as InternalLogEntry, V as VedaTraceLoggerInterface, a as VedaTraceConfig, L as LogMetadata, R as RedactionConfig } from './types-CGtcllp9.mjs';
2
- export { c as VedaTraceLevel, d as VedaTraceLog } from './types-CGtcllp9.mjs';
1
+ import { b as VedaTraceTransport, B as BatcherConfig, I as InternalLogEntry, V as VedaTraceLoggerInterface, a as VedaTraceConfig, L as LogMetadata, R as RedactionConfig } from './types-CcdFb-vY.mjs';
2
+ export { c as VedaTraceLevel, d as VedaTraceLog } from './types-CcdFb-vY.mjs';
3
3
  export { ConsoleFormat, ConsoleTransportConfig, HttpTransportConfig, VedaTraceConsoleTransport, VedaTraceHttpTransport } from './transports/index.mjs';
4
4
 
5
5
  /**
package/dist/index.mjs CHANGED
@@ -55,7 +55,11 @@ class VedaTraceBatcher {
55
55
  const combinedError = new Error(
56
56
  `Failed to send logs after ${this.config.maxRetries} retries: ${errors.map((e) => e.message).join(", ")}`
57
57
  );
58
- this.onError?.(combinedError);
58
+ if (this.onError) {
59
+ this.onError(combinedError);
60
+ } else {
61
+ console.error("[VedaTrace]", combinedError.message);
62
+ }
59
63
  return;
60
64
  }
61
65
  this.onSuccess?.();
@@ -67,10 +71,21 @@ class VedaTraceBatcher {
67
71
  }
68
72
  this.flushTimer = setInterval(() => {
69
73
  if (this.queue.length > 0) {
70
- this.flush();
74
+ this.flush().catch((error) => {
75
+ if (this.onError) {
76
+ this.onError(
77
+ error instanceof Error ? error : new Error(String(error))
78
+ );
79
+ } else {
80
+ console.error(
81
+ "[VedaTrace] Flush error:",
82
+ error instanceof Error ? error.message : String(error)
83
+ );
84
+ }
85
+ });
71
86
  }
72
87
  }, this.config.flushInterval);
73
- if (this.config.unrefTimer !== false) {
88
+ if (this.config.unrefTimer === true) {
74
89
  this.flushTimer.unref();
75
90
  }
76
91
  }
@@ -110,7 +125,8 @@ class VedaTraceLogger {
110
125
  onError: config.onError,
111
126
  onSuccess: config.onSuccess,
112
127
  debug: config.debug ?? false,
113
- immediateFlush: config.immediateFlush ?? false
128
+ immediateFlush: config.immediateFlush ?? false,
129
+ unrefTimer: config.unrefTimer
114
130
  };
115
131
  if (!config.disabled) {
116
132
  this.initializeBatcher(config);
@@ -127,7 +143,8 @@ class VedaTraceLogger {
127
143
  batchSize: this.config.batchSize,
128
144
  flushInterval: this.config.flushInterval,
129
145
  maxRetries: this.config.maxRetries,
130
- retryDelay: this.config.retryDelay
146
+ retryDelay: this.config.retryDelay,
147
+ unrefTimer: this.config.unrefTimer
131
148
  },
132
149
  this.config.onError,
133
150
  this.config.onSuccess,
@@ -315,7 +332,8 @@ function vedatrace(config = {}) {
315
332
  batchSize: config.batchSize ?? 100,
316
333
  flushInterval: config.flushInterval ?? 1e3,
317
334
  maxRetries: config.maxRetries ?? 3,
318
- retryDelay: config.retryDelay ?? 1e3
335
+ retryDelay: config.retryDelay ?? 1e3,
336
+ unrefTimer: config.unrefTimer
319
337
  },
320
338
  config.onError,
321
339
  config.onSuccess
@@ -1,5 +1,5 @@
1
1
  import { Request, Response, NextFunction } from 'express';
2
- import { V as VedaTraceLoggerInterface, a as VedaTraceConfig, L as LogMetadata } from '../types-CGtcllp9.cjs';
2
+ import { V as VedaTraceLoggerInterface, a as VedaTraceConfig, L as LogMetadata } from '../types-CcdFb-vY.cjs';
3
3
 
4
4
  /**
5
5
  * Express.js middleware integration for VedaTrace
@@ -1,5 +1,5 @@
1
1
  import { Request, Response, NextFunction } from 'express';
2
- import { V as VedaTraceLoggerInterface, a as VedaTraceConfig, L as LogMetadata } from '../types-CGtcllp9.mjs';
2
+ import { V as VedaTraceLoggerInterface, a as VedaTraceConfig, L as LogMetadata } from '../types-CcdFb-vY.mjs';
3
3
 
4
4
  /**
5
5
  * Express.js middleware integration for VedaTrace
@@ -1,4 +1,4 @@
1
- import { a as VedaTraceConfig, L as LogMetadata, V as VedaTraceLoggerInterface } from '../types-CGtcllp9.cjs';
1
+ import { a as VedaTraceConfig, L as LogMetadata, V as VedaTraceLoggerInterface } from '../types-CcdFb-vY.cjs';
2
2
 
3
3
  /**
4
4
  * Next.js integration for VedaTrace
@@ -1,4 +1,4 @@
1
- import { a as VedaTraceConfig, L as LogMetadata, V as VedaTraceLoggerInterface } from '../types-CGtcllp9.mjs';
1
+ import { a as VedaTraceConfig, L as LogMetadata, V as VedaTraceLoggerInterface } from '../types-CcdFb-vY.mjs';
2
2
 
3
3
  /**
4
4
  * Next.js integration for VedaTrace
@@ -1,5 +1,5 @@
1
1
  import { ReactNode, ReactElement } from 'react';
2
- import { a as VedaTraceConfig, V as VedaTraceLoggerInterface, L as LogMetadata } from '../types-CGtcllp9.cjs';
2
+ import { a as VedaTraceConfig, V as VedaTraceLoggerInterface, L as LogMetadata } from '../types-CcdFb-vY.cjs';
3
3
 
4
4
  /**
5
5
  * React integration for VedaTrace
@@ -1,5 +1,5 @@
1
1
  import { ReactNode, ReactElement } from 'react';
2
- import { a as VedaTraceConfig, V as VedaTraceLoggerInterface, L as LogMetadata } from '../types-CGtcllp9.mjs';
2
+ import { a as VedaTraceConfig, V as VedaTraceLoggerInterface, L as LogMetadata } from '../types-CcdFb-vY.mjs';
3
3
 
4
4
  /**
5
5
  * React integration for VedaTrace
@@ -1,4 +1,4 @@
1
- import { c as VedaTraceLevel, b as VedaTraceTransport, I as InternalLogEntry } from '../types-CGtcllp9.cjs';
1
+ import { c as VedaTraceLevel, b as VedaTraceTransport, I as InternalLogEntry } from '../types-CcdFb-vY.cjs';
2
2
 
3
3
  /**
4
4
  * Console transport for development/debugging
@@ -1,4 +1,4 @@
1
- import { c as VedaTraceLevel, b as VedaTraceTransport, I as InternalLogEntry } from '../types-CGtcllp9.mjs';
1
+ import { c as VedaTraceLevel, b as VedaTraceTransport, I as InternalLogEntry } from '../types-CcdFb-vY.mjs';
2
2
 
3
3
  /**
4
4
  * Console transport for development/debugging
@@ -49,6 +49,8 @@ interface VedaTraceConfig {
49
49
  debug?: boolean;
50
50
  /** Flush immediately after each log (for console/dev mode) */
51
51
  immediateFlush?: boolean;
52
+ /** Unref the flush timer (Node.js only, default: false) */
53
+ unrefTimer?: boolean;
52
54
  }
53
55
  /** Redaction configuration */
54
56
  interface RedactionConfig {
@@ -49,6 +49,8 @@ interface VedaTraceConfig {
49
49
  debug?: boolean;
50
50
  /** Flush immediately after each log (for console/dev mode) */
51
51
  immediateFlush?: boolean;
52
+ /** Unref the flush timer (Node.js only, default: false) */
53
+ unrefTimer?: boolean;
52
54
  }
53
55
  /** Redaction configuration */
54
56
  interface RedactionConfig {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vedatrace",
3
3
  "description": "Universal JavaScript logging SDK for VedaTrace - type-safe, lightweight, and developer-friendly",
4
- "version": "0.1.6",
4
+ "version": "0.1.8",
5
5
  "scripts": {
6
6
  "setup": "rm -rf node_modules && npm i && git init && husky",
7
7
  "prepublishOnly": "npm run build",
@@ -23,7 +23,7 @@
23
23
  ],
24
24
  "lint-staged": {
25
25
  "*.{ts,tsx}": [
26
- "npm run lint"
26
+ "bun run lint"
27
27
  ]
28
28
  },
29
29
  "type": "module",