logixia 1.13.3 → 2.0.4
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/README.md +117 -44
- package/dist/async-context-B05ArHgM.mjs +134 -0
- package/dist/async-context-B05ArHgM.mjs.map +1 -0
- package/dist/async-context-DTQgi8f7.js +150 -0
- package/dist/async-context-DTQgi8f7.js.map +1 -0
- package/dist/{azure-monitor.transport-CHnjVRF-.mjs → azure-monitor.transport-BPbgjATu.mjs} +27 -15
- package/dist/azure-monitor.transport-BPbgjATu.mjs.map +1 -0
- package/dist/{azure-monitor.transport-BDFO4F-i.d.ts → azure-monitor.transport-C7kYyZUW.d.mts} +3 -6
- package/dist/azure-monitor.transport-C7kYyZUW.d.mts.map +1 -0
- package/dist/{azure-monitor.transport-CrvfHd9C.js → azure-monitor.transport-CwbOLZHB.js} +32 -20
- package/dist/azure-monitor.transport-CwbOLZHB.js.map +1 -0
- package/dist/{azure-monitor.transport-D5wQEH04.d.mts → azure-monitor.transport-DV03Z5P4.d.ts} +3 -6
- package/dist/azure-monitor.transport-DV03Z5P4.d.ts.map +1 -0
- package/dist/azure.d.mts +1 -2
- package/dist/azure.d.ts +1 -2
- package/dist/azure.js +3 -6
- package/dist/azure.mjs +1 -6
- package/dist/{batch-buffer-PGvSgbmd.mjs → batch-buffer-0fgLmIPn.mjs} +21 -7
- package/dist/batch-buffer-0fgLmIPn.mjs.map +1 -0
- package/dist/{batch-buffer-BY-mRWIK.js → batch-buffer-DT4gdXmf.js} +53 -40
- package/dist/batch-buffer-DT4gdXmf.js.map +1 -0
- package/dist/browser.d.mts +52 -23
- package/dist/browser.d.mts.map +1 -1
- package/dist/browser.d.ts +52 -23
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +460 -62
- package/dist/browser.js.map +1 -1
- package/dist/browser.mjs +461 -65
- package/dist/browser.mjs.map +1 -1
- package/dist/{nestjs-extras-ImbuDhs1.mjs → builder-D70z6kjj.mjs} +279 -965
- package/dist/builder-D70z6kjj.mjs.map +1 -0
- package/dist/{nestjs-extras-DnJ6vrIC.js → builder-M7NoaugM.js} +421 -1177
- package/dist/builder-M7NoaugM.js.map +1 -0
- package/dist/cli/index.js +86 -67
- package/dist/cloudwatch.d.mts +1 -2
- package/dist/cloudwatch.d.ts +1 -2
- package/dist/cloudwatch.js +3 -7
- package/dist/cloudwatch.mjs +1 -7
- package/dist/{cloudwatch.transport-BO1ahxw-.js → cloudwatch.transport-B2wKQFF7.js} +61 -36
- package/dist/cloudwatch.transport-B2wKQFF7.js.map +1 -0
- package/dist/{cloudwatch.transport-DZ6ies7g.mjs → cloudwatch.transport-BTvYfLs9.mjs} +54 -28
- package/dist/cloudwatch.transport-BTvYfLs9.mjs.map +1 -0
- package/dist/{cloudwatch.transport-B00st6Xv.d.ts → cloudwatch.transport-Bf7L4I59.d.ts} +2 -6
- package/dist/cloudwatch.transport-Bf7L4I59.d.ts.map +1 -0
- package/dist/{cloudwatch.transport-Blc7Gtxt.d.mts → cloudwatch.transport-Rj4yTpRn.d.mts} +2 -6
- package/dist/cloudwatch.transport-Rj4yTpRn.d.mts.map +1 -0
- package/dist/{coerce.utils-Cu6IUTgX.mjs → coerce.utils-B_rEudCn.mjs} +3 -4
- package/dist/{coerce.utils-Cu6IUTgX.mjs.map → coerce.utils-B_rEudCn.mjs.map} +1 -1
- package/dist/{coerce.utils-B-LilukN.js → coerce.utils-C1C5sIX0.js} +8 -10
- package/dist/{coerce.utils-B-LilukN.js.map → coerce.utils-C1C5sIX0.js.map} +1 -1
- package/dist/correlation.d.mts +13 -16
- package/dist/correlation.d.mts.map +1 -1
- package/dist/correlation.d.ts +13 -16
- package/dist/correlation.d.ts.map +1 -1
- package/dist/correlation.js +58 -9
- package/dist/correlation.js.map +1 -1
- package/dist/correlation.mjs +56 -6
- package/dist/correlation.mjs.map +1 -1
- package/dist/{entry-fields-BJkuPnIg.mjs → entry-fields-CGuvT2R0.mjs} +5 -6
- package/dist/entry-fields-CGuvT2R0.mjs.map +1 -0
- package/dist/{entry-fields-BvOLFlJ4.js → entry-fields-RLd1jCoR.js} +10 -12
- package/dist/entry-fields-RLd1jCoR.js.map +1 -0
- package/dist/gcp.d.mts +1 -2
- package/dist/gcp.d.ts +1 -2
- package/dist/gcp.js +3 -7
- package/dist/gcp.mjs +1 -7
- package/dist/{gcp.transport-m4fVw0b1.d.ts → gcp.transport-C5D72b1g.d.mts} +3 -6
- package/dist/gcp.transport-C5D72b1g.d.mts.map +1 -0
- package/dist/{gcp.transport-zzNyIoih.d.mts → gcp.transport-CFQfdAOK.d.ts} +3 -6
- package/dist/gcp.transport-CFQfdAOK.d.ts.map +1 -0
- package/dist/{gcp.transport-DBX5TPIy.mjs → gcp.transport-CGKopAhQ.mjs} +55 -16
- package/dist/gcp.transport-CGKopAhQ.mjs.map +1 -0
- package/dist/{gcp.transport-CHV8MGgz.js → gcp.transport-KZe9hCAR.js} +60 -22
- package/dist/gcp.transport-KZe9hCAR.js.map +1 -0
- package/dist/{index-nZEeCr3X.d.ts → index-DwozbmB4.d.ts} +3 -8
- package/dist/index-DwozbmB4.d.ts.map +1 -0
- package/dist/{index-BPwEisy4.d.mts → index-xqaJtAZn.d.mts} +3 -8
- package/dist/index-xqaJtAZn.d.mts.map +1 -0
- package/dist/index.d.mts +141 -203
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +140 -202
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +196 -381
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +145 -294
- package/dist/index.mjs.map +1 -1
- package/dist/internal-log-b0Vp4qrB.js +183 -0
- package/dist/internal-log-b0Vp4qrB.js.map +1 -0
- package/dist/internal-log-uCSd1PMc.mjs +142 -0
- package/dist/internal-log-uCSd1PMc.mjs.map +1 -0
- package/dist/logitron-logger-D2B75Oc7.d.ts +365 -0
- package/dist/logitron-logger-D2B75Oc7.d.ts.map +1 -0
- package/dist/logitron-logger-oEd6wNhf.d.mts +365 -0
- package/dist/logitron-logger-oEd6wNhf.d.mts.map +1 -0
- package/dist/middleware.d.mts +10 -12
- package/dist/middleware.d.mts.map +1 -1
- package/dist/middleware.d.ts +10 -12
- package/dist/middleware.d.ts.map +1 -1
- package/dist/middleware.js +16 -47
- package/dist/middleware.js.map +1 -1
- package/dist/middleware.mjs +13 -45
- package/dist/middleware.mjs.map +1 -1
- package/dist/nest.d.mts +467 -10
- package/dist/nest.d.mts.map +1 -1
- package/dist/nest.d.ts +467 -10
- package/dist/nest.d.ts.map +1 -1
- package/dist/nest.js +889 -43
- package/dist/nest.js.map +1 -0
- package/dist/nest.mjs +850 -9
- package/dist/nest.mjs.map +1 -0
- package/dist/{trace.utils-CvXgaiQT.mjs → request-trace-C_fvIDv4.mjs} +44 -9
- package/dist/request-trace-C_fvIDv4.mjs.map +1 -0
- package/dist/{trace.utils-DpBOLDtq.js → request-trace-wTJdKp6-.js} +121 -77
- package/dist/request-trace-wTJdKp6-.js.map +1 -0
- package/dist/rolldown-runtime-D3PmRqjj.mjs +4 -0
- package/dist/{safe-stringify-DJ66tW5I.mjs → safe-stringify-BMRl3EX3.mjs} +3 -4
- package/dist/safe-stringify-BMRl3EX3.mjs.map +1 -0
- package/dist/{safe-stringify-DWo3aZp_.js → safe-stringify-DLz1Kz3o.js} +23 -25
- package/dist/safe-stringify-DLz1Kz3o.js.map +1 -0
- package/dist/{search-CHUZPl0h.d.ts → search-BH33XhuU.d.mts} +2 -22
- package/dist/search-BH33XhuU.d.mts.map +1 -0
- package/dist/{search-DjXSn6v5.mjs → search-CWMVYC-R.mjs} +34 -41
- package/dist/search-CWMVYC-R.mjs.map +1 -0
- package/dist/{search-BfBzDIT9.d.mts → search-CazwyX5Z.d.ts} +2 -22
- package/dist/search-CazwyX5Z.d.ts.map +1 -0
- package/dist/{search-B0MH1SJJ.js → search-DUfWuzFP.js} +64 -71
- package/dist/search-DUfWuzFP.js.map +1 -0
- package/dist/search.d.mts +2 -4
- package/dist/search.d.ts +2 -4
- package/dist/search.js +3 -4
- package/dist/search.mjs +1 -4
- package/dist/secret-config-BegMLkYl.mjs +209 -0
- package/dist/secret-config-BegMLkYl.mjs.map +1 -0
- package/dist/secret-config-CBZBs0p1.js +271 -0
- package/dist/secret-config-CBZBs0p1.js.map +1 -0
- package/dist/slack.transport-Ce96JBDk.mjs +824 -0
- package/dist/slack.transport-Ce96JBDk.mjs.map +1 -0
- package/dist/slack.transport-Dlx3xvb7.js +847 -0
- package/dist/slack.transport-Dlx3xvb7.js.map +1 -0
- package/dist/slack.transport-DrirgDNy.d.ts +159 -0
- package/dist/slack.transport-DrirgDNy.d.ts.map +1 -0
- package/dist/slack.transport-DxHOXlLu.d.mts +159 -0
- package/dist/slack.transport-DxHOXlLu.d.mts.map +1 -0
- package/dist/testing.d.mts +3 -8
- package/dist/testing.d.mts.map +1 -1
- package/dist/testing.d.ts +3 -8
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +3 -4
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +2 -3
- package/dist/testing.mjs.map +1 -1
- package/dist/{transport.manager-Crau3Rle.js → transport.manager-DkcEOlqV.js} +331 -234
- package/dist/transport.manager-DkcEOlqV.js.map +1 -0
- package/dist/{transport.manager-CpdVHEGP.mjs → transport.manager-eZ_EeC00.mjs} +274 -178
- package/dist/transport.manager-eZ_EeC00.mjs.map +1 -0
- package/dist/{transport.types-CtNr3D7S.d.mts → transport.types-BJVL1QQl.d.mts} +5 -4
- package/dist/transport.types-BJVL1QQl.d.mts.map +1 -0
- package/dist/{transport.types-DqVLZTyf.d.ts → transport.types-BJVL1QQl.d.ts} +5 -4
- package/dist/transport.types-BJVL1QQl.d.ts.map +1 -0
- package/dist/transports.d.mts +32 -41
- package/dist/transports.d.mts.map +1 -1
- package/dist/transports.d.ts +32 -41
- package/dist/transports.d.ts.map +1 -1
- package/dist/transports.js +12 -12
- package/dist/transports.mjs +7 -12
- package/dist/worker-entry.js +337 -87
- package/dist/worker.d.mts +1 -2
- package/dist/worker.d.ts +1 -2
- package/dist/worker.js +3 -4
- package/dist/worker.mjs +1 -4
- package/dist/{worker.transport-Bj-i0P9V.d.ts → worker.transport-BuPwBi3d.d.ts} +2 -6
- package/dist/worker.transport-BuPwBi3d.d.ts.map +1 -0
- package/dist/{worker.transport-JP8YHBuU.js → worker.transport-C6GNl_r2.js} +44 -14
- package/dist/worker.transport-C6GNl_r2.js.map +1 -0
- package/dist/{worker.transport-otwhJ_Et.mjs → worker.transport-DLVA4y2e.mjs} +39 -9
- package/dist/worker.transport-DLVA4y2e.mjs.map +1 -0
- package/dist/{worker.transport-Bgv9heDI.d.mts → worker.transport-hJay1wxA.d.mts} +2 -6
- package/dist/worker.transport-hJay1wxA.d.mts.map +1 -0
- package/package.json +36 -19
- package/dist/async-context-BzJrbfQs.mjs +0 -72
- package/dist/async-context-BzJrbfQs.mjs.map +0 -1
- package/dist/async-context-DyQQYq3I.js +0 -92
- package/dist/async-context-DyQQYq3I.js.map +0 -1
- package/dist/azure-monitor.transport-BDFO4F-i.d.ts.map +0 -1
- package/dist/azure-monitor.transport-CHnjVRF-.mjs.map +0 -1
- package/dist/azure-monitor.transport-CrvfHd9C.js.map +0 -1
- package/dist/azure-monitor.transport-D5wQEH04.d.mts.map +0 -1
- package/dist/batch-buffer-BY-mRWIK.js.map +0 -1
- package/dist/batch-buffer-PGvSgbmd.mjs.map +0 -1
- package/dist/chunk-DLSkYcPk.mjs +0 -7
- package/dist/chunk-nOFOJqeH.js +0 -30
- package/dist/cloudwatch.transport-B00st6Xv.d.ts.map +0 -1
- package/dist/cloudwatch.transport-BO1ahxw-.js.map +0 -1
- package/dist/cloudwatch.transport-Blc7Gtxt.d.mts.map +0 -1
- package/dist/cloudwatch.transport-DZ6ies7g.mjs.map +0 -1
- package/dist/entry-fields-BJkuPnIg.mjs.map +0 -1
- package/dist/entry-fields-BvOLFlJ4.js.map +0 -1
- package/dist/gcp.transport-CHV8MGgz.js.map +0 -1
- package/dist/gcp.transport-DBX5TPIy.mjs.map +0 -1
- package/dist/gcp.transport-m4fVw0b1.d.ts.map +0 -1
- package/dist/gcp.transport-zzNyIoih.d.mts.map +0 -1
- package/dist/index-BPwEisy4.d.mts.map +0 -1
- package/dist/index-nZEeCr3X.d.ts.map +0 -1
- package/dist/internal-log-BUJYMZbE.js +0 -70
- package/dist/internal-log-BUJYMZbE.js.map +0 -1
- package/dist/internal-log-Cm8SOWSV.mjs +0 -52
- package/dist/internal-log-Cm8SOWSV.mjs.map +0 -1
- package/dist/nestjs-extras-DnJ6vrIC.js.map +0 -1
- package/dist/nestjs-extras-ImbuDhs1.mjs.map +0 -1
- package/dist/nestjs-extras-OkC796py.d.mts +0 -725
- package/dist/nestjs-extras-OkC796py.d.mts.map +0 -1
- package/dist/nestjs-extras-mKrHE9S6.d.ts +0 -725
- package/dist/nestjs-extras-mKrHE9S6.d.ts.map +0 -1
- package/dist/safe-stringify-DJ66tW5I.mjs.map +0 -1
- package/dist/safe-stringify-DWo3aZp_.js.map +0 -1
- package/dist/search-B0MH1SJJ.js.map +0 -1
- package/dist/search-BfBzDIT9.d.mts.map +0 -1
- package/dist/search-CHUZPl0h.d.ts.map +0 -1
- package/dist/search-DjXSn6v5.mjs.map +0 -1
- package/dist/trace.utils-CvXgaiQT.mjs.map +0 -1
- package/dist/trace.utils-DpBOLDtq.js.map +0 -1
- package/dist/transport.manager-CpdVHEGP.mjs.map +0 -1
- package/dist/transport.manager-Crau3Rle.js.map +0 -1
- package/dist/transport.types-CtNr3D7S.d.mts.map +0 -1
- package/dist/transport.types-DqVLZTyf.d.ts.map +0 -1
- package/dist/worker.transport-Bgv9heDI.d.mts.map +0 -1
- package/dist/worker.transport-Bj-i0P9V.d.ts.map +0 -1
- package/dist/worker.transport-JP8YHBuU.js.map +0 -1
- package/dist/worker.transport-otwhJ_Et.mjs.map +0 -1
|
@@ -1,22 +1,17 @@
|
|
|
1
|
-
const
|
|
2
|
-
const require_internal_log = require(
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
let node_fs = require("node:fs");
|
|
7
|
-
node_fs = require_chunk.__toESM(node_fs);
|
|
8
|
-
let node_path = require("node:path");
|
|
9
|
-
node_path = require_chunk.__toESM(node_path);
|
|
1
|
+
const require_secret_config = require("./secret-config-CBZBs0p1.js");
|
|
2
|
+
const require_internal_log = require("./internal-log-b0Vp4qrB.js");
|
|
3
|
+
const require_coerce_utils = require("./coerce.utils-C1C5sIX0.js");
|
|
4
|
+
const require_safe_stringify = require("./safe-stringify-DLz1Kz3o.js");
|
|
5
|
+
const require_entry_fields = require("./entry-fields-RLd1jCoR.js");
|
|
10
6
|
let node_events = require("node:events");
|
|
11
|
-
node_events = require_chunk.__toESM(node_events);
|
|
12
|
-
let node_stream_promises = require("node:stream/promises");
|
|
13
|
-
node_stream_promises = require_chunk.__toESM(node_stream_promises);
|
|
14
7
|
let node_util = require("node:util");
|
|
15
|
-
node_util = require_chunk.__toESM(node_util);
|
|
16
8
|
let node_zlib = require("node:zlib");
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
let node_fs = require("node:fs");
|
|
10
|
+
node_fs = require_secret_config.__toESM(node_fs);
|
|
11
|
+
let node_path = require("node:path");
|
|
12
|
+
node_path = require_secret_config.__toESM(node_path);
|
|
13
|
+
let node_stream_promises = require("node:stream/promises");
|
|
14
|
+
// src/utils/sanitize.utils.ts
|
|
20
15
|
/**
|
|
21
16
|
* Control-character stripping for text-mode log output.
|
|
22
17
|
*
|
|
@@ -32,9 +27,7 @@ const VISIBLE_ESCAPES = {
|
|
|
32
27
|
function stripControlChars(value) {
|
|
33
28
|
return value.replace(CONTROL_CHARS_RE, (ch) => VISIBLE_ESCAPES[ch] ?? "");
|
|
34
29
|
}
|
|
35
|
-
|
|
36
|
-
//#endregion
|
|
37
|
-
//#region src/transports/console.transport.ts
|
|
30
|
+
// src/transports/console.transport.ts
|
|
38
31
|
/**
|
|
39
32
|
* Writes log entries to stdout (info/debug/verbose) and stderr (error/warn).
|
|
40
33
|
*
|
|
@@ -44,26 +37,6 @@ function stripControlChars(value) {
|
|
|
44
37
|
* transports: { console: { format: 'json' } }
|
|
45
38
|
*/
|
|
46
39
|
var ConsoleTransport = class ConsoleTransport {
|
|
47
|
-
static #_ = this.COLORS = new Map([
|
|
48
|
-
["black", "\x1B[30m"],
|
|
49
|
-
["red", "\x1B[31m"],
|
|
50
|
-
["green", "\x1B[32m"],
|
|
51
|
-
["yellow", "\x1B[33m"],
|
|
52
|
-
["blue", "\x1B[34m"],
|
|
53
|
-
["magenta", "\x1B[35m"],
|
|
54
|
-
["cyan", "\x1B[36m"],
|
|
55
|
-
["white", "\x1B[37m"],
|
|
56
|
-
["gray", "\x1B[90m"],
|
|
57
|
-
["grey", "\x1B[90m"],
|
|
58
|
-
["brightred", "\x1B[91m"],
|
|
59
|
-
["brightgreen", "\x1B[92m"],
|
|
60
|
-
["brightyellow", "\x1B[93m"],
|
|
61
|
-
["brightblue", "\x1B[94m"],
|
|
62
|
-
["brightmagenta", "\x1B[95m"],
|
|
63
|
-
["brightcyan", "\x1B[96m"],
|
|
64
|
-
["brightwhite", "\x1B[97m"],
|
|
65
|
-
["reset", "\x1B[0m"]
|
|
66
|
-
]);
|
|
67
40
|
static sanitize(value) {
|
|
68
41
|
return stripControlChars(require_coerce_utils.safeToString(value));
|
|
69
42
|
}
|
|
@@ -132,10 +105,28 @@ var ConsoleTransport = class ConsoleTransport {
|
|
|
132
105
|
close() {
|
|
133
106
|
return Promise.resolve();
|
|
134
107
|
}
|
|
108
|
+
static #_ = () => this.COLORS = /* @__PURE__ */ new Map([
|
|
109
|
+
["black", "\x1B[30m"],
|
|
110
|
+
["red", "\x1B[31m"],
|
|
111
|
+
["green", "\x1B[32m"],
|
|
112
|
+
["yellow", "\x1B[33m"],
|
|
113
|
+
["blue", "\x1B[34m"],
|
|
114
|
+
["magenta", "\x1B[35m"],
|
|
115
|
+
["cyan", "\x1B[36m"],
|
|
116
|
+
["white", "\x1B[37m"],
|
|
117
|
+
["gray", "\x1B[90m"],
|
|
118
|
+
["grey", "\x1B[90m"],
|
|
119
|
+
["brightred", "\x1B[91m"],
|
|
120
|
+
["brightgreen", "\x1B[92m"],
|
|
121
|
+
["brightyellow", "\x1B[93m"],
|
|
122
|
+
["brightblue", "\x1B[94m"],
|
|
123
|
+
["brightmagenta", "\x1B[95m"],
|
|
124
|
+
["brightcyan", "\x1B[96m"],
|
|
125
|
+
["brightwhite", "\x1B[97m"],
|
|
126
|
+
["reset", "\x1B[0m"]
|
|
127
|
+
]);
|
|
135
128
|
};
|
|
136
|
-
|
|
137
|
-
//#endregion
|
|
138
|
-
//#region src/transports/buffer-cap.ts
|
|
129
|
+
// src/transports/buffer-cap.ts
|
|
139
130
|
const DEFAULT_BUFFER_CAP = 1e4;
|
|
140
131
|
const DROP_WARN_INTERVAL_MS$1 = 5e3;
|
|
141
132
|
/**
|
|
@@ -151,8 +142,10 @@ var BufferCap = class {
|
|
|
151
142
|
this.dropped = 0;
|
|
152
143
|
this.lastWarning = 0;
|
|
153
144
|
let max = fallback;
|
|
154
|
-
if (requested !== void 0)
|
|
155
|
-
|
|
145
|
+
if (requested !== void 0) {
|
|
146
|
+
if (Number.isInteger(requested) && requested >= 1) max = requested;
|
|
147
|
+
else require_internal_log.internalWarn(`${name}: maxBufferSize ${String(requested)} is not a positive integer; using ${fallback}`);
|
|
148
|
+
}
|
|
156
149
|
this.max = Math.max(max, batchSize);
|
|
157
150
|
}
|
|
158
151
|
/** Drops the oldest items beyond the cap, in place. */
|
|
@@ -174,9 +167,7 @@ var BufferCap = class {
|
|
|
174
167
|
this.lastWarning = now;
|
|
175
168
|
}
|
|
176
169
|
};
|
|
177
|
-
|
|
178
|
-
//#endregion
|
|
179
|
-
//#region src/transports/database.transport.ts
|
|
170
|
+
// src/transports/database.transport.ts
|
|
180
171
|
/**
|
|
181
172
|
* Validates that a SQL identifier (table/index name) contains only safe characters.
|
|
182
173
|
* Prevents SQL injection via user-supplied table names.
|
|
@@ -199,7 +190,7 @@ const PG_DATA_CLASSES = [
|
|
|
199
190
|
"23",
|
|
200
191
|
"54"
|
|
201
192
|
];
|
|
202
|
-
const MYSQL_DATA_CODES = new Set([
|
|
193
|
+
const MYSQL_DATA_CODES = /* @__PURE__ */ new Set([
|
|
203
194
|
"ER_DATA_TOO_LONG",
|
|
204
195
|
"ER_TRUNCATED_WRONG_VALUE",
|
|
205
196
|
"ER_TRUNCATED_WRONG_VALUE_FOR_FIELD",
|
|
@@ -209,7 +200,7 @@ const MYSQL_DATA_CODES = new Set([
|
|
|
209
200
|
"ER_INVALID_JSON_TEXT",
|
|
210
201
|
"ER_INVALID_CHARACTER_STRING"
|
|
211
202
|
]);
|
|
212
|
-
const MYSQL_DATA_ERRNOS = new Set([
|
|
203
|
+
const MYSQL_DATA_ERRNOS = /* @__PURE__ */ new Set([
|
|
213
204
|
1048,
|
|
214
205
|
1062,
|
|
215
206
|
1264,
|
|
@@ -218,12 +209,12 @@ const MYSQL_DATA_ERRNOS = new Set([
|
|
|
218
209
|
1406,
|
|
219
210
|
3140
|
|
220
211
|
]);
|
|
221
|
-
const SQLITE_DATA_CODES = new Set([
|
|
212
|
+
const SQLITE_DATA_CODES = /* @__PURE__ */ new Set([
|
|
222
213
|
"SQLITE_CONSTRAINT",
|
|
223
214
|
"SQLITE_TOOBIG",
|
|
224
215
|
"SQLITE_MISMATCH"
|
|
225
216
|
]);
|
|
226
|
-
const MONGO_DATA_CODES = new Set([
|
|
217
|
+
const MONGO_DATA_CODES = /* @__PURE__ */ new Set([
|
|
227
218
|
2,
|
|
228
219
|
121,
|
|
229
220
|
10334,
|
|
@@ -285,6 +276,7 @@ var DatabaseTransport = class {
|
|
|
285
276
|
this.name = "database";
|
|
286
277
|
this.batch = [];
|
|
287
278
|
this.isConnected = false;
|
|
279
|
+
require_secret_config.protectSecrets(this, ["config", "connection"]);
|
|
288
280
|
this.batchSize = config.batchSize || 100;
|
|
289
281
|
this.flushInterval = config.flushInterval || 5e3;
|
|
290
282
|
this.cap = new BufferCap("DatabaseTransport", config.maxBufferSize, this.batchSize);
|
|
@@ -292,6 +284,14 @@ var DatabaseTransport = class {
|
|
|
292
284
|
if (config.table) validateSqlIdentifier(config.table, "table");
|
|
293
285
|
this.setupFlushTimer();
|
|
294
286
|
}
|
|
287
|
+
secretValues() {
|
|
288
|
+
const { connectionString, password } = this.config;
|
|
289
|
+
return [
|
|
290
|
+
connectionString,
|
|
291
|
+
password,
|
|
292
|
+
...connectionString ? require_secret_config.urlSecrets(connectionString) : []
|
|
293
|
+
];
|
|
294
|
+
}
|
|
295
295
|
async write(entry) {
|
|
296
296
|
if (!this.isConnected) await this.connect();
|
|
297
297
|
this.addToBatch(entry);
|
|
@@ -352,6 +352,13 @@ var DatabaseTransport = class {
|
|
|
352
352
|
this.cap.enforce(this.batch);
|
|
353
353
|
}
|
|
354
354
|
async writeEntries(entries) {
|
|
355
|
+
try {
|
|
356
|
+
await this.writeEntriesUnscrubbed(entries);
|
|
357
|
+
} catch (error) {
|
|
358
|
+
throw require_secret_config.scrubError(error, this.secretValues());
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
async writeEntriesUnscrubbed(entries) {
|
|
355
362
|
switch (this.config.type) {
|
|
356
363
|
case "mongodb":
|
|
357
364
|
await this.flushToMongoDB(entries);
|
|
@@ -430,13 +437,12 @@ var DatabaseTransport = class {
|
|
|
430
437
|
case "mysql":
|
|
431
438
|
await this.connectMySQL();
|
|
432
439
|
break;
|
|
433
|
-
case "sqlite":
|
|
434
|
-
await this.connectSQLite();
|
|
435
|
-
break;
|
|
440
|
+
case "sqlite": await this.connectSQLite();
|
|
436
441
|
}
|
|
437
442
|
this.isConnected = true;
|
|
438
443
|
} catch (error) {
|
|
439
444
|
this.isConnected = false;
|
|
445
|
+
require_secret_config.scrubError(error, this.secretValues());
|
|
440
446
|
throw new Error(`Database connection failed: ${error}`, { cause: error });
|
|
441
447
|
}
|
|
442
448
|
}
|
|
@@ -445,7 +451,8 @@ var DatabaseTransport = class {
|
|
|
445
451
|
const { MongoClient } = await import("mongodb").catch(() => {
|
|
446
452
|
throw new Error("MongoDB driver not installed. Run: npm install mongodb");
|
|
447
453
|
});
|
|
448
|
-
|
|
454
|
+
const connectionString = this.config.connectionString || `mongodb://${this.config.host}:${this.config.port}/${this.config.database}`;
|
|
455
|
+
this.connection = new MongoClient(connectionString);
|
|
449
456
|
await this.connection.connect();
|
|
450
457
|
await this.connection.db(this.config.database).admin().ping();
|
|
451
458
|
} catch (error) {
|
|
@@ -557,12 +564,13 @@ var DatabaseTransport = class {
|
|
|
557
564
|
entry.environment
|
|
558
565
|
].map((value, column) => stripNul(column === 3 ? stripJsonNulEscape(value) : value))), POSTGRES_ROWS_PER_INSERT);
|
|
559
566
|
const insertChunk = async (rows) => {
|
|
567
|
+
const placeholders = rows.map((_, i) => {
|
|
568
|
+
return `(${Array.from({ length: POSTGRES_COLUMNS }, (_unused, c) => `$${i * POSTGRES_COLUMNS + c + 1}`).join(", ")})`;
|
|
569
|
+
}).join(", ");
|
|
560
570
|
const query = `
|
|
561
571
|
INSERT INTO ${tableName}
|
|
562
572
|
(timestamp, level, message, payload, context, trace_id, app_name, environment)
|
|
563
|
-
VALUES ${
|
|
564
|
-
return `(${Array.from({ length: POSTGRES_COLUMNS }, (_unused, c) => `$${i * POSTGRES_COLUMNS + c + 1}`).join(", ")})`;
|
|
565
|
-
}).join(", ")}
|
|
573
|
+
VALUES ${placeholders}
|
|
566
574
|
`;
|
|
567
575
|
await this.connection.query(query, rows.flat());
|
|
568
576
|
};
|
|
@@ -726,9 +734,7 @@ var DatabaseTransport = class {
|
|
|
726
734
|
case "mysql":
|
|
727
735
|
await this.connection.end();
|
|
728
736
|
break;
|
|
729
|
-
case "sqlite":
|
|
730
|
-
await this.connection.close();
|
|
731
|
-
break;
|
|
737
|
+
case "sqlite": await this.connection.close();
|
|
732
738
|
}
|
|
733
739
|
this.isConnected = false;
|
|
734
740
|
}
|
|
@@ -769,9 +775,18 @@ var DatabaseTransport = class {
|
|
|
769
775
|
}
|
|
770
776
|
}
|
|
771
777
|
};
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
778
|
+
// src/transports/analytics.transport.ts
|
|
779
|
+
/**
|
|
780
|
+
* Thrown by sendBatch() when part of a batch was already delivered. drain()
|
|
781
|
+
* requeues only `unsent`, so delivered entries are not sent twice.
|
|
782
|
+
*/
|
|
783
|
+
var PartialBatchError = class extends Error {
|
|
784
|
+
constructor(message, unsent, options) {
|
|
785
|
+
super(message, options);
|
|
786
|
+
this.unsent = unsent;
|
|
787
|
+
this.name = "PartialBatchError";
|
|
788
|
+
}
|
|
789
|
+
};
|
|
775
790
|
var AnalyticsTransport = class {
|
|
776
791
|
constructor(name, config) {
|
|
777
792
|
this.batch = [];
|
|
@@ -784,16 +799,25 @@ var AnalyticsTransport = class {
|
|
|
784
799
|
enableEventTracking: true,
|
|
785
800
|
...config
|
|
786
801
|
};
|
|
802
|
+
require_secret_config.protectSecrets(this, ["config"]);
|
|
787
803
|
this.level = config.level;
|
|
788
804
|
this.batchSize = this.config.batchSize || 50;
|
|
789
805
|
this.flushInterval = this.config.flushInterval || 1e4;
|
|
790
806
|
this.cap = new BufferCap(name, config.maxBufferSize, this.batchSize);
|
|
791
807
|
}
|
|
808
|
+
/** Secret strings to scrub from errors: everything secret-looking in the config. Override to add more. */
|
|
809
|
+
secretValues() {
|
|
810
|
+
return require_secret_config.collectSecrets(this.config);
|
|
811
|
+
}
|
|
792
812
|
async write(entry) {
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
813
|
+
try {
|
|
814
|
+
if (!this.isReady) await this.ensureReady();
|
|
815
|
+
if (this.shouldSkipEntry(entry)) return;
|
|
816
|
+
if (this.config.batchSize && this.config.batchSize > 1) this.addToBatch(entry);
|
|
817
|
+
else await this.sendEntry(entry);
|
|
818
|
+
} catch (error) {
|
|
819
|
+
throw require_secret_config.scrubError(error, this.secretValues());
|
|
820
|
+
}
|
|
797
821
|
}
|
|
798
822
|
addToBatch(entry) {
|
|
799
823
|
this.batch.push(entry);
|
|
@@ -831,8 +855,9 @@ var AnalyticsTransport = class {
|
|
|
831
855
|
try {
|
|
832
856
|
await this.sendBatch(entriesToSend);
|
|
833
857
|
} catch (error) {
|
|
858
|
+
require_secret_config.scrubError(error, this.secretValues());
|
|
834
859
|
require_internal_log.internalError(`Analytics transport ${this.name} flush failed`, error);
|
|
835
|
-
this.batch.unshift(...entriesToSend);
|
|
860
|
+
this.batch.unshift(...error instanceof PartialBatchError ? error.unsent : entriesToSend);
|
|
836
861
|
this.cap.enforce(this.batch);
|
|
837
862
|
return;
|
|
838
863
|
}
|
|
@@ -892,11 +917,72 @@ var AnalyticsTransport = class {
|
|
|
892
917
|
await this.ensureReady();
|
|
893
918
|
}
|
|
894
919
|
};
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
920
|
+
// src/transports/datadog.transport.ts
|
|
921
|
+
const gzipAsync = (0, node_util.promisify)(node_zlib.gzip);
|
|
922
|
+
const MAX_LOGS_PER_REQUEST = 1e3;
|
|
923
|
+
const MAX_LOGS_PAYLOAD_BYTES = 5e6;
|
|
924
|
+
const MAX_LOG_BYTES = 1e6;
|
|
925
|
+
const MAX_TRUNCATED_MESSAGE_CHARS = 15e4;
|
|
926
|
+
const TRUNCATED_LOG_KEYS = [
|
|
927
|
+
"ddsource",
|
|
928
|
+
"ddtags",
|
|
929
|
+
"hostname",
|
|
930
|
+
"service",
|
|
931
|
+
"status",
|
|
932
|
+
"timestamp",
|
|
933
|
+
"level",
|
|
934
|
+
"context",
|
|
935
|
+
"traceId",
|
|
936
|
+
"appName",
|
|
937
|
+
"environment",
|
|
938
|
+
"env",
|
|
939
|
+
"version",
|
|
940
|
+
"logger",
|
|
941
|
+
"dd.trace_id",
|
|
942
|
+
"dd.span_id"
|
|
943
|
+
];
|
|
944
|
+
const STATUS_MAP = {
|
|
945
|
+
fatal: "critical",
|
|
946
|
+
critical: "critical",
|
|
947
|
+
error: "error",
|
|
948
|
+
warn: "warn",
|
|
949
|
+
warning: "warn",
|
|
950
|
+
info: "info",
|
|
951
|
+
debug: "debug",
|
|
952
|
+
trace: "debug",
|
|
953
|
+
verbose: "debug"
|
|
954
|
+
};
|
|
955
|
+
const MAX_UINT64 = (1n << 64n) - 1n;
|
|
956
|
+
const DASHED_UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
957
|
+
const HEX = /^[0-9a-f]+$/i;
|
|
958
|
+
const DIGITS = /^\d+$/;
|
|
898
959
|
/**
|
|
899
|
-
*
|
|
960
|
+
* Datadog correlates on a decimal 64-bit id. Accepts:
|
|
961
|
+
* - a dashed UUID (logixia's default trace id): dashes stripped, then 32-hex;
|
|
962
|
+
* - 32 hex chars (W3C trace id) or 16 hex chars containing a-f: low 64 bits as decimal;
|
|
963
|
+
* - an all-digit string: already decimal (dd-trace's native format), passed through.
|
|
964
|
+
* An all-digit string is ambiguous when it is 16 or 32 long: 32 is read as hex (a
|
|
965
|
+
* decimal id has at most 20 digits), 16 is read as decimal.
|
|
966
|
+
* Anything else yields the raw string for trace ids (`passthrough`) and nothing for span ids.
|
|
967
|
+
*/
|
|
968
|
+
function toDatadogId(id, passthrough) {
|
|
969
|
+
if (typeof id !== "string" || id === "") return void 0;
|
|
970
|
+
const fallback = passthrough ? id : void 0;
|
|
971
|
+
const compact = DASHED_UUID.test(id) ? id.replaceAll("-", "") : id;
|
|
972
|
+
const isHexId = HEX.test(compact) && (compact.length === 32 || compact.length === 16);
|
|
973
|
+
if (DIGITS.test(compact) && compact.length !== 32) {
|
|
974
|
+
const value = BigInt(compact);
|
|
975
|
+
return value <= MAX_UINT64 ? value.toString() : fallback;
|
|
976
|
+
}
|
|
977
|
+
if (isHexId) return BigInt(`0x${compact.slice(-16)}`).toString();
|
|
978
|
+
return fallback;
|
|
979
|
+
}
|
|
980
|
+
/** Datadog tags: no commas or whitespace, lowercase, at most 200 chars. */
|
|
981
|
+
function tag(key, value) {
|
|
982
|
+
return `${key}:${value}`.replaceAll(/[\s,]+/g, "_").toLowerCase().slice(0, 200);
|
|
983
|
+
}
|
|
984
|
+
/**
|
|
985
|
+
* Sends log entries and metrics to Datadog via the Logs (v2) and Metrics HTTP APIs.
|
|
900
986
|
*
|
|
901
987
|
* The API key is transmitted via the `DD-API-KEY` request header — never in the URL.
|
|
902
988
|
*
|
|
@@ -911,6 +997,7 @@ var DataDogTransport = class extends AnalyticsTransport {
|
|
|
911
997
|
this.baseUrl = `https://api.${site}`;
|
|
912
998
|
this.logsUrl = `https://http-intake.logs.${site}`;
|
|
913
999
|
this.metricsUrl = `https://api.${site}`;
|
|
1000
|
+
require_secret_config.protectSecrets(this, ["datadogConfig"]);
|
|
914
1001
|
}
|
|
915
1002
|
async initialize() {
|
|
916
1003
|
try {
|
|
@@ -922,29 +1009,68 @@ var DataDogTransport = class extends AnalyticsTransport {
|
|
|
922
1009
|
}
|
|
923
1010
|
}
|
|
924
1011
|
async sendEntry(entry) {
|
|
925
|
-
|
|
926
|
-
if (this.datadogConfig.enableLogs !== false) promises.push(this.sendLog(entry));
|
|
927
|
-
if (this.datadogConfig.enableMetrics) promises.push(this.sendMetric(entry));
|
|
928
|
-
if (this.datadogConfig.enableTraces && entry.traceId) promises.push(this.sendTrace(entry));
|
|
929
|
-
await Promise.all(promises);
|
|
1012
|
+
await this.sendBatch([entry]);
|
|
930
1013
|
}
|
|
1014
|
+
/**
|
|
1015
|
+
* Logs go first, chunk by chunk; metrics follow once every log chunk is out.
|
|
1016
|
+
* A failure part-way throws PartialBatchError naming only the entries that were
|
|
1017
|
+
* not delivered, so a retry never re-posts a chunk Datadog already accepted.
|
|
1018
|
+
*/
|
|
931
1019
|
async sendBatch(entries) {
|
|
932
|
-
|
|
933
|
-
if (this.datadogConfig.
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
1020
|
+
if (this.datadogConfig.enableLogs !== false) await this.sendLogBatch(entries);
|
|
1021
|
+
if (this.datadogConfig.enableMetrics) try {
|
|
1022
|
+
await this.sendMetricBatch(entries);
|
|
1023
|
+
} catch (error) {
|
|
1024
|
+
if (this.datadogConfig.enableLogs === false) throw error;
|
|
1025
|
+
throw new PartialBatchError(error.message, [], { cause: error });
|
|
938
1026
|
}
|
|
939
|
-
await Promise.all(promises);
|
|
940
1027
|
}
|
|
941
1028
|
async cleanup() {}
|
|
942
|
-
async sendLog(entry) {
|
|
943
|
-
await this.sendLogBatch([entry]);
|
|
944
|
-
}
|
|
945
1029
|
async sendLogBatch(entries) {
|
|
946
|
-
const
|
|
947
|
-
|
|
1030
|
+
const items = entries.map((entry) => ({
|
|
1031
|
+
entry,
|
|
1032
|
+
json: this.serializeLog(entry)
|
|
1033
|
+
}));
|
|
1034
|
+
const chunks = this.chunkLogs(items);
|
|
1035
|
+
for (let i = 0; i < chunks.length; i += 1) {
|
|
1036
|
+
const chunk = chunks[i];
|
|
1037
|
+
try {
|
|
1038
|
+
await this.makeLogsRequest("/api/v2/logs", `[${chunk.map((item) => item.json).join(",")}]`);
|
|
1039
|
+
} catch (error) {
|
|
1040
|
+
if (i === 0) throw error;
|
|
1041
|
+
const unsent = chunks.slice(i).flatMap((c) => c.map((item) => item.entry));
|
|
1042
|
+
throw new PartialBatchError(error.message, unsent, { cause: error });
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
/** Splits into requests of at most 1000 entries and about 5MB of JSON. */
|
|
1047
|
+
chunkLogs(items) {
|
|
1048
|
+
const chunks = [];
|
|
1049
|
+
let current = [];
|
|
1050
|
+
let currentBytes = 2;
|
|
1051
|
+
for (const item of items) {
|
|
1052
|
+
const bytes = Buffer.byteLength(item.json) + 1;
|
|
1053
|
+
if (current.length > 0 && (current.length >= MAX_LOGS_PER_REQUEST || currentBytes + bytes > MAX_LOGS_PAYLOAD_BYTES)) {
|
|
1054
|
+
chunks.push(current);
|
|
1055
|
+
current = [];
|
|
1056
|
+
currentBytes = 2;
|
|
1057
|
+
}
|
|
1058
|
+
current.push(item);
|
|
1059
|
+
currentBytes += bytes;
|
|
1060
|
+
}
|
|
1061
|
+
if (current.length > 0) chunks.push(current);
|
|
1062
|
+
return chunks;
|
|
1063
|
+
}
|
|
1064
|
+
/** Serializes once. A log over 1MB keeps its identity and correlation fields but loses its attributes and most of its message. */
|
|
1065
|
+
serializeLog(entry) {
|
|
1066
|
+
const log = this.transformToDataDogLog(entry);
|
|
1067
|
+
const json = require_safe_stringify.stringifyForLog(log);
|
|
1068
|
+
if (Buffer.byteLength(json) <= MAX_LOG_BYTES) return json;
|
|
1069
|
+
const kept = {};
|
|
1070
|
+
for (const key of TRUNCATED_LOG_KEYS) if (log[key] !== void 0) kept[key] = log[key];
|
|
1071
|
+
kept["message"] = String(log["message"]).slice(0, MAX_TRUNCATED_MESSAGE_CHARS);
|
|
1072
|
+
kept["truncated"] = true;
|
|
1073
|
+
return require_safe_stringify.stringifyForLog(kept);
|
|
948
1074
|
}
|
|
949
1075
|
async sendMetric(entry) {
|
|
950
1076
|
await this.sendMetricBatch([entry]);
|
|
@@ -953,29 +1079,35 @@ var DataDogTransport = class extends AnalyticsTransport {
|
|
|
953
1079
|
const payload = { series: entries.map((entry) => this.transformToDataDogMetric(entry)) };
|
|
954
1080
|
await this.makeMetricsRequest("/api/v1/series", payload);
|
|
955
1081
|
}
|
|
956
|
-
async sendTrace(entry) {
|
|
957
|
-
await this.sendLog(entry);
|
|
958
|
-
}
|
|
959
|
-
async sendTraceBatch(entries) {
|
|
960
|
-
await this.sendLogBatch(entries);
|
|
961
|
-
}
|
|
962
1082
|
transformToDataDogLog(entry) {
|
|
1083
|
+
var _entry$data, _entry$data2;
|
|
1084
|
+
const transformed = this.transformEntry(entry);
|
|
1085
|
+
const service = this.datadogConfig.service || "logixia";
|
|
1086
|
+
const env = this.datadogConfig.env || "production";
|
|
1087
|
+
const version = this.datadogConfig.version;
|
|
1088
|
+
const tags = [
|
|
1089
|
+
tag("env", env),
|
|
1090
|
+
tag("service", service),
|
|
1091
|
+
...version ? [tag("version", version)] : []
|
|
1092
|
+
];
|
|
1093
|
+
const spanId = toDatadogId(((_entry$data = entry.data) === null || _entry$data === void 0 ? void 0 : _entry$data["spanId"]) ?? ((_entry$data2 = entry.data) === null || _entry$data2 === void 0 ? void 0 : _entry$data2["span_id"]), false);
|
|
1094
|
+
const traceId = toDatadogId(entry.traceId, true);
|
|
963
1095
|
return {
|
|
964
|
-
...
|
|
965
|
-
"
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
level: this.mapLogLevel(entry.level),
|
|
1096
|
+
...transformed,
|
|
1097
|
+
ddsource: "nodejs",
|
|
1098
|
+
ddtags: tags.join(","),
|
|
1099
|
+
hostname: this.getHostname(),
|
|
1100
|
+
service,
|
|
1101
|
+
status: this.mapLogLevel(entry.level),
|
|
971
1102
|
message: entry.message,
|
|
972
|
-
|
|
973
|
-
version
|
|
974
|
-
env: this.datadogConfig.env || "production",
|
|
1103
|
+
env,
|
|
1104
|
+
version,
|
|
975
1105
|
logger: {
|
|
976
1106
|
name: "logixia",
|
|
977
1107
|
thread_name: "main"
|
|
978
|
-
}
|
|
1108
|
+
},
|
|
1109
|
+
...traceId && { "dd.trace_id": traceId },
|
|
1110
|
+
...traceId && spanId && { "dd.span_id": spanId }
|
|
979
1111
|
};
|
|
980
1112
|
}
|
|
981
1113
|
reservedKeys() {
|
|
@@ -1001,58 +1133,29 @@ var DataDogTransport = class extends AnalyticsTransport {
|
|
|
1001
1133
|
type: "count",
|
|
1002
1134
|
host: this.getHostname(),
|
|
1003
1135
|
tags: [
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
...entry.context ? [
|
|
1008
|
-
...entry.appName ? [
|
|
1136
|
+
tag("level", entry.level),
|
|
1137
|
+
tag("service", this.datadogConfig.service || "logixia"),
|
|
1138
|
+
tag("env", this.datadogConfig.env || "production"),
|
|
1139
|
+
...entry.context ? [tag("context", entry.context)] : [],
|
|
1140
|
+
...entry.appName ? [tag("app", entry.appName)] : []
|
|
1009
1141
|
]
|
|
1010
1142
|
};
|
|
1011
1143
|
}
|
|
1012
|
-
transformToDataDogTrace(entry) {
|
|
1013
|
-
return {
|
|
1014
|
-
trace_id: entry.traceId,
|
|
1015
|
-
span_id: this.generateSpanId(),
|
|
1016
|
-
parent_id: null,
|
|
1017
|
-
name: "log.entry",
|
|
1018
|
-
service: this.datadogConfig.service || "logixia",
|
|
1019
|
-
resource: entry.message,
|
|
1020
|
-
type: "log",
|
|
1021
|
-
start: entry.timestamp.getTime() * 1e6,
|
|
1022
|
-
duration: 1e6,
|
|
1023
|
-
meta: {
|
|
1024
|
-
"log.level": entry.level,
|
|
1025
|
-
"log.message": entry.message,
|
|
1026
|
-
...entry.context && { "log.context": entry.context },
|
|
1027
|
-
...entry.data && Object.keys(entry.data).reduce((acc, key) => {
|
|
1028
|
-
acc[`log.${key}`] = String(entry.data[key]);
|
|
1029
|
-
return acc;
|
|
1030
|
-
}, {})
|
|
1031
|
-
},
|
|
1032
|
-
metrics: { _sampling_priority_v1: 1 }
|
|
1033
|
-
};
|
|
1034
|
-
}
|
|
1035
1144
|
mapLogLevel(level) {
|
|
1036
|
-
return
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
warning: "warn",
|
|
1040
|
-
info: "info",
|
|
1041
|
-
debug: "debug",
|
|
1042
|
-
trace: "trace",
|
|
1043
|
-
verbose: "debug"
|
|
1044
|
-
}[level.toLowerCase()] || "info";
|
|
1045
|
-
}
|
|
1046
|
-
async makeLogsRequest(endpoint, data) {
|
|
1145
|
+
return STATUS_MAP[level.toLowerCase()] || "info";
|
|
1146
|
+
}
|
|
1147
|
+
async makeLogsRequest(endpoint, json) {
|
|
1047
1148
|
const url = `${this.logsUrl}${endpoint}`;
|
|
1048
1149
|
try {
|
|
1150
|
+
const compress = this.datadogConfig.compress === true;
|
|
1049
1151
|
const response = await fetch(url, {
|
|
1050
1152
|
method: "POST",
|
|
1051
1153
|
headers: {
|
|
1052
1154
|
"Content-Type": "application/json",
|
|
1053
|
-
"DD-API-KEY": this.datadogConfig.apiKey
|
|
1155
|
+
"DD-API-KEY": this.datadogConfig.apiKey,
|
|
1156
|
+
...compress && { "Content-Encoding": "gzip" }
|
|
1054
1157
|
},
|
|
1055
|
-
body:
|
|
1158
|
+
body: compress ? await gzipAsync(json) : json
|
|
1056
1159
|
});
|
|
1057
1160
|
if (!response.ok) throw new Error(`DataDog Logs API error: ${response.status} ${response.statusText}`);
|
|
1058
1161
|
} catch (error) {
|
|
@@ -1075,9 +1178,6 @@ var DataDogTransport = class extends AnalyticsTransport {
|
|
|
1075
1178
|
throw new Error(`Failed to send metrics to DataDog: ${error.message}`, { cause: error });
|
|
1076
1179
|
}
|
|
1077
1180
|
}
|
|
1078
|
-
generateSpanId() {
|
|
1079
|
-
return Math.floor(Math.random() * 0xffffffffffff).toString(16);
|
|
1080
|
-
}
|
|
1081
1181
|
getHostname() {
|
|
1082
1182
|
try {
|
|
1083
1183
|
return require("node:os").hostname();
|
|
@@ -1124,9 +1224,7 @@ var DataDogTransport = class extends AnalyticsTransport {
|
|
|
1124
1224
|
}
|
|
1125
1225
|
}
|
|
1126
1226
|
};
|
|
1127
|
-
|
|
1128
|
-
//#endregion
|
|
1129
|
-
//#region src/transports/file.transport.ts
|
|
1227
|
+
// src/transports/file.transport.ts
|
|
1130
1228
|
const appendFile = (0, node_util.promisify)(node_fs.appendFile);
|
|
1131
1229
|
const rename = (0, node_util.promisify)(node_fs.rename);
|
|
1132
1230
|
const unlink = (0, node_util.promisify)(node_fs.unlink);
|
|
@@ -1389,7 +1487,6 @@ var FileTransport = class {
|
|
|
1389
1487
|
csvField(entry.traceId),
|
|
1390
1488
|
csvField(require_safe_stringify.stringifyForLog(entry.data || {}))
|
|
1391
1489
|
].join(",");
|
|
1392
|
-
case "text":
|
|
1393
1490
|
default: return `${entry.timestamp.toISOString()} [${stripControlChars(require_coerce_utils.safeToString(entry.level)).toUpperCase()}] ${stripControlChars(require_coerce_utils.safeToString(entry.message))}${entry.data ? " " + require_safe_stringify.stringifyForLog(entry.data) : ""}`;
|
|
1394
1491
|
}
|
|
1395
1492
|
}
|
|
@@ -1415,22 +1512,22 @@ var FileTransport = class {
|
|
|
1415
1512
|
await this.append(content);
|
|
1416
1513
|
return;
|
|
1417
1514
|
}
|
|
1418
|
-
let chunk
|
|
1515
|
+
let chunk = "";
|
|
1419
1516
|
let chunkBytes = 0;
|
|
1420
1517
|
for (const entry of entries) {
|
|
1421
1518
|
const line = this.formatEntry(entry) + "\n";
|
|
1422
1519
|
const lineBytes = Buffer.byteLength(line);
|
|
1423
1520
|
const used = this.bytesWritten + chunkBytes;
|
|
1424
1521
|
if (used > 0 && used + lineBytes > this.maxBytes) {
|
|
1425
|
-
if (chunk
|
|
1426
|
-
chunk
|
|
1522
|
+
if (chunk) await this.append(chunk, chunkBytes);
|
|
1523
|
+
chunk = "";
|
|
1427
1524
|
chunkBytes = 0;
|
|
1428
1525
|
await this.rotateFile();
|
|
1429
1526
|
}
|
|
1430
|
-
chunk
|
|
1527
|
+
chunk += line;
|
|
1431
1528
|
chunkBytes += lineBytes;
|
|
1432
1529
|
}
|
|
1433
|
-
if (chunk
|
|
1530
|
+
if (chunk) await this.append(chunk, chunkBytes);
|
|
1434
1531
|
}
|
|
1435
1532
|
async append(content, bytes = Buffer.byteLength(content)) {
|
|
1436
1533
|
await appendFile(this.currentFilePath, content, { mode: this.fileMode });
|
|
@@ -1459,7 +1556,7 @@ var FileTransport = class {
|
|
|
1459
1556
|
}
|
|
1460
1557
|
parseInterval(interval) {
|
|
1461
1558
|
const match = /^(\d{1,6})([hdwmy])$/i.exec(interval.trim());
|
|
1462
|
-
if (!match) return
|
|
1559
|
+
if (!match) return 864e5;
|
|
1463
1560
|
const value = Number.parseInt(match[1] || "1", 10);
|
|
1464
1561
|
switch ((match[2] || "h").toLowerCase()) {
|
|
1465
1562
|
case "h": return value * 60 * 60 * 1e3;
|
|
@@ -1574,9 +1671,7 @@ var FileTransport = class {
|
|
|
1574
1671
|
this.reportDropped(0);
|
|
1575
1672
|
}
|
|
1576
1673
|
};
|
|
1577
|
-
|
|
1578
|
-
//#endregion
|
|
1579
|
-
//#region src/transports/google-analytics.transport.ts
|
|
1674
|
+
// src/transports/google-analytics.transport.ts
|
|
1580
1675
|
/**
|
|
1581
1676
|
* Sends log entries as Google Analytics 4 Measurement Protocol events.
|
|
1582
1677
|
*
|
|
@@ -1591,6 +1686,7 @@ var GoogleAnalyticsTransport = class extends AnalyticsTransport {
|
|
|
1591
1686
|
this.baseUrl = "https://www.google-analytics.com/mp/collect";
|
|
1592
1687
|
this.debugUrl = "https://www.google-analytics.com/debug/mp/collect";
|
|
1593
1688
|
this.gaConfig = config;
|
|
1689
|
+
require_secret_config.protectSecrets(this, ["gaConfig"]);
|
|
1594
1690
|
}
|
|
1595
1691
|
async initialize() {
|
|
1596
1692
|
try {
|
|
@@ -1678,10 +1774,10 @@ var GoogleAnalyticsTransport = class extends AnalyticsTransport {
|
|
|
1678
1774
|
}
|
|
1679
1775
|
async sendEvents(events) {
|
|
1680
1776
|
const chunks = this.chunkArray(events, 25);
|
|
1681
|
-
for (const chunk
|
|
1777
|
+
for (const chunk of chunks) {
|
|
1682
1778
|
const payload = {
|
|
1683
1779
|
client_id: this.gaConfig.clientId || this.generateClientId(),
|
|
1684
|
-
events: chunk
|
|
1780
|
+
events: chunk
|
|
1685
1781
|
};
|
|
1686
1782
|
await this.makeRequest(payload);
|
|
1687
1783
|
}
|
|
@@ -1802,9 +1898,7 @@ var GoogleAnalyticsTransport = class extends AnalyticsTransport {
|
|
|
1802
1898
|
await this.sendEvent(event);
|
|
1803
1899
|
}
|
|
1804
1900
|
};
|
|
1805
|
-
|
|
1806
|
-
//#endregion
|
|
1807
|
-
//#region src/transports/mixpanel.transport.ts
|
|
1901
|
+
// src/transports/mixpanel.transport.ts
|
|
1808
1902
|
/**
|
|
1809
1903
|
* Sends log entries as Mixpanel events via the Track and Engage HTTP APIs.
|
|
1810
1904
|
*
|
|
@@ -1816,6 +1910,7 @@ var MixpanelTransport = class extends AnalyticsTransport {
|
|
|
1816
1910
|
super("mixpanel", config);
|
|
1817
1911
|
this.baseUrl = "https://api.mixpanel.com";
|
|
1818
1912
|
this.mixpanelConfig = config;
|
|
1913
|
+
require_secret_config.protectSecrets(this, ["mixpanelConfig"]);
|
|
1819
1914
|
}
|
|
1820
1915
|
async initialize() {
|
|
1821
1916
|
try {
|
|
@@ -1941,9 +2036,7 @@ var MixpanelTransport = class extends AnalyticsTransport {
|
|
|
1941
2036
|
await this.makeRequest("/track", [payload]);
|
|
1942
2037
|
}
|
|
1943
2038
|
};
|
|
1944
|
-
|
|
1945
|
-
//#endregion
|
|
1946
|
-
//#region src/version.ts
|
|
2039
|
+
// src/version.ts
|
|
1947
2040
|
/**
|
|
1948
2041
|
* The published version of this package.
|
|
1949
2042
|
*
|
|
@@ -1952,9 +2045,7 @@ var MixpanelTransport = class extends AnalyticsTransport {
|
|
|
1952
2045
|
* free of a JSON import that bundlers and consumers would have to resolve.
|
|
1953
2046
|
*/
|
|
1954
2047
|
const LOGIXIA_VERSION = "1.12.0";
|
|
1955
|
-
|
|
1956
|
-
//#endregion
|
|
1957
|
-
//#region src/transports/segment.transport.ts
|
|
2048
|
+
// src/transports/segment.transport.ts
|
|
1958
2049
|
/**
|
|
1959
2050
|
* Sends log entries as Segment track/identify events via the HTTP Tracking API.
|
|
1960
2051
|
*
|
|
@@ -1972,6 +2063,10 @@ var SegmentTransport = class extends AnalyticsTransport {
|
|
|
1972
2063
|
...config
|
|
1973
2064
|
};
|
|
1974
2065
|
this.baseUrl = config.dataPlaneUrl || "https://api.segment.io";
|
|
2066
|
+
require_secret_config.protectSecrets(this, ["segmentConfig", "baseUrl"]);
|
|
2067
|
+
}
|
|
2068
|
+
secretValues() {
|
|
2069
|
+
return [...super.secretValues(), Buffer.from(`${this.segmentConfig.writeKey}:`).toString("base64")];
|
|
1975
2070
|
}
|
|
1976
2071
|
async initialize() {
|
|
1977
2072
|
try {
|
|
@@ -2039,8 +2134,8 @@ var SegmentTransport = class extends AnalyticsTransport {
|
|
|
2039
2134
|
}
|
|
2040
2135
|
async batchTrack(events) {
|
|
2041
2136
|
const chunks = this.chunkArray(events, this.segmentConfig.maxBatchSize || 100);
|
|
2042
|
-
for (const chunk
|
|
2043
|
-
const payload = { batch: chunk
|
|
2137
|
+
for (const chunk of chunks) {
|
|
2138
|
+
const payload = { batch: chunk };
|
|
2044
2139
|
await this.makeRequest("/v1/batch", payload);
|
|
2045
2140
|
}
|
|
2046
2141
|
}
|
|
@@ -2217,9 +2312,7 @@ var SegmentTransport = class extends AnalyticsTransport {
|
|
|
2217
2312
|
await this.makeRequest("/v1/track", payload);
|
|
2218
2313
|
}
|
|
2219
2314
|
};
|
|
2220
|
-
|
|
2221
|
-
//#endregion
|
|
2222
|
-
//#region src/transports/transport.manager.ts
|
|
2315
|
+
// src/transports/transport.manager.ts
|
|
2223
2316
|
function _sleep(ms) {
|
|
2224
2317
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
2225
2318
|
}
|
|
@@ -2414,7 +2507,6 @@ var TransportManager = class extends node_events.EventEmitter {
|
|
|
2414
2507
|
case "linear":
|
|
2415
2508
|
wait = baseDelay * (attempt + 1);
|
|
2416
2509
|
break;
|
|
2417
|
-
case "exponential":
|
|
2418
2510
|
default: wait = Math.min(baseDelay * Math.pow(2, attempt), maxDelay);
|
|
2419
2511
|
}
|
|
2420
2512
|
this.emit("transport:retry", transport.name, attempt + 1, maxRetries, wait);
|
|
@@ -2568,66 +2660,71 @@ var TransportManager = class extends node_events.EventEmitter {
|
|
|
2568
2660
|
require_internal_log.internalLog("Transport level preferences cleared");
|
|
2569
2661
|
}
|
|
2570
2662
|
};
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
return AnalyticsTransport;
|
|
2577
|
-
}
|
|
2663
|
+
Object.defineProperty(exports, "AnalyticsTransport", {
|
|
2664
|
+
enumerable: true,
|
|
2665
|
+
get: function() {
|
|
2666
|
+
return AnalyticsTransport;
|
|
2667
|
+
}
|
|
2578
2668
|
});
|
|
2579
|
-
Object.defineProperty(exports,
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2669
|
+
Object.defineProperty(exports, "BufferCap", {
|
|
2670
|
+
enumerable: true,
|
|
2671
|
+
get: function() {
|
|
2672
|
+
return BufferCap;
|
|
2673
|
+
}
|
|
2674
|
+
});
|
|
2675
|
+
Object.defineProperty(exports, "ConsoleTransport", {
|
|
2676
|
+
enumerable: true,
|
|
2677
|
+
get: function() {
|
|
2678
|
+
return ConsoleTransport;
|
|
2679
|
+
}
|
|
2584
2680
|
});
|
|
2585
|
-
Object.defineProperty(exports,
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2681
|
+
Object.defineProperty(exports, "DataDogTransport", {
|
|
2682
|
+
enumerable: true,
|
|
2683
|
+
get: function() {
|
|
2684
|
+
return DataDogTransport;
|
|
2685
|
+
}
|
|
2590
2686
|
});
|
|
2591
|
-
Object.defineProperty(exports,
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2687
|
+
Object.defineProperty(exports, "DatabaseTransport", {
|
|
2688
|
+
enumerable: true,
|
|
2689
|
+
get: function() {
|
|
2690
|
+
return DatabaseTransport;
|
|
2691
|
+
}
|
|
2596
2692
|
});
|
|
2597
|
-
Object.defineProperty(exports,
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2693
|
+
Object.defineProperty(exports, "FileTransport", {
|
|
2694
|
+
enumerable: true,
|
|
2695
|
+
get: function() {
|
|
2696
|
+
return FileTransport;
|
|
2697
|
+
}
|
|
2602
2698
|
});
|
|
2603
|
-
Object.defineProperty(exports,
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2699
|
+
Object.defineProperty(exports, "GoogleAnalyticsTransport", {
|
|
2700
|
+
enumerable: true,
|
|
2701
|
+
get: function() {
|
|
2702
|
+
return GoogleAnalyticsTransport;
|
|
2703
|
+
}
|
|
2608
2704
|
});
|
|
2609
|
-
Object.defineProperty(exports,
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2705
|
+
Object.defineProperty(exports, "MixpanelTransport", {
|
|
2706
|
+
enumerable: true,
|
|
2707
|
+
get: function() {
|
|
2708
|
+
return MixpanelTransport;
|
|
2709
|
+
}
|
|
2614
2710
|
});
|
|
2615
|
-
Object.defineProperty(exports,
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2711
|
+
Object.defineProperty(exports, "SegmentTransport", {
|
|
2712
|
+
enumerable: true,
|
|
2713
|
+
get: function() {
|
|
2714
|
+
return SegmentTransport;
|
|
2715
|
+
}
|
|
2620
2716
|
});
|
|
2621
|
-
Object.defineProperty(exports,
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2717
|
+
Object.defineProperty(exports, "TransportManager", {
|
|
2718
|
+
enumerable: true,
|
|
2719
|
+
get: function() {
|
|
2720
|
+
return TransportManager;
|
|
2721
|
+
}
|
|
2626
2722
|
});
|
|
2627
|
-
Object.defineProperty(exports,
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2723
|
+
Object.defineProperty(exports, "stripControlChars", {
|
|
2724
|
+
enumerable: true,
|
|
2725
|
+
get: function() {
|
|
2726
|
+
return stripControlChars;
|
|
2727
|
+
}
|
|
2632
2728
|
});
|
|
2633
|
-
|
|
2729
|
+
|
|
2730
|
+
//# sourceMappingURL=transport.manager-DkcEOlqV.js.map
|