mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-02 15:37:14 +00:00
logging: isolate test logs to /tmp/openclaw-test under vitest
This commit is contained in:
@@ -9,7 +9,18 @@ import { readLoggingConfig } from "./config.js";
|
|||||||
import { type LogLevel, levelToMinLevel, normalizeLogLevel } from "./levels.js";
|
import { type LogLevel, levelToMinLevel, normalizeLogLevel } from "./levels.js";
|
||||||
import { loggingState } from "./state.js";
|
import { loggingState } from "./state.js";
|
||||||
|
|
||||||
export const DEFAULT_LOG_DIR = resolvePreferredOpenClawTmpDir();
|
// When running under vitest, isolate logs to avoid polluting production logs.
|
||||||
|
function getDefaultLogDir(): string {
|
||||||
|
if (process.env.OPENCLAW_LOG_DIR) {
|
||||||
|
return process.env.OPENCLAW_LOG_DIR;
|
||||||
|
}
|
||||||
|
if (process.env.VITEST === "true") {
|
||||||
|
return "/tmp/openclaw-test";
|
||||||
|
}
|
||||||
|
return resolvePreferredOpenClawTmpDir();
|
||||||
|
}
|
||||||
|
|
||||||
|
export const DEFAULT_LOG_DIR = getDefaultLogDir();
|
||||||
export const DEFAULT_LOG_FILE = path.join(DEFAULT_LOG_DIR, "openclaw.log"); // legacy single-file path
|
export const DEFAULT_LOG_FILE = path.join(DEFAULT_LOG_DIR, "openclaw.log"); // legacy single-file path
|
||||||
|
|
||||||
const LOG_PREFIX = "openclaw";
|
const LOG_PREFIX = "openclaw";
|
||||||
|
|||||||
Reference in New Issue
Block a user