Skip to content

Commit 3e07942

Browse files
authored
Merge pull request #398 from BraCR10/feat/logging-phase-1
Feat: Add in-app logs screen (Phase 1)
2 parents d549633 + 5ab314d commit 3e07942

File tree

9 files changed

+740
-46
lines changed

9 files changed

+740
-46
lines changed

docs/LOGGING_IMPLEMENTATION.md

Lines changed: 44 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,47 @@
44

55
Implementation of a comprehensive logging system for MostroP2P mobile app with in-memory capture, background isolate support, privacy sanitization, and export capabilities.
66

7+
## Implementation Phases
8+
9+
10+
### Phase 1: UI Components & Translations (Completed)
11+
- Logs screen with filtering (no share button yet)
12+
- Translations (EN, ES, IT)
13+
- Settings screen integration (Dev Tools section after Relays)
14+
- Logging toggle with performance warning
15+
- Toggle resets to OFF on every app restart (not persisted)
16+
- Route configuration
17+
18+
### Phase 2: Logger Service & Integration (Current)
19+
- Logger service with memory buffer and sanitization
20+
- Riverpod providers
21+
- Initialize in main.dart
22+
- Connect UI to actual logger
23+
- Test with 2 files: RelaysNotifier, SubscriptionManager
24+
25+
### Phase 3: Core Services Migration
26+
- NostrService
27+
- MostroService
28+
- DeepLinkService
29+
- 2 additional core files
30+
31+
### Phase 4: Background Services
32+
- Mobile and desktop background service
33+
- Isolate logging
34+
35+
### Phase 5: File Export & Persistence
36+
- Auto-save to storage
37+
- Restore on app restart
38+
- Generate .txt files
39+
- Folder picker and permissions
40+
41+
### Phase 6: UI Enhancements
42+
- Recording indicator widget
43+
- Statistics and controls
44+
45+
### Phase 7: Remaining Migrations
46+
- 25+ files with logs
47+
748
## Design Approach
849

950
### Why This Architecture?
@@ -114,41 +155,6 @@ void main() async {
114155
}
115156
```
116157

117-
### 4. Privacy Sanitization
118-
119-
The `cleanMessage()` function automatically redacts:
120-
121-
| Pattern | Replacement | Example |
122-
|---------|-------------|---------|
123-
| `nsec[0-9a-z]+` | `[PRIVATE_KEY]` | `nsec1abc...``[PRIVATE_KEY]` |
124-
| `"privateKey":"..."` | `"privateKey":"[REDACTED]"` | JSON field redacted |
125-
| `"mnemonic":"..."` | `"mnemonic":"[REDACTED]"` | Seed phrase redacted |
126-
| ANSI codes | Removed | Color/formatting stripped |
127-
| Emojis | Removed | All emoji ranges |
128-
129-
### 5. File Storage & Permissions
130-
131-
**Android/iOS**:
132-
```dart
133-
// External storage (requires permissions in future)
134-
final directory = await getExternalStorageDirectory();
135-
final logsDir = Directory('${directory.path}/MostroLogs');
136-
```
137-
138-
**PERMISSIONS REQUIRED** (not yet implemented):
139-
- Android: `WRITE_EXTERNAL_STORAGE` permission
140-
- iOS: Automatic with app sandbox
141-
142-
**Desktop/Web**:
143-
```dart
144-
// Application documents (no special permissions)
145-
final directory = await getApplicationDocumentsDirectory();
146-
```
147-
148-
**Storage location display**:
149-
- UI shows storage path to user
150-
- Configurable via `Settings.customLogStorageDirectory`
151-
152158
## Migration Example
153159

154160
### Service Integration
@@ -196,8 +202,8 @@ void backgroundMain(SendPort sendPort) async {
196202
}
197203
```
198204

199-
200205
---
201206

202-
**Version**: 1.0
203-
**Status**: Phase 1 - Planning Complete
207+
**Version**: 2
208+
**Status**: Phase 2 - Ready
209+
**Last Updated**: 2026-01-06

lib/core/app_routes.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import 'package:mostro_mobile/features/walkthrough/screens/walkthrough_screen.da
2424
import 'package:mostro_mobile/features/disputes/screens/dispute_chat_screen.dart';
2525

2626
import 'package:mostro_mobile/features/notifications/screens/notifications_screen.dart';
27+
import 'package:mostro_mobile/features/logs/screens/logs_screen.dart';
2728

2829
import 'package:mostro_mobile/features/walkthrough/providers/first_run_provider.dart';
2930
import 'package:mostro_mobile/shared/widgets/navigation_listener_widget.dart';
@@ -284,6 +285,15 @@ GoRouter createRouter(WidgetRef ref) {
284285
child: const NotificationsScreen(),
285286
),
286287
),
288+
GoRoute(
289+
path: '/logs',
290+
pageBuilder: (context, state) =>
291+
buildPageWithDefaultTransition<void>(
292+
context: context,
293+
state: state,
294+
child: const LogsScreen(),
295+
),
296+
),
287297
],
288298
),
289299
],

0 commit comments

Comments
 (0)