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