Add daily log rotation with monthly folder structure

All log output is now additionally written to daily log files:
  daily-logs/YYYY-MM/YYYY-MM-DD.log (main log)
  daily-logs/YYYY-MM/YYYY-MM-DD-rename.log (rename log)

Automatic cleanup of daily logs older than 30 days. The existing
rd_downloader.log and rename.log continue to work as before.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Sucukdeluxe
2026-03-24 09:16:24 +01:00
co-authored by Claude Opus 4.6
parent 1c78bb61c6
commit d7149829ea
3 changed files with 623 additions and 428 deletions
+4 -5
View File
@@ -1,5 +1,6 @@
import fs from "node:fs";
import path from "node:path";
import { writeToDailyRenameLog } from "./daily-log";
type RenameLogLevel = "INFO" | "WARN" | "ERROR";
@@ -93,11 +94,9 @@ export function logRenameEvent(level: RenameLogLevel, message: string, fields?:
if (!fs.existsSync(renameLogPath)) {
fs.writeFileSync(renameLogPath, "", "utf8");
}
fs.appendFileSync(
renameLogPath,
`${new Date().toISOString()} [${level}] ${message}${formatFields(fields)}\n`,
"utf8"
);
const line = `${new Date().toISOString()} [${level}] ${message}${formatFields(fields)}\n`;
fs.appendFileSync(renameLogPath, line, "utf8");
writeToDailyRenameLog(line);
} catch {
// ignore write errors
}