Refactor error logging across the application to use a centralized logger

- Introduced a new logger utility (`logError`) to standardize error logging.
- Replaced all instances of `console.error` with `logError` in various API routes and libraries.
- Enhanced error logging to sanitize sensitive information, particularly for Prisma and Stripe errors.
- Ensured consistent error handling and logging practices throughout the codebase.
This commit is contained in:
Yusuf İpek
2026-04-10 21:10:09 +03:00
parent 07f7b6fb02
commit 8014fc3986
60 changed files with 235 additions and 115 deletions
+3 -2
View File
@@ -2,6 +2,7 @@ import { DeleteObjectCommand, ListObjectsV2Command, type ListObjectsV2CommandInp
import { db, disconnectDb } from '../lib/db';
import { r2Client, R2_BUCKET_NAME } from '../lib/r2';
import { cleanupExpiredBillingWorkspaces } from './expired-billing-cleanup';
import { logError } from '@/lib/logger';
const UNATTACHED_UPLOAD_TTL_MS = 15 * 60 * 1000;
const CHUNK_SIZE = 500;
@@ -166,7 +167,7 @@ async function main() {
deleted += 1;
} catch (error) {
failed += 1;
console.error(`[r2-orphan-cleanup] Failed deleting ${candidate.key}:`, error);
logError(`[r2-orphan-cleanup] Failed deleting ${candidate.key}:`, error);
}
}
@@ -179,7 +180,7 @@ async function main() {
main()
.catch((error) => {
console.error('[r2-orphan-cleanup] Fatal error:', error);
logError('[r2-orphan-cleanup] Fatal error:', error);
process.exitCode = 1;
})
.finally(async () => {