Skip to content

[LOW] Replace console wrapper logger with structured logging #116

@NateIsern

Description

@NateIsern

Description

The backend logger is a minimal console wrapper that lacks features needed for production operations: no timestamps, no structured output, no log level configuration, no transport options.

Affected Files

  • packages/backend/src/utils/logger.ts:12-26 — console wrapper implementation
  • packages/backend/src/scripts/fixPostStats.ts — uses console.log/console.error directly
  • packages/backend/src/scripts/testUserBehavior.ts — uses console.log directly
  • packages/frontend/components/Feed/PostErrorBoundary.tsx:25 — uses console.warn
  • packages/frontend/utils/logger.ts:56-59 — similar console wrapper

Current Implementation

// packages/backend/src/utils/logger.ts
export const logger = {
  info: (message: string, ...args: any[]) => {
    console.log(\`[INFO] \${message}\`, ...args);  // No timestamp, no structure
  },
  error: (message: string, error?: any) => {
    console.error(\`[ERROR] \${message}\`, error || '');
  }
};

Expected Behavior

Backend

  1. Replace with pino or winston for structured JSON logging
  2. Include timestamps, request IDs, and structured metadata
  3. Configure log levels via environment variable
  4. Ensure all scripts use the logger instead of direct console.* calls

Frontend

  1. Ensure the logger utility is used consistently (not console.warn in PostErrorBoundary)
  2. Consider a remote error reporting service (Sentry, etc.) for production

Impact

  • Severity: Low
  • Risk: Difficult to parse and search logs in production, no correlation between requests, missing timestamps

Metadata

Metadata

Labels

P3Low priority — nice to havebackendBackend (Express/Node.js)code-qualityCode quality improvementtype: choreMaintenance, cleanup, refactor

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions