fix: refactoring logs and adding pino logger for production and dev. (#236)

This commit is contained in:
Charles GTE
2026-03-29 11:22:28 +02:00
committed by GitHub
parent 057c192314
commit e1c0fc6917
24 changed files with 354 additions and 120 deletions
+5 -3
View File
@@ -2,6 +2,9 @@ import {db} from "@/db";
import {and, eq, isNotNull, isNull} from "drizzle-orm";
import * as drizzleDb from "@/db";
import {withUpdatedAt} from "@/db/utils";
import {logger} from "@/lib/logger";
const log = logger.child({module: "tasks/cleaning"});
export const backupCleanTask = async () => {
try {
@@ -11,8 +14,7 @@ export const backupCleanTask = async () => {
eq(drizzleDb.schemas.backup.status, "ongoing")
)
});
console.log(`Backups to clean: ${backups.length}`);
log.info(`Backups to clean: ${backups.length}`);
for (const backup of backups) {
await db.update(drizzleDb.schemas.backup).set(withUpdatedAt({
@@ -22,7 +24,7 @@ export const backupCleanTask = async () => {
}
} catch (e: any) {
console.error("Backup cleanup failed:", e);
log.info({name: "backupCleanTask", error: e},`Backup cleanup failed`);
throw e;
}
};