fix: align rolling logs to local time

This commit is contained in:
Peter Steinberger
2026-01-22 06:53:56 +00:00
parent b91e72824f
commit d19a0249f8
7 changed files with 103 additions and 3 deletions

View File

@@ -70,7 +70,7 @@ describe("logger helpers", () => {
it("uses daily rolling default log file and prunes old ones", () => {
resetLogger();
setLoggerOverride({}); // force defaults regardless of user config
const today = new Date().toISOString().slice(0, 10);
const today = localDateString(new Date());
const todayPath = path.join(DEFAULT_LOG_DIR, `clawdbot-${today}.log`);
// create an old file to be pruned
@@ -103,3 +103,10 @@ function cleanup(file: string) {
// ignore
}
}
function localDateString(date: Date) {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, "0");
const day = String(date.getDate()).padStart(2, "0");
return `${year}-${month}-${day}`;
}