infront-logger 1.1.22 → 1.1.24

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.es.js CHANGED
@@ -2681,14 +2681,26 @@ const TOKEN_STRING_RE = /"(access_token|refresh_token|id_token|bearer|authorizat
2681
2681
  function redactString(str) {
2682
2682
  return str.replace(JWT_RE, "*****").replace(TOKEN_STRING_RE, (_, key) => `"${key}":"*****"`);
2683
2683
  }
2684
+ function toSerializable(value) {
2685
+ if (typeof value.toJSON !== "function") return value;
2686
+ try {
2687
+ return value.toJSON();
2688
+ } catch (err) {
2689
+ return value;
2690
+ }
2691
+ }
2684
2692
  function redact$3(value, seen = /* @__PURE__ */ new WeakSet()) {
2685
2693
  if (value === null || value === void 0) return value;
2686
2694
  if (typeof value === "string") return redactString(value);
2695
+ if (typeof value === "function") return void 0;
2687
2696
  if (typeof value !== "object") return value;
2688
2697
  if (seen.has(value)) return "[Circular]";
2689
2698
  seen.add(value);
2690
2699
  let out;
2691
- if (Array.isArray(value)) {
2700
+ const serializable = toSerializable(value);
2701
+ if (serializable !== value) {
2702
+ out = redact$3(serializable, seen);
2703
+ } else if (Array.isArray(value)) {
2692
2704
  out = value.map((item) => redact$3(item, seen));
2693
2705
  } else {
2694
2706
  out = {};
@@ -2702,7 +2714,7 @@ function redact$3(value, seen = /* @__PURE__ */ new WeakSet()) {
2702
2714
  const transportCache = /* @__PURE__ */ new Map();
2703
2715
  class CoralogixTransport extends Transport {
2704
2716
  static getOrCreate(opts = {}) {
2705
- const key = `${opts.applicationName}|${opts.subsystemName}|${opts.apiKey}|${opts.domain || "us2.coralogix.com"}`;
2717
+ const key = `${opts.applicationName}|${opts.subsystemName}|${opts.apiKey}|${opts.domain || "us2.coralogix.com"}|${JSON.stringify(opts.labels || {})}`;
2706
2718
  let instance = transportCache.get(key);
2707
2719
  if (!instance) {
2708
2720
  instance = new CoralogixTransport(opts);
@@ -2715,6 +2727,7 @@ class CoralogixTransport extends Transport {
2715
2727
  this.applicationName = opts.applicationName;
2716
2728
  this.subsystemName = opts.subsystemName;
2717
2729
  this.apiKey = opts.apiKey;
2730
+ this.labels = opts.labels || {};
2718
2731
  this.cxDomain = opts.domain || "us2.coralogix.com";
2719
2732
  this.host = `ingress.${this.cxDomain}`;
2720
2733
  this.path = opts.path || "/logs/v1/bulk";
@@ -2733,7 +2746,7 @@ class CoralogixTransport extends Transport {
2733
2746
  this.queue.push({
2734
2747
  severity: SEVERITY[info.level] || SEVERITY.info,
2735
2748
  timestamp: Date.now(),
2736
- text: JSON.stringify(sanitized)
2749
+ text: JSON.stringify({ ...sanitized, ...this.labels })
2737
2750
  });
2738
2751
  if (this.queue.length >= this.batchCount) this.flush();
2739
2752
  } catch (err) {
package/dist/index.umd.js CHANGED
@@ -2682,14 +2682,26 @@
2682
2682
  function redactString(str) {
2683
2683
  return str.replace(JWT_RE, "*****").replace(TOKEN_STRING_RE, (_, key) => `"${key}":"*****"`);
2684
2684
  }
2685
+ function toSerializable(value) {
2686
+ if (typeof value.toJSON !== "function") return value;
2687
+ try {
2688
+ return value.toJSON();
2689
+ } catch (err) {
2690
+ return value;
2691
+ }
2692
+ }
2685
2693
  function redact$3(value, seen = /* @__PURE__ */ new WeakSet()) {
2686
2694
  if (value === null || value === void 0) return value;
2687
2695
  if (typeof value === "string") return redactString(value);
2696
+ if (typeof value === "function") return void 0;
2688
2697
  if (typeof value !== "object") return value;
2689
2698
  if (seen.has(value)) return "[Circular]";
2690
2699
  seen.add(value);
2691
2700
  let out;
2692
- if (Array.isArray(value)) {
2701
+ const serializable = toSerializable(value);
2702
+ if (serializable !== value) {
2703
+ out = redact$3(serializable, seen);
2704
+ } else if (Array.isArray(value)) {
2693
2705
  out = value.map((item) => redact$3(item, seen));
2694
2706
  } else {
2695
2707
  out = {};
@@ -2703,7 +2715,7 @@
2703
2715
  const transportCache = /* @__PURE__ */ new Map();
2704
2716
  class CoralogixTransport extends Transport {
2705
2717
  static getOrCreate(opts = {}) {
2706
- const key = `${opts.applicationName}|${opts.subsystemName}|${opts.apiKey}|${opts.domain || "us2.coralogix.com"}`;
2718
+ const key = `${opts.applicationName}|${opts.subsystemName}|${opts.apiKey}|${opts.domain || "us2.coralogix.com"}|${JSON.stringify(opts.labels || {})}`;
2707
2719
  let instance = transportCache.get(key);
2708
2720
  if (!instance) {
2709
2721
  instance = new CoralogixTransport(opts);
@@ -2716,6 +2728,7 @@
2716
2728
  this.applicationName = opts.applicationName;
2717
2729
  this.subsystemName = opts.subsystemName;
2718
2730
  this.apiKey = opts.apiKey;
2731
+ this.labels = opts.labels || {};
2719
2732
  this.cxDomain = opts.domain || "us2.coralogix.com";
2720
2733
  this.host = `ingress.${this.cxDomain}`;
2721
2734
  this.path = opts.path || "/logs/v1/bulk";
@@ -2734,7 +2747,7 @@
2734
2747
  this.queue.push({
2735
2748
  severity: SEVERITY[info.level] || SEVERITY.info,
2736
2749
  timestamp: Date.now(),
2737
- text: JSON.stringify(sanitized)
2750
+ text: JSON.stringify({ ...sanitized, ...this.labels })
2738
2751
  });
2739
2752
  if (this.queue.length >= this.batchCount) this.flush();
2740
2753
  } catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "infront-logger",
3
- "version": "1.1.22",
3
+ "version": "1.1.24",
4
4
  "description": "",
5
5
  "files": [
6
6
  "dist"