Feature/debug log viewer#98
Merged
Merged
Conversation
Replaces positional error/stackTrace params with named params across all call sites (~40 files), adds LogCategory support, and integrates LogFileService for persistent log writing.
Long-pressing the version text 5 times in the About section enables debug mode. When debug mode is active, a Debug section appears in the settings list above About, routing to a placeholder DebugLogViewerPage (to be replaced in Task 9).
Creates NativeLogger singleton that forwards log events to Flutter via the Pigeon onLogEvent callback while mirroring output to Android logcat. Replaces all android.util.Log calls in DiveComputerHostApiImpl and BleIoStream with NativeLogger using BLE/LDC category tagging.
Creates NativeLogger.swift in the shared darwin/Sources/LibDCDarwin/ directory to centralize log output — printing to the console and forwarding each event to Flutter via DiveComputerFlutterApi.onLogEvent. Replaces all NSLog calls in BleIoStream.swift and BleScanner.swift with the appropriate NativeLogger level methods (d/i/w/e with BLE/SER categories). Wires NativeLogger.flutterApi in both the macOS and iOS plugin registration entry points, and adds the missing onLogEvent method to the macOS-specific DiveComputerApi.g.swift. Symlinks for NativeLogger.swift are added to both macos/Classes and ios/Classes so each podspec picks up the file automatically.
… debug mode
Navigator.of(context).pop() crashes because the debug log viewer is rendered
inline as section content in the master-detail layout, not as a pushed route.
Using context.go('/settings') properly navigates back via go_router.
Cover LoggerService, debug log providers with filtering logic, DebugLogViewerPage, LogEntryTile, and LogFilterBar. Extend debug mode provider tests with ProviderContainer integration. Update Pigeon-generated API and DiveComputerService mock for log event stream.
Add broadcast stream to LoggerService and subscribe in logEntriesProvider via invalidateSelf() so the debug log viewer refreshes automatically during dive computer downloads and other logging activity.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an in-app “hidden” debug mode with persistent structured logging, native log capture, and a full debug log viewer UI (filter/search/export), while migrating existing logging call sites to the updated LoggerService API.
Changes:
- Introduces structured log models (
LogEntry,LogCategory,LogLevel) plusLogFileServicefor persistent log storage/rotation. - Adds debug-mode state (
DebugModeNotifier) and a debug log viewer page with filters, search, and export actions. - Extends
libdivecomputer_pluginPigeon APIs and native implementations (Swift/Kotlin/C/JNI) to forward native logs into Flutter, and updates many repositories/services to the new logger API.
Reviewed changes
Copilot reviewed 86 out of 87 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| test/features/settings/presentation/widgets/log_filter_bar_test.dart | Widget tests for category/severity filtering UI. |
| test/features/settings/presentation/widgets/log_entry_tile_test.dart | Widget tests for log entry rendering (icon/tag/timestamp/message). |
| test/features/settings/presentation/providers/debug_mode_provider_test.dart | Unit/provider tests for debug mode persistence and toggling. |
| test/features/settings/presentation/pages/debug_log_viewer_page_test.dart | Widget tests for debug log viewer page UI states and actions. |
| test/features/import_wizard/presentation/widgets/dc_adapter_steps_test.dart | Updates fake dive computer service for new log event API. |
| test/features/dive_computer/presentation/widgets/usb_search_test.dart | Updates fake dive computer service for new log event API. |
| test/features/dive_computer/presentation/widgets/download_step_widget_test.dart | Updates fake dive computer service for new log event API. |
| test/features/dive_computer/presentation/providers/download_notifier_fingerprint_test.mocks.dart | Regenerates mocks to include new log event members. |
| test/core/services/logger_service_test.dart | Adds tests for new LoggerService behavior and file logging. |
| test/core/services/log_file_service_test.dart | Adds tests for file I/O, rotation, and init guards. |
| test/core/models/log_entry_test.dart | Adds tests for parsing/formatting/equality of log entries. |
| packages/libdivecomputer_plugin/windows/dive_computer_api.g.h | Adds onLogEvent Pigeon API for Windows C++ side. |
| packages/libdivecomputer_plugin/windows/dive_computer_api.g.cc | Implements Windows C++ OnLogEvent message dispatch. |
| packages/libdivecomputer_plugin/pigeons/dive_computer_api.dart | Declares new onLogEvent callback in the Pigeon schema. |
| packages/libdivecomputer_plugin/macos/Classes/libdc_wrapper.h | Exposes C API to set libdivecomputer log callback. |
| packages/libdivecomputer_plugin/macos/Classes/libdc_wrapper.c | Stores and applies the libdivecomputer log callback. |
| packages/libdivecomputer_plugin/macos/Classes/libdc_download.c | Bridges libdivecomputer log func to the stored callback. |
| packages/libdivecomputer_plugin/macos/Classes/NativeLogger.swift | Adds NativeLogger shim reference (path link). |
| packages/libdivecomputer_plugin/macos/Classes/LibdivecomputerPlugin.swift | Wires NativeLogger to Flutter Pigeon API. |
| packages/libdivecomputer_plugin/macos/Classes/DiveComputerApi.g.swift | Regenerated Swift Pigeon code with onLogEvent. |
| packages/libdivecomputer_plugin/linux/dive_computer_api.g.h | Adds onLogEvent response types and API declarations. |
| packages/libdivecomputer_plugin/linux/dive_computer_api.g.cc | Implements Linux onLogEvent messaging plumbing. |
| packages/libdivecomputer_plugin/lib/src/generated/dive_computer_api.g.dart | Regenerated Dart Pigeon bindings with onLogEvent. |
| packages/libdivecomputer_plugin/lib/src/dive_computer_service.dart | Exposes a Dart logEvents stream and implements onLogEvent. |
| packages/libdivecomputer_plugin/ios/Classes/NativeLogger.swift | Adds NativeLogger shim reference (path link). |
| packages/libdivecomputer_plugin/ios/Classes/LibdivecomputerPlugin.swift | Wires NativeLogger to Flutter Pigeon API on iOS. |
| packages/libdivecomputer_plugin/ios/Classes/DiveComputerApi.g.swift | Regenerated iOS Swift Pigeon code with onLogEvent. |
| packages/libdivecomputer_plugin/darwin/Sources/LibDCDarwin/NativeLogger.swift | Adds shared Darwin NativeLogger that forwards logs to Flutter. |
| packages/libdivecomputer_plugin/darwin/Sources/LibDCDarwin/DiveComputerHostApiImpl.swift | Routes libdc + host logs through NativeLogger (and registers libdc callback). |
| packages/libdivecomputer_plugin/darwin/Sources/LibDCDarwin/BleScanner.swift | Migrates BLE scanner logging to NativeLogger. |
| packages/libdivecomputer_plugin/android/src/main/kotlin/com/submersion/libdivecomputer/NativeLogger.kt | Adds Android NativeLogger to forward logs to Flutter + logcat. |
| packages/libdivecomputer_plugin/android/src/main/kotlin/com/submersion/libdivecomputer/DiveComputerHostApiImpl.kt | Migrates host logging to NativeLogger and wires flutter API into it. |
| packages/libdivecomputer_plugin/android/src/main/kotlin/com/submersion/libdivecomputer/DiveComputerApi.g.kt | Regenerated Kotlin Pigeon code with onLogEvent. |
| packages/libdivecomputer_plugin/android/src/main/kotlin/com/submersion/libdivecomputer/BleIoStream.kt | Migrates BLE I/O logging from Log.* to NativeLogger. |
| packages/libdivecomputer_plugin/android/src/main/cpp/libdc_jni.cpp | Registers libdc log callback on Android native side (logcat). |
| lib/main.dart | Initializes log file service and injects it via ProviderScope. |
| lib/features/trips/data/repositories/trip_repository.dart | Updates error logging calls to named-parameter API. |
| lib/features/trips/data/repositories/liveaboard_details_repository.dart | Updates error logging calls to named-parameter API. |
| lib/features/trips/data/repositories/itinerary_day_repository.dart | Updates error logging calls to named-parameter API. |
| lib/features/tank_presets/data/repositories/tank_preset_repository.dart | Updates error logging calls to named-parameter API. |
| lib/features/tags/data/repositories/tag_repository.dart | Updates error logging calls to named-parameter API. |
| lib/features/statistics/data/repositories/statistics_repository.dart | Updates error logging calls to named-parameter API. |
| lib/features/signatures/data/services/signature_storage_service.dart | Updates error logging calls to named-parameter API. |
| lib/features/settings/presentation/widgets/settings_list_content.dart | Shows Debug section when debug mode is enabled. |
| lib/features/settings/presentation/widgets/log_filter_bar.dart | Adds log filter UI (category chips + severity dropdown). |
| lib/features/settings/presentation/widgets/log_entry_tile.dart | Adds UI row for rendering a log entry. |
| lib/features/settings/presentation/providers/settings_providers.dart | Updates logging call to new named-parameter API. |
| lib/features/settings/presentation/providers/debug_mode_provider.dart | Adds debug mode persistence provider (SharedPreferences). |
| lib/features/settings/presentation/providers/debug_log_providers.dart | Adds log file provider, live reloading, filtering, and export helpers. |
| lib/features/settings/presentation/pages/settings_page.dart | Adds Debug section content + debug-mode “Easter egg” activation hook. |
| lib/features/settings/presentation/pages/debug_log_viewer_page.dart | Adds debug log viewer page (search/filter/export/clear/disable). |
| lib/features/settings/data/repositories/diver_settings_repository.dart | Updates error logging calls to named-parameter API. |
| lib/features/notifications/data/repositories/scheduled_notification_repository.dart | Updates error logging calls to named-parameter API. |
| lib/features/media/data/services/metadata_write_service.dart | Updates error logging calls to named-parameter API. |
| lib/features/media/data/services/media_import_service.dart | Updates error logging calls to named-parameter API. |
| lib/features/media/data/services/exif_write_service.dart | Updates error logging calls to named-parameter API. |
| lib/features/media/data/services/asset_resolution_service.dart | Updates error logging calls to named-parameter API. |
| lib/features/media/data/repositories/media_repository.dart | Updates error logging calls to named-parameter API. |
| lib/features/equipment/data/repositories/equipment_repository_impl.dart | Updates error logging calls to named-parameter API. |
| lib/features/divers/data/repositories/diver_repository.dart | Updates error logging calls to named-parameter API. |
| lib/features/dive_types/data/repositories/dive_type_repository.dart | Updates error logging calls to named-parameter API. |
| lib/features/dive_sites/data/repositories/site_repository_impl.dart | Updates error logging calls to named-parameter API. |
| lib/features/dive_log/presentation/providers/profile_analysis_provider.dart | Updates error logging calls to named-parameter API. |
| lib/features/dive_log/data/repositories/dive_computer_repository_impl.dart | Updates error logging calls to named-parameter API. |
| lib/features/dive_computer/presentation/providers/discovery_providers.dart | Listens to native log events and routes them into LoggerService. |
| lib/features/dive_centers/data/repositories/dive_center_repository.dart | Updates error logging calls to named-parameter API. |
| lib/features/courses/data/repositories/course_repository.dart | Updates error logging calls to named-parameter API. |
| lib/features/certifications/data/repositories/certification_repository.dart | Updates error logging calls to named-parameter API. |
| lib/features/buddies/data/repositories/buddy_repository.dart | Updates error logging calls to named-parameter API. |
| lib/features/buddies/data/repositories/buddy_merge_repository.dart | Updates error logging calls to named-parameter API. |
| lib/features/backup/data/services/backup_service.dart | Updates error logging calls to named-parameter API. |
| lib/core/services/sync/sync_service.dart | Updates error/warn logging calls to named-parameter API. |
| lib/core/services/sync/sync_initializer.dart | Updates error logging calls to named-parameter API. |
| lib/core/services/sync/sync_data_serializer.dart | Updates error logging calls to named-parameter API. |
| lib/core/services/logger_service.dart | Expands logger to support categories, file writes, and live log stream. |
| lib/core/services/log_file_service.dart | Adds log file I/O, rotation, and init guards. |
| lib/core/services/location_service.dart | Updates error logging calls to named-parameter API. |
| lib/core/services/cloud_storage/icloud_storage_provider.dart | Updates error logging calls to named-parameter API. |
| lib/core/services/cloud_storage/icloud_native_service.dart | Updates warning logging calls to named-parameter API. |
| lib/core/services/cloud_storage/google_drive_storage_provider.dart | Updates error logging calls to named-parameter API. |
| lib/core/services/background_service.dart | Updates error logging calls to named-parameter API. |
| lib/core/router/app_router.dart | Adds /settings/debug-logs route. |
| lib/core/models/log_entry.dart | Adds structured log models and parsing/formatting. |
| lib/core/data/repositories/sync_repository.dart | Updates error/warn logging calls to named-parameter API. |
Connect LoggerService file backend to DebugModeNotifier so enabling debug mode starts file logging and disabling stops it. Rename providers to follow Riverpod conventions (debugModeNotifierProvider, logFilterNotifierProvider). Serialize LogFileService writes to prevent rotation races. Change debug mode activation from long-press to tap.
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
… coverage Add error-path tests for 20+ repositories to verify methods propagate database errors correctly. Extend debug log viewer widget tests with error state, search filtering, and clipboard copy scenarios. Add settings page tests for debug mode section visibility.
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.
Summary
Adds a hidden debug mode and full-featured debug log viewer to Submersion. When activated via an Easter egg in Settings, all application logging is written to a structured log file and can be viewed, filtered, searched, and exported from
within the app. Native platform logs (iOS/macOS, Android) are also captured and routed through the same system.
Changes
LogEntry,LogCategory,LogLeveldata models with structured log line parsingLogFileServicewith file I/O, rotation (keeps last ~50% when exceeding 5MB), and initialization guardsLoggerServicewith file writing, log categories, and native log callback supportDebugModeProviderwith SharedPreferences persistence and Easter egg activation (tap version 7 times)LogFilterBarandLogEntryTilewidgets for the viewer UI/settings/debug-logsroute via go_routerNativeLogger(Swift) routingos_logandNSLogcalls to Flutter via Pigeon callbackNativeLogger(Kotlin) routing native logs to Flutter via Pigeon callbackNativeLoggerdeveloper.logto categorizedLoggerServicecallsLogFileServiceat app startup (main.dart)Test Plan
flutter testpassesflutter analyzepassesScreenshots