@openhoo/hoopilot 2.1.7 → 2.1.8
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 +6 -0
- package/dist/cli.js +69 -2
- package/dist/cli.js.map +1 -1
- package/dist/index.js +69 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -379,6 +379,12 @@ Console logs default to pretty output at `info` level:
|
|
|
379
379
|
hoopilot --log-level info --log-format pretty
|
|
380
380
|
```
|
|
381
381
|
|
|
382
|
+
Pretty logs keep common request and diagnostic fields inline for terminal use:
|
|
383
|
+
|
|
384
|
+
```text
|
|
385
|
+
INFO [16:40:14]: request completed component=server event=http.request.completed method=POST path=/v1/chat/completions status=200 duration=42.37ms stream=true requestId=req-test
|
|
386
|
+
```
|
|
387
|
+
|
|
382
388
|
For newline-delimited JSON:
|
|
383
389
|
|
|
384
390
|
```sh
|
package/dist/cli.js
CHANGED
|
@@ -667,6 +667,32 @@ var DEFAULT_LOG_FORMAT = "pretty";
|
|
|
667
667
|
var DEFAULT_LOG_LEVEL = "info";
|
|
668
668
|
var LOG_FORMATS = ["json", "pretty"];
|
|
669
669
|
var LOG_LEVELS = ["trace", "debug", "info", "warn", "error", "fatal", "silent"];
|
|
670
|
+
var PRETTY_INLINE_FIELDS = [
|
|
671
|
+
"component",
|
|
672
|
+
"command",
|
|
673
|
+
"event",
|
|
674
|
+
"method",
|
|
675
|
+
"path",
|
|
676
|
+
"status",
|
|
677
|
+
"durationMs",
|
|
678
|
+
"stream",
|
|
679
|
+
"route",
|
|
680
|
+
"requestId",
|
|
681
|
+
"upstreamPath",
|
|
682
|
+
"upstreamStatus",
|
|
683
|
+
"url",
|
|
684
|
+
"baseUrl",
|
|
685
|
+
"origin",
|
|
686
|
+
"currentVersion",
|
|
687
|
+
"installKind",
|
|
688
|
+
"latestVersion",
|
|
689
|
+
"assetName",
|
|
690
|
+
"count",
|
|
691
|
+
"plan",
|
|
692
|
+
"apiBaseUrl",
|
|
693
|
+
"authStorePath"
|
|
694
|
+
];
|
|
695
|
+
var PRETTY_IGNORED_FIELDS = ["pid", "hostname", "service", ...PRETTY_INLINE_FIELDS];
|
|
670
696
|
var REDACT_PATHS = [
|
|
671
697
|
"apiKey",
|
|
672
698
|
"authorization",
|
|
@@ -730,9 +756,11 @@ function createHoopilotLogger(options = {}) {
|
|
|
730
756
|
// stream's TTY-ness is unknown, so default to no color there.
|
|
731
757
|
colorize: options.colorize ?? (options.stream ? false : process.stdout.isTTY),
|
|
732
758
|
destination: options.stream ?? 1,
|
|
733
|
-
ignore: "
|
|
759
|
+
ignore: PRETTY_IGNORED_FIELDS.join(","),
|
|
760
|
+
levelFirst: true,
|
|
761
|
+
messageFormat: formatPrettyMessage,
|
|
734
762
|
singleLine: true,
|
|
735
|
-
translateTime: "SYS:
|
|
763
|
+
translateTime: "SYS:HH:MM:ss"
|
|
736
764
|
})
|
|
737
765
|
)
|
|
738
766
|
);
|
|
@@ -778,6 +806,45 @@ function errorDetails(error) {
|
|
|
778
806
|
}
|
|
779
807
|
return { message: String(error) };
|
|
780
808
|
}
|
|
809
|
+
function formatPrettyMessage(log, messageKey) {
|
|
810
|
+
const message = formatPrettyLogMessage(log[messageKey]);
|
|
811
|
+
const fields = PRETTY_INLINE_FIELDS.flatMap((field) => {
|
|
812
|
+
const value = log[field];
|
|
813
|
+
if (value === void 0) {
|
|
814
|
+
return [];
|
|
815
|
+
}
|
|
816
|
+
return `${prettyFieldLabel(field)}=${formatPrettyFieldValue(field, value)}`;
|
|
817
|
+
});
|
|
818
|
+
return fields.length > 0 ? `${message} ${fields.join(" ")}` : message;
|
|
819
|
+
}
|
|
820
|
+
function formatPrettyLogMessage(value) {
|
|
821
|
+
return typeof value === "string" ? value : formatPrettyValue(value);
|
|
822
|
+
}
|
|
823
|
+
function prettyFieldLabel(field) {
|
|
824
|
+
return field === "durationMs" ? "duration" : field;
|
|
825
|
+
}
|
|
826
|
+
function formatPrettyFieldValue(field, value) {
|
|
827
|
+
const formatted = formatPrettyValue(value);
|
|
828
|
+
return field === "durationMs" && typeof value === "number" ? `${formatted}ms` : formatted;
|
|
829
|
+
}
|
|
830
|
+
function formatPrettyValue(value) {
|
|
831
|
+
if (typeof value === "number") {
|
|
832
|
+
return Number.isFinite(value) ? String(value) : JSON.stringify(value);
|
|
833
|
+
}
|
|
834
|
+
if (typeof value === "boolean") {
|
|
835
|
+
return String(value);
|
|
836
|
+
}
|
|
837
|
+
if (typeof value === "string") {
|
|
838
|
+
return isBarePrettyValue(value) ? value : JSON.stringify(value);
|
|
839
|
+
}
|
|
840
|
+
if (value === null) {
|
|
841
|
+
return "null";
|
|
842
|
+
}
|
|
843
|
+
return JSON.stringify(value) ?? String(value);
|
|
844
|
+
}
|
|
845
|
+
function isBarePrettyValue(value) {
|
|
846
|
+
return /^[A-Za-z0-9._~:/?#[\]@!$&'()*+,;=%-]+$/.test(value);
|
|
847
|
+
}
|
|
781
848
|
function isLogFormat(value) {
|
|
782
849
|
return LOG_FORMATS.includes(value);
|
|
783
850
|
}
|