Skip to content

feat: implement centralized logger and replace console statements#67

Merged
RUKAYAT-CODER merged 2 commits into
rinafcode:mainfrom
Jayking40:#50-No-Centralized-Error-Logging
Apr 23, 2026
Merged

feat: implement centralized logger and replace console statements#67
RUKAYAT-CODER merged 2 commits into
rinafcode:mainfrom
Jayking40:#50-No-Centralized-Error-Logging

Conversation

@Jayking40
Copy link
Copy Markdown
Contributor

feat: Implement centralized logger and replace scattered console statements

Summary

Error logging was scattered across the codebase using raw console.log, console.warn, and console.error calls with no consistent format, no environment awareness, and no structured output. This PR wires up the src/utils/logger utility as the single source of truth for all application logging.

In development, every log level (debug, info, warn, error) is emitted to the Metro bundler terminal with a clear prefix emoji. In production, only errors are emitted — info, warn, and debug are silenced automatically. This required no third-party dependency.

Changes

  • Centralized logger (src/utils/logger) — Enhanced with a LogLevel enum for consumers that need to reference severity levels programmatically. Added a safe __DEV__ guard that falls back gracefully in non-React-Native environments (e.g. Jest), preventing ReferenceError in tests. Cleaned up the component() helper's optional-data fallback.

  • Socket service — Replaced three console.log / console.error calls (socket connected, disconnected, error) with logger.info and logger.error.

  • Axios config — Replaced the __DEV__-guarded console.warn and console.error calls in the response interceptor with logger.warn and logger.error. The logger now owns the dev/prod gate internally, removing the need for a manual if (__DEV__) wrapper at each call site.

  • App entry point — Removed a no-op console.error monkey-patch (it called the original function verbatim, accomplishing nothing). Replaced the notification-launch console.log with logger.info. Added a logger.debug call in the __DEV__ block to confirm centralized logging is active on startup.

  • Unit tests — Added 15 tests for the logger covering: LogLevel enum values, all log methods in dev mode (correct prefix, multiple arguments), error() always firing regardless of environment, error() printing stack traces for Error instances, and all non-error methods being silent in production mode.

Testing

  • New logger unit tests: 15 / 15 passing (npm test -- --testPathPattern="logger")
  • Full test suite: 54 / 54 passing (2 pre-existing TypeScript compilation failures in unrelated test files are not caused by this PR)
  • Manually verified Metro bundler output shows structured log prefixes during app startup

Closes #50

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 22, 2026

@Jayking40 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@RUKAYAT-CODER RUKAYAT-CODER merged commit b5d8384 into rinafcode:main Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No Centralized Error Logging

2 participants