Description
Current State
The codebase has ~430 console.log/console.error statements scattered throughout, despite having a proper logging system implemented in lib/debug-logger.ts. This was expedient during rapid development but makes production debugging difficult since there's no way to control log levels.
Examples found
// app/admin/superadmin-setup/page.tsx:93
console.error('Error assigning superadmin role:', error)
// components/navigation.tsx:381
console.log('🔍 DEBUG: Rendering visibleItems:', visibleItems.map((i: any) => i.name));
// app/api/debug-stakeholders/route.ts:35-40
console.log('=== STAKEHOLDERS DEBUG ===')
console.log('Project ID:', projectId)
Desired Outcome
Replace with the existing logger:
import { logger } from '@/lib/debug-logger';
logger.debug('User does not have permission', { userId, permission });
logger.error('Database operation failed', { action: 'create_project' }, error as Error);
How to get started
- Run
grep -rn "console\.\(log\|error\|warn\)" --include="*.ts" --include="*.tsx" app/ components/ lib/ to find all instances
- Start with API routes in
app/api/ as they're simpler
- Leave
lib/debug-logger.ts alone (it's the implementation)
- Test by running
npm run dev and verifying logs still appear
Acceptance Criteria
Description
Current State
The codebase has ~430
console.log/console.errorstatements scattered throughout, despite having a proper logging system implemented inlib/debug-logger.ts. This was expedient during rapid development but makes production debugging difficult since there's no way to control log levels.Examples found
Desired Outcome
Replace with the existing logger:
How to get started
grep -rn "console\.\(log\|error\|warn\)" --include="*.ts" --include="*.tsx" app/ components/ lib/to find all instancesapp/api/as they're simplerlib/debug-logger.tsalone (it's the implementation)npm run devand verifying logs still appearAcceptance Criteria
console.logoutside oflib/debug-logger.ts