@graphql-hive/logger 1.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/dist/index.cjs ADDED
@@ -0,0 +1,747 @@
1
+ 'use strict';
2
+
3
+ function getDefaultExportFromCjs (x) {
4
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
5
+ }
6
+
7
+ function tryStringify (o) {
8
+ try { return JSON.stringify(o) } catch(e) { return '"[Circular]"' }
9
+ }
10
+
11
+ var quickFormatUnescaped = format;
12
+
13
+ function format(f, args, opts) {
14
+ var ss = (opts && opts.stringify) || tryStringify;
15
+ var offset = 1;
16
+ if (typeof f === 'object' && f !== null) {
17
+ var len = args.length + offset;
18
+ if (len === 1) return f
19
+ var objects = new Array(len);
20
+ objects[0] = ss(f);
21
+ for (var index = 1; index < len; index++) {
22
+ objects[index] = ss(args[index]);
23
+ }
24
+ return objects.join(' ')
25
+ }
26
+ if (typeof f !== 'string') {
27
+ return f
28
+ }
29
+ var argLen = args.length;
30
+ if (argLen === 0) return f
31
+ var str = '';
32
+ var a = 1 - offset;
33
+ var lastPos = -1;
34
+ var flen = (f && f.length) || 0;
35
+ for (var i = 0; i < flen;) {
36
+ if (f.charCodeAt(i) === 37 && i + 1 < flen) {
37
+ lastPos = lastPos > -1 ? lastPos : 0;
38
+ switch (f.charCodeAt(i + 1)) {
39
+ case 100: // 'd'
40
+ case 102: // 'f'
41
+ if (a >= argLen)
42
+ break
43
+ if (args[a] == null) break
44
+ if (lastPos < i)
45
+ str += f.slice(lastPos, i);
46
+ str += Number(args[a]);
47
+ lastPos = i + 2;
48
+ i++;
49
+ break
50
+ case 105: // 'i'
51
+ if (a >= argLen)
52
+ break
53
+ if (args[a] == null) break
54
+ if (lastPos < i)
55
+ str += f.slice(lastPos, i);
56
+ str += Math.floor(Number(args[a]));
57
+ lastPos = i + 2;
58
+ i++;
59
+ break
60
+ case 79: // 'O'
61
+ case 111: // 'o'
62
+ case 106: // 'j'
63
+ if (a >= argLen)
64
+ break
65
+ if (args[a] === undefined) break
66
+ if (lastPos < i)
67
+ str += f.slice(lastPos, i);
68
+ var type = typeof args[a];
69
+ if (type === 'string') {
70
+ str += '\'' + args[a] + '\'';
71
+ lastPos = i + 2;
72
+ i++;
73
+ break
74
+ }
75
+ if (type === 'function') {
76
+ str += args[a].name || '<anonymous>';
77
+ lastPos = i + 2;
78
+ i++;
79
+ break
80
+ }
81
+ str += ss(args[a]);
82
+ lastPos = i + 2;
83
+ i++;
84
+ break
85
+ case 115: // 's'
86
+ if (a >= argLen)
87
+ break
88
+ if (lastPos < i)
89
+ str += f.slice(lastPos, i);
90
+ str += String(args[a]);
91
+ lastPos = i + 2;
92
+ i++;
93
+ break
94
+ case 37: // '%'
95
+ if (lastPos < i)
96
+ str += f.slice(lastPos, i);
97
+ str += '%';
98
+ lastPos = i + 2;
99
+ i++;
100
+ a--;
101
+ break
102
+ }
103
+ ++a;
104
+ }
105
+ ++i;
106
+ }
107
+ if (lastPos === -1)
108
+ return f
109
+ else if (lastPos < flen) {
110
+ str += f.slice(lastPos);
111
+ }
112
+
113
+ return str
114
+ }
115
+
116
+ var format$1 = /*@__PURE__*/getDefaultExportFromCjs(quickFormatUnescaped);
117
+
118
+ var fastSafeStringify = stringify;
119
+ stringify.default = stringify;
120
+ stringify.stable = deterministicStringify;
121
+ stringify.stableStringify = deterministicStringify;
122
+
123
+ var LIMIT_REPLACE_NODE = '[...]';
124
+ var CIRCULAR_REPLACE_NODE = '[Circular]';
125
+
126
+ var arr = [];
127
+ var replacerStack = [];
128
+
129
+ function defaultOptions () {
130
+ return {
131
+ depthLimit: Number.MAX_SAFE_INTEGER,
132
+ edgesLimit: Number.MAX_SAFE_INTEGER
133
+ }
134
+ }
135
+
136
+ // Regular stringify
137
+ function stringify (obj, replacer, spacer, options) {
138
+ if (typeof options === 'undefined') {
139
+ options = defaultOptions();
140
+ }
141
+
142
+ decirc(obj, '', 0, [], undefined, 0, options);
143
+ var res;
144
+ try {
145
+ if (replacerStack.length === 0) {
146
+ res = JSON.stringify(obj, replacer, spacer);
147
+ } else {
148
+ res = JSON.stringify(obj, replaceGetterValues(replacer), spacer);
149
+ }
150
+ } catch (_) {
151
+ return JSON.stringify('[unable to serialize, circular reference is too complex to analyze]')
152
+ } finally {
153
+ while (arr.length !== 0) {
154
+ var part = arr.pop();
155
+ if (part.length === 4) {
156
+ Object.defineProperty(part[0], part[1], part[3]);
157
+ } else {
158
+ part[0][part[1]] = part[2];
159
+ }
160
+ }
161
+ }
162
+ return res
163
+ }
164
+
165
+ function setReplace (replace, val, k, parent) {
166
+ var propertyDescriptor = Object.getOwnPropertyDescriptor(parent, k);
167
+ if (propertyDescriptor.get !== undefined) {
168
+ if (propertyDescriptor.configurable) {
169
+ Object.defineProperty(parent, k, { value: replace });
170
+ arr.push([parent, k, val, propertyDescriptor]);
171
+ } else {
172
+ replacerStack.push([val, k, replace]);
173
+ }
174
+ } else {
175
+ parent[k] = replace;
176
+ arr.push([parent, k, val]);
177
+ }
178
+ }
179
+
180
+ function decirc (val, k, edgeIndex, stack, parent, depth, options) {
181
+ depth += 1;
182
+ var i;
183
+ if (typeof val === 'object' && val !== null) {
184
+ for (i = 0; i < stack.length; i++) {
185
+ if (stack[i] === val) {
186
+ setReplace(CIRCULAR_REPLACE_NODE, val, k, parent);
187
+ return
188
+ }
189
+ }
190
+
191
+ if (
192
+ typeof options.depthLimit !== 'undefined' &&
193
+ depth > options.depthLimit
194
+ ) {
195
+ setReplace(LIMIT_REPLACE_NODE, val, k, parent);
196
+ return
197
+ }
198
+
199
+ if (
200
+ typeof options.edgesLimit !== 'undefined' &&
201
+ edgeIndex + 1 > options.edgesLimit
202
+ ) {
203
+ setReplace(LIMIT_REPLACE_NODE, val, k, parent);
204
+ return
205
+ }
206
+
207
+ stack.push(val);
208
+ // Optimize for Arrays. Big arrays could kill the performance otherwise!
209
+ if (Array.isArray(val)) {
210
+ for (i = 0; i < val.length; i++) {
211
+ decirc(val[i], i, i, stack, val, depth, options);
212
+ }
213
+ } else {
214
+ var keys = Object.keys(val);
215
+ for (i = 0; i < keys.length; i++) {
216
+ var key = keys[i];
217
+ decirc(val[key], key, i, stack, val, depth, options);
218
+ }
219
+ }
220
+ stack.pop();
221
+ }
222
+ }
223
+
224
+ // Stable-stringify
225
+ function compareFunction (a, b) {
226
+ if (a < b) {
227
+ return -1
228
+ }
229
+ if (a > b) {
230
+ return 1
231
+ }
232
+ return 0
233
+ }
234
+
235
+ function deterministicStringify (obj, replacer, spacer, options) {
236
+ if (typeof options === 'undefined') {
237
+ options = defaultOptions();
238
+ }
239
+
240
+ var tmp = deterministicDecirc(obj, '', 0, [], undefined, 0, options) || obj;
241
+ var res;
242
+ try {
243
+ if (replacerStack.length === 0) {
244
+ res = JSON.stringify(tmp, replacer, spacer);
245
+ } else {
246
+ res = JSON.stringify(tmp, replaceGetterValues(replacer), spacer);
247
+ }
248
+ } catch (_) {
249
+ return JSON.stringify('[unable to serialize, circular reference is too complex to analyze]')
250
+ } finally {
251
+ // Ensure that we restore the object as it was.
252
+ while (arr.length !== 0) {
253
+ var part = arr.pop();
254
+ if (part.length === 4) {
255
+ Object.defineProperty(part[0], part[1], part[3]);
256
+ } else {
257
+ part[0][part[1]] = part[2];
258
+ }
259
+ }
260
+ }
261
+ return res
262
+ }
263
+
264
+ function deterministicDecirc (val, k, edgeIndex, stack, parent, depth, options) {
265
+ depth += 1;
266
+ var i;
267
+ if (typeof val === 'object' && val !== null) {
268
+ for (i = 0; i < stack.length; i++) {
269
+ if (stack[i] === val) {
270
+ setReplace(CIRCULAR_REPLACE_NODE, val, k, parent);
271
+ return
272
+ }
273
+ }
274
+ try {
275
+ if (typeof val.toJSON === 'function') {
276
+ return
277
+ }
278
+ } catch (_) {
279
+ return
280
+ }
281
+
282
+ if (
283
+ typeof options.depthLimit !== 'undefined' &&
284
+ depth > options.depthLimit
285
+ ) {
286
+ setReplace(LIMIT_REPLACE_NODE, val, k, parent);
287
+ return
288
+ }
289
+
290
+ if (
291
+ typeof options.edgesLimit !== 'undefined' &&
292
+ edgeIndex + 1 > options.edgesLimit
293
+ ) {
294
+ setReplace(LIMIT_REPLACE_NODE, val, k, parent);
295
+ return
296
+ }
297
+
298
+ stack.push(val);
299
+ // Optimize for Arrays. Big arrays could kill the performance otherwise!
300
+ if (Array.isArray(val)) {
301
+ for (i = 0; i < val.length; i++) {
302
+ deterministicDecirc(val[i], i, i, stack, val, depth, options);
303
+ }
304
+ } else {
305
+ // Create a temporary object in the required way
306
+ var tmp = {};
307
+ var keys = Object.keys(val).sort(compareFunction);
308
+ for (i = 0; i < keys.length; i++) {
309
+ var key = keys[i];
310
+ deterministicDecirc(val[key], key, i, stack, val, depth, options);
311
+ tmp[key] = val[key];
312
+ }
313
+ if (typeof parent !== 'undefined') {
314
+ arr.push([parent, k, val]);
315
+ parent[k] = tmp;
316
+ } else {
317
+ return tmp
318
+ }
319
+ }
320
+ stack.pop();
321
+ }
322
+ }
323
+
324
+ // wraps replacer function to handle values we couldn't replace
325
+ // and mark them as replaced value
326
+ function replaceGetterValues (replacer) {
327
+ replacer =
328
+ typeof replacer !== 'undefined'
329
+ ? replacer
330
+ : function (k, v) {
331
+ return v
332
+ };
333
+ return function (key, val) {
334
+ if (replacerStack.length > 0) {
335
+ for (var i = 0; i < replacerStack.length; i++) {
336
+ var part = replacerStack[i];
337
+ if (part[1] === key && part[0] === val) {
338
+ val = part[2];
339
+ replacerStack.splice(i, 1);
340
+ break
341
+ }
342
+ }
343
+ }
344
+ return replacer.call(this, key, val)
345
+ }
346
+ }
347
+
348
+ var fastSafeStringify$1 = /*@__PURE__*/getDefaultExportFromCjs(fastSafeStringify);
349
+
350
+ const logLevel = {
351
+ trace: 0,
352
+ debug: 1,
353
+ info: 2,
354
+ warn: 3,
355
+ error: 4
356
+ };
357
+ function shouldLog(setLevel, loggingLevel) {
358
+ return setLevel !== false && // logging is not disabled
359
+ logLevel[setLevel] <= logLevel[loggingLevel];
360
+ }
361
+ function logLevelToString(level) {
362
+ switch (level) {
363
+ case "trace":
364
+ return "TRC";
365
+ case "debug":
366
+ return "DBG";
367
+ case "info":
368
+ return "INF";
369
+ case "warn":
370
+ return "WRN";
371
+ case "error":
372
+ return "ERR";
373
+ default:
374
+ throw new Error(`Unknown log level "${level}"`);
375
+ }
376
+ }
377
+ function isPromise(val) {
378
+ const obj = Object(val);
379
+ return typeof obj.then === "function" && typeof obj.catch === "function" && typeof obj.finally === "function";
380
+ }
381
+ function jsonStringify(val, pretty) {
382
+ return fastSafeStringify$1(
383
+ val,
384
+ (_key, val2) => {
385
+ if (val2 instanceof Error) {
386
+ return objectifyError(val2);
387
+ }
388
+ return val2;
389
+ },
390
+ pretty ? 2 : void 0
391
+ );
392
+ }
393
+ function parseAttrs(attrs, depth = 0) {
394
+ if (depth > 10) {
395
+ throw new Error("Too much recursion while unwrapping function attributes");
396
+ }
397
+ if (typeof attrs === "function") {
398
+ return parseAttrs(attrs(), depth + 1);
399
+ }
400
+ if (Array.isArray(attrs)) {
401
+ return attrs.map((val) => unwrapAttrVal(val, depth + 1));
402
+ }
403
+ if (Object.prototype.toString.call(attrs) === "[object Object]") {
404
+ const unwrapped = {};
405
+ for (const key of Object.keys(attrs)) {
406
+ const val = attrs[key];
407
+ unwrapped[key] = unwrapAttrVal(val, depth + 1);
408
+ }
409
+ return unwrapped;
410
+ }
411
+ return objectifyClass(attrs);
412
+ }
413
+ function unwrapAttrVal(attr, depth = 0) {
414
+ if (depth > 10) {
415
+ throw new Error(
416
+ "Too much recursion while unwrapping function attribute values"
417
+ );
418
+ }
419
+ if (!attr) {
420
+ return attr;
421
+ }
422
+ if (isPrimitive(attr)) {
423
+ return attr;
424
+ }
425
+ if (typeof attr === "function") {
426
+ return unwrapAttrVal(attr(), depth + 1);
427
+ }
428
+ if (Array.isArray(attr)) {
429
+ return attr.map((val) => unwrapAttrVal(val, depth + 1));
430
+ }
431
+ if (Object.prototype.toString.call(attr) === "[object Object]") {
432
+ const unwrapped = {};
433
+ for (const key of Object.keys(attr)) {
434
+ const val = attr[key];
435
+ unwrapped[key] = unwrapAttrVal(val, depth + 1);
436
+ }
437
+ return unwrapped;
438
+ }
439
+ return objectifyClass(attr);
440
+ }
441
+ function isPrimitive(val) {
442
+ return val !== Object(val);
443
+ }
444
+ function objectifyClass(val) {
445
+ if (!val) {
446
+ return {};
447
+ }
448
+ const props = {};
449
+ for (const propName of Object.getOwnPropertyNames(val)) {
450
+ props[propName] = val[propName];
451
+ }
452
+ for (const protoPropName of Object.getOwnPropertyNames(
453
+ Object.getPrototypeOf(val)
454
+ )) {
455
+ const propVal = val[protoPropName];
456
+ if (typeof propVal === "function") {
457
+ continue;
458
+ }
459
+ props[protoPropName] = propVal;
460
+ }
461
+ return {
462
+ ...props,
463
+ class: val.constructor.name
464
+ };
465
+ }
466
+ function objectifyError(err) {
467
+ return objectifyClass(err);
468
+ }
469
+ function getEnv(key) {
470
+ return globalThis.process?.env?.[key] || // @ts-expect-error can exist in wrangler and maybe other runtimes
471
+ globalThis.env?.[key] || // @ts-expect-error can exist in deno
472
+ globalThis.Deno?.env?.get(key) || // @ts-expect-error could be
473
+ globalThis[key];
474
+ }
475
+ function truthyEnv(key) {
476
+ return ["1", "t", "true", "y", "yes"].includes(
477
+ getEnv(key)?.toLowerCase() || ""
478
+ );
479
+ }
480
+
481
+ class MemoryLogWriter {
482
+ logs = [];
483
+ write(level, attrs, msg) {
484
+ this.logs.push({
485
+ level,
486
+ ...msg ? { msg } : {},
487
+ ...attrs ? { attrs } : {}
488
+ });
489
+ }
490
+ flush() {
491
+ }
492
+ }
493
+ const asciMap = {
494
+ timestamp: "\x1B[90m",
495
+ // bright black
496
+ trace: "\x1B[36m",
497
+ // cyan
498
+ debug: "\x1B[90m",
499
+ // bright black
500
+ info: "\x1B[32m",
501
+ // green
502
+ warn: "\x1B[33m",
503
+ // yellow
504
+ error: "\x1B[41;39m",
505
+ // red; white
506
+ message: "\x1B[1m",
507
+ // bold
508
+ reset: "\x1B[0m"
509
+ // reset
510
+ };
511
+ class ConsoleLogWriter {
512
+ #nocolor = (
513
+ // no color if we're running in browser-like (edge) environments
514
+ // TODO: is this the most accurate way to detect it?
515
+ typeof process === "undefined" || // no color if https://no-color.org/
516
+ truthyEnv("NO_COLOR")
517
+ );
518
+ color(style, text) {
519
+ if (!text) {
520
+ return text;
521
+ }
522
+ if (this.#nocolor) {
523
+ return text;
524
+ }
525
+ return asciMap[style] + text + asciMap.reset;
526
+ }
527
+ write(level, attrs, msg) {
528
+ console[level === "trace" ? "debug" : level](
529
+ [
530
+ this.color("timestamp", (/* @__PURE__ */ new Date()).toISOString()),
531
+ this.color(level, logLevelToString(level)),
532
+ this.color("message", msg),
533
+ // we want to stringify because we want all properties (even nested ones)be properly displayed
534
+ attrs ? jsonStringify(attrs, truthyEnv("LOG_JSON_PRETTY")) : void 0
535
+ ].join(" ")
536
+ );
537
+ }
538
+ flush() {
539
+ }
540
+ }
541
+ class JSONLogWriter {
542
+ write(level, attrs, msg) {
543
+ console.log(
544
+ jsonStringify(
545
+ {
546
+ ...attrs,
547
+ level,
548
+ ...msg ? { msg } : {},
549
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
550
+ },
551
+ truthyEnv("LOG_JSON_PRETTY")
552
+ )
553
+ );
554
+ }
555
+ flush() {
556
+ }
557
+ }
558
+
559
+ class Logger {
560
+ #level;
561
+ #prefix;
562
+ #attrs;
563
+ #writers;
564
+ #pendingWrites = /* @__PURE__ */ new Set();
565
+ constructor(opts = {}) {
566
+ let logLevelEnv = getEnv("LOG_LEVEL");
567
+ if (logLevelEnv && !(logLevelEnv in logLevel)) {
568
+ throw new Error(
569
+ `Invalid LOG_LEVEL environment variable "${logLevelEnv}". Must be one of: ${[...Object.keys(logLevel), "false"].join(", ")}`
570
+ );
571
+ }
572
+ this.#level = opts.level ?? logLevelEnv ?? (truthyEnv("DEBUG") ? "debug" : "info");
573
+ this.#prefix = opts.prefix;
574
+ this.#attrs = opts.attrs;
575
+ this.#writers = opts.writers ?? [new ConsoleLogWriter()];
576
+ }
577
+ get prefix() {
578
+ return this.#prefix;
579
+ }
580
+ get level() {
581
+ return this.#level;
582
+ }
583
+ write(level, attrs, msg) {
584
+ const pendingWrites = this.#writers.map((writer) => writer.write(level, attrs, msg)).filter(isPromise);
585
+ for (const pendingWrite of pendingWrites) {
586
+ this.#pendingWrites.add(pendingWrite);
587
+ pendingWrite.catch(() => {
588
+ });
589
+ pendingWrite.finally(() => this.#pendingWrites.delete(pendingWrite));
590
+ }
591
+ }
592
+ flush() {
593
+ if (this.#pendingWrites.size) {
594
+ return Promise.all(this.#pendingWrites).then(() => {
595
+ });
596
+ }
597
+ return;
598
+ }
599
+ child(prefixOrAttrs, prefix) {
600
+ if (typeof prefixOrAttrs === "string") {
601
+ return new Logger({
602
+ level: this.#level,
603
+ prefix: (this.#prefix || "") + prefixOrAttrs,
604
+ attrs: this.#attrs,
605
+ writers: this.#writers
606
+ });
607
+ }
608
+ return new Logger({
609
+ level: this.#level,
610
+ prefix: (this.#prefix || "") + (prefix || "") || void 0,
611
+ attrs: { ...this.#attrs, ...prefixOrAttrs },
612
+ writers: this.#writers
613
+ });
614
+ }
615
+ log(level, maybeAttrsOrMsg, ...rest) {
616
+ if (!shouldLog(this.#level, level)) {
617
+ return;
618
+ }
619
+ let msg;
620
+ let attrs;
621
+ if (typeof maybeAttrsOrMsg === "string") {
622
+ msg = maybeAttrsOrMsg;
623
+ } else if (maybeAttrsOrMsg) {
624
+ attrs = maybeAttrsOrMsg;
625
+ if (typeof rest[0] === "string") {
626
+ msg = rest.shift();
627
+ }
628
+ }
629
+ if (this.#prefix) {
630
+ msg = `${this.#prefix}${msg || ""}`.trim();
631
+ }
632
+ attrs = attrs ? parseAttrs(attrs) : attrs;
633
+ attrs = this.#attrs ? { ...parseAttrs(this.#attrs), ...attrs } : attrs;
634
+ msg = msg ? format$1(msg, rest) : msg;
635
+ this.write(level, attrs, msg);
636
+ if (truthyEnv("LOG_TRACE_LOGS")) {
637
+ console.trace("\u{1F446}");
638
+ }
639
+ }
640
+ trace(...args) {
641
+ this.log(
642
+ "trace",
643
+ ...args
644
+ );
645
+ }
646
+ debug(...args) {
647
+ this.log(
648
+ "debug",
649
+ ...args
650
+ );
651
+ }
652
+ info(...args) {
653
+ this.log(
654
+ "info",
655
+ ...args
656
+ );
657
+ }
658
+ warn(...args) {
659
+ this.log(
660
+ "warn",
661
+ ...args
662
+ );
663
+ }
664
+ error(...args) {
665
+ this.log(
666
+ "error",
667
+ ...args
668
+ );
669
+ }
670
+ }
671
+
672
+ class LegacyLogger {
673
+ #logger;
674
+ constructor(logger) {
675
+ this.#logger = logger;
676
+ }
677
+ static from(logger) {
678
+ return new LegacyLogger(logger);
679
+ }
680
+ #log(level, ...[maybeMsgOrArg, ...restArgs]) {
681
+ if (typeof maybeMsgOrArg === "string") {
682
+ this.#logger.log(level, restArgs, maybeMsgOrArg);
683
+ } else {
684
+ if (restArgs.length) {
685
+ this.#logger.log(level, [maybeMsgOrArg, ...restArgs]);
686
+ } else {
687
+ this.#logger.log(level, maybeMsgOrArg);
688
+ }
689
+ }
690
+ }
691
+ log(...args) {
692
+ this.#log("info", ...args);
693
+ }
694
+ warn(...args) {
695
+ this.#log("warn", ...args);
696
+ }
697
+ info(...args) {
698
+ this.#log("info", ...args);
699
+ }
700
+ error(...args) {
701
+ this.#log("error", ...args);
702
+ }
703
+ debug(...lazyArgs) {
704
+ if (!shouldLog(this.#logger.level, "debug")) {
705
+ return;
706
+ }
707
+ this.#log("debug", ...handleLazyMessage(lazyArgs));
708
+ }
709
+ child(name) {
710
+ name = stringifyName(name);
711
+ if (this.#logger.prefix?.includes(name)) {
712
+ return this;
713
+ }
714
+ return LegacyLogger.from(this.#logger.child(name));
715
+ }
716
+ addPrefix(prefix) {
717
+ prefix = stringifyName(prefix);
718
+ if (this.#logger.prefix?.includes(prefix)) {
719
+ return this;
720
+ }
721
+ return LegacyLogger.from(this.#logger.child(prefix));
722
+ }
723
+ }
724
+ function stringifyName(name) {
725
+ if (typeof name === "string" || typeof name === "number") {
726
+ return `${name}`;
727
+ }
728
+ const names = [];
729
+ for (const [key, value] of Object.entries(name)) {
730
+ names.push(`${key}=${value}`);
731
+ }
732
+ return `${names.join(", ")}`;
733
+ }
734
+ function handleLazyMessage(lazyArgs) {
735
+ return lazyArgs.flat(Infinity).flatMap((arg) => {
736
+ if (typeof arg === "function") {
737
+ return arg();
738
+ }
739
+ return arg;
740
+ });
741
+ }
742
+
743
+ exports.ConsoleLogWriter = ConsoleLogWriter;
744
+ exports.JSONLogWriter = JSONLogWriter;
745
+ exports.LegacyLogger = LegacyLogger;
746
+ exports.Logger = Logger;
747
+ exports.MemoryLogWriter = MemoryLogWriter;