Feat : Logger Singleton Migration - #429
Conversation
- app_routes.dart: Use singleton logger - deep_link_handler.dart: Replace Logger() with logger - deep_link_interceptor.dart: Replace Logger() with logger
- dispute_repository.dart: Replace Logger() with logger - open_orders_repository.dart: Replace Logger() with logger
- chat_room_provider.dart: Replace Logger() with logger - chat_rooms_notifier.dart: Replace Logger() with logger - chat_room_notifier.dart: Replace Logger() with logger - chat_room_providers.dart: Replace Logger() with logger
- dispute_chat_notifier.dart: Replace Logger() with logger
- logs_actions_menu.dart: Replace Logger() with logger
- background_notification_service.dart: Replace Logger() with logger - notification_data_extractor.dart: Replace Logger() with logger
- order_state.dart: Replace Logger() with logger - rate_counterpart_screen.dart: Replace Logger() with logger
- restore_manager.dart: Replace Logger() with logger - restore_progress_notifier.dart: Replace Logger() with logger
- settings_notifier.dart: Replace Logger() with logger - trades_provider.dart: Replace Logger() with logger - status_filter_widget.dart: Replace Logger() with logger
- blossom_client.dart: Replace Logger() with logger - blossom_download_service.dart: Replace Logger() with logger - blossom_upload_helper.dart: Replace Logger() with logger - encrypted_file_upload_service.dart: Replace Logger() with logger - encrypted_image_upload_service.dart: Replace Logger() with logger - encryption_service.dart: Replace Logger() with logger - fcm_service.dart: Replace Logger() with logger - file_validation_service.dart: Replace Logger() with logger - image_upload_service.dart: Replace Logger() with logger - lifecycle_manager.dart: Replace Logger() with logger - media_validation_service.dart: Replace Logger() with logger - push_notification_service.dart: Replace Logger() with logger
- session_notifier.dart: Replace Logger() with logger - notification_listener_widget.dart: Replace Logger() with logger - pay_lightning_invoice_widget.dart: Replace Logger() with logger
- Mark Phase 7 as completed - Document migration of 40+ files to singleton logger - Add reference to check_logger_usage.dart tool
Remove duplicate imports of logger_service.dart in: - logs_actions_menu.dart - settings_notifier.dart Ensure pay_lightning_invoice_widget.dart uses singleton logger correctly.
Mark constructors as const in: - LogsActionsMenu - PayLightningInvoiceWidget Resolves prefer_const_constructors_in_immutables lint warnings.
Ensures that all logging within the application exclusively uses the centralized logger from `logger_service.dart`. Updates documentation to reflect the completion of the logger migration and reinforces the prohibition of direct `Logger()` instantiation.
WalkthroughThis PR migrates per-file Logger instances to a centralized singleton logger_service across the codebase, updates docs to mark Phase 7 completed, and adds a few new public APIs and providers (ChatRoomNotifier.getSharedKey, DisputeRepository.sendDisputeMessage, RestoreProgressNotifier.incrementProgress, filteredTradesWithOrderStateProvider). Changes
Sequence Diagram(s)(Skipped — changes are primarily logging replacement and small provider/API additions; no new multi-component control-flow requiring visualization.) Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
lib/shared/widgets/pay_lightning_invoice_widget.dart (1)
78-111:⚠️ Potential issue | 🟠 MajorAvoid logging full Lightning invoices (sensitive).
With centralized logging (and UI log display), this exposes payment data. Please redact or log only metadata (length/prefix).🔐 Suggested redaction (log only length)
- logger.i('Copied LN Invoice to clipboard: ${widget.lnInvoice}'); + logger.i('Copied LN Invoice to clipboard (length: ${widget.lnInvoice.length})'); ... - logger.i('Launched Lightning wallet with invoice: ${widget.lnInvoice}'); + logger.i('Launched Lightning wallet with invoice (length: ${widget.lnInvoice.length})'); ... - logger.i('Shared LN Invoice via share sheet: ${widget.lnInvoice}'); + logger.i('Shared LN Invoice via share sheet (length: ${widget.lnInvoice.length})');lib/features/restore/restore_progress_notifier.dart (1)
91-97:⚠️ Potential issue | 🟠 MajorLocalize the timeout error message.
'Request timeout'is user-facing and should come from ARB/localizations (or via a localization key mapped in UI), not a hard-coded literal.As per coding guidelines, Localize all user-facing strings via ARB files and access them with S.of(context) rather than hard-coded literals.
lib/data/repositories/dispute_repository.dart (1)
119-122:⚠️ Potential issue | 🟠 MajorRemove or implement
sendDisputeMessagestub.The method is currently unused throughout the codebase and is just a mock delay. If this is placeholder code for future implementation, replace the mock with
throw UnimplementedError('sendDisputeMessage is not implemented yet');to fail fast and prevent silent failures. Alternatively, if no longer needed, remove it entirely.
🤖 Fix all issues with AI agents
In `@docs/LOGGING_IMPLEMENTATION.md`:
- Around line 214-216: Remove the duplicate "Last Updated" entry so only the
most recent date remains; specifically delete the older line "**Last Updated**:
2026-01-21" and keep "**Last Updated**: 2026-02-02" so the section shows a
single Last Updated entry.
🧹 Nitpick comments (2)
lib/features/trades/providers/trades_provider.dart (1)
42-53: Potential performance consideration with many orders.Watching individual
orderNotifierProviderfor each order in a loop (line 46) is necessary for reactive updates but could impact performance with a large number of orders. The current implementation with try-catch is defensive and handles failures gracefully.Consider monitoring performance if the order count grows significantly in the future.
lib/features/chat/providers/chat_room_providers.dart (1)
47-48: Consider removing the orphaned comment.The comment on line 47 ("// Logger instance for session start time operations") now refers to a removed field. Consider removing this comment to avoid confusion.
🧹 Proposed cleanup
-// Logger instance for session start time operations - +
Phase 7: Logger Singleton Migration
This PR completes the migration to the centralized logger singleton and updates documentation.
What's Included
Logger()usage with the singletonloggerfromlogger_service.dart.Testing
Summary by CodeRabbit
New Features
Bug Fixes
Documentation