Skip to content

[CODE QUALITY] Replace console.log statements with centralized logger #2

@itigges22

Description

@itigges22

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

  1. Run grep -rn "console\.\(log\|error\|warn\)" --include="*.ts" --include="*.tsx" app/ components/ lib/ to find all instances
  2. Start with API routes in app/api/ as they're simpler
  3. Leave lib/debug-logger.ts alone (it's the implementation)
  4. Test by running npm run dev and verifying logs still appear

Acceptance Criteria

  • Zero console.log outside of lib/debug-logger.ts
  • All logs use appropriate level (debug, info, warn, error)
  • Include context objects where helpful

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions