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:
16
lib/utils/logger.ts
Normal file
16
lib/utils/logger.ts
Normal 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)
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user