fix: enhance error logging by replacing console.error with a centralized logger across the application to improve security and maintainability

This commit is contained in:
Usman Baig
2026-02-22 20:57:21 +01:00
parent 837c677b51
commit 2d0307d328
17 changed files with 62 additions and 31 deletions

16
lib/utils/logger.ts Normal file
View File

@@ -0,0 +1,16 @@
/**
* Dev-only logger that suppresses client-side output in production.
* Server-side logs always pass through (they go to server logs, not the browser).
*/
const isServer = typeof window === 'undefined'
const isDev = process.env.NODE_ENV === 'development'
export const logger = {
error(...args: unknown[]) {
if (isServer || isDev) console.error(...args)
},
warn(...args: unknown[]) {
if (isServer || isDev) console.warn(...args)
},
}