@nexload-sdk/logger 4.1.0 → 5.0.0
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 +240 -34
- package/dist/config.d.ts +62 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/context.browser.d.ts +9 -0
- package/dist/context.browser.d.ts.map +1 -0
- package/dist/context.node.d.ts +6 -0
- package/dist/context.node.d.ts.map +1 -0
- package/dist/index.browser.d.ts +3 -0
- package/dist/index.browser.d.ts.map +1 -0
- package/dist/index.browser.mjs +1383 -0
- package/dist/index.browser.mjs.map +7 -0
- package/dist/index.cjs +236 -412
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +8 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +227 -409
- package/dist/index.mjs.map +4 -4
- package/dist/levels.d.ts +3 -0
- package/dist/levels.d.ts.map +1 -0
- package/dist/pretty.d.ts +4 -0
- package/dist/pretty.d.ts.map +1 -0
- package/dist/proxy.d.ts +3 -0
- package/dist/proxy.d.ts.map +1 -0
- package/dist/redact.d.ts +2 -0
- package/dist/redact.d.ts.map +1 -0
- package/dist/serialize-error.d.ts +2 -0
- package/dist/serialize-error.d.ts.map +1 -0
- package/dist/testing.cjs +206 -0
- package/dist/testing.cjs.map +7 -0
- package/dist/testing.d.ts +7 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.mjs +168 -0
- package/dist/testing.mjs.map +7 -0
- package/dist/trace.d.ts +6 -0
- package/dist/trace.d.ts.map +1 -0
- package/dist/types.d.ts +39 -16
- package/dist/types.d.ts.map +1 -1
- package/package.json +17 -11
- package/dist/log-test.cjs +0 -102
- package/dist/log-test.cjs.map +0 -7
- package/dist/log-test.d.ts +0 -3
- package/dist/log-test.d.ts.map +0 -1
- package/dist/log-test.mjs +0 -78
- package/dist/log-test.mjs.map +0 -7
- package/dist/logger.d.ts +0 -20
- package/dist/logger.d.ts.map +0 -1
- package/dist/renderers/browser-pretty.d.ts +0 -12
- package/dist/renderers/browser-pretty.d.ts.map +0 -1
- package/dist/renderers/browser-pure.d.ts +0 -3
- package/dist/renderers/browser-pure.d.ts.map +0 -1
- package/dist/renderers/node-pretty.d.ts +0 -12
- package/dist/renderers/node-pretty.d.ts.map +0 -1
- package/dist/renderers/node-pure-json.d.ts +0 -3
- package/dist/renderers/node-pure-json.d.ts.map +0 -1
- package/dist/utils/create-global.d.ts +0 -3
- package/dist/utils/create-global.d.ts.map +0 -1
- package/dist/utils/json-humanize.d.ts +0 -2
- package/dist/utils/json-humanize.d.ts.map +0 -1
|
@@ -0,0 +1,1383 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __esm = (fn, res) => function __init() {
|
|
8
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
9
|
+
};
|
|
10
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
11
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
|
|
30
|
+
// src/context.browser.ts
|
|
31
|
+
function withLogContext(_bindings, fn) {
|
|
32
|
+
return fn();
|
|
33
|
+
}
|
|
34
|
+
function getLogContext() {
|
|
35
|
+
return {};
|
|
36
|
+
}
|
|
37
|
+
function newTraceId() {
|
|
38
|
+
return globalThis.crypto.randomUUID();
|
|
39
|
+
}
|
|
40
|
+
var isBrowser, runtime, browserProcess;
|
|
41
|
+
var init_context_browser = __esm({
|
|
42
|
+
"src/context.browser.ts"() {
|
|
43
|
+
"use strict";
|
|
44
|
+
isBrowser = true;
|
|
45
|
+
runtime = globalThis;
|
|
46
|
+
browserProcess = runtime.process ?? { env: {} };
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// ../../node_modules/.pnpm/quick-format-unescaped@4.0.4/node_modules/quick-format-unescaped/index.js
|
|
51
|
+
var require_quick_format_unescaped = __commonJS({
|
|
52
|
+
"../../node_modules/.pnpm/quick-format-unescaped@4.0.4/node_modules/quick-format-unescaped/index.js"(exports, module) {
|
|
53
|
+
"use strict";
|
|
54
|
+
init_context_browser();
|
|
55
|
+
function tryStringify(o) {
|
|
56
|
+
try {
|
|
57
|
+
return JSON.stringify(o);
|
|
58
|
+
} catch (e) {
|
|
59
|
+
return '"[Circular]"';
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
module.exports = format;
|
|
63
|
+
function format(f, args, opts) {
|
|
64
|
+
var ss = opts && opts.stringify || tryStringify;
|
|
65
|
+
var offset = 1;
|
|
66
|
+
if (typeof f === "object" && f !== null) {
|
|
67
|
+
var len = args.length + offset;
|
|
68
|
+
if (len === 1) return f;
|
|
69
|
+
var objects = new Array(len);
|
|
70
|
+
objects[0] = ss(f);
|
|
71
|
+
for (var index = 1; index < len; index++) {
|
|
72
|
+
objects[index] = ss(args[index]);
|
|
73
|
+
}
|
|
74
|
+
return objects.join(" ");
|
|
75
|
+
}
|
|
76
|
+
if (typeof f !== "string") {
|
|
77
|
+
return f;
|
|
78
|
+
}
|
|
79
|
+
var argLen = args.length;
|
|
80
|
+
if (argLen === 0) return f;
|
|
81
|
+
var str = "";
|
|
82
|
+
var a = 1 - offset;
|
|
83
|
+
var lastPos = -1;
|
|
84
|
+
var flen = f && f.length || 0;
|
|
85
|
+
for (var i = 0; i < flen; ) {
|
|
86
|
+
if (f.charCodeAt(i) === 37 && i + 1 < flen) {
|
|
87
|
+
lastPos = lastPos > -1 ? lastPos : 0;
|
|
88
|
+
switch (f.charCodeAt(i + 1)) {
|
|
89
|
+
case 100:
|
|
90
|
+
// 'd'
|
|
91
|
+
case 102:
|
|
92
|
+
if (a >= argLen)
|
|
93
|
+
break;
|
|
94
|
+
if (args[a] == null) break;
|
|
95
|
+
if (lastPos < i)
|
|
96
|
+
str += f.slice(lastPos, i);
|
|
97
|
+
str += Number(args[a]);
|
|
98
|
+
lastPos = i + 2;
|
|
99
|
+
i++;
|
|
100
|
+
break;
|
|
101
|
+
case 105:
|
|
102
|
+
if (a >= argLen)
|
|
103
|
+
break;
|
|
104
|
+
if (args[a] == null) break;
|
|
105
|
+
if (lastPos < i)
|
|
106
|
+
str += f.slice(lastPos, i);
|
|
107
|
+
str += Math.floor(Number(args[a]));
|
|
108
|
+
lastPos = i + 2;
|
|
109
|
+
i++;
|
|
110
|
+
break;
|
|
111
|
+
case 79:
|
|
112
|
+
// 'O'
|
|
113
|
+
case 111:
|
|
114
|
+
// 'o'
|
|
115
|
+
case 106:
|
|
116
|
+
if (a >= argLen)
|
|
117
|
+
break;
|
|
118
|
+
if (args[a] === void 0) break;
|
|
119
|
+
if (lastPos < i)
|
|
120
|
+
str += f.slice(lastPos, i);
|
|
121
|
+
var type = typeof args[a];
|
|
122
|
+
if (type === "string") {
|
|
123
|
+
str += "'" + args[a] + "'";
|
|
124
|
+
lastPos = i + 2;
|
|
125
|
+
i++;
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
if (type === "function") {
|
|
129
|
+
str += args[a].name || "<anonymous>";
|
|
130
|
+
lastPos = i + 2;
|
|
131
|
+
i++;
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
str += ss(args[a]);
|
|
135
|
+
lastPos = i + 2;
|
|
136
|
+
i++;
|
|
137
|
+
break;
|
|
138
|
+
case 115:
|
|
139
|
+
if (a >= argLen)
|
|
140
|
+
break;
|
|
141
|
+
if (lastPos < i)
|
|
142
|
+
str += f.slice(lastPos, i);
|
|
143
|
+
str += String(args[a]);
|
|
144
|
+
lastPos = i + 2;
|
|
145
|
+
i++;
|
|
146
|
+
break;
|
|
147
|
+
case 37:
|
|
148
|
+
if (lastPos < i)
|
|
149
|
+
str += f.slice(lastPos, i);
|
|
150
|
+
str += "%";
|
|
151
|
+
lastPos = i + 2;
|
|
152
|
+
i++;
|
|
153
|
+
a--;
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
++a;
|
|
157
|
+
}
|
|
158
|
+
++i;
|
|
159
|
+
}
|
|
160
|
+
if (lastPos === -1)
|
|
161
|
+
return f;
|
|
162
|
+
else if (lastPos < flen) {
|
|
163
|
+
str += f.slice(lastPos);
|
|
164
|
+
}
|
|
165
|
+
return str;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
// ../../node_modules/.pnpm/@pinojs+redact@0.4.0/node_modules/@pinojs/redact/index.js
|
|
171
|
+
var require_redact = __commonJS({
|
|
172
|
+
"../../node_modules/.pnpm/@pinojs+redact@0.4.0/node_modules/@pinojs/redact/index.js"(exports, module) {
|
|
173
|
+
"use strict";
|
|
174
|
+
init_context_browser();
|
|
175
|
+
function deepClone(obj) {
|
|
176
|
+
if (obj === null || typeof obj !== "object") {
|
|
177
|
+
return obj;
|
|
178
|
+
}
|
|
179
|
+
if (obj instanceof Date) {
|
|
180
|
+
return new Date(obj.getTime());
|
|
181
|
+
}
|
|
182
|
+
if (obj instanceof Array) {
|
|
183
|
+
const cloned = [];
|
|
184
|
+
for (let i = 0; i < obj.length; i++) {
|
|
185
|
+
cloned[i] = deepClone(obj[i]);
|
|
186
|
+
}
|
|
187
|
+
return cloned;
|
|
188
|
+
}
|
|
189
|
+
if (typeof obj === "object") {
|
|
190
|
+
const cloned = Object.create(Object.getPrototypeOf(obj));
|
|
191
|
+
for (const key in obj) {
|
|
192
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
193
|
+
cloned[key] = deepClone(obj[key]);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return cloned;
|
|
197
|
+
}
|
|
198
|
+
return obj;
|
|
199
|
+
}
|
|
200
|
+
function parsePath(path) {
|
|
201
|
+
const parts = [];
|
|
202
|
+
let current = "";
|
|
203
|
+
let inBrackets = false;
|
|
204
|
+
let inQuotes = false;
|
|
205
|
+
let quoteChar = "";
|
|
206
|
+
for (let i = 0; i < path.length; i++) {
|
|
207
|
+
const char = path[i];
|
|
208
|
+
if (!inBrackets && char === ".") {
|
|
209
|
+
if (current) {
|
|
210
|
+
parts.push(current);
|
|
211
|
+
current = "";
|
|
212
|
+
}
|
|
213
|
+
} else if (char === "[") {
|
|
214
|
+
if (current) {
|
|
215
|
+
parts.push(current);
|
|
216
|
+
current = "";
|
|
217
|
+
}
|
|
218
|
+
inBrackets = true;
|
|
219
|
+
} else if (char === "]" && inBrackets) {
|
|
220
|
+
parts.push(current);
|
|
221
|
+
current = "";
|
|
222
|
+
inBrackets = false;
|
|
223
|
+
inQuotes = false;
|
|
224
|
+
} else if ((char === '"' || char === "'") && inBrackets) {
|
|
225
|
+
if (!inQuotes) {
|
|
226
|
+
inQuotes = true;
|
|
227
|
+
quoteChar = char;
|
|
228
|
+
} else if (char === quoteChar) {
|
|
229
|
+
inQuotes = false;
|
|
230
|
+
quoteChar = "";
|
|
231
|
+
} else {
|
|
232
|
+
current += char;
|
|
233
|
+
}
|
|
234
|
+
} else {
|
|
235
|
+
current += char;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
if (current) {
|
|
239
|
+
parts.push(current);
|
|
240
|
+
}
|
|
241
|
+
return parts;
|
|
242
|
+
}
|
|
243
|
+
function setValue(obj, parts, value) {
|
|
244
|
+
let current = obj;
|
|
245
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
246
|
+
const key = parts[i];
|
|
247
|
+
if (typeof current !== "object" || current === null || !(key in current)) {
|
|
248
|
+
return false;
|
|
249
|
+
}
|
|
250
|
+
if (typeof current[key] !== "object" || current[key] === null) {
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
current = current[key];
|
|
254
|
+
}
|
|
255
|
+
const lastKey = parts[parts.length - 1];
|
|
256
|
+
if (lastKey === "*") {
|
|
257
|
+
if (Array.isArray(current)) {
|
|
258
|
+
for (let i = 0; i < current.length; i++) {
|
|
259
|
+
current[i] = value;
|
|
260
|
+
}
|
|
261
|
+
} else if (typeof current === "object" && current !== null) {
|
|
262
|
+
for (const key in current) {
|
|
263
|
+
if (Object.prototype.hasOwnProperty.call(current, key)) {
|
|
264
|
+
current[key] = value;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
} else {
|
|
269
|
+
if (typeof current === "object" && current !== null && lastKey in current && Object.prototype.hasOwnProperty.call(current, lastKey)) {
|
|
270
|
+
current[lastKey] = value;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
return true;
|
|
274
|
+
}
|
|
275
|
+
function removeKey(obj, parts) {
|
|
276
|
+
let current = obj;
|
|
277
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
278
|
+
const key = parts[i];
|
|
279
|
+
if (typeof current !== "object" || current === null || !(key in current)) {
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
if (typeof current[key] !== "object" || current[key] === null) {
|
|
283
|
+
return false;
|
|
284
|
+
}
|
|
285
|
+
current = current[key];
|
|
286
|
+
}
|
|
287
|
+
const lastKey = parts[parts.length - 1];
|
|
288
|
+
if (lastKey === "*") {
|
|
289
|
+
if (Array.isArray(current)) {
|
|
290
|
+
for (let i = 0; i < current.length; i++) {
|
|
291
|
+
current[i] = void 0;
|
|
292
|
+
}
|
|
293
|
+
} else if (typeof current === "object" && current !== null) {
|
|
294
|
+
for (const key in current) {
|
|
295
|
+
if (Object.prototype.hasOwnProperty.call(current, key)) {
|
|
296
|
+
delete current[key];
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
} else {
|
|
301
|
+
if (typeof current === "object" && current !== null && lastKey in current && Object.prototype.hasOwnProperty.call(current, lastKey)) {
|
|
302
|
+
delete current[lastKey];
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
return true;
|
|
306
|
+
}
|
|
307
|
+
var PATH_NOT_FOUND = /* @__PURE__ */ Symbol("PATH_NOT_FOUND");
|
|
308
|
+
function getValueIfExists(obj, parts) {
|
|
309
|
+
let current = obj;
|
|
310
|
+
for (const part of parts) {
|
|
311
|
+
if (current === null || current === void 0) {
|
|
312
|
+
return PATH_NOT_FOUND;
|
|
313
|
+
}
|
|
314
|
+
if (typeof current !== "object" || current === null) {
|
|
315
|
+
return PATH_NOT_FOUND;
|
|
316
|
+
}
|
|
317
|
+
if (!(part in current)) {
|
|
318
|
+
return PATH_NOT_FOUND;
|
|
319
|
+
}
|
|
320
|
+
current = current[part];
|
|
321
|
+
}
|
|
322
|
+
return current;
|
|
323
|
+
}
|
|
324
|
+
function getValue(obj, parts) {
|
|
325
|
+
let current = obj;
|
|
326
|
+
for (const part of parts) {
|
|
327
|
+
if (current === null || current === void 0) {
|
|
328
|
+
return void 0;
|
|
329
|
+
}
|
|
330
|
+
if (typeof current !== "object" || current === null) {
|
|
331
|
+
return void 0;
|
|
332
|
+
}
|
|
333
|
+
current = current[part];
|
|
334
|
+
}
|
|
335
|
+
return current;
|
|
336
|
+
}
|
|
337
|
+
function redactPaths(obj, paths, censor, remove = false) {
|
|
338
|
+
for (const path of paths) {
|
|
339
|
+
const parts = parsePath(path);
|
|
340
|
+
if (parts.includes("*")) {
|
|
341
|
+
redactWildcardPath(obj, parts, censor, path, remove);
|
|
342
|
+
} else {
|
|
343
|
+
if (remove) {
|
|
344
|
+
removeKey(obj, parts);
|
|
345
|
+
} else {
|
|
346
|
+
const value = getValueIfExists(obj, parts);
|
|
347
|
+
if (value === PATH_NOT_FOUND) {
|
|
348
|
+
continue;
|
|
349
|
+
}
|
|
350
|
+
const actualCensor = typeof censor === "function" ? censor(value, parts) : censor;
|
|
351
|
+
setValue(obj, parts, actualCensor);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
function redactWildcardPath(obj, parts, censor, originalPath, remove = false) {
|
|
357
|
+
const wildcardIndex = parts.indexOf("*");
|
|
358
|
+
if (wildcardIndex === parts.length - 1) {
|
|
359
|
+
const parentParts = parts.slice(0, -1);
|
|
360
|
+
let current = obj;
|
|
361
|
+
for (const part of parentParts) {
|
|
362
|
+
if (current === null || current === void 0) return;
|
|
363
|
+
if (typeof current !== "object" || current === null) return;
|
|
364
|
+
current = current[part];
|
|
365
|
+
}
|
|
366
|
+
if (Array.isArray(current)) {
|
|
367
|
+
if (remove) {
|
|
368
|
+
for (let i = 0; i < current.length; i++) {
|
|
369
|
+
current[i] = void 0;
|
|
370
|
+
}
|
|
371
|
+
} else {
|
|
372
|
+
for (let i = 0; i < current.length; i++) {
|
|
373
|
+
const indexPath = [...parentParts, i.toString()];
|
|
374
|
+
const actualCensor = typeof censor === "function" ? censor(current[i], indexPath) : censor;
|
|
375
|
+
current[i] = actualCensor;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
} else if (typeof current === "object" && current !== null) {
|
|
379
|
+
if (remove) {
|
|
380
|
+
const keysToDelete = [];
|
|
381
|
+
for (const key in current) {
|
|
382
|
+
if (Object.prototype.hasOwnProperty.call(current, key)) {
|
|
383
|
+
keysToDelete.push(key);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
for (const key of keysToDelete) {
|
|
387
|
+
delete current[key];
|
|
388
|
+
}
|
|
389
|
+
} else {
|
|
390
|
+
for (const key in current) {
|
|
391
|
+
const keyPath = [...parentParts, key];
|
|
392
|
+
const actualCensor = typeof censor === "function" ? censor(current[key], keyPath) : censor;
|
|
393
|
+
current[key] = actualCensor;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
} else {
|
|
398
|
+
redactIntermediateWildcard(obj, parts, censor, wildcardIndex, originalPath, remove);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
function redactIntermediateWildcard(obj, parts, censor, wildcardIndex, originalPath, remove = false) {
|
|
402
|
+
const beforeWildcard = parts.slice(0, wildcardIndex);
|
|
403
|
+
const afterWildcard = parts.slice(wildcardIndex + 1);
|
|
404
|
+
const pathArray = [];
|
|
405
|
+
function traverse(current, pathLength) {
|
|
406
|
+
if (pathLength === beforeWildcard.length) {
|
|
407
|
+
if (Array.isArray(current)) {
|
|
408
|
+
for (let i = 0; i < current.length; i++) {
|
|
409
|
+
pathArray[pathLength] = i.toString();
|
|
410
|
+
traverse(current[i], pathLength + 1);
|
|
411
|
+
}
|
|
412
|
+
} else if (typeof current === "object" && current !== null) {
|
|
413
|
+
for (const key in current) {
|
|
414
|
+
pathArray[pathLength] = key;
|
|
415
|
+
traverse(current[key], pathLength + 1);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
} else if (pathLength < beforeWildcard.length) {
|
|
419
|
+
const nextKey = beforeWildcard[pathLength];
|
|
420
|
+
if (current && typeof current === "object" && current !== null && nextKey in current) {
|
|
421
|
+
pathArray[pathLength] = nextKey;
|
|
422
|
+
traverse(current[nextKey], pathLength + 1);
|
|
423
|
+
}
|
|
424
|
+
} else {
|
|
425
|
+
if (afterWildcard.includes("*")) {
|
|
426
|
+
const wrappedCensor = typeof censor === "function" ? (value, path) => {
|
|
427
|
+
const fullPath = [...pathArray.slice(0, pathLength), ...path];
|
|
428
|
+
return censor(value, fullPath);
|
|
429
|
+
} : censor;
|
|
430
|
+
redactWildcardPath(current, afterWildcard, wrappedCensor, originalPath, remove);
|
|
431
|
+
} else {
|
|
432
|
+
if (remove) {
|
|
433
|
+
removeKey(current, afterWildcard);
|
|
434
|
+
} else {
|
|
435
|
+
const actualCensor = typeof censor === "function" ? censor(getValue(current, afterWildcard), [...pathArray.slice(0, pathLength), ...afterWildcard]) : censor;
|
|
436
|
+
setValue(current, afterWildcard, actualCensor);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
if (beforeWildcard.length === 0) {
|
|
442
|
+
traverse(obj, 0);
|
|
443
|
+
} else {
|
|
444
|
+
let current = obj;
|
|
445
|
+
for (let i = 0; i < beforeWildcard.length; i++) {
|
|
446
|
+
const part = beforeWildcard[i];
|
|
447
|
+
if (current === null || current === void 0) return;
|
|
448
|
+
if (typeof current !== "object" || current === null) return;
|
|
449
|
+
current = current[part];
|
|
450
|
+
pathArray[i] = part;
|
|
451
|
+
}
|
|
452
|
+
if (current !== null && current !== void 0) {
|
|
453
|
+
traverse(current, beforeWildcard.length);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
function buildPathStructure(pathsToClone) {
|
|
458
|
+
if (pathsToClone.length === 0) {
|
|
459
|
+
return null;
|
|
460
|
+
}
|
|
461
|
+
const pathStructure = /* @__PURE__ */ new Map();
|
|
462
|
+
for (const path of pathsToClone) {
|
|
463
|
+
const parts = parsePath(path);
|
|
464
|
+
let current = pathStructure;
|
|
465
|
+
for (let i = 0; i < parts.length; i++) {
|
|
466
|
+
const part = parts[i];
|
|
467
|
+
if (!current.has(part)) {
|
|
468
|
+
current.set(part, /* @__PURE__ */ new Map());
|
|
469
|
+
}
|
|
470
|
+
current = current.get(part);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
return pathStructure;
|
|
474
|
+
}
|
|
475
|
+
function selectiveClone(obj, pathStructure) {
|
|
476
|
+
if (!pathStructure) {
|
|
477
|
+
return obj;
|
|
478
|
+
}
|
|
479
|
+
function cloneSelectively(source, pathMap, depth = 0) {
|
|
480
|
+
if (!pathMap || pathMap.size === 0) {
|
|
481
|
+
return source;
|
|
482
|
+
}
|
|
483
|
+
if (source === null || typeof source !== "object") {
|
|
484
|
+
return source;
|
|
485
|
+
}
|
|
486
|
+
if (source instanceof Date) {
|
|
487
|
+
return new Date(source.getTime());
|
|
488
|
+
}
|
|
489
|
+
if (Array.isArray(source)) {
|
|
490
|
+
const cloned2 = [];
|
|
491
|
+
for (let i = 0; i < source.length; i++) {
|
|
492
|
+
const indexStr = i.toString();
|
|
493
|
+
if (pathMap.has(indexStr) || pathMap.has("*")) {
|
|
494
|
+
cloned2[i] = cloneSelectively(source[i], pathMap.get(indexStr) || pathMap.get("*"));
|
|
495
|
+
} else {
|
|
496
|
+
cloned2[i] = source[i];
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
return cloned2;
|
|
500
|
+
}
|
|
501
|
+
const cloned = Object.create(Object.getPrototypeOf(source));
|
|
502
|
+
for (const key in source) {
|
|
503
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
504
|
+
if (pathMap.has(key) || pathMap.has("*")) {
|
|
505
|
+
cloned[key] = cloneSelectively(source[key], pathMap.get(key) || pathMap.get("*"));
|
|
506
|
+
} else {
|
|
507
|
+
cloned[key] = source[key];
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
return cloned;
|
|
512
|
+
}
|
|
513
|
+
return cloneSelectively(obj, pathStructure);
|
|
514
|
+
}
|
|
515
|
+
function validatePath(path) {
|
|
516
|
+
if (typeof path !== "string") {
|
|
517
|
+
throw new Error("Paths must be (non-empty) strings");
|
|
518
|
+
}
|
|
519
|
+
if (path === "") {
|
|
520
|
+
throw new Error("Invalid redaction path ()");
|
|
521
|
+
}
|
|
522
|
+
if (path.includes("..")) {
|
|
523
|
+
throw new Error(`Invalid redaction path (${path})`);
|
|
524
|
+
}
|
|
525
|
+
if (path.includes(",")) {
|
|
526
|
+
throw new Error(`Invalid redaction path (${path})`);
|
|
527
|
+
}
|
|
528
|
+
let bracketCount = 0;
|
|
529
|
+
let inQuotes = false;
|
|
530
|
+
let quoteChar = "";
|
|
531
|
+
for (let i = 0; i < path.length; i++) {
|
|
532
|
+
const char = path[i];
|
|
533
|
+
if ((char === '"' || char === "'") && bracketCount > 0) {
|
|
534
|
+
if (!inQuotes) {
|
|
535
|
+
inQuotes = true;
|
|
536
|
+
quoteChar = char;
|
|
537
|
+
} else if (char === quoteChar) {
|
|
538
|
+
inQuotes = false;
|
|
539
|
+
quoteChar = "";
|
|
540
|
+
}
|
|
541
|
+
} else if (char === "[" && !inQuotes) {
|
|
542
|
+
bracketCount++;
|
|
543
|
+
} else if (char === "]" && !inQuotes) {
|
|
544
|
+
bracketCount--;
|
|
545
|
+
if (bracketCount < 0) {
|
|
546
|
+
throw new Error(`Invalid redaction path (${path})`);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
if (bracketCount !== 0) {
|
|
551
|
+
throw new Error(`Invalid redaction path (${path})`);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
function validatePaths(paths) {
|
|
555
|
+
if (!Array.isArray(paths)) {
|
|
556
|
+
throw new TypeError("paths must be an array");
|
|
557
|
+
}
|
|
558
|
+
for (const path of paths) {
|
|
559
|
+
validatePath(path);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
function slowRedact(options = {}) {
|
|
563
|
+
const {
|
|
564
|
+
paths = [],
|
|
565
|
+
censor = "[REDACTED]",
|
|
566
|
+
serialize = JSON.stringify,
|
|
567
|
+
strict = true,
|
|
568
|
+
remove = false
|
|
569
|
+
} = options;
|
|
570
|
+
validatePaths(paths);
|
|
571
|
+
const pathStructure = buildPathStructure(paths);
|
|
572
|
+
return function redact(obj) {
|
|
573
|
+
if (strict && (obj === null || typeof obj !== "object")) {
|
|
574
|
+
if (obj === null || obj === void 0) {
|
|
575
|
+
return serialize ? serialize(obj) : obj;
|
|
576
|
+
}
|
|
577
|
+
if (typeof obj !== "object") {
|
|
578
|
+
return serialize ? serialize(obj) : obj;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
const cloned = selectiveClone(obj, pathStructure);
|
|
582
|
+
const original = obj;
|
|
583
|
+
let actualCensor = censor;
|
|
584
|
+
if (typeof censor === "function") {
|
|
585
|
+
actualCensor = censor;
|
|
586
|
+
}
|
|
587
|
+
redactPaths(cloned, paths, actualCensor, remove);
|
|
588
|
+
if (serialize === false) {
|
|
589
|
+
cloned.restore = function() {
|
|
590
|
+
return deepClone(original);
|
|
591
|
+
};
|
|
592
|
+
return cloned;
|
|
593
|
+
}
|
|
594
|
+
if (typeof serialize === "function") {
|
|
595
|
+
return serialize(cloned);
|
|
596
|
+
}
|
|
597
|
+
return JSON.stringify(cloned);
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
module.exports = slowRedact;
|
|
601
|
+
}
|
|
602
|
+
});
|
|
603
|
+
|
|
604
|
+
// ../../node_modules/.pnpm/pino@10.4.0/node_modules/pino/browser.js
|
|
605
|
+
var require_browser = __commonJS({
|
|
606
|
+
"../../node_modules/.pnpm/pino@10.4.0/node_modules/pino/browser.js"(exports, module) {
|
|
607
|
+
"use strict";
|
|
608
|
+
init_context_browser();
|
|
609
|
+
var format = require_quick_format_unescaped();
|
|
610
|
+
var Redact = require_redact();
|
|
611
|
+
module.exports = pino2;
|
|
612
|
+
var CENSOR = "[Redacted]";
|
|
613
|
+
function handleRedactOpts(opts) {
|
|
614
|
+
if (Array.isArray(opts)) {
|
|
615
|
+
return { paths: opts, censor: CENSOR };
|
|
616
|
+
}
|
|
617
|
+
const { paths, censor = CENSOR, remove } = opts;
|
|
618
|
+
if (!Array.isArray(paths)) {
|
|
619
|
+
throw Error("pino \u2013 redact must contain an array of strings");
|
|
620
|
+
}
|
|
621
|
+
return { paths, censor: remove ? void 0 : censor, remove };
|
|
622
|
+
}
|
|
623
|
+
function buildRedactFn(redact) {
|
|
624
|
+
if (!redact) return null;
|
|
625
|
+
const { paths, censor, remove } = handleRedactOpts(redact);
|
|
626
|
+
return Redact({
|
|
627
|
+
paths,
|
|
628
|
+
censor,
|
|
629
|
+
remove,
|
|
630
|
+
serialize: false
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
var _console = pfGlobalThisOrFallback().console || {};
|
|
634
|
+
var stdSerializers = {
|
|
635
|
+
mapHttpRequest: mock,
|
|
636
|
+
mapHttpResponse: mock,
|
|
637
|
+
wrapRequestSerializer: passthrough,
|
|
638
|
+
wrapResponseSerializer: passthrough,
|
|
639
|
+
wrapErrorSerializer: passthrough,
|
|
640
|
+
req: mock,
|
|
641
|
+
res: mock,
|
|
642
|
+
err: asErrValue,
|
|
643
|
+
errWithCause: asErrValue
|
|
644
|
+
};
|
|
645
|
+
function levelToValue(level, logger2) {
|
|
646
|
+
return level === "silent" ? Infinity : logger2.levels.values[level];
|
|
647
|
+
}
|
|
648
|
+
var baseLogFunctionSymbol = /* @__PURE__ */ Symbol("pino.logFuncs");
|
|
649
|
+
var hierarchySymbol = /* @__PURE__ */ Symbol("pino.hierarchy");
|
|
650
|
+
var ownBindingsSymbol = /* @__PURE__ */ Symbol("pino.ownBindings");
|
|
651
|
+
var bindingsSymbol = /* @__PURE__ */ Symbol("pino.bindings");
|
|
652
|
+
var logFallbackMap = {
|
|
653
|
+
error: "log",
|
|
654
|
+
fatal: "error",
|
|
655
|
+
warn: "error",
|
|
656
|
+
info: "log",
|
|
657
|
+
debug: "log",
|
|
658
|
+
trace: "log"
|
|
659
|
+
};
|
|
660
|
+
function appendChildLogger(parentLogger, childLogger) {
|
|
661
|
+
const newEntry = {
|
|
662
|
+
logger: childLogger,
|
|
663
|
+
parent: parentLogger[hierarchySymbol]
|
|
664
|
+
};
|
|
665
|
+
childLogger[hierarchySymbol] = newEntry;
|
|
666
|
+
}
|
|
667
|
+
function setupBaseLogFunctions(logger2, levels, proto) {
|
|
668
|
+
const logFunctions = {};
|
|
669
|
+
levels.forEach((level) => {
|
|
670
|
+
logFunctions[level] = proto[level] ? proto[level] : _console[level] || _console[logFallbackMap[level] || "log"] || noop;
|
|
671
|
+
});
|
|
672
|
+
logger2[baseLogFunctionSymbol] = logFunctions;
|
|
673
|
+
}
|
|
674
|
+
function shouldSerialize(serialize, serializers) {
|
|
675
|
+
if (Array.isArray(serialize)) {
|
|
676
|
+
const hasToFilter = serialize.filter(function(k) {
|
|
677
|
+
return k !== "!stdSerializers.err";
|
|
678
|
+
});
|
|
679
|
+
return hasToFilter;
|
|
680
|
+
} else if (serialize === true) {
|
|
681
|
+
return Object.keys(serializers);
|
|
682
|
+
}
|
|
683
|
+
return false;
|
|
684
|
+
}
|
|
685
|
+
function pino2(opts) {
|
|
686
|
+
opts = opts || {};
|
|
687
|
+
opts.browser = opts.browser || {};
|
|
688
|
+
const transmit2 = opts.browser.transmit;
|
|
689
|
+
if (transmit2 && typeof transmit2.send !== "function") {
|
|
690
|
+
throw Error("pino: transmit option must have a send function");
|
|
691
|
+
}
|
|
692
|
+
const proto = opts.browser.write || _console;
|
|
693
|
+
if (opts.browser.write) opts.browser.asObject = true;
|
|
694
|
+
const serializers = opts.serializers || {};
|
|
695
|
+
const serialize = shouldSerialize(opts.browser.serialize, serializers);
|
|
696
|
+
let stdErrSerialize = opts.browser.serialize;
|
|
697
|
+
if (Array.isArray(opts.browser.serialize) && opts.browser.serialize.indexOf("!stdSerializers.err") > -1) stdErrSerialize = false;
|
|
698
|
+
const customLevels = Object.keys(opts.customLevels || {});
|
|
699
|
+
const levels = ["error", "fatal", "warn", "info", "debug", "trace"].concat(customLevels);
|
|
700
|
+
if (typeof proto === "function") {
|
|
701
|
+
levels.forEach(function(level2) {
|
|
702
|
+
proto[level2] = proto;
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
if (opts.enabled === false || opts.browser.disabled) opts.level = "silent";
|
|
706
|
+
const level = opts.level || "info";
|
|
707
|
+
const logger2 = Object.create(proto);
|
|
708
|
+
if (!logger2.log) logger2.log = noop;
|
|
709
|
+
setupBaseLogFunctions(logger2, levels, proto);
|
|
710
|
+
appendChildLogger({}, logger2);
|
|
711
|
+
logger2[bindingsSymbol] = {};
|
|
712
|
+
Object.defineProperty(logger2, "levelVal", {
|
|
713
|
+
get: getLevelVal
|
|
714
|
+
});
|
|
715
|
+
Object.defineProperty(logger2, "level", {
|
|
716
|
+
get: getLevel,
|
|
717
|
+
set: setLevel
|
|
718
|
+
});
|
|
719
|
+
const redactFn = buildRedactFn(opts.redact);
|
|
720
|
+
const setOpts = {
|
|
721
|
+
transmit: transmit2,
|
|
722
|
+
serialize,
|
|
723
|
+
asObject: opts.browser.asObject,
|
|
724
|
+
asObjectBindingsOnly: opts.browser.asObjectBindingsOnly,
|
|
725
|
+
formatters: opts.browser.formatters,
|
|
726
|
+
reportCaller: opts.browser.reportCaller,
|
|
727
|
+
levels,
|
|
728
|
+
timestamp: getTimeFunction(opts),
|
|
729
|
+
messageKey: opts.messageKey || "msg",
|
|
730
|
+
onChild: opts.onChild || noop,
|
|
731
|
+
redactFn
|
|
732
|
+
};
|
|
733
|
+
logger2.levels = getLevels(opts);
|
|
734
|
+
logger2.level = level;
|
|
735
|
+
logger2.isLevelEnabled = function(level2) {
|
|
736
|
+
if (!this.levels.values[level2]) {
|
|
737
|
+
return false;
|
|
738
|
+
}
|
|
739
|
+
return this.levels.values[level2] >= this.levels.values[this.level];
|
|
740
|
+
};
|
|
741
|
+
logger2.setMaxListeners = logger2.getMaxListeners = logger2.emit = logger2.addListener = logger2.on = logger2.prependListener = logger2.once = logger2.prependOnceListener = logger2.removeListener = logger2.removeAllListeners = logger2.listeners = logger2.listenerCount = logger2.eventNames = logger2.write = logger2.flush = noop;
|
|
742
|
+
logger2.serializers = serializers;
|
|
743
|
+
logger2._serialize = serialize;
|
|
744
|
+
logger2._stdErrSerialize = stdErrSerialize;
|
|
745
|
+
logger2.child = function(...args) {
|
|
746
|
+
return child.call(this, setOpts, ...args);
|
|
747
|
+
};
|
|
748
|
+
logger2.bindings = function() {
|
|
749
|
+
return Object.assign({}, this[bindingsSymbol]);
|
|
750
|
+
};
|
|
751
|
+
logger2.setBindings = function(newBindings) {
|
|
752
|
+
this[ownBindingsSymbol] = Object.assign({}, this[ownBindingsSymbol], newBindings);
|
|
753
|
+
this[bindingsSymbol] = Object.assign({}, this[bindingsSymbol], newBindings);
|
|
754
|
+
if (this._logEvent) {
|
|
755
|
+
this._logEvent.bindings.push(newBindings);
|
|
756
|
+
}
|
|
757
|
+
this.level = this._level;
|
|
758
|
+
};
|
|
759
|
+
if (transmit2) logger2._logEvent = createLogEventShape();
|
|
760
|
+
function getLevelVal() {
|
|
761
|
+
return levelToValue(this.level, this);
|
|
762
|
+
}
|
|
763
|
+
function getLevel() {
|
|
764
|
+
return this._level;
|
|
765
|
+
}
|
|
766
|
+
function setLevel(level2) {
|
|
767
|
+
if (level2 !== "silent" && !this.levels.values[level2]) {
|
|
768
|
+
throw Error("unknown level " + level2);
|
|
769
|
+
}
|
|
770
|
+
this._level = level2;
|
|
771
|
+
set(this, setOpts, logger2, "error");
|
|
772
|
+
set(this, setOpts, logger2, "fatal");
|
|
773
|
+
set(this, setOpts, logger2, "warn");
|
|
774
|
+
set(this, setOpts, logger2, "info");
|
|
775
|
+
set(this, setOpts, logger2, "debug");
|
|
776
|
+
set(this, setOpts, logger2, "trace");
|
|
777
|
+
customLevels.forEach((level3) => {
|
|
778
|
+
set(this, setOpts, logger2, level3);
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
function child(setOpts2, bindings, childOptions) {
|
|
782
|
+
if (!bindings) {
|
|
783
|
+
throw new Error("missing bindings for child Pino");
|
|
784
|
+
}
|
|
785
|
+
childOptions = childOptions || {};
|
|
786
|
+
if (serialize && bindings.serializers) {
|
|
787
|
+
childOptions.serializers = bindings.serializers;
|
|
788
|
+
}
|
|
789
|
+
const childOptionsSerializers = childOptions.serializers;
|
|
790
|
+
if (serialize && childOptionsSerializers) {
|
|
791
|
+
var childSerializers = Object.assign({}, serializers, childOptionsSerializers);
|
|
792
|
+
var childSerialize = opts.browser.serialize === true ? Object.keys(childSerializers) : serialize;
|
|
793
|
+
delete bindings.serializers;
|
|
794
|
+
applySerializers([bindings], childSerialize, childSerializers, this._stdErrSerialize);
|
|
795
|
+
}
|
|
796
|
+
function Child(parent) {
|
|
797
|
+
this._childLevel = (parent._childLevel | 0) + 1;
|
|
798
|
+
this[ownBindingsSymbol] = bindings;
|
|
799
|
+
this[bindingsSymbol] = Object.assign(
|
|
800
|
+
{},
|
|
801
|
+
parent[bindingsSymbol],
|
|
802
|
+
bindings
|
|
803
|
+
);
|
|
804
|
+
if (childSerializers) {
|
|
805
|
+
this.serializers = childSerializers;
|
|
806
|
+
this._serialize = childSerialize;
|
|
807
|
+
}
|
|
808
|
+
if (transmit2) {
|
|
809
|
+
this._logEvent = createLogEventShape(
|
|
810
|
+
[].concat(parent._logEvent.bindings, bindings)
|
|
811
|
+
);
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
Child.prototype = this;
|
|
815
|
+
const newLogger = new Child(this);
|
|
816
|
+
appendChildLogger(this, newLogger);
|
|
817
|
+
newLogger.child = function(...args) {
|
|
818
|
+
return child.call(this, setOpts2, ...args);
|
|
819
|
+
};
|
|
820
|
+
newLogger.level = childOptions.level || this.level;
|
|
821
|
+
setOpts2.onChild(newLogger);
|
|
822
|
+
return newLogger;
|
|
823
|
+
}
|
|
824
|
+
return logger2;
|
|
825
|
+
}
|
|
826
|
+
function getLevels(opts) {
|
|
827
|
+
const customLevels = opts.customLevels || {};
|
|
828
|
+
const values = Object.assign({}, pino2.levels.values, customLevels);
|
|
829
|
+
const labels = Object.assign({}, pino2.levels.labels, invertObject(customLevels));
|
|
830
|
+
return {
|
|
831
|
+
values,
|
|
832
|
+
labels
|
|
833
|
+
};
|
|
834
|
+
}
|
|
835
|
+
function invertObject(obj) {
|
|
836
|
+
const inverted = {};
|
|
837
|
+
Object.keys(obj).forEach(function(key) {
|
|
838
|
+
inverted[obj[key]] = key;
|
|
839
|
+
});
|
|
840
|
+
return inverted;
|
|
841
|
+
}
|
|
842
|
+
pino2.levels = {
|
|
843
|
+
values: {
|
|
844
|
+
fatal: 60,
|
|
845
|
+
error: 50,
|
|
846
|
+
warn: 40,
|
|
847
|
+
info: 30,
|
|
848
|
+
debug: 20,
|
|
849
|
+
trace: 10
|
|
850
|
+
},
|
|
851
|
+
labels: {
|
|
852
|
+
10: "trace",
|
|
853
|
+
20: "debug",
|
|
854
|
+
30: "info",
|
|
855
|
+
40: "warn",
|
|
856
|
+
50: "error",
|
|
857
|
+
60: "fatal"
|
|
858
|
+
}
|
|
859
|
+
};
|
|
860
|
+
pino2.stdSerializers = stdSerializers;
|
|
861
|
+
pino2.stdTimeFunctions = Object.assign({}, { nullTime, epochTime, unixTime, isoTime });
|
|
862
|
+
function getBindingChain(logger2) {
|
|
863
|
+
const bindings = [];
|
|
864
|
+
if (logger2[ownBindingsSymbol]) {
|
|
865
|
+
bindings.push(logger2[ownBindingsSymbol]);
|
|
866
|
+
}
|
|
867
|
+
let hierarchy = logger2[hierarchySymbol];
|
|
868
|
+
while (hierarchy.parent) {
|
|
869
|
+
hierarchy = hierarchy.parent;
|
|
870
|
+
if (hierarchy.logger[ownBindingsSymbol]) {
|
|
871
|
+
bindings.push(hierarchy.logger[ownBindingsSymbol]);
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
return bindings.reverse();
|
|
875
|
+
}
|
|
876
|
+
function set(self2, opts, rootLogger, level) {
|
|
877
|
+
Object.defineProperty(self2, level, {
|
|
878
|
+
value: levelToValue(self2.level, rootLogger) > levelToValue(level, rootLogger) ? noop : rootLogger[baseLogFunctionSymbol][level],
|
|
879
|
+
writable: true,
|
|
880
|
+
enumerable: true,
|
|
881
|
+
configurable: true
|
|
882
|
+
});
|
|
883
|
+
if (self2[level] === noop) {
|
|
884
|
+
if (!opts.transmit) return;
|
|
885
|
+
const transmitLevel = opts.transmit.level || self2.level;
|
|
886
|
+
const transmitValue = levelToValue(transmitLevel, rootLogger);
|
|
887
|
+
const methodValue = levelToValue(level, rootLogger);
|
|
888
|
+
if (methodValue < transmitValue) return;
|
|
889
|
+
}
|
|
890
|
+
self2[level] = createWrap(self2, opts, rootLogger, level);
|
|
891
|
+
const bindings = getBindingChain(self2);
|
|
892
|
+
if (bindings.length === 0) {
|
|
893
|
+
return;
|
|
894
|
+
}
|
|
895
|
+
self2[level] = prependBindingsInArguments(bindings, self2[level]);
|
|
896
|
+
}
|
|
897
|
+
function prependBindingsInArguments(bindings, logFunc) {
|
|
898
|
+
return function() {
|
|
899
|
+
return logFunc.apply(this, [...bindings, ...arguments]);
|
|
900
|
+
};
|
|
901
|
+
}
|
|
902
|
+
function createWrap(self2, opts, rootLogger, level) {
|
|
903
|
+
return /* @__PURE__ */ (function(write) {
|
|
904
|
+
return function LOG() {
|
|
905
|
+
const ts = opts.timestamp();
|
|
906
|
+
const args = new Array(arguments.length);
|
|
907
|
+
const proto = Object.getPrototypeOf && Object.getPrototypeOf(this) === _console ? _console : this;
|
|
908
|
+
for (var i = 0; i < args.length; i++) args[i] = arguments[i];
|
|
909
|
+
var argsIsSerialized = false;
|
|
910
|
+
if (opts.serialize) {
|
|
911
|
+
applySerializers(args, this._serialize, this.serializers, this._stdErrSerialize);
|
|
912
|
+
argsIsSerialized = true;
|
|
913
|
+
}
|
|
914
|
+
if (opts.asObject || opts.formatters) {
|
|
915
|
+
const out = asObject(this, level, args, ts, opts);
|
|
916
|
+
if (opts.reportCaller && out && out.length > 0 && out[0] && typeof out[0] === "object") {
|
|
917
|
+
try {
|
|
918
|
+
const caller = getCallerLocation();
|
|
919
|
+
if (caller) out[0].caller = caller;
|
|
920
|
+
} catch (e) {
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
write.call(proto, ...out);
|
|
924
|
+
} else {
|
|
925
|
+
if (opts.reportCaller) {
|
|
926
|
+
try {
|
|
927
|
+
const caller = getCallerLocation();
|
|
928
|
+
if (caller) args.push(caller);
|
|
929
|
+
} catch (e) {
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
write.apply(proto, args);
|
|
933
|
+
}
|
|
934
|
+
if (opts.transmit) {
|
|
935
|
+
const transmitLevel = opts.transmit.level || self2._level;
|
|
936
|
+
const transmitValue = levelToValue(transmitLevel, rootLogger);
|
|
937
|
+
const methodValue = levelToValue(level, rootLogger);
|
|
938
|
+
if (methodValue < transmitValue) return;
|
|
939
|
+
transmit(this, {
|
|
940
|
+
ts,
|
|
941
|
+
methodLevel: level,
|
|
942
|
+
methodValue,
|
|
943
|
+
transmitLevel,
|
|
944
|
+
transmitValue: rootLogger.levels.values[opts.transmit.level || self2._level],
|
|
945
|
+
send: opts.transmit.send,
|
|
946
|
+
val: levelToValue(self2._level, rootLogger)
|
|
947
|
+
}, args, argsIsSerialized);
|
|
948
|
+
}
|
|
949
|
+
};
|
|
950
|
+
})(self2[baseLogFunctionSymbol][level]);
|
|
951
|
+
}
|
|
952
|
+
function asObject(logger2, level, args, ts, opts) {
|
|
953
|
+
const {
|
|
954
|
+
level: levelFormatter,
|
|
955
|
+
log: logObjectFormatter = (obj) => obj
|
|
956
|
+
} = opts.formatters || {};
|
|
957
|
+
const argsCloned = args.slice();
|
|
958
|
+
let msg = argsCloned[0];
|
|
959
|
+
const logObject = {};
|
|
960
|
+
let lvl = (logger2._childLevel | 0) + 1;
|
|
961
|
+
if (lvl < 1) lvl = 1;
|
|
962
|
+
if (ts) {
|
|
963
|
+
logObject.time = ts;
|
|
964
|
+
}
|
|
965
|
+
if (levelFormatter) {
|
|
966
|
+
const formattedLevel = levelFormatter(level, logger2.levels.values[level]);
|
|
967
|
+
Object.assign(logObject, formattedLevel);
|
|
968
|
+
} else {
|
|
969
|
+
logObject.level = logger2.levels.values[level];
|
|
970
|
+
}
|
|
971
|
+
if (opts.asObjectBindingsOnly) {
|
|
972
|
+
if (msg !== null && typeof msg === "object") {
|
|
973
|
+
while (lvl-- && typeof argsCloned[0] === "object") {
|
|
974
|
+
Object.assign(logObject, argsCloned.shift());
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
let formattedLogObject = logObjectFormatter(logObject);
|
|
978
|
+
if (opts.redactFn) {
|
|
979
|
+
formattedLogObject = opts.redactFn(formattedLogObject);
|
|
980
|
+
}
|
|
981
|
+
return [formattedLogObject, ...argsCloned];
|
|
982
|
+
} else {
|
|
983
|
+
if (msg !== null && typeof msg === "object") {
|
|
984
|
+
while (lvl-- && typeof argsCloned[0] === "object") {
|
|
985
|
+
Object.assign(logObject, argsCloned.shift());
|
|
986
|
+
}
|
|
987
|
+
msg = argsCloned.length ? format(argsCloned.shift(), argsCloned) : void 0;
|
|
988
|
+
} else if (typeof msg === "string") msg = format(argsCloned.shift(), argsCloned);
|
|
989
|
+
if (msg !== void 0) logObject[opts.messageKey] = msg;
|
|
990
|
+
let formattedLogObject = logObjectFormatter(logObject);
|
|
991
|
+
if (opts.redactFn) {
|
|
992
|
+
formattedLogObject = opts.redactFn(formattedLogObject);
|
|
993
|
+
}
|
|
994
|
+
return [formattedLogObject];
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
function applySerializers(args, serialize, serializers, stdErrSerialize) {
|
|
998
|
+
for (const i in args) {
|
|
999
|
+
if (stdErrSerialize && args[i] instanceof Error) {
|
|
1000
|
+
args[i] = pino2.stdSerializers.err(args[i]);
|
|
1001
|
+
} else if (typeof args[i] === "object" && !Array.isArray(args[i]) && serialize) {
|
|
1002
|
+
for (const k in args[i]) {
|
|
1003
|
+
if (serialize.indexOf(k) > -1 && k in serializers) {
|
|
1004
|
+
args[i][k] = serializers[k](args[i][k]);
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
function transmit(logger2, opts, args, argsIsSerialized = false) {
|
|
1011
|
+
const send = opts.send;
|
|
1012
|
+
const ts = opts.ts;
|
|
1013
|
+
const methodLevel = opts.methodLevel;
|
|
1014
|
+
const methodValue = opts.methodValue;
|
|
1015
|
+
const val = opts.val;
|
|
1016
|
+
const bindings = logger2._logEvent.bindings;
|
|
1017
|
+
if (!argsIsSerialized) {
|
|
1018
|
+
applySerializers(
|
|
1019
|
+
args,
|
|
1020
|
+
logger2._serialize || Object.keys(logger2.serializers),
|
|
1021
|
+
logger2.serializers,
|
|
1022
|
+
logger2._stdErrSerialize === void 0 ? true : logger2._stdErrSerialize
|
|
1023
|
+
);
|
|
1024
|
+
}
|
|
1025
|
+
logger2._logEvent.ts = ts;
|
|
1026
|
+
logger2._logEvent.messages = args.filter(function(arg) {
|
|
1027
|
+
return bindings.indexOf(arg) === -1;
|
|
1028
|
+
});
|
|
1029
|
+
logger2._logEvent.level.label = methodLevel;
|
|
1030
|
+
logger2._logEvent.level.value = methodValue;
|
|
1031
|
+
send(methodLevel, logger2._logEvent, val);
|
|
1032
|
+
logger2._logEvent = createLogEventShape(bindings);
|
|
1033
|
+
}
|
|
1034
|
+
function createLogEventShape(bindings) {
|
|
1035
|
+
return {
|
|
1036
|
+
ts: 0,
|
|
1037
|
+
messages: [],
|
|
1038
|
+
bindings: bindings || [],
|
|
1039
|
+
level: { label: "", value: 0 }
|
|
1040
|
+
};
|
|
1041
|
+
}
|
|
1042
|
+
function asErrValue(err) {
|
|
1043
|
+
const obj = {
|
|
1044
|
+
type: err.constructor.name,
|
|
1045
|
+
msg: err.message,
|
|
1046
|
+
stack: err.stack
|
|
1047
|
+
};
|
|
1048
|
+
for (const key in err) {
|
|
1049
|
+
if (obj[key] === void 0) {
|
|
1050
|
+
obj[key] = err[key];
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
return obj;
|
|
1054
|
+
}
|
|
1055
|
+
function getTimeFunction(opts) {
|
|
1056
|
+
if (typeof opts.timestamp === "function") {
|
|
1057
|
+
return opts.timestamp;
|
|
1058
|
+
}
|
|
1059
|
+
if (opts.timestamp === false) {
|
|
1060
|
+
return nullTime;
|
|
1061
|
+
}
|
|
1062
|
+
return epochTime;
|
|
1063
|
+
}
|
|
1064
|
+
function mock() {
|
|
1065
|
+
return {};
|
|
1066
|
+
}
|
|
1067
|
+
function passthrough(a) {
|
|
1068
|
+
return a;
|
|
1069
|
+
}
|
|
1070
|
+
function noop() {
|
|
1071
|
+
}
|
|
1072
|
+
function nullTime() {
|
|
1073
|
+
return false;
|
|
1074
|
+
}
|
|
1075
|
+
function epochTime() {
|
|
1076
|
+
return Date.now();
|
|
1077
|
+
}
|
|
1078
|
+
function unixTime() {
|
|
1079
|
+
return Math.round(Date.now() / 1e3);
|
|
1080
|
+
}
|
|
1081
|
+
function isoTime() {
|
|
1082
|
+
return new Date(Date.now()).toISOString();
|
|
1083
|
+
}
|
|
1084
|
+
function pfGlobalThisOrFallback() {
|
|
1085
|
+
function defd(o) {
|
|
1086
|
+
return typeof o !== "undefined" && o;
|
|
1087
|
+
}
|
|
1088
|
+
try {
|
|
1089
|
+
if (typeof globalThis !== "undefined") return globalThis;
|
|
1090
|
+
Object.defineProperty(Object.prototype, "globalThis", {
|
|
1091
|
+
get: function() {
|
|
1092
|
+
delete Object.prototype.globalThis;
|
|
1093
|
+
return this.globalThis = this;
|
|
1094
|
+
},
|
|
1095
|
+
configurable: true
|
|
1096
|
+
});
|
|
1097
|
+
return globalThis;
|
|
1098
|
+
} catch (e) {
|
|
1099
|
+
return defd(self) || defd(window) || defd(this) || {};
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
module.exports.default = pino2;
|
|
1103
|
+
module.exports.pino = pino2;
|
|
1104
|
+
function getCallerLocation() {
|
|
1105
|
+
const stack = new Error().stack;
|
|
1106
|
+
if (!stack) return null;
|
|
1107
|
+
const lines = stack.split("\n");
|
|
1108
|
+
for (let i = 1; i < lines.length; i++) {
|
|
1109
|
+
const l = lines[i].trim();
|
|
1110
|
+
if (/(^at\s+)?(createWrap|LOG|set\s*\(|asObject|Object\.apply|Function\.apply)/.test(l)) continue;
|
|
1111
|
+
if (l.indexOf("browser.js") !== -1) continue;
|
|
1112
|
+
if (l.indexOf("node:internal") !== -1) continue;
|
|
1113
|
+
if (l.indexOf("node_modules") !== -1) continue;
|
|
1114
|
+
let m = l.match(/\((.*?):(\d+):(\d+)\)/);
|
|
1115
|
+
if (!m) m = l.match(/at\s+(.*?):(\d+):(\d+)/);
|
|
1116
|
+
if (m) {
|
|
1117
|
+
const file = m[1];
|
|
1118
|
+
const line = m[2];
|
|
1119
|
+
const col = m[3];
|
|
1120
|
+
return file + ":" + line + ":" + col;
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
return null;
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
});
|
|
1127
|
+
|
|
1128
|
+
// src/index.browser.ts
|
|
1129
|
+
init_context_browser();
|
|
1130
|
+
|
|
1131
|
+
// src/index.ts
|
|
1132
|
+
init_context_browser();
|
|
1133
|
+
|
|
1134
|
+
// src/proxy.ts
|
|
1135
|
+
init_context_browser();
|
|
1136
|
+
|
|
1137
|
+
// src/config.ts
|
|
1138
|
+
init_context_browser();
|
|
1139
|
+
var import_pino = __toESM(require_browser(), 1);
|
|
1140
|
+
init_context_browser();
|
|
1141
|
+
|
|
1142
|
+
// src/levels.ts
|
|
1143
|
+
init_context_browser();
|
|
1144
|
+
var LEVELS = {
|
|
1145
|
+
trace: 10,
|
|
1146
|
+
debug: 20,
|
|
1147
|
+
info: 30,
|
|
1148
|
+
success: 35,
|
|
1149
|
+
warn: 40,
|
|
1150
|
+
error: 50,
|
|
1151
|
+
fatal: 60
|
|
1152
|
+
};
|
|
1153
|
+
|
|
1154
|
+
// src/pretty.ts
|
|
1155
|
+
init_context_browser();
|
|
1156
|
+
var COLORS = {
|
|
1157
|
+
trace: 90,
|
|
1158
|
+
debug: 36,
|
|
1159
|
+
info: 34,
|
|
1160
|
+
success: 32,
|
|
1161
|
+
warn: 33,
|
|
1162
|
+
error: 31,
|
|
1163
|
+
fatal: 35
|
|
1164
|
+
};
|
|
1165
|
+
function createPrettyStream(write) {
|
|
1166
|
+
return {
|
|
1167
|
+
write(line) {
|
|
1168
|
+
const record = JSON.parse(line);
|
|
1169
|
+
const { time, level, service, msg, err, ...fields } = record;
|
|
1170
|
+
const date = new Date(String(time));
|
|
1171
|
+
const clock = Number.isNaN(date.getTime()) ? "--:--:--" : date.toTimeString().slice(0, 8);
|
|
1172
|
+
const label = String(level ?? "").toUpperCase();
|
|
1173
|
+
const color = COLORS[String(level)];
|
|
1174
|
+
const formattedLevel = browserProcess.stdout.isTTY && color ? `\x1B[${color}m${label}\x1B[0m` : label;
|
|
1175
|
+
const values = Object.entries(fields).map(([key, value]) => `${key}=${typeof value === "string" ? value : JSON.stringify(value)}`);
|
|
1176
|
+
let output = [clock, formattedLevel, service, msg, ...values].filter((part) => part !== void 0 && part !== "").join(" ");
|
|
1177
|
+
if (err && typeof err === "object") {
|
|
1178
|
+
const error = err;
|
|
1179
|
+
output += ` ${String(error.type ?? "Error")}: ${String(error.message ?? "")}`;
|
|
1180
|
+
if (typeof error.stack === "string") {
|
|
1181
|
+
const lines = error.stack.split("\n");
|
|
1182
|
+
output += `
|
|
1183
|
+
${lines.slice(1).join("\n")}`;
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
write(`${output}
|
|
1187
|
+
`);
|
|
1188
|
+
}
|
|
1189
|
+
};
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
// src/redact.ts
|
|
1193
|
+
init_context_browser();
|
|
1194
|
+
var keys = ["password", "token", "secret", "apiKey", "authorization", "cookie", "otp", "phone", "mobile", "merchant"];
|
|
1195
|
+
var DEFAULT_REDACT_PATHS = [
|
|
1196
|
+
...keys.flatMap((key) => [key, `*.${key}`]),
|
|
1197
|
+
"req.headers.authorization",
|
|
1198
|
+
"req.headers.cookie",
|
|
1199
|
+
"headers.authorization",
|
|
1200
|
+
"headers.cookie",
|
|
1201
|
+
"body",
|
|
1202
|
+
"req.body"
|
|
1203
|
+
];
|
|
1204
|
+
|
|
1205
|
+
// src/serialize-error.ts
|
|
1206
|
+
init_context_browser();
|
|
1207
|
+
function serializeError(error, depth = 0) {
|
|
1208
|
+
if (!(error instanceof Error)) {
|
|
1209
|
+
return { type: typeof error, message: String(error).slice(0, 500) };
|
|
1210
|
+
}
|
|
1211
|
+
const result = {
|
|
1212
|
+
type: error.name,
|
|
1213
|
+
message: error.message.slice(0, 500)
|
|
1214
|
+
};
|
|
1215
|
+
const code = error.code;
|
|
1216
|
+
if (typeof code === "string" && /^[A-Z][A-Z0-9_]{1,99}$/.test(code)) result.code = code;
|
|
1217
|
+
if (browserProcess.env.NODE_ENV !== "production" && error.stack) result.stack = error.stack;
|
|
1218
|
+
if (error.cause !== void 0 && depth < 2) result.cause = serializeError(error.cause, depth + 1);
|
|
1219
|
+
return result;
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
// src/config.ts
|
|
1223
|
+
var configured;
|
|
1224
|
+
var fallbackLogger;
|
|
1225
|
+
var configuredProxy;
|
|
1226
|
+
function isLogLevel(value) {
|
|
1227
|
+
return Object.prototype.hasOwnProperty.call(LEVELS, value);
|
|
1228
|
+
}
|
|
1229
|
+
function resolveLevel() {
|
|
1230
|
+
const level = browserProcess.env.LOG_LEVEL?.trim().toLowerCase();
|
|
1231
|
+
if (level && isLogLevel(level)) {
|
|
1232
|
+
return level;
|
|
1233
|
+
}
|
|
1234
|
+
return browserProcess.env.NODE_ENV === "production" ? "info" : "debug";
|
|
1235
|
+
}
|
|
1236
|
+
function buildPinoOptions(options) {
|
|
1237
|
+
return {
|
|
1238
|
+
redact: { paths: [...options.redact?.replaceDefaults ? [] : DEFAULT_REDACT_PATHS, ...options.redact?.paths ?? []], censor: options.redact?.censor ?? "[REDACTED]" },
|
|
1239
|
+
serializers: { err: serializeError },
|
|
1240
|
+
mixin: getLogContext,
|
|
1241
|
+
level: options.level ?? resolveLevel(),
|
|
1242
|
+
base: {
|
|
1243
|
+
...options.base,
|
|
1244
|
+
service: options.service ?? browserProcess.env.SERVICE_NAME ?? "unknown",
|
|
1245
|
+
release: options.release ?? browserProcess.env.RELEASE,
|
|
1246
|
+
instance: options.instance,
|
|
1247
|
+
environment: options.environment,
|
|
1248
|
+
pid: browserProcess.pid
|
|
1249
|
+
},
|
|
1250
|
+
timestamp: import_pino.default.stdTimeFunctions.isoTime,
|
|
1251
|
+
formatters: { level: (label) => ({ level: label }) }
|
|
1252
|
+
};
|
|
1253
|
+
}
|
|
1254
|
+
function createPinoLogger(options, sharedOptions = buildPinoOptions(options)) {
|
|
1255
|
+
const pinoOptions = {
|
|
1256
|
+
...sharedOptions,
|
|
1257
|
+
customLevels: { success: LEVELS.success },
|
|
1258
|
+
useOnlyCustomLevels: false
|
|
1259
|
+
};
|
|
1260
|
+
if (isBrowser) {
|
|
1261
|
+
return (0, import_pino.default)({
|
|
1262
|
+
...pinoOptions,
|
|
1263
|
+
browser: {
|
|
1264
|
+
asObject: true,
|
|
1265
|
+
serialize: ["err", "!stdSerializers.err"],
|
|
1266
|
+
formatters: {
|
|
1267
|
+
level: pinoOptions.formatters.level,
|
|
1268
|
+
log: (record) => ({ ...pinoOptions.base, ...record })
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
});
|
|
1272
|
+
}
|
|
1273
|
+
const destination = options.destination ?? (options.pretty ?? browserProcess.env.NODE_ENV !== "production" ? createPrettyStream((line) => {
|
|
1274
|
+
browserProcess.stdout.write(line);
|
|
1275
|
+
}) : void 0);
|
|
1276
|
+
return (0, import_pino.default)(pinoOptions, destination);
|
|
1277
|
+
}
|
|
1278
|
+
function configureLogger(options) {
|
|
1279
|
+
if (configured && !options.force) {
|
|
1280
|
+
configured.logger.child({}, { level: "warn" }).warn(
|
|
1281
|
+
{ event: "logger.reconfigure.ignored" },
|
|
1282
|
+
"Logger is already configured"
|
|
1283
|
+
);
|
|
1284
|
+
return configuredProxy ??= createProxy();
|
|
1285
|
+
}
|
|
1286
|
+
const sharedOptions = buildPinoOptions(options);
|
|
1287
|
+
configured = {
|
|
1288
|
+
logger: createPinoLogger(options, sharedOptions),
|
|
1289
|
+
config: { options: sharedOptions, destination: options.destination }
|
|
1290
|
+
};
|
|
1291
|
+
fallbackLogger = void 0;
|
|
1292
|
+
return configuredProxy ??= createProxy();
|
|
1293
|
+
}
|
|
1294
|
+
function getActiveLogger() {
|
|
1295
|
+
return configured?.logger ?? (fallbackLogger ??= createPinoLogger({}));
|
|
1296
|
+
}
|
|
1297
|
+
function getPayloadLoggerConfig() {
|
|
1298
|
+
const { options, destination } = configured?.config ?? {
|
|
1299
|
+
options: buildPinoOptions({})
|
|
1300
|
+
};
|
|
1301
|
+
return {
|
|
1302
|
+
options: {
|
|
1303
|
+
...options,
|
|
1304
|
+
level: options.level === "success" ? "warn" : options.level,
|
|
1305
|
+
redact: { ...options.redact, paths: [...options.redact.paths] },
|
|
1306
|
+
serializers: { ...options.serializers },
|
|
1307
|
+
base: { ...options.base },
|
|
1308
|
+
formatters: { ...options.formatters }
|
|
1309
|
+
},
|
|
1310
|
+
...destination === void 0 ? {} : { destination }
|
|
1311
|
+
};
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
// src/proxy.ts
|
|
1315
|
+
function createProxy(bindings) {
|
|
1316
|
+
let root;
|
|
1317
|
+
let child;
|
|
1318
|
+
function resolve() {
|
|
1319
|
+
const active = getActiveLogger();
|
|
1320
|
+
if (!bindings) {
|
|
1321
|
+
return active;
|
|
1322
|
+
}
|
|
1323
|
+
if (!child || root !== active) {
|
|
1324
|
+
child = active.child(bindings);
|
|
1325
|
+
root = active;
|
|
1326
|
+
}
|
|
1327
|
+
return child;
|
|
1328
|
+
}
|
|
1329
|
+
function forward(level) {
|
|
1330
|
+
return (objOrMsg, msg) => {
|
|
1331
|
+
const active = resolve();
|
|
1332
|
+
active[level](objOrMsg instanceof Error ? { err: objOrMsg } : objOrMsg, msg);
|
|
1333
|
+
};
|
|
1334
|
+
}
|
|
1335
|
+
return {
|
|
1336
|
+
trace: forward("trace"),
|
|
1337
|
+
debug: forward("debug"),
|
|
1338
|
+
info: forward("info"),
|
|
1339
|
+
success: forward("success"),
|
|
1340
|
+
warn: forward("warn"),
|
|
1341
|
+
error: forward("error"),
|
|
1342
|
+
fatal: forward("fatal"),
|
|
1343
|
+
child: (additionalBindings) => createProxy({ ...bindings, ...additionalBindings }),
|
|
1344
|
+
isLevelEnabled: (level) => resolve().isLevelEnabled(level)
|
|
1345
|
+
};
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
// src/index.ts
|
|
1349
|
+
init_context_browser();
|
|
1350
|
+
|
|
1351
|
+
// src/trace.ts
|
|
1352
|
+
init_context_browser();
|
|
1353
|
+
init_context_browser();
|
|
1354
|
+
var TRACE_HEADER = "x-trace-id";
|
|
1355
|
+
var VALID_TRACE_ID = /^[A-Za-z0-9-]{8,64}$/;
|
|
1356
|
+
function isHeaders(headers) {
|
|
1357
|
+
return typeof headers.get === "function";
|
|
1358
|
+
}
|
|
1359
|
+
function resolveTraceId(headers) {
|
|
1360
|
+
const id = isHeaders(headers) ? headers.get(TRACE_HEADER) : headers[TRACE_HEADER];
|
|
1361
|
+
return id && VALID_TRACE_ID.test(id) ? id : newTraceId();
|
|
1362
|
+
}
|
|
1363
|
+
function traceHeaders() {
|
|
1364
|
+
const { traceId } = getLogContext();
|
|
1365
|
+
return typeof traceId === "string" && traceId ? { [TRACE_HEADER]: traceId } : {};
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
// src/index.ts
|
|
1369
|
+
var logger = createProxy();
|
|
1370
|
+
var index_default = logger;
|
|
1371
|
+
export {
|
|
1372
|
+
DEFAULT_REDACT_PATHS,
|
|
1373
|
+
TRACE_HEADER,
|
|
1374
|
+
configureLogger,
|
|
1375
|
+
index_default as default,
|
|
1376
|
+
getLogContext,
|
|
1377
|
+
getPayloadLoggerConfig,
|
|
1378
|
+
logger,
|
|
1379
|
+
resolveTraceId,
|
|
1380
|
+
traceHeaders,
|
|
1381
|
+
withLogContext
|
|
1382
|
+
};
|
|
1383
|
+
//# sourceMappingURL=index.browser.mjs.map
|