mirror of
https://github.com/openclaw/openclaw.git
synced 2026-02-19 18:39:20 -05:00
perf(test): fold console prefix tests into logger suite
This commit is contained in:
@@ -6,7 +6,12 @@ import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import type { RuntimeEnv } from "./runtime.js";
|
||||
import { isVerbose, isYes, logVerbose, setVerbose, setYes } from "./globals.js";
|
||||
import { logDebug, logError, logInfo, logSuccess, logWarn } from "./logger.js";
|
||||
import { DEFAULT_LOG_DIR, resetLogger, setLoggerOverride } from "./logging.js";
|
||||
import {
|
||||
DEFAULT_LOG_DIR,
|
||||
resetLogger,
|
||||
setLoggerOverride,
|
||||
stripRedundantSubsystemPrefixForConsole,
|
||||
} from "./logging.js";
|
||||
|
||||
describe("logger helpers", () => {
|
||||
afterEach(() => {
|
||||
@@ -116,6 +121,34 @@ describe("globals", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("stripRedundantSubsystemPrefixForConsole", () => {
|
||||
it("drops '<subsystem>:' prefix", () => {
|
||||
expect(stripRedundantSubsystemPrefixForConsole("discord: hello", "discord")).toBe("hello");
|
||||
});
|
||||
|
||||
it("drops '<Subsystem>:' prefix case-insensitively", () => {
|
||||
expect(stripRedundantSubsystemPrefixForConsole("WhatsApp: hello", "whatsapp")).toBe("hello");
|
||||
});
|
||||
|
||||
it("drops '<subsystem> ' prefix", () => {
|
||||
expect(stripRedundantSubsystemPrefixForConsole("discord gateway: closed", "discord")).toBe(
|
||||
"gateway: closed",
|
||||
);
|
||||
});
|
||||
|
||||
it("drops '[subsystem]' prefix", () => {
|
||||
expect(stripRedundantSubsystemPrefixForConsole("[discord] connection stalled", "discord")).toBe(
|
||||
"connection stalled",
|
||||
);
|
||||
});
|
||||
|
||||
it("keeps messages that do not start with the subsystem", () => {
|
||||
expect(stripRedundantSubsystemPrefixForConsole("discordant: hello", "discord")).toBe(
|
||||
"discordant: hello",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
function pathForTest() {
|
||||
const file = path.join(os.tmpdir(), `openclaw-log-${crypto.randomUUID()}.log`);
|
||||
fs.mkdirSync(path.dirname(file), { recursive: true });
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { stripRedundantSubsystemPrefixForConsole } from "../logging.js";
|
||||
|
||||
describe("stripRedundantSubsystemPrefixForConsole", () => {
|
||||
it("drops '<subsystem>:' prefix", () => {
|
||||
expect(stripRedundantSubsystemPrefixForConsole("discord: hello", "discord")).toBe("hello");
|
||||
});
|
||||
|
||||
it("drops '<Subsystem>:' prefix case-insensitively", () => {
|
||||
expect(stripRedundantSubsystemPrefixForConsole("WhatsApp: hello", "whatsapp")).toBe("hello");
|
||||
});
|
||||
|
||||
it("drops '<subsystem> ' prefix", () => {
|
||||
expect(stripRedundantSubsystemPrefixForConsole("discord gateway: closed", "discord")).toBe(
|
||||
"gateway: closed",
|
||||
);
|
||||
});
|
||||
|
||||
it("drops '[subsystem]' prefix", () => {
|
||||
expect(stripRedundantSubsystemPrefixForConsole("[discord] connection stalled", "discord")).toBe(
|
||||
"connection stalled",
|
||||
);
|
||||
});
|
||||
|
||||
it("keeps messages that do not start with the subsystem", () => {
|
||||
expect(stripRedundantSubsystemPrefixForConsole("discordant: hello", "discord")).toBe(
|
||||
"discordant: hello",
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user