halua 1.0.0 → 1.1.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/lib/index.cjs +11 -2
- package/lib/index.d.cts +2 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +11 -2
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -315,7 +315,7 @@ var Halua = class _Halua {
|
|
|
315
315
|
}
|
|
316
316
|
};
|
|
317
317
|
|
|
318
|
-
// src/handlers/webConsoleUtils.ts
|
|
318
|
+
// src/handlers/WebConsoleHandler/webConsoleUtils.ts
|
|
319
319
|
function getColorKey(level) {
|
|
320
320
|
return {
|
|
321
321
|
["TRACE" /* Trace */]: "grey",
|
|
@@ -534,6 +534,9 @@ function replaceDataBeforeStringify(value) {
|
|
|
534
534
|
}
|
|
535
535
|
return obj;
|
|
536
536
|
}
|
|
537
|
+
if (value instanceof Error) {
|
|
538
|
+
return value.toString();
|
|
539
|
+
}
|
|
537
540
|
return value;
|
|
538
541
|
}
|
|
539
542
|
|
|
@@ -626,6 +629,9 @@ function stringifyValue(value, stringifier = JSON.stringify) {
|
|
|
626
629
|
if (value instanceof Set) {
|
|
627
630
|
return `Set[${Array.from(value)}]`;
|
|
628
631
|
}
|
|
632
|
+
if (value instanceof Error) {
|
|
633
|
+
return value.toString();
|
|
634
|
+
}
|
|
629
635
|
if (Array.isArray(value)) {
|
|
630
636
|
return `[${value}]`;
|
|
631
637
|
}
|
|
@@ -664,7 +670,10 @@ function NewTextHandler(send, options = {}) {
|
|
|
664
670
|
}
|
|
665
671
|
msg = removeTailingUndefinedValues(msg, log);
|
|
666
672
|
send(
|
|
667
|
-
msg.replace("%w", withArgs).replace("%a", args).replace("%l", log.level).replace(
|
|
673
|
+
msg.replace("%w", withArgs).replace("%a", args).replace("%l", log.level).replace(
|
|
674
|
+
"%t",
|
|
675
|
+
this.options.dateGetter?.(log.timestamp) ?? getPrettyDate(log.timestamp)
|
|
676
|
+
)
|
|
668
677
|
);
|
|
669
678
|
}
|
|
670
679
|
composeVariablesString(format, data) {
|
package/lib/index.d.cts
CHANGED
|
@@ -131,6 +131,8 @@ interface TextLogHandler extends Handler {
|
|
|
131
131
|
}
|
|
132
132
|
interface TextLogHandlerOptions {
|
|
133
133
|
linkArguments?: boolean;
|
|
134
|
+
dateGetter?: (t: number) => string;
|
|
135
|
+
/** @deprecated will be removed in version 2.0.0 */
|
|
134
136
|
messageFormat?: string;
|
|
135
137
|
/** replace value during stringify, return null to fallback on JSONHandler replacer */
|
|
136
138
|
replaceBeforeStringify?: (value: any) => any;
|
package/lib/index.d.ts
CHANGED
|
@@ -131,6 +131,8 @@ interface TextLogHandler extends Handler {
|
|
|
131
131
|
}
|
|
132
132
|
interface TextLogHandlerOptions {
|
|
133
133
|
linkArguments?: boolean;
|
|
134
|
+
dateGetter?: (t: number) => string;
|
|
135
|
+
/** @deprecated will be removed in version 2.0.0 */
|
|
134
136
|
messageFormat?: string;
|
|
135
137
|
/** replace value during stringify, return null to fallback on JSONHandler replacer */
|
|
136
138
|
replaceBeforeStringify?: (value: any) => any;
|
package/lib/index.js
CHANGED
|
@@ -285,7 +285,7 @@ var Halua = class _Halua {
|
|
|
285
285
|
}
|
|
286
286
|
};
|
|
287
287
|
|
|
288
|
-
// src/handlers/webConsoleUtils.ts
|
|
288
|
+
// src/handlers/WebConsoleHandler/webConsoleUtils.ts
|
|
289
289
|
function getColorKey(level) {
|
|
290
290
|
return {
|
|
291
291
|
["TRACE" /* Trace */]: "grey",
|
|
@@ -504,6 +504,9 @@ function replaceDataBeforeStringify(value) {
|
|
|
504
504
|
}
|
|
505
505
|
return obj;
|
|
506
506
|
}
|
|
507
|
+
if (value instanceof Error) {
|
|
508
|
+
return value.toString();
|
|
509
|
+
}
|
|
507
510
|
return value;
|
|
508
511
|
}
|
|
509
512
|
|
|
@@ -596,6 +599,9 @@ function stringifyValue(value, stringifier = JSON.stringify) {
|
|
|
596
599
|
if (value instanceof Set) {
|
|
597
600
|
return `Set[${Array.from(value)}]`;
|
|
598
601
|
}
|
|
602
|
+
if (value instanceof Error) {
|
|
603
|
+
return value.toString();
|
|
604
|
+
}
|
|
599
605
|
if (Array.isArray(value)) {
|
|
600
606
|
return `[${value}]`;
|
|
601
607
|
}
|
|
@@ -634,7 +640,10 @@ function NewTextHandler(send, options = {}) {
|
|
|
634
640
|
}
|
|
635
641
|
msg = removeTailingUndefinedValues(msg, log);
|
|
636
642
|
send(
|
|
637
|
-
msg.replace("%w", withArgs).replace("%a", args).replace("%l", log.level).replace(
|
|
643
|
+
msg.replace("%w", withArgs).replace("%a", args).replace("%l", log.level).replace(
|
|
644
|
+
"%t",
|
|
645
|
+
this.options.dateGetter?.(log.timestamp) ?? getPrettyDate(log.timestamp)
|
|
646
|
+
)
|
|
638
647
|
);
|
|
639
648
|
}
|
|
640
649
|
composeVariablesString(format, data) {
|