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

View File

@@ -6,6 +6,7 @@ import apiRequest from '@/lib/api/client'
import { LoadingOverlay } from '@ciphera-net/ui'
import { logoutAction, getSessionAction, setSessionAction } from '@/app/actions/auth'
import { getUserOrganizations, switchContext } from '@/lib/api/organization'
import { logger } from '@/lib/utils/logger'
interface User {
id: string
@@ -66,7 +67,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
return merged
})
})
.catch((e) => console.error('Failed to fetch full profile after login', e))
.catch((e) => logger.error('Failed to fetch full profile after login', e))
}
const logout = useCallback(async () => {
@@ -96,7 +97,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
return merged
})
} catch (e) {
console.error('Failed to refresh user data', e)
logger.error('Failed to refresh user data', e)
}
router.refresh()
}, [router])
@@ -121,7 +122,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
setUser(merged)
localStorage.setItem('user', JSON.stringify(merged))
} catch (e) {
console.error('Failed to fetch full profile', e)
logger.error('Failed to fetch full profile', e)
}
} else {
// * Session invalid/expired
@@ -178,11 +179,11 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
router.refresh()
}
} catch (e) {
console.error('Failed to auto-switch context', e)
logger.error('Failed to auto-switch context', e)
}
}
} catch (e) {
console.error("Failed to fetch organizations", e)
logger.error("Failed to fetch organizations", e)
}
}
}