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
@@ -5,6 +5,7 @@ import {
syncStripeSubscriptionToUser,
} from '@/lib/billing';
import { getStripe, getStripeWebhookSecret } from '@/lib/stripe';
import { logError } from '@/lib/logger';
export const runtime = 'nodejs';
@@ -42,7 +43,7 @@ export async function POST(request: NextRequest) {
const body = await request.text();
event = stripe.webhooks.constructEvent(body, signature, getStripeWebhookSecret());
} catch (error) {
console.error('Failed to verify Stripe webhook:', error);
logError('Failed to verify Stripe webhook:', error);
return new Response('Invalid webhook signature', { status: 400 });
}
@@ -82,7 +83,7 @@ export async function POST(request: NextRequest) {
headers: { 'Content-Type': 'application/json' },
});
} catch (error) {
console.error('Failed to process Stripe webhook:', error);
logError('Failed to process Stripe webhook:', error);
return new Response('Webhook processing failed', { status: 500 });
}
}