mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-17 04:01:05 +00:00
fix: list loaded plugins in gateway ready log
This commit is contained in:
@@ -19,7 +19,7 @@ describe("gateway startup log", () => {
|
||||
},
|
||||
},
|
||||
bindHost: "127.0.0.1",
|
||||
pluginCount: 0,
|
||||
loadedPluginIds: [],
|
||||
port: 18789,
|
||||
log: { info, warn },
|
||||
isNixMode: false,
|
||||
@@ -40,7 +40,7 @@ describe("gateway startup log", () => {
|
||||
logGatewayStartup({
|
||||
cfg: {},
|
||||
bindHost: "127.0.0.1",
|
||||
pluginCount: 0,
|
||||
loadedPluginIds: [],
|
||||
port: 18789,
|
||||
log: { info, warn },
|
||||
isNixMode: false,
|
||||
@@ -49,7 +49,7 @@ describe("gateway startup log", () => {
|
||||
expect(warn).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("logs a compact ready line with plugin count and duration", () => {
|
||||
it("logs a compact ready line with loaded plugin ids and duration", () => {
|
||||
vi.useFakeTimers();
|
||||
vi.setSystemTime(new Date("2026-04-03T10:00:16.000Z"));
|
||||
|
||||
@@ -60,7 +60,7 @@ describe("gateway startup log", () => {
|
||||
cfg: {},
|
||||
bindHost: "127.0.0.1",
|
||||
bindHosts: ["127.0.0.1", "::1"],
|
||||
pluginCount: 8,
|
||||
loadedPluginIds: ["delta", "alpha", "delta", "beta"],
|
||||
port: 18789,
|
||||
startupStartedAt: Date.parse("2026-04-03T10:00:00.000Z"),
|
||||
log: { info, warn },
|
||||
@@ -70,6 +70,6 @@ describe("gateway startup log", () => {
|
||||
const readyMessages = info.mock.calls
|
||||
.map((call) => call[0])
|
||||
.filter((message) => message.startsWith("ready ("));
|
||||
expect(readyMessages).toEqual(["ready (8 plugins, 16.0s)"]);
|
||||
expect(readyMessages).toEqual(["ready (3 plugins: alpha, beta, delta; 16.0s)"]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -10,7 +10,7 @@ export function logGatewayStartup(params: {
|
||||
bindHost: string;
|
||||
bindHosts?: string[];
|
||||
port: number;
|
||||
pluginCount: number;
|
||||
loadedPluginIds: readonly string[];
|
||||
startupStartedAt?: number;
|
||||
tlsEnabled?: boolean;
|
||||
log: { info: (msg: string, meta?: Record<string, unknown>) => void; warn: (msg: string) => void };
|
||||
@@ -29,9 +29,7 @@ export function logGatewayStartup(params: {
|
||||
typeof params.startupStartedAt === "number" ? Date.now() - params.startupStartedAt : null;
|
||||
const startupDurationLabel =
|
||||
startupDurationMs == null ? null : `${(startupDurationMs / 1000).toFixed(1)}s`;
|
||||
params.log.info(
|
||||
`ready (${params.pluginCount} ${params.pluginCount === 1 ? "plugin" : "plugins"}${startupDurationLabel ? `, ${startupDurationLabel}` : ""})`,
|
||||
);
|
||||
params.log.info(`ready (${formatReadyDetails(params.loadedPluginIds, startupDurationLabel)})`);
|
||||
params.log.info(`log file: ${getResolvedLoggerSettings().file}`);
|
||||
if (params.isNixMode) {
|
||||
params.log.info("gateway: running in Nix mode (config managed externally)");
|
||||
@@ -45,3 +43,23 @@ export function logGatewayStartup(params: {
|
||||
params.log.warn(warning);
|
||||
}
|
||||
}
|
||||
|
||||
function formatReadyDetails(
|
||||
loadedPluginIds: readonly string[],
|
||||
startupDurationLabel: string | null,
|
||||
) {
|
||||
const pluginIds = [...new Set(loadedPluginIds.map((id) => id.trim()).filter(Boolean))].toSorted(
|
||||
(a, b) => a.localeCompare(b),
|
||||
);
|
||||
const pluginSummary =
|
||||
pluginIds.length === 0
|
||||
? "0 plugins"
|
||||
: `${pluginIds.length} ${pluginIds.length === 1 ? "plugin" : "plugins"}: ${pluginIds.join(", ")}`;
|
||||
|
||||
if (!startupDurationLabel) {
|
||||
return pluginSummary;
|
||||
}
|
||||
return pluginIds.length === 0
|
||||
? `${pluginSummary}, ${startupDurationLabel}`
|
||||
: `${pluginSummary}; ${startupDurationLabel}`;
|
||||
}
|
||||
|
||||
@@ -127,7 +127,6 @@ describe("startGatewayPostAttachRuntime", () => {
|
||||
bindHosts: ["127.0.0.1"],
|
||||
port: 18789,
|
||||
tlsEnabled: false,
|
||||
pluginCount: 0,
|
||||
log: { info: vi.fn(), warn: vi.fn() },
|
||||
isNixMode: false,
|
||||
broadcast: vi.fn(),
|
||||
@@ -140,7 +139,14 @@ describe("startGatewayPostAttachRuntime", () => {
|
||||
error: vi.fn(),
|
||||
},
|
||||
gatewayPluginConfigAtStart: { hooks: { internal: { enabled: false } } } as never,
|
||||
pluginRegistry: { plugins: [] } as never,
|
||||
pluginRegistry: {
|
||||
plugins: [
|
||||
{ id: "beta", status: "loaded" },
|
||||
{ id: "alpha", status: "loaded" },
|
||||
{ id: "cold", status: "disabled" },
|
||||
{ id: "broken", status: "error" },
|
||||
],
|
||||
} as never,
|
||||
defaultWorkspaceDir: "/tmp/openclaw-workspace",
|
||||
deps: {} as never,
|
||||
startChannels: vi.fn(async () => undefined),
|
||||
@@ -159,5 +165,8 @@ describe("startGatewayPostAttachRuntime", () => {
|
||||
expect(unavailableGatewayMethods.has("chat.history")).toBe(false);
|
||||
expect(hoisted.startPluginServices).toHaveBeenCalledTimes(1);
|
||||
expect(hoisted.setInternalHooksEnabled).toHaveBeenCalledWith(false);
|
||||
expect(hoisted.logGatewayStartup).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ loadedPluginIds: ["beta", "alpha"] }),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -244,7 +244,6 @@ export async function startGatewayPostAttachRuntime(params: {
|
||||
bindHosts: string[];
|
||||
port: number;
|
||||
tlsEnabled: boolean;
|
||||
pluginCount: number;
|
||||
log: {
|
||||
info: (msg: string) => void;
|
||||
warn: (msg: string) => void;
|
||||
@@ -280,7 +279,9 @@ export async function startGatewayPostAttachRuntime(params: {
|
||||
bindHosts: params.bindHosts,
|
||||
port: params.port,
|
||||
tlsEnabled: params.tlsEnabled,
|
||||
pluginCount: params.pluginCount,
|
||||
loadedPluginIds: params.pluginRegistry.plugins
|
||||
.filter((plugin) => plugin.status === "loaded")
|
||||
.map((plugin) => plugin.id),
|
||||
log: params.log,
|
||||
isNixMode: params.isNixMode,
|
||||
startupStartedAt: params.startupStartedAt,
|
||||
|
||||
@@ -737,7 +737,6 @@ export async function startGatewayServer(
|
||||
bindHosts: httpBindHosts,
|
||||
port,
|
||||
tlsEnabled: gatewayTls.enabled,
|
||||
pluginCount: pluginRegistry.plugins.length,
|
||||
log,
|
||||
isNixMode,
|
||||
startupStartedAt: opts.startupStartedAt,
|
||||
|
||||
Reference in New Issue
Block a user