feat: implement centralized logger and replace console statements#67
Merged
RUKAYAT-CODER merged 2 commits intoApr 23, 2026
Merged
Conversation
|
@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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 thesrc/utils/loggerutility 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 aLogLevelenum 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), preventingReferenceErrorin 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 manualif (__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.logwith 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:
LogLevelenum values, all log methods in dev mode (correct prefix, multiple arguments), error() always firing regardless of environment, error() printing stack traces forErrorinstances, and all non-error methods being silent in production mode.Testing
npm test -- --testPathPattern="logger")Closes #50