π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mobile] Remove LogViewer
laurenspriem24c125534c8c
diff --git a/mobile/apps/photos/lib/core/error-reporting/super_logging.dart b/mobile/apps/photos/lib/core/error-reporting/super_logging.dartindex aa3af593a8..f24bd72635 100644--- a/mobile/apps/photos/lib/core/error-reporting/super_logging.dart+++ b/mobile/apps/photos/lib/core/error-reporting/super_logging.dart@@ -6,10 +6,9 @@ import 'dart:io';import "package:dio/dio.dart";import "package:ente_pure_utils/ente_pure_utils.dart";import 'package:flutter/foundation.dart';-import 'package:flutter/material.dart';+import 'package:flutter/widgets.dart';import 'package:http/http.dart' as http;import 'package:intl/intl.dart';-import 'package:log_viewer/log_viewer.dart';import 'package:logging/logging.dart';import 'package:package_info_plus/package_info_plus.dart';import 'package:path/path.dart';@@ -164,20 +163,6 @@ class SuperLogging {EnteWatch.setLogLevel(_terminalLoggerLevel);Logger.root.onRecord.listen(onLogRecord);- // Bg engines killed mid-write can wedge log_viewer.db; keep DB logging- // foreground-only and never let startup block on it.- if (_getExecutionContext() == 'foreground' &&- (_preferences.getBool("enable_db_logging") ?? kDebugMode)) {- try {- await LogViewer.initialize(- prefix: appConfig.prefix,- ).timeout(const Duration(seconds: 2));- $.info("Log viewer initialized successfully");- } catch (e) {- $.warning("Failed to initialize log viewer: $e");- }- }-if (isFDroidClient) {assert(sentryIsEnabled == false,@@ -553,11 +538,4 @@ class SuperLogging {final pkgName = (await PackageInfo.fromPlatform()).packageName;return pkgName.startsWith("io.ente.photos.fdroid");}-- static void showLogViewer(BuildContext context) {- Navigator.push(- context,- MaterialPageRoute(builder: (context) => const LogViewerPage()),- );- }}diff --git a/mobile/apps/photos/lib/settings/local_settings.dart b/mobile/apps/photos/lib/settings/local_settings.dartindex d95190ce88..0fbb60e9fd 100644--- a/mobile/apps/photos/lib/settings/local_settings.dart+++ b/mobile/apps/photos/lib/settings/local_settings.dart@@ -1,6 +1,5 @@import "dart:io";-import 'package:flutter/foundation.dart';import 'package:home_widget/home_widget.dart' as hw;import 'package:photos/app_mode.dart';import 'package:photos/core/constants.dart';@@ -89,7 +88,6 @@ class LocalSettings {static const kPeopleSortSimilaritySelected ="people_sort_similarity_selected";static const kShowLocalIDOverThumbnails = "show_local_id_over_thumbnails";- static const kEnableDatabaseLogging = "enable_db_logging";static const _kInternalUserDisabled = "ls.internal_user_disabled";static const _kBGDebugNotificationsEnabled ="ls.bg_debug_notifications_enabled";@@ -526,13 +524,6 @@ class LocalSettings {await _prefs.setBool(kShowLocalIDOverThumbnails, value);}- bool get enableDatabaseLogging =>- _prefs.getBool(kEnableDatabaseLogging) ?? kDebugMode;-- Future<void> setEnableDatabaseLogging(bool value) async {- await _prefs.setBool(kEnableDatabaseLogging, value);- }-bool get isInternalUserDisabled =>_prefs.getBool(_kInternalUserDisabled) ?? false;diff --git a/mobile/apps/photos/lib/ui/settings/debug/debug_settings_page.dart b/mobile/apps/photos/lib/ui/settings/debug/debug_settings_page.dartindex c983200080..817463667d 100644--- a/mobile/apps/photos/lib/ui/settings/debug/debug_settings_page.dart+++ b/mobile/apps/photos/lib/ui/settings/debug/debug_settings_page.dart@@ -136,32 +136,6 @@ class _DebugSettingsPageState extends State<DebugSettingsPage> {},),),- MenuItemWidgetNew(- title: "Enable database logging",- leadingIconWidget: _buildIconWidget(- context,- HugeIcons.strokeRoundedDatabase01,- ),- trailingWidget: ToggleSwitchWidget(- value: () => localSettings.enableDatabaseLogging,- onChanged: () async {- final newValue =- !localSettings.enableDatabaseLogging;- await localSettings.setEnableDatabaseLogging(- newValue,- );- if (!mounted) return;- setState(() {});- if (!context.mounted) return;- showShortToast(- context,- newValue- ? "Database logging enabled. Restart app."- : "Database logging disabled. Restart app.",- );- },- ),- ),MenuItemWidgetNew(title: "Show local ID over thumbnails",leadingIconWidget: _buildIconWidget(diff --git a/mobile/apps/photos/lib/ui/settings_page.dart b/mobile/apps/photos/lib/ui/settings_page.dartindex 48c65cb1f4..01c79e1b86 100644--- a/mobile/apps/photos/lib/ui/settings_page.dart+++ b/mobile/apps/photos/lib/ui/settings_page.dart@@ -9,7 +9,6 @@ import "package:ente_ui/pages/settings_search_page.dart";import "package:flutter/foundation.dart";import "package:flutter/material.dart";import "package:hugeicons/hugeicons.dart";-import "package:log_viewer/log_viewer.dart";import "package:photos/core/configuration.dart";import "package:photos/emergency/emergency_page.dart";import "package:photos/models/user_details.dart";@@ -220,18 +219,6 @@ class _SettingsBody extends StatelessWidget {);},),- if (localSettings.enableDatabaseLogging) ...[- IconButtonComponent(- variant: IconButtonComponentVariant.primary,- shouldSurfaceExecutionStates: false,- icon: const HugeIcon(icon: HugeIcons.strokeRoundedBug02),- onTap: () {- Navigator.of(context).push(- MaterialPageRoute(builder: (context) => const LogViewerPage()),- );- },- ),- ],];}diff --git a/mobile/apps/photos/pubspec.yaml b/mobile/apps/photos/pubspec.yamlindex 456516032b..b7c87853bd 100644--- a/mobile/apps/photos/pubspec.yaml+++ b/mobile/apps/photos/pubspec.yaml@@ -135,8 +135,6 @@ dependencies:local_auth: 3.0.1local_auth_android: 2.0.8local_auth_darwin: 2.0.3- log_viewer:- path: ../../packages/log_viewerlogging: 1.3.0lottie: 3.3.1media_extension:diff --git a/mobile/packages/log_viewer/README.md b/mobile/packages/log_viewer/README.mddeleted file mode 100644index 9b885ae87d..0000000000--- a/mobile/packages/log_viewer/README.md+++ /dev/null@@ -1,60 +0,0 @@-# Log Viewer--A Flutter package that provides an in-app log viewer with advanced filtering capabilities for Ente apps.--## Features--- π Real-time log capture and display-- π Advanced filtering by logger name, log level, and text search-- π¨ Color-coded log levels for easy identification-- π SQLite-based storage with automatic truncation-- π€ Export filtered logs as text-- β‘ Performance optimized with batch inserts and indexing-- π·οΈ Optional prefix support for multi-process logging--## Usage--### 1. Initialize in your app--```dart-import 'package:log_viewer/log_viewer.dart';--void main() async {- WidgetsFlutterBinding.ensureInitialized();-- // Initialize log viewer (basic)- await LogViewer.initialize();-- // Or with a prefix for multi-process apps- await LogViewer.initialize(prefix: '[MAIN]');-- runApp(MyApp());-}-```--### 2. Open the log viewer--```dart-// As a navigation action-LogViewer.openViewer(context);--// Or embed as a widget-LogViewer.getViewerPage()-```--### 3. Automatic log capture--The log viewer automatically registers with `Logger.root.onRecord` to capture all logs from the logging package. No additional setup is required.--## Filtering Options--- **Logger Name**: Filter by specific loggers (e.g., "auth", "sync", "ui")-- **Log Level**: Filter by severity (SEVERE, WARNING, INFO, etc.)-- **Text Search**: Search within log messages and error descriptions-- **Time Range**: Filter logs by date/time range--## Database Management--- Logs are stored in a local SQLite database-- By default, automatic truncation keeps only the most recent 10000 entries-- Batch inserts for optimal performancediff --git a/mobile/packages/log_viewer/example_integration.md b/mobile/packages/log_viewer/example_integration.mddeleted file mode 100644index 6a4bb2ddd3..0000000000--- a/mobile/packages/log_viewer/example_integration.md+++ /dev/null@@ -1,292 +0,0 @@-# Log Viewer Integration Examples--This document provides examples of integrating the log_viewer package into your Flutter application, both as a standalone solution and integrated with SuperLogging.--## Standalone Integration (Without SuperLogging)--### Basic Setup--```dart-import 'package:flutter/material.dart';-import 'package:log_viewer/log_viewer.dart';-import 'package:logging/logging.dart';--void main() async {- WidgetsFlutterBinding.ensureInitialized();-- // Initialize the log viewer- await LogViewer.initialize();-- // Set up logging- Logger.root.level = Level.ALL;-- // Log viewer automatically captures all logs - no manual setup needed!-- runApp(MyApp());-}--class MyApp extends StatelessWidget {- @override- Widget build(BuildContext context) {- return MaterialApp(- title: 'Log Viewer Example',- home: MyHomePage(),- );- }-}--class MyHomePage extends StatefulWidget {- @override- _MyHomePageState createState() => _MyHomePageState();-}--class _MyHomePageState extends State<MyHomePage> {- final Logger _logger = Logger('MyHomePage');-- @override- Widget build(BuildContext context) {- return Scaffold(- appBar: AppBar(- title: Text('Log Viewer Example'),- actions: [- IconButton(- icon: Icon(Icons.bug_report),- onPressed: () {- // Navigate to log viewer- LogViewer.openViewer(context);- },- ),- ],- ),- body: Center(- child: Column(- mainAxisAlignment: MainAxisAlignment.center,- children: [- ElevatedButton(- onPressed: () {- _logger.info('Info log message');- },- child: Text('Log Info'),- ),- ElevatedButton(- onPressed: () {- _logger.warning('Warning log message');- },- child: Text('Log Warning'),- ),- ElevatedButton(- onPressed: () {- try {- throw Exception('Test error');- } catch (e, s) {- _logger.severe('Error occurred', e, s);- }- },- child: Text('Log Error'),- ),- ],- ),- ),- );- }-}-```--## SuperLogging Integration (Ente Photos Style)--### Complete Integration Example--```dart-import 'package:flutter/foundation.dart';-import 'package:flutter/material.dart';-import 'package:log_viewer/log_viewer.dart';-import 'package:logging/logging.dart';-import 'package:path_provider/path_provider.dart';--// SuperLogging-like configuration-class LogConfig {- final String? logDirPath;- final int maxLogFiles;- final bool enableInDebugMode;- final FutureOrVoidCallback? body;- final String prefix;-- LogConfig({- this.logDirPath,- this.maxLogFiles = 10,- this.enableInDebugMode = false,- this.body,- this.prefix = "",- });-}--class SuperLogging {- static final Logger _logger = Logger('SuperLogging');- static late LogConfig config;-- static Future<void> main([LogConfig? appConfig]) async {- appConfig ??= LogConfig();- SuperLogging.config = appConfig;-- WidgetsFlutterBinding.ensureInitialized();-- // Initialize log viewer in debug mode with prefix- if (kDebugMode) {- try {- await LogViewer.initialize(prefix: appConfig.prefix);- _logger.info("Log viewer initialized successfully");- } catch (e) {- _logger.warning("Failed to initialize log viewer: $e");- }- }-- Logger.root.level = kDebugMode ? Level.ALL : Level.INFO;- Logger.root.onRecord.listen(onLogRecord);-- if (appConfig.body != null) {- await appConfig.body!();- }- }-- static Future<void> onLogRecord(LogRecord rec) async {- final str = "${config.prefix} ${rec.toString()}";-- // Print to console- if (kDebugMode) {- print(str);- }-- // Log viewer automatically captures all logs - no manual integration needed!- }-}--// Main application with SuperLogging integration-Future<void> main() async {- await SuperLogging.main(- LogConfig(- body: () async {- runApp(MyApp());- },- logDirPath: (await getApplicationSupportDirectory()).path + "/logs",- maxLogFiles: 5,- enableInDebugMode: true,- prefix: "[APP]",- ),- );-}-```--### Ente Photos Integration Example--In your Ente Photos app's main.dart or SuperLogging class, add the log viewer initialization:--```dart-Future runWithLogs(Function() function, {String prefix = ""}) async {- await SuperLogging.main(- LogConfig(- body: function,- logDirPath: (await getApplicationSupportDirectory()).path + "/logs",- maxLogFiles: 5,- sentryDsn: kDebugMode ? sentryDebugDSN : sentryDSN,- tunnel: sentryTunnel,- enableInDebugMode: true,- prefix: prefix,- ),- );-}--// In SuperLogging.main():-if (kDebugMode) {- try {- // Simply initialize with prefix - no callbacks needed!- await LogViewer.initialize(prefix: appConfig.prefix);- _logger.info("Log viewer initialized successfully");- } catch (e) {- _logger.warning("Failed to initialize log viewer: $e");- }-}-```--### Settings Page Integration--Add log viewer access in your settings page (debug mode only):--```dart-import 'package:flutter/foundation.dart';-import 'package:flutter/material.dart';-import 'package:log_viewer/log_viewer.dart';--class SettingsPage extends StatelessWidget {- @override- Widget build(BuildContext context) {- return Scaffold(- body: Column(- children: [- // Existing email/user info with debug button- Row(- children: [- Expanded(- child: Text(- '[email protected]',- style: TextStyle(color: Colors.grey),- ),- ),- if (kDebugMode)- GestureDetector(- onTap: () {- LogViewer.openViewer(context);- },- child: Container(- padding: const EdgeInsets.all(8),- child: Icon(- Icons.bug_report,- size: 20,- color: Colors.grey,- ),- ),- ),- ],- ),- // Other settings items...- ],- ),- );- }-}-```--## Features Available--Once integrated, users will have access to:--1. **Real-time log viewing** - Logs appear as they're generated-2. **Filtering by log level** - Show only errors, warnings, info, etc.-3. **Filtering by logger name** - Focus on specific components-4. **Text search** - Search within log messages and errors-5. **Date range filtering** - View logs from specific time periods-6. **Export functionality** - Share logs as text files-7. **Detailed view** - Tap any log to see full details including stack traces--## How It Works--1. The `log_viewer` package automatically registers with `Logger.root.onRecord` on initialization-2. Logs are stored in a local SQLite database (auto-truncated to 10000 entries by default)-3. The UI provides filtering and search capabilities-4. When a prefix is provided, it's automatically prepended to all log messages-5. No manual callback registration or integration needed - just initialize and go!--## Troubleshooting--If logs aren't appearing:--1. Ensure `LogViewer.initialize()` is called early in app initialization-2. Check that the app has write permissions for the database-3. Verify that `Logger.root.level` is set appropriately (not OFF)-4. If using a prefix, verify it's being passed correctly to `LogViewer.initialize(prefix: yourPrefix)`--## Performance Notes--- Logs are buffered and batch-inserted for optimal performance-- Database is indexed for fast filtering-- UI updates are debounced to avoid excessive refreshes-- Old logs are automatically cleaned updiff --git a/mobile/packages/log_viewer/example_logger_filter.md b/mobile/packages/log_viewer/example_logger_filter.mddeleted file mode 100644index 0f41e94385..0000000000--- a/mobile/packages/log_viewer/example_logger_filter.md+++ /dev/null@@ -1,43 +0,0 @@-# Logger Filter Feature Usage--The log viewer now supports filtering logs by logger names directly through the search box, without any UI changes.--## Search Syntax--### Basic Logger Filtering--- `logger:AuthService` - Shows only logs from the AuthService logger-- `logger:UserService` - Shows only logs from the UserService logger--### Wildcard Support--- `logger:Auth*` - Shows logs from all loggers starting with "Auth" (e.g., AuthService, Authentication, AuthManager)-- `logger:*Service` - Not supported yet (only prefix wildcards are supported)--### Combined Search--- `logger:AuthService error` - Shows logs from AuthService that contain "error" in the message-- `login logger:UserService` - Shows logs from UserService that contain "login"-- `logger:Auth* failed` - Shows logs from loggers starting with "Auth" that contain "failed"--## Quick Access from Analytics--1. Navigate to Logger Analytics (via the menu in the log viewer)-2. Tap on any logger name card-3. The log viewer will automatically populate the search box with `logger:LoggerName` and filter the logs--## Implementation Details--- The search box hint text now shows "Search logs or use logger:name..."-- When logger: syntax is detected, it's parsed and converted to logger filters-- The remaining text (after removing logger: patterns) is used for message search-- Multiple logger patterns can be used: `logger:Auth* logger:User*`-- Clearing the search box removes all filters--## Benefits--1. **No UI Changes**: The existing search box is enhanced with new functionality-2. **Intuitive Syntax**: Similar to GitHub and Google search operators-3. **Quick Navigation**: Tap logger names in analytics to instantly filter-4. **Powerful Combinations**: Mix logger filters with text search-5. **Wildcard Support**: Filter multiple related loggers with prefix patternsdiff --git a/mobile/packages/log_viewer/lib/log_viewer.dart b/mobile/packages/log_viewer/lib/log_viewer.dartdeleted file mode 100644index 31013f2b25..0000000000--- a/mobile/packages/log_viewer/lib/log_viewer.dart+++ /dev/null@@ -1,73 +0,0 @@-import 'package:flutter/material.dart';-import 'package:log_viewer/src/core/log_store.dart';-import 'package:log_viewer/src/ui/log_viewer_page.dart';-import 'package:logging/logging.dart' as log;--export 'src/core/log_database.dart';-export 'src/core/log_models.dart';-export 'src/core/log_store.dart';-export 'src/ui/log_detail_page.dart';-export 'src/ui/log_filter_dialog.dart';-export 'src/ui/log_list_tile.dart';-export 'src/ui/log_viewer_page.dart';--class LogViewer {- static bool _initialized = false;- static String _prefix = '';-- static Future<void> initialize({String prefix = ''}) async {- if (_initialized) return;-- _prefix = prefix;-- await LogStore.instance.initialize();-- _registerWithSuperLogging();-- _initialized = true;- }-- static void _registerWithSuperLogging() {- try {- log.Logger.root.onRecord.listen((record) {- LogStore.addLogRecord(record, _prefix);- });- } catch (e) {- log.Logger.root.onRecord.listen((record) {- LogStore.addLogRecord(record, '');- });- }- }-- static Widget getViewerPage() {- if (!_initialized) {- throw StateError(- 'LogViewer not initialized. Call LogViewer.initialize() first.',- );- }- return const LogViewerPage();- }-- static Future<void> openViewer(BuildContext context) async {- if (!_initialized) {- await initialize();- }- if (!context.mounted) {- return;- }-- await Navigator.push(- context,- MaterialPageRoute(builder: (context) => const LogViewerPage()),- );- }-- static bool get isInitialized => _initialized;-- static Future<void> dispose() async {- if (_initialized) {- await LogStore.instance.dispose();- _initialized = false;- }- }-}diff --git a/mobile/packages/log_viewer/lib/src/core/log_database.dart b/mobile/packages/log_viewer/lib/src/core/log_database.dartdeleted file mode 100644index 791abcc1cb..0000000000--- a/mobile/packages/log_viewer/lib/src/core/log_database.dart+++ /dev/null@@ -1,413 +0,0 @@-import 'dart:async';--import 'package:log_viewer/src/core/log_models.dart';-import 'package:path/path.dart';-import 'package:path_provider/path_provider.dart';-import 'package:sqflite/sqflite.dart';--class LogDatabase {- static const String _databaseName = 'log_viewer.db';- static const String _tableName = 'logs';- static const int _databaseVersion = 1;-- final int maxEntries;- Database? _database;-- LogDatabase({this.maxEntries = 10000});-- Future<Database> get database async {- _database ??= await _initDatabase();- return _database!;- }-- Future<Database> _initDatabase() async {- final documentsDirectory = await getApplicationDocumentsDirectory();- final path = join(documentsDirectory.path, _databaseName);-- return await databaseFactory.openDatabase(- path,- options: OpenDatabaseOptions(- version: _databaseVersion,- onCreate: _onCreate,- onOpen: _onOpen,- // Transactions orphaned by killed engines must not block later opens.- rollbackActiveTransactionOnOpen: true,- ),- );- }-- Future<void> _onCreate(Database db, int version) async {- await db.execute('''- CREATE TABLE $_tableName(- id INTEGER PRIMARY KEY AUTOINCREMENT,- message TEXT NOT NULL,- level TEXT NOT NULL,- timestamp INTEGER NOT NULL,- logger_name TEXT NOT NULL,- error TEXT,- stack_trace TEXT,- process_prefix TEXT NOT NULL DEFAULT ''- )- ''');-- await db.execute(- 'CREATE INDEX idx_timestamp ON $_tableName(timestamp DESC)',- );- }-- Future<void> _onOpen(Database db) async {- await db.rawQuery('PRAGMA journal_mode = WAL');- }-- Future<int> insertLog(LogEntry entry) async {- final db = await database;- final id = await db.insert(_tableName, entry.toMap());-- await _truncateIfNeeded(db);-- return id;- }-- Future<void> insertLogs(List<LogEntry> entries) async {- if (entries.isEmpty) return;-- final db = await database;- final batch = db.batch();-- for (final entry in entries) {- batch.insert(_tableName, entry.toMap());- }-- await batch.commit(noResult: true);- await _truncateIfNeeded(db);- }-- Future<List<LogEntry>> getLogs({- LogFilter? filter,- int limit = 250,- int offset = 0,- }) async {- final db = await database;-- final conditions = <String>[];- final args = <dynamic>[];-- if (filter != null) {- if (filter.selectedLoggers.isNotEmpty) {- final placeholders = List.filled(- filter.selectedLoggers.length,- '?',- ).join(',');- conditions.add('logger_name IN ($placeholders)');- args.addAll(filter.selectedLoggers);- }-- if (filter.selectedLevels.isNotEmpty) {- final placeholders = List.filled(- filter.selectedLevels.length,- '?',- ).join(',');- conditions.add('level IN ($placeholders)');- args.addAll(filter.selectedLevels);- }-- if (filter.selectedProcesses.isNotEmpty) {- final placeholders = List.filled(- filter.selectedProcesses.length,- '?',- ).join(',');- conditions.add('process_prefix IN ($placeholders)');- args.addAll(filter.selectedProcesses);- }-- if (filter.searchQuery != null && filter.searchQuery!.isNotEmpty) {- conditions.add('(message LIKE ? OR error LIKE ?)');- final searchPattern = '%${filter.searchQuery}%';- args.add(searchPattern);- args.add(searchPattern);- }-- if (filter.startTime != null) {- conditions.add('timestamp >= ?');- args.add(filter.startTime!.millisecondsSinceEpoch);- }- if (filter.endTime != null) {- conditions.add('timestamp <= ?');- args.add(filter.endTime!.millisecondsSinceEpoch);- }- }-- final whereClause = conditions.isEmpty ? null : conditions.join(' AND ');-- final results = await db.query(- _tableName,- where: whereClause,- whereArgs: args.isEmpty ? null : args,- orderBy: filter?.sortNewestFirst == false- ? 'timestamp ASC'- : 'timestamp DESC',- limit: limit,- offset: offset,- );-- return results.map((map) => LogEntry.fromMap(map)).toList();- }-- Future<List<String>> getUniqueLoggers() async {- final db = await database;- final results = await db.rawQuery(- 'SELECT DISTINCT logger_name FROM $_tableName ORDER BY logger_name',- );-- return results.map((row) => row['logger_name'] as String).toList();- }-- Future<List<String>> getUniqueProcesses() async {- final db = await database;- final results = await db.rawQuery(- 'SELECT DISTINCT process_prefix FROM $_tableName WHERE process_prefix != "" ORDER BY process_prefix',- );-- final prefixes = results- .map((row) => row['process_prefix'] as String)- .toList();-- final uniquePrefixes = <String>[''];- uniquePrefixes.addAll(prefixes);-- return uniquePrefixes;- }-- Future<int> getLogCount({LogFilter? filter}) async {- final db = await database;-- if (filter == null || !filter.hasActiveFilters) {- final result = await db.rawQuery(- 'SELECT COUNT(*) as count FROM $_tableName',- );- return result.first['count'] as int;- }-- final conditions = <String>[];- final args = <dynamic>[];-- if (filter.selectedLoggers.isNotEmpty) {- final placeholders = List.filled(- filter.selectedLoggers.length,- '?',- ).join(',');- conditions.add('logger_name IN ($placeholders)');- args.addAll(filter.selectedLoggers);- }-- if (filter.selectedLevels.isNotEmpty) {- final placeholders = List.filled(- filter.selectedLevels.length,- '?',- ).join(',');- conditions.add('level IN ($placeholders)');- args.addAll(filter.selectedLevels);- }-- if (filter.selectedProcesses.isNotEmpty) {- final placeholders = List.filled(- filter.selectedProcesses.length,- '?',- ).join(',');- conditions.add('process_prefix IN ($placeholders)');- args.addAll(filter.selectedProcesses);- }-- if (filter.searchQuery != null && filter.searchQuery!.isNotEmpty) {- conditions.add('(message LIKE ? OR error LIKE ?)');- final searchPattern = '%${filter.searchQuery}%';- args.add(searchPattern);- args.add(searchPattern);- }-- if (filter.startTime != null) {- conditions.add('timestamp >= ?');- args.add(filter.startTime!.millisecondsSinceEpoch);- }- if (filter.endTime != null) {- conditions.add('timestamp <= ?');- args.add(filter.endTime!.millisecondsSinceEpoch);- }-- final whereClause = conditions.join(' AND ');- final query =- 'SELECT COUNT(*) as count FROM $_tableName WHERE $whereClause';- final result = await db.rawQuery(query, args);-- return result.first['count'] as int;- }-- Future<void> clearLogs() async {- final db = await database;- await db.delete(_tableName);- }-- Future<void> clearLogsByLogger(String loggerName) async {- final db = await database;- await db.delete(- _tableName,- where: 'logger_name = ?',- whereArgs: [loggerName],- );- }-- Future<void> _truncateIfNeeded(Database db) async {- final countResult = await db.rawQuery(- 'SELECT COUNT(*) as count FROM $_tableName',- );- final count = countResult.first['count'] as int;-- if (count >= maxEntries + 1000) {- final toDelete = count - maxEntries;-- await db.execute(- '''- DELETE FROM $_tableName- WHERE id IN (- SELECT id FROM $_tableName- ORDER BY timestamp ASC- LIMIT ?- )- ''',- [toDelete],- );- }- }-- Future<List<LoggerStatistic>> getLoggerStatistics({LogFilter? filter}) async {- final db = await database;-- final conditions = <String>[];- final args = <dynamic>[];-- if (filter != null) {- if (filter.selectedLoggers.isNotEmpty) {- final placeholders = List.filled(- filter.selectedLoggers.length,- '?',- ).join(',');- conditions.add('logger_name IN ($placeholders)');- args.addAll(filter.selectedLoggers);- }-- if (filter.selectedLevels.isNotEmpty) {- final placeholders = List.filled(- filter.selectedLevels.length,- '?',- ).join(',');- conditions.add('level IN ($placeholders)');- args.addAll(filter.selectedLevels);- }-- if (filter.selectedProcesses.isNotEmpty) {- final placeholders = List.filled(- filter.selectedProcesses.length,- '?',- ).join(',');- conditions.add('process_prefix IN ($placeholders)');- args.addAll(filter.selectedProcesses);- }-- if (filter.searchQuery != null && filter.searchQuery!.isNotEmpty) {- conditions.add('(message LIKE ? OR error LIKE ?)');- final searchPattern = '%${filter.searchQuery}%';- args.add(searchPattern);- args.add(searchPattern);- }-- if (filter.startTime != null) {- conditions.add('timestamp >= ?');- args.add(filter.startTime!.millisecondsSinceEpoch);- }- if (filter.endTime != null) {- conditions.add('timestamp <= ?');- args.add(filter.endTime!.millisecondsSinceEpoch);- }- }-- final whereClause = conditions.isEmpty- ? ''- : 'WHERE ${conditions.join(' AND ')}';-- final totalQuery = 'SELECT COUNT(*) as total FROM $_tableName $whereClause';- final totalResult = await db.rawQuery(totalQuery, args);- final totalCount = totalResult.first['total'] as int;-- if (totalCount == 0) return [];-- final statsQuery =- '''- SELECT- logger_name,- COUNT(*) as count,- (COUNT(*) * 100.0 / $totalCount) as percentage- FROM $_tableName- $whereClause- GROUP BY logger_name- ORDER BY count DESC- ''';-- final results = await db.rawQuery(statsQuery, args);-- return results- .map(- (row) => LoggerStatistic(- loggerName: row['logger_name'] as String,- logCount: row['count'] as int,- percentage: row['percentage'] as double,- ),- )- .toList();- }-- Future<TimeRange?> getTimeRange() async {- final db = await database;- final result = await db.rawQuery('''- SELECT- MIN(timestamp) as min_timestamp,- MAX(timestamp) as max_timestamp- FROM $_tableName- ''');-- if (result.isNotEmpty && result.first['min_timestamp'] != null) {- return TimeRange(- start: DateTime.fromMillisecondsSinceEpoch(- result.first['min_timestamp'] as int,- ),- end: DateTime.fromMillisecondsSinceEpoch(- result.first['max_timestamp'] as int,- ),- );- }-- return null;- }-- Future<List<DateTime>> getLogTimestamps() async {- final db = await database;- final result = await db.rawQuery('''- SELECT timestamp- FROM $_tableName- ORDER BY timestamp ASC- ''');-- return result- .map(- (row) => DateTime.fromMillisecondsSinceEpoch(row['timestamp'] as int),- )- .toList();- }-- Future<void> close() async {- final db = _database;- if (db != null) {- await db.close();- _database = null;- }- }-}diff --git a/mobile/packages/log_viewer/lib/src/core/log_models.dart b/mobile/packages/log_viewer/lib/src/core/log_models.dartdeleted file mode 100644index f2f37065d2..0000000000--- a/mobile/packages/log_viewer/lib/src/core/log_models.dart+++ /dev/null@@ -1,233 +0,0 @@-import 'package:flutter/material.dart';--class LogEntry {- final int? id;- final String message;- final String level;- final DateTime timestamp;- final String loggerName;- final String? error;- final String? stackTrace;- final String processPrefix;-- LogEntry({- this.id,- required this.message,- required this.level,- required this.timestamp,- required this.loggerName,- this.error,- this.stackTrace,- this.processPrefix = '',- });-- factory LogEntry.fromMap(Map<String, dynamic> map) {- return LogEntry(- id: map['id'] as int?,- message: map['message'] as String,- level: map['level'] as String,- timestamp: DateTime.fromMillisecondsSinceEpoch(map['timestamp'] as int),- loggerName: map['logger_name'] as String,- error: map['error'] as String?,- stackTrace: map['stack_trace'] as String?,- processPrefix: map['process_prefix'] as String? ?? '',- );- }-- Map<String, dynamic> toMap() {- return {- if (id != null) 'id': id,- 'message': message,- 'level': level,- 'timestamp': timestamp.millisecondsSinceEpoch,- 'logger_name': loggerName,- 'error': error,- 'stack_trace': stackTrace,- 'process_prefix': processPrefix,- };- }-- Color get levelColor {- switch (level.toUpperCase()) {- case 'SHOUT':- case 'SEVERE':- return Colors.red;- case 'WARNING':- return Colors.orange;- case 'INFO':- return Colors.blue;- case 'CONFIG':- return Colors.green;- case 'FINE':- case 'FINER':- case 'FINEST':- return Colors.grey;- default:- return Colors.black54;- }- }-- Color? get backgroundColor {- switch (level.toUpperCase()) {- case 'SHOUT':- case 'SEVERE':- return Colors.red.withValues(alpha: 0.1);- case 'WARNING':- return Colors.orange.withValues(alpha: 0.1);- default:- return null;- }- }-- String get truncatedMessage {- final lines = message.split('\n');- const maxLines = 4;-- if (lines.length <= maxLines) {- return message;- }-- return '${lines.take(maxLines).join('\n')}...';- }-- String get formattedTime {- final hour = timestamp.hour.toString().padLeft(2, '0');- final minute = timestamp.minute.toString().padLeft(2, '0');- final second = timestamp.second.toString().padLeft(2, '0');- final millis = timestamp.millisecond.toString().padLeft(3, '0');- return '$hour:$minute:$second.$millis';- }-- String get processDisplayName {- if (processPrefix.isEmpty) {- return 'Foreground';- }- final cleanPrefix = processPrefix.replaceAll(RegExp(r'[\[\]]'), '');- switch (cleanPrefix) {- case 'fbg':- return 'Firebase Background';- default:- return cleanPrefix.isEmpty ? 'Foreground' : cleanPrefix;- }- }-- @override- String toString() {- final buffer = StringBuffer();- buffer.writeln('[$formattedTime] [$loggerName] [$level]');- buffer.writeln(message);- if (error != null) {- buffer.writeln('Error: $error');- }- if (stackTrace != null) {- buffer.writeln('Stack trace:\n$stackTrace');- }- return buffer.toString();- }-}--class LogFilter {- final Set<String> selectedLoggers;- final Set<String> selectedLevels;- final Set<String> selectedProcesses;- final String? searchQuery;- final DateTime? startTime;- final DateTime? endTime;- final bool sortNewestFirst;-- const LogFilter({- this.selectedLoggers = const {},- this.selectedLevels = const {},- this.selectedProcesses = const {},- this.searchQuery,- this.startTime,- this.endTime,- this.sortNewestFirst = true,- });-- LogFilter copyWith({- Set<String>? selectedLoggers,- Set<String>? selectedLevels,- Set<String>? selectedProcesses,- String? searchQuery,- DateTime? startTime,- DateTime? endTime,- bool? sortNewestFirst,- bool clearSearchQuery = false,- bool clearTimeFilter = false,- }) {- return LogFilter(- selectedLoggers: selectedLoggers ?? this.selectedLoggers,- selectedLevels: selectedLevels ?? this.selectedLevels,- selectedProcesses: selectedProcesses ?? this.selectedProcesses,- searchQuery: clearSearchQuery ? null : (searchQuery ?? this.searchQuery),- startTime: clearTimeFilter ? null : (startTime ?? this.startTime),- endTime: clearTimeFilter ? null : (endTime ?? this.endTime),- sortNewestFirst: sortNewestFirst ?? this.sortNewestFirst,- );- }-- bool get hasActiveFilters {- return selectedLoggers.isNotEmpty ||- selectedLevels.isNotEmpty ||- selectedProcesses.isNotEmpty ||- (searchQuery != null && searchQuery!.isNotEmpty) ||- startTime != null ||- endTime != null;- }-- static const LogFilter empty = LogFilter();-}--class LoggerStatistic {- final String loggerName;- final int logCount;- final double percentage;-- const LoggerStatistic({- required this.loggerName,- required this.logCount,- required this.percentage,- });-- int get count => logCount;-- String get formattedPercentage {- if (percentage >= 10) {- return '${percentage.toStringAsFixed(1)}%';- } else if (percentage >= 1) {- return '${percentage.toStringAsFixed(1)}%';- } else {- return '${percentage.toStringAsFixed(2)}%';- }- }-}--class LogLevels {- static const List<String> all = [- 'ALL',- 'FINEST',- 'FINER',- 'FINE',- 'CONFIG',- 'INFO',- 'WARNING',- 'SEVERE',- 'SHOUT',- 'OFF',- ];-- static const List<String> defaultVisible = [- 'INFO',- 'WARNING',- 'SEVERE',- 'SHOUT',- ];-}--class TimeRange {- final DateTime start;- final DateTime end;-- const TimeRange({required this.start, required this.end});-}diff --git a/mobile/packages/log_viewer/lib/src/core/log_store.dart b/mobile/packages/log_viewer/lib/src/core/log_store.dartdeleted file mode 100644index 634dc19599..0000000000--- a/mobile/packages/log_viewer/lib/src/core/log_store.dart+++ /dev/null@@ -1,208 +0,0 @@-import 'dart:async';--import 'package:log_viewer/src/core/log_database.dart';-import 'package:log_viewer/src/core/log_models.dart';-import 'package:logging/logging.dart' as log;--class LogStore {- static final LogStore _instance = LogStore._internal();- static LogStore get instance => _instance;-- LogStore._internal();-- final LogDatabase _database = LogDatabase();- final _logStreamController = StreamController<LogEntry>.broadcast();-- final List<LogEntry> _buffer = [];- Timer? _flushTimer;- static const int _bufferSize = 10;-- bool _initialized = false;- bool get initialized => _initialized;-- Stream<LogEntry> get logStream => _logStreamController.stream;-- Future<void> initialize() async {- if (_initialized) return;-- await _database.database;-- _flushTimer = Timer.periodic(const Duration(seconds: 15), (_) => _flush());-- _initialized = true;- }-- static void addLogRecord(log.LogRecord record, [String? processPrefix]) {- if (_instance._initialized) {- _instance._addLog(record, processPrefix ?? '');- }- }-- void _addLog(log.LogRecord record, String processPrefix) {- final entry = LogEntry(- message: record.message,- level: record.level.name,- timestamp: record.time,- loggerName: record.loggerName,- error: record.error?.toString(),- stackTrace: record.stackTrace?.toString(),- processPrefix: processPrefix,- );-- _buffer.add(entry);-- _logStreamController.add(entry);-- if (_buffer.length >= _bufferSize) {- _flush();- }- }-- Future<void>? _activeFlush;- Future<void>? _queuedFlush;-- Future<void> _flush() {- final active = _activeFlush;- if (active == null) {- return _activeFlush = _drainOnce().whenComplete(() {- _activeFlush = null;- });- }- return _queuedFlush ??= active.then((_) {- _queuedFlush = null;- return _flush();- });- }-- Future<void> _drainOnce() async {- if (_buffer.isEmpty) return;-- final toInsert = List<LogEntry>.from(_buffer);- _buffer.clear();-- try {- await _database.insertLogs(toInsert);- } catch (e) {- // ignore: avoid_print- print('Failed to insert logs to database: $e');- }- }-- Future<List<LogEntry>> getLogs({- LogFilter? filter,- int limit = 250,- int offset = 0,- }) async {- await _flush();-- return _database.getLogs(filter: filter, limit: limit, offset: offset);- }-- Future<List<String>> getLoggerNames() async {- return _database.getUniqueLoggers();- }-- Future<List<String>> getProcessNames() async {- return _database.getUniqueProcesses();- }-- Future<List<LoggerStatistic>> getLoggerStatistics({LogFilter? filter}) async {- await _flush();- return _database.getLoggerStatistics(filter: filter);- }-- Future<int> getLogCount({LogFilter? filter}) async {- await _flush();- return _database.getLogCount(filter: filter);- }-- Future<void> clearLogs() async {- _buffer.clear();- await _database.clearLogs();- }-- Future<void> clearLogsByLogger(String loggerName) async {- _buffer.removeWhere((log) => log.loggerName == loggerName);- await _database.clearLogsByLogger(loggerName);- }-- Future<String> exportLogs({LogFilter? filter}) async {- final logs = await getLogs(filter: filter, limit: 10000);-- final buffer = StringBuffer();- buffer.writeln('=== Ente App Logs ===');- buffer.writeln('Exported at: ${DateTime.now()}');- if (filter != null && filter.hasActiveFilters) {- buffer.writeln('Filters applied:');- if (filter.selectedLoggers.isNotEmpty) {- buffer.writeln(' Loggers: ${filter.selectedLoggers.join(', ')}');- }- if (filter.selectedLevels.isNotEmpty) {- buffer.writeln(' Levels: ${filter.selectedLevels.join(', ')}');- }- if (filter.searchQuery != null && filter.searchQuery!.isNotEmpty) {- buffer.writeln(' Search: ${filter.searchQuery}');- }- }- buffer.writeln('Total logs: ${logs.length}');- buffer.writeln('=' * 40);- buffer.writeln();-- for (final log in logs) {- buffer.writeln(log.toString());- buffer.writeln('-' * 40);- }-- return buffer.toString();- }-- Future<TimeRange?> getTimeRange() async {- await _flush();- return _database.getTimeRange();- }-- Future<List<DateTime>> getLogTimestamps() async {- await _flush();- return _database.getLogTimestamps();- }-- Future<String> exportLogsAsJson({LogFilter? filter}) async {- final logs = await getLogs(filter: filter, limit: 10000);-- final jsonLogs = logs- .map(- (log) => {- 'timestamp': log.timestamp.toIso8601String(),- 'level': log.level,- 'logger': log.loggerName,- 'message': log.message,- if (log.error != null) 'error': log.error,- if (log.stackTrace != null) 'stackTrace': log.stackTrace,- },- )- .toList();-- final buffer = StringBuffer();- buffer.writeln('[');- for (int i = 0; i < jsonLogs.length; i++) {- buffer.write(' ');- buffer.write(jsonLogs[i].toString());- if (i < jsonLogs.length - 1) {- buffer.writeln(',');- } else {- buffer.writeln();- }- }- buffer.writeln(']');-- return buffer.toString();- }-- Future<void> dispose() async {- _initialized = false;- _flushTimer?.cancel();- await _flush();- await _database.close();- await _logStreamController.close();- }-}diff --git a/mobile/packages/log_viewer/lib/src/ui/log_detail_page.dart b/mobile/packages/log_viewer/lib/src/ui/log_detail_page.dartdeleted file mode 100644index 68e0e6fa7d..0000000000--- a/mobile/packages/log_viewer/lib/src/ui/log_detail_page.dart+++ /dev/null@@ -1,183 +0,0 @@-import 'package:flutter/material.dart';-import 'package:flutter/services.dart';-import 'package:log_viewer/src/core/log_models.dart';--class LogDetailPage extends StatelessWidget {- final LogEntry log;-- const LogDetailPage({super.key, required this.log});-- void _copyToClipboard(BuildContext context, String text, String label) {- Clipboard.setData(ClipboardData(text: text));- ScaffoldMessenger.of(context).showSnackBar(- SnackBar(- content: Text('$label copied to clipboard'),- duration: const Duration(seconds: 2),- ),- );- }-- Widget _buildSection({- required BuildContext context,- required String title,- required String content,- bool isMonospace = true,- }) {- final theme = Theme.of(context);-- return Padding(- padding: const EdgeInsets.all(16),- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- Row(- mainAxisAlignment: MainAxisAlignment.spaceBetween,- children: [- Text(- title,- style: theme.textTheme.titleSmall?.copyWith(- fontWeight: FontWeight.bold,- color: theme.primaryColor,- ),- ),- IconButton(- icon: const Icon(Icons.copy, size: 18),- onPressed: () => _copyToClipboard(context, content, title),- tooltip: 'Copy $title',- ),- ],- ),- const SizedBox(height: 8),- Container(- width: double.infinity,- padding: const EdgeInsets.all(12),- decoration: BoxDecoration(- color: theme.cardColor,- borderRadius: BorderRadius.circular(8),- border: Border.all(color: theme.dividerColor, width: 1),- ),- child: SelectableText(- content,- style: TextStyle(- fontFamily: isMonospace ? 'monospace' : null,- fontSize: 13,- ),- ),- ),- ],- ),- );- }-- Widget _buildInfoRow({- required BuildContext context,- required IconData icon,- required String label,- required String value,- Color? valueColor,- }) {- final theme = Theme.of(context);-- return Padding(- padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),- child: Row(- children: [- Icon(icon, size: 20, color: theme.disabledColor),- const SizedBox(width: 12),- Text(- '$label: ',- style: theme.textTheme.bodyMedium?.copyWith(- fontWeight: FontWeight.w500,- ),- ),- Expanded(- child: Text(- value,- style: theme.textTheme.bodyMedium?.copyWith(- color: valueColor,- fontWeight: valueColor != null ? FontWeight.bold : null,- ),- ),- ),- ],- ),- );- }-- @override- Widget build(BuildContext context) {- final theme = Theme.of(context);-- return Scaffold(- appBar: AppBar(- title: const Text('Log Details'),- elevation: 0,- actions: [- IconButton(- icon: const Icon(Icons.copy),- onPressed: () =>- _copyToClipboard(context, log.toString(), 'Complete log'),- tooltip: 'Copy all',- ),- ],- ),- body: SingleChildScrollView(- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- Container(- width: double.infinity,- color: theme.appBarTheme.backgroundColor,- padding: const EdgeInsets.symmetric(vertical: 8),- child: Column(- children: [- _buildInfoRow(- context: context,- icon: Icons.access_time,- label: 'Time',- value: '${log.timestamp.toLocal()}',- ),- _buildInfoRow(- context: context,- icon: Icons.flag,- label: 'Level',- value: log.level,- valueColor: log.levelColor,- ),- _buildInfoRow(- context: context,- icon: Icons.source,- label: 'Logger',- value: log.loggerName,- ),- ],- ),- ),-- _buildSection(- context: context,- title: 'MESSAGE',- content: log.message,- ),-- if (log.error != null)- _buildSection(- context: context,- title: 'ERROR',- content: log.error!,- ),-- if (log.stackTrace != null)- _buildSection(- context: context,- title: 'STACK TRACE',- content: log.stackTrace!,- ),-- const SizedBox(height: 16),- ],- ),- ),- );- }-}diff --git a/mobile/packages/log_viewer/lib/src/ui/log_filter_dialog.dart b/mobile/packages/log_viewer/lib/src/ui/log_filter_dialog.dartdeleted file mode 100644index 7985384bba..0000000000--- a/mobile/packages/log_viewer/lib/src/ui/log_filter_dialog.dart+++ /dev/null@@ -1,448 +0,0 @@-import 'package:flutter/material.dart';-import 'package:log_viewer/src/core/log_models.dart';--class LogFilterDialog extends StatefulWidget {- final List<String> availableLoggers;- final List<String> availableProcesses;- final LogFilter currentFilter;-- const LogFilterDialog({- super.key,- required this.availableLoggers,- required this.availableProcesses,- required this.currentFilter,- });-- @override- State<LogFilterDialog> createState() => _LogFilterDialogState();-}--class _LogFilterDialogState extends State<LogFilterDialog> {- late Set<String> _selectedLoggers;- late Set<String> _selectedLevels;- late Set<String> _selectedProcesses;- DateTime? _startTime;- DateTime? _endTime;-- @override- void initState() {- super.initState();- _selectedLoggers = Set.from(widget.currentFilter.selectedLoggers);- _selectedLevels = Set.from(widget.currentFilter.selectedLevels);- _selectedProcesses = Set.from(widget.currentFilter.selectedProcesses);- _startTime = widget.currentFilter.startTime;- _endTime = widget.currentFilter.endTime;- }-- void _applyFilters() {- final newFilter = LogFilter(- selectedLoggers: _selectedLoggers,- selectedLevels: _selectedLevels,- selectedProcesses: _selectedProcesses,- searchQuery: widget.currentFilter.searchQuery,- startTime: _startTime,- endTime: _endTime,- );- Navigator.pop(context, newFilter);- }-- void _clearFilters() {- setState(() {- _selectedLoggers.clear();- _selectedLevels.clear();- _selectedProcesses.clear();- });- }-- Widget _buildLevelChip(String level) {- final isSelected = _selectedLevels.contains(level);- final color = LogEntry(- message: '',- level: level,- timestamp: DateTime.now(),- loggerName: '',- ).levelColor;-- return FilterChip(- label: Text(- level,- style: TextStyle(- color: isSelected ? Colors.white : color,- fontSize: 9,- fontWeight: isSelected ? FontWeight.w600 : FontWeight.w500,- ),- ),- selected: isSelected,- selectedColor: color,- backgroundColor: color.withValues(alpha: 0.15),- checkmarkColor: Colors.white,- side: BorderSide(- color: isSelected ? color : color.withValues(alpha: 0.3),- width: isSelected ? 1.5 : 1,- ),- padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 1),- onSelected: (selected) {- setState(() {- if (selected) {- _selectedLevels.add(level);- } else {- _selectedLevels.remove(level);- }- });- },- );- }-- @override- Widget build(BuildContext context) {- final theme = Theme.of(context);-- return Dialog(- shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),- child: Container(- constraints: const BoxConstraints(maxWidth: 380, maxHeight: 500),- decoration: BoxDecoration(borderRadius: BorderRadius.circular(16)),- child: Column(- mainAxisSize: MainAxisSize.min,- children: [- Container(- padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),- decoration: const BoxDecoration(- borderRadius: BorderRadius.vertical(top: Radius.circular(16)),- ),- child: Row(- mainAxisAlignment: MainAxisAlignment.spaceBetween,- children: [- Text(- 'Filter Logs',- style: theme.textTheme.titleLarge?.copyWith(- fontWeight: FontWeight.w600,- fontSize: 18,- ),- ),- IconButton(- icon: const Icon(Icons.close, size: 22),- onPressed: () => Navigator.pop(context),- padding: EdgeInsets.zero,- constraints: const BoxConstraints(),- ),- ],- ),- ),-- Flexible(- child: SingleChildScrollView(- padding: const EdgeInsets.symmetric(- horizontal: 16,- vertical: 6,- ),- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- Text(- 'Log Levels',- style: theme.textTheme.titleMedium?.copyWith(- fontWeight: FontWeight.w600,- fontSize: 14,- ),- ),- const SizedBox(height: 8),- Wrap(- spacing: 8,- runSpacing: 3,- children: LogLevels.all- .where((level) => level != 'ALL' && level != 'OFF')- .map(_buildLevelChip)- .toList(),- ),- const SizedBox(height: 16),-- if (widget.availableProcesses.isNotEmpty) ...[- Text(- 'Process',- style: theme.textTheme.titleMedium?.copyWith(- fontWeight: FontWeight.w600,- fontSize: 15,- ),- ),- const SizedBox(height: 8),- Container(- constraints: const BoxConstraints(maxHeight: 120),- decoration: BoxDecoration(- border: Border.all(- color: theme.dividerColor.withValues(alpha: 0.5),- width: 1,- ),- borderRadius: BorderRadius.circular(6),- color: theme.cardColor,- ),- child: ClipRRect(- borderRadius: BorderRadius.circular(6),- child: ListView.separated(- shrinkWrap: true,- itemCount: widget.availableProcesses.length,- separatorBuilder: (context, index) => Divider(- height: 1,- thickness: 0.5,- color: theme.dividerColor.withValues(alpha: 0.3),- ),- itemBuilder: (context, index) {- final process = widget.availableProcesses[index];- final isSelected = _selectedProcesses.contains(- process,- );- final displayName = LogEntry(- message: '',- level: 'INFO',- timestamp: DateTime.now(),- loggerName: '',- processPrefix: process,- ).processDisplayName;-- return InkWell(- onTap: () {- setState(() {- if (isSelected) {- _selectedProcesses.remove(process);- } else {- _selectedProcesses.add(process);- }- });- },- child: Container(- padding: const EdgeInsets.symmetric(- horizontal: 12,- vertical: 8,- ),- child: Row(- children: [- Expanded(- child: Text(- displayName,- style: TextStyle(- fontSize: 13,- color: isSelected- ? theme.primaryColor- : theme- .textTheme- .bodyLarge- ?.color,- fontWeight: isSelected- ? FontWeight.w500- : FontWeight.normal,- ),- overflow: TextOverflow.ellipsis,- ),- ),- SizedBox(- width: 20,- height: 20,- child: Checkbox(- value: isSelected,- onChanged: (selected) {- setState(() {- if (selected == true) {- _selectedProcesses.add(process);- } else {- _selectedProcesses.remove(- process,- );- }- });- },- materialTapTargetSize:- MaterialTapTargetSize.shrinkWrap,- ),- ),- ],- ),- ),- );- },- ),- ),- ),- const SizedBox(height: 16),- ],-- if (widget.availableLoggers.isNotEmpty) ...[- Text(- 'Loggers',- style: theme.textTheme.titleMedium?.copyWith(- fontWeight: FontWeight.w600,- fontSize: 15,- ),- ),- const SizedBox(height: 8),- Container(- constraints: const BoxConstraints(maxHeight: 120),- decoration: BoxDecoration(- border: Border.all(- color: theme.dividerColor.withValues(alpha: 0.5),- width: 1,- ),- borderRadius: BorderRadius.circular(6),- color: theme.cardColor,- ),- child: ClipRRect(- borderRadius: BorderRadius.circular(6),- child: ListView.separated(- shrinkWrap: true,- itemCount: widget.availableLoggers.length,- separatorBuilder: (context, index) => Divider(- height: 1,- thickness: 0.5,- color: theme.dividerColor.withValues(alpha: 0.3),- ),- itemBuilder: (context, index) {- final logger = widget.availableLoggers[index];- final isSelected = _selectedLoggers.contains(- logger,- );- return InkWell(- onTap: () {- setState(() {- if (isSelected) {- _selectedLoggers.remove(logger);- } else {- _selectedLoggers.add(logger);- }- });- },- child: Container(- padding: const EdgeInsets.symmetric(- horizontal: 12,- vertical: 8,- ),- child: Row(- children: [- Expanded(- child: Text(- logger,- style: TextStyle(- fontSize: 13,- color: isSelected- ? theme.primaryColor- : theme- .textTheme- .bodyLarge- ?.color,- fontWeight: isSelected- ? FontWeight.w500- : FontWeight.normal,- ),- overflow: TextOverflow.ellipsis,- ),- ),- SizedBox(- width: 20,- height: 20,- child: Checkbox(- value: isSelected,- onChanged: (selected) {- setState(() {- if (selected == true) {- _selectedLoggers.add(logger);- } else {- _selectedLoggers.remove(logger);- }- });- },- materialTapTargetSize:- MaterialTapTargetSize.shrinkWrap,- ),- ),- ],- ),- ),- );- },- ),- ),- ),- const SizedBox(height: 16),- ],- ],- ),- ),- ),-- Container(- padding: const EdgeInsets.all(12),- decoration: BoxDecoration(- border: Border(- top: BorderSide(- color: theme.dividerColor.withValues(alpha: 0.2),- width: 1,- ),- ),- borderRadius: const BorderRadius.vertical(- bottom: Radius.circular(16),- ),- ),- child: Row(- mainAxisAlignment: MainAxisAlignment.spaceBetween,- children: [- TextButton(- onPressed: _clearFilters,- style: TextButton.styleFrom(- foregroundColor: theme.colorScheme.error,- padding: const EdgeInsets.symmetric(- horizontal: 12,- vertical: 8,- ),- ),- child: const Text(- 'Clear All',- style: TextStyle(fontSize: 14),- ),- ),- Row(- children: [- TextButton(- onPressed: () => Navigator.pop(context),- style: TextButton.styleFrom(- padding: const EdgeInsets.symmetric(- horizontal: 16,- vertical: 8,- ),- ),- child: Text(- 'Cancel',- style: TextStyle(- fontSize: 14,- color: theme.textTheme.bodyLarge?.color,- ),- ),- ),- const SizedBox(width: 8),- FilledButton(- onPressed: _applyFilters,- style: FilledButton.styleFrom(- padding: const EdgeInsets.symmetric(- horizontal: 20,- vertical: 8,- ),- shape: RoundedRectangleBorder(- borderRadius: BorderRadius.circular(8),- ),- ),- child: const Text(- 'Apply',- style: TextStyle(- fontSize: 14,- fontWeight: FontWeight.w600,- ),- ),- ),- ],- ),- ],- ),- ),- ],- ),- ),- );- }-}diff --git a/mobile/packages/log_viewer/lib/src/ui/log_list_tile.dart b/mobile/packages/log_viewer/lib/src/ui/log_list_tile.dartdeleted file mode 100644index 3eec5038d6..0000000000--- a/mobile/packages/log_viewer/lib/src/ui/log_list_tile.dart+++ /dev/null@@ -1,82 +0,0 @@-import 'package:flutter/material.dart';-import 'package:log_viewer/src/core/log_models.dart';--class LogListTile extends StatelessWidget {- final LogEntry log;- final VoidCallback onTap;-- const LogListTile({super.key, required this.log, required this.onTap});-- @override- Widget build(BuildContext context) {- final theme = Theme.of(context);-- return ListTile(- onTap: onTap,- tileColor: log.backgroundColor,- leading: Container(- width: 10,- height: 10,- decoration: BoxDecoration(- color: log.levelColor,- shape: BoxShape.circle,- ),- ),- title: Text(- log.truncatedMessage,- style: TextStyle(- fontFamily: 'monospace',- fontSize: 13,- color: theme.textTheme.bodyLarge?.color,- ),- maxLines: 4,- overflow: TextOverflow.ellipsis,- ),- subtitle: Padding(- padding: const EdgeInsets.only(top: 4),- child: Row(- children: [- Icon(- Icons.access_time,- size: 12,- color: theme.textTheme.bodySmall?.color,- ),- const SizedBox(width: 4),- Text(- log.formattedTime,- style: TextStyle(- fontSize: 11,- color: theme.textTheme.bodySmall?.color,- ),- ),- const SizedBox(width: 12),- Icon(- Icons.source,- size: 12,- color: theme.textTheme.bodySmall?.color,- ),- const SizedBox(width: 4),- Flexible(- child: Text(- log.loggerName,- style: TextStyle(- fontSize: 11,- color: theme.textTheme.bodySmall?.color,- fontWeight: FontWeight.w500,- ),- overflow: TextOverflow.ellipsis,- ),- ),- if (log.error != null) ...[- const SizedBox(width: 8),- Icon(Icons.error_outline, size: 14, color: Colors.red[400]),- ],- ],- ),- ),- trailing: Icon(Icons.chevron_right, size: 20, color: theme.disabledColor),- visualDensity: VisualDensity.compact,- contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),- );- }-}diff --git a/mobile/packages/log_viewer/lib/src/ui/log_viewer_page.dart b/mobile/packages/log_viewer/lib/src/ui/log_viewer_page.dartdeleted file mode 100644index e2548bac78..0000000000--- a/mobile/packages/log_viewer/lib/src/ui/log_viewer_page.dart+++ /dev/null@@ -1,678 +0,0 @@-import 'dart:async';--import 'package:flutter/material.dart';-import 'package:log_viewer/src/core/log_models.dart';-import 'package:log_viewer/src/core/log_store.dart';-import 'package:log_viewer/src/ui/log_detail_page.dart';-import 'package:log_viewer/src/ui/log_filter_dialog.dart';-import 'package:log_viewer/src/ui/log_list_tile.dart';-import 'package:log_viewer/src/ui/logger_statistics_page.dart';-import 'package:log_viewer/src/ui/timeline_widget.dart';-import 'package:share_plus/share_plus.dart';--class LogViewerPage extends StatefulWidget {- const LogViewerPage({super.key});-- @override- State<LogViewerPage> createState() => _LogViewerPageState();-}--class _LogViewerPageState extends State<LogViewerPage> {- final LogStore _logStore = LogStore.instance;- final TextEditingController _searchController = TextEditingController();-- List<LogEntry> _logs = [];- List<String> _availableLoggers = [];- List<String> _availableProcesses = [];- LogFilter _filter = const LogFilter(- selectedLevels: {'WARNING', 'SEVERE', 'SHOUT'},- );- bool _isLoading = true;- bool _isLoadingMore = false;- bool _hasMoreLogs = true;- int _currentOffset = 0;- static const int _pageSize = 100;- StreamSubscription<LogEntry>? _logStreamSubscription;-- bool _timeFilterEnabled = false;-- DateTime? _overallStartTime;- DateTime? _overallEndTime;- DateTime? _timelineStartTime;- DateTime? _timelineEndTime;- List<DateTime> _logTimestamps = [];-- @override- void initState() {- super.initState();- _initialize();- }-- Future<void> _initialize() async {- await _loadLoggers();- await _loadProcesses();- await _initializeTimeline();- await _loadLogs();-- _logStreamSubscription = _logStore.logStream.listen((_) {- _scheduleRefresh();- });- }-- Future<void> _initializeTimeline() async {- final timeRange = await _logStore.getTimeRange();- if (timeRange != null) {- setState(() {- _overallStartTime = timeRange.start;- _overallEndTime = timeRange.end;- _timelineStartTime = timeRange.start;- _timelineEndTime = timeRange.end;- });- }- await _loadLogTimestamps();- }-- Future<void> _loadLogTimestamps() async {- final timestamps = await _logStore.getLogTimestamps();- setState(() {- _logTimestamps = timestamps;- });- }-- void _onTimelineRangeChanged(DateTime start, DateTime end) {- setState(() {- _timelineStartTime = start;- _timelineEndTime = end;- _filter = _filter.copyWith(startTime: start, endTime: end);- });- _loadLogs();- }-- Timer? _refreshTimer;- void _scheduleRefresh() {- _refreshTimer?.cancel();- _refreshTimer = Timer(const Duration(seconds: 1), () {- if (mounted) {- _loadLogs();- }- });- }-- Future<void> _loadLogs({bool reset = true}) async {- if (reset) {- setState(() {- _isLoading = true;- _currentOffset = 0;- _hasMoreLogs = true;- _logs.clear();- });- } else {- setState(() => _isLoadingMore = true);- }-- try {- final logs = await _logStore.getLogs(- filter: _filter,- limit: _pageSize,- offset: _currentOffset,- );-- if (mounted) {- setState(() {- if (reset) {- _logs = logs;- _isLoading = false;- } else {- _logs.addAll(logs);- _isLoadingMore = false;- }-- _currentOffset += logs.length;- _hasMoreLogs = logs.length == _pageSize;- });- }- } catch (e) {- if (mounted) {- setState(() {- _isLoading = false;- _isLoadingMore = false;- });- ScaffoldMessenger.of(- context,- ).showSnackBar(SnackBar(content: Text('Failed to load logs: $e')));- }- }- }-- Future<void> _loadMoreLogs() async {- if (!_hasMoreLogs || _isLoadingMore) return;- await _loadLogs(reset: false);- }-- Future<void> _loadLoggers() async {- try {- final loggers = await _logStore.getLoggerNames();- if (mounted) {- setState(() => _availableLoggers = loggers);- }- } catch (e) {- debugPrint('Failed to load logger names: $e');- }- }-- Future<void> _loadProcesses() async {- try {- final processes = await _logStore.getProcessNames();- if (mounted) {- setState(() => _availableProcesses = processes);- }- } catch (e) {- debugPrint('Failed to load process names: $e');- }- }-- void _onSearchChanged(String query) {- String? searchText = query;- Set<String>? loggerFilters;-- if (query.isNotEmpty) {- final loggerPattern = RegExp(r'logger:(\S+)');- final matches = loggerPattern.allMatches(query);-- if (matches.isNotEmpty) {- loggerFilters = {};- for (final match in matches) {- final loggerName = match.group(1);- if (loggerName != null) {- if (loggerName.endsWith('*')) {- final prefix = loggerName.substring(0, loggerName.length - 1);- for (final logger in _availableLoggers) {- if (logger.startsWith(prefix)) {- loggerFilters.add(logger);- }- }- } else {- loggerFilters.add(loggerName);- }- }- }-- searchText = query.replaceAll(loggerPattern, '').trim();- if (searchText.isEmpty) {- searchText = null;- }- }- } else {- loggerFilters = {};- }-- setState(() {- final newLoggerFilters =- loggerFilters ??- (query.isEmpty ? <String>{} : _filter.selectedLoggers);-- _filter = _filter.copyWith(- searchQuery: searchText,- clearSearchQuery: query.isEmpty,- selectedLoggers: newLoggerFilters,- );- });- _loadLogs();- }-- void _updateTimeFilter() {- setState(() {- if (_timeFilterEnabled &&- _timelineStartTime != null &&- _timelineEndTime != null) {- _filter = _filter.copyWith(- startTime: _timelineStartTime,- endTime: _timelineEndTime,- );- } else {- _filter = _filter.copyWith(clearTimeFilter: true);- }- });- _loadLogs();- }-- Future<void> _showFilterDialog() async {- final newFilter = await showDialog<LogFilter>(- context: context,- builder: (context) => LogFilterDialog(- availableLoggers: _availableLoggers,- availableProcesses: _availableProcesses,- currentFilter: _filter,- ),- );-- if (newFilter != null && mounted) {- setState(() => _filter = newFilter);- await _loadLogs();- }- }-- Future<void> _clearLogs() async {- final confirmed = await showDialog<bool>(- context: context,- builder: (context) => AlertDialog(- title: const Text('Clear Logs'),- content: const Text('Are you sure you want to clear all logs?'),- actions: [- TextButton(- onPressed: () => Navigator.pop(context, false),- child: const Text('Cancel'),- ),- TextButton(- onPressed: () => Navigator.pop(context, true),- child: const Text('Clear', style: TextStyle(color: Colors.red)),- ),- ],- ),- );-- if (confirmed == true) {- await _logStore.clearLogs();- await _loadLogs();- if (mounted) {- ScaffoldMessenger.of(- context,- ).showSnackBar(const SnackBar(content: Text('Logs cleared')));- }- }- }-- Future<void> _exportLogs() async {- try {- final logText = await _logStore.exportLogs(filter: _filter);-- await SharePlus.instance.share(- ShareParams(text: logText, subject: 'App Logs'),- );- } catch (e) {- if (mounted) {- ScaffoldMessenger.of(- context,- ).showSnackBar(SnackBar(content: Text('Failed to export logs: $e')));- }- }- }-- void _toggleSort() {- setState(() {- _filter = _filter.copyWith(sortNewestFirst: !_filter.sortNewestFirst);- });- _loadLogs();- }-- void _showAnalytics() async {- final result = await Navigator.push<String>(- context,- MaterialPageRoute(- builder: (context) => LoggerStatisticsPage(filter: _filter),- ),- );-- if (result != null && mounted) {- _searchController.text = result;- _onSearchChanged(result);- }- }-- void _showLogDetail(LogEntry log) {- Navigator.push(- context,- MaterialPageRoute(builder: (context) => LogDetailPage(log: log)),- );- }-- @override- void dispose() {- _searchController.dispose();- _logStreamSubscription?.cancel();- _refreshTimer?.cancel();- super.dispose();- }-- @override- Widget build(BuildContext context) {- final theme = Theme.of(context);-- return Scaffold(- appBar: AppBar(- title: const Text('Logs'),- elevation: 0,- actions: [- if (_filter.hasActiveFilters)- IconButton(- icon: Stack(- children: [- const Icon(Icons.filter_list),- Positioned(- right: 0,- top: 0,- child: Container(- width: 8,- height: 8,- decoration: const BoxDecoration(- color: Colors.red,- shape: BoxShape.circle,- ),- ),- ),- ],- ),- onPressed: _showFilterDialog,- tooltip: 'Filters',- )- else- IconButton(- icon: const Icon(Icons.filter_list),- onPressed: _showFilterDialog,- tooltip: 'Filters',- ),- IconButton(- icon: Icon(- _filter.sortNewestFirst- ? Icons.arrow_downward- : Icons.arrow_upward,- ),- onPressed: _toggleSort,- tooltip: _filter.sortNewestFirst- ? 'Sort oldest first'- : 'Sort newest first',- ),- PopupMenuButton<String>(- onSelected: (value) {- switch (value) {- case 'analytics':- _showAnalytics();- break;- case 'clear':- _clearLogs();- break;- case 'export':- _exportLogs();- break;- }- },- itemBuilder: (context) => [- const PopupMenuItem(- value: 'analytics',- child: ListTile(- leading: Icon(Icons.analytics),- title: Text('View Analytics'),- contentPadding: EdgeInsets.zero,- ),- ),- const PopupMenuItem(- value: 'export',- child: ListTile(- leading: Icon(Icons.share),- title: Text('Export Logs'),- contentPadding: EdgeInsets.zero,- ),- ),- const PopupMenuItem(- value: 'clear',- child: ListTile(- leading: Icon(Icons.clear_all, color: Colors.red),- title: Text(- 'Clear Logs',- style: TextStyle(color: Colors.red),- ),- contentPadding: EdgeInsets.zero,- ),- ),- ],- ),- ],- ),- body: Column(- children: [- Container(- color: theme.appBarTheme.backgroundColor,- padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 6.0),- child: TextField(- controller: _searchController,- style: const TextStyle(fontSize: 14),- decoration: InputDecoration(- hintText: 'Search logs...',- hintStyle: const TextStyle(fontSize: 14),- prefixIcon: const Icon(Icons.search, size: 20),- suffixIcon: _searchController.text.isNotEmpty- ? IconButton(- icon: const Icon(Icons.clear, size: 20),- onPressed: () {- _searchController.clear();- _onSearchChanged('');- },- )- : null,- border: OutlineInputBorder(- borderRadius: BorderRadius.circular(8),- ),- contentPadding: const EdgeInsets.symmetric(- horizontal: 12,- vertical: 8,- ),- isDense: true,- ),- onChanged: _onSearchChanged,- ),- ),-- if (_overallStartTime != null && _overallEndTime != null) ...[- Container(- color: theme.appBarTheme.backgroundColor,- padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),- child: Row(- children: [- Icon(- Icons.timeline,- size: 18,- color: theme.colorScheme.onSurface.withValues(alpha: 0.6),- ),- const SizedBox(width: 8),- Text(- 'Timeline Filter',- style: theme.textTheme.bodyMedium?.copyWith(- fontWeight: FontWeight.w500,- ),- ),- const Spacer(),- IconButton(- icon: Icon(- _timeFilterEnabled- ? Icons.timeline- : Icons.timeline_outlined,- color: _timeFilterEnabled- ? theme.colorScheme.primary- : theme.colorScheme.onSurface,- ),- onPressed: () {- setState(() {- _timeFilterEnabled = !_timeFilterEnabled;- if (_timeFilterEnabled) {- _timelineStartTime = _overallStartTime;- _timelineEndTime = _overallEndTime;- }- });- _updateTimeFilter();- },- tooltip: _timeFilterEnabled- ? 'Disable Timeline Filter'- : 'Enable Timeline Filter',- ),- ],- ),- ),- if (_timeFilterEnabled) ...[- TimelineWidget(- startTime: _overallStartTime!,- endTime: _overallEndTime!,- currentStart: _timelineStartTime ?? _overallStartTime!,- currentEnd: _timelineEndTime ?? _overallEndTime!,- onTimeRangeChanged: _onTimelineRangeChanged,- logTimestamps: _logTimestamps,- ),- ],- ],-- if (_filter.hasActiveFilters)- Container(- height: 40,- padding: const EdgeInsets.symmetric(horizontal: 8),- child: ListView(- scrollDirection: Axis.horizontal,- children: [- if (_filter.selectedLoggers.isNotEmpty)- ..._filter.selectedLoggers.map(- (logger) => Padding(- padding: const EdgeInsets.only(right: 4),- child: Chip(- label: Text(- logger,- style: const TextStyle(fontSize: 12),- ),- deleteIcon: const Icon(Icons.close, size: 16),- onDeleted: () {- setState(() {- final newLoggers = Set<String>.from(- _filter.selectedLoggers,- );- newLoggers.remove(logger);- _filter = _filter.copyWith(- selectedLoggers: newLoggers,- );- });- _loadLogs();- },- ),- ),- ),- if (_filter.selectedLevels.isNotEmpty)- ..._filter.selectedLevels.map(- (level) => Padding(- padding: const EdgeInsets.only(right: 4),- child: Chip(- label: Text(- level,- style: const TextStyle(fontSize: 12),- ),- backgroundColor: LogEntry(- message: '',- level: level,- timestamp: DateTime.now(),- loggerName: '',- ).levelColor.withValues(alpha: 0.2),- deleteIcon: const Icon(Icons.close, size: 16),- onDeleted: () {- setState(() {- final newLevels = Set<String>.from(- _filter.selectedLevels,- );- newLevels.remove(level);- _filter = _filter.copyWith(- selectedLevels: newLevels,- );- });- _loadLogs();- },- ),- ),- ),- if (_filter.selectedProcesses.isNotEmpty)- ..._filter.selectedProcesses.map(- (process) => Padding(- padding: const EdgeInsets.only(right: 4),- child: Chip(- label: Text(- LogEntry(- message: '',- level: 'INFO',- timestamp: DateTime.now(),- loggerName: '',- processPrefix: process,- ).processDisplayName,- style: const TextStyle(fontSize: 12),- ),- backgroundColor: Colors.purple.withValues(alpha: 0.2),- deleteIcon: const Icon(Icons.close, size: 16),- onDeleted: () {- setState(() {- final newProcesses = Set<String>.from(- _filter.selectedProcesses,- );- newProcesses.remove(process);- _filter = _filter.copyWith(- selectedProcesses: newProcesses,- );- });- _loadLogs();- },- ),- ),- ),- ],- ),- ),-- Expanded(- child: _isLoading- ? const Center(child: CircularProgressIndicator())- : _logs.isEmpty- ? Center(- child: Column(- mainAxisAlignment: MainAxisAlignment.center,- children: [- Icon(Icons.inbox, size: 64, color: theme.disabledColor),- const SizedBox(height: 16),- Text(- _filter.hasActiveFilters- ? 'No logs match the current filters'- : 'No logs available',- style: theme.textTheme.bodyLarge?.copyWith(- color: theme.disabledColor,- ),- ),- ],- ),- )- : RefreshIndicator(- onRefresh: _loadLogs,- child: ListView.separated(- itemCount: _logs.length + (_hasMoreLogs ? 1 : 0),- separatorBuilder: (context, index) =>- index >= _logs.length- ? const SizedBox.shrink()- : const Divider(height: 1),- itemBuilder: (context, index) {- if (index >= _logs.length) {- if (_isLoadingMore) {- return const Padding(- padding: EdgeInsets.all(16),- child: Center(child: CircularProgressIndicator()),- );- } else {- WidgetsBinding.instance.addPostFrameCallback((_) {- _loadMoreLogs();- });- return const SizedBox.shrink();- }- }-- final log = _logs[index];- return LogListTile(- log: log,- onTap: () => _showLogDetail(log),- );- },- ),- ),- ),- ],- ),- );- }-}diff --git a/mobile/packages/log_viewer/lib/src/ui/logger_statistics_page.dart b/mobile/packages/log_viewer/lib/src/ui/logger_statistics_page.dartdeleted file mode 100644index e0f6fefc4e..0000000000--- a/mobile/packages/log_viewer/lib/src/ui/logger_statistics_page.dart+++ /dev/null@@ -1,290 +0,0 @@-import 'package:flutter/material.dart';-import 'package:log_viewer/src/core/log_models.dart';-import 'package:log_viewer/src/core/log_store.dart';--class LoggerStatisticsPage extends StatefulWidget {- final LogFilter filter;-- const LoggerStatisticsPage({super.key, required this.filter});-- @override- State<LoggerStatisticsPage> createState() => _LoggerStatisticsPageState();-}--class _LoggerStatisticsPageState extends State<LoggerStatisticsPage> {- final LogStore _logStore = LogStore.instance;- List<LoggerStatistic> _statistics = [];- bool _isLoading = true;- String? _error;-- @override- void initState() {- super.initState();- _loadStatistics();- }-- Future<void> _loadStatistics() async {- setState(() {- _isLoading = true;- _error = null;- });-- try {- final stats = await _logStore.getLoggerStatistics(filter: widget.filter);- if (mounted) {- setState(() {- _statistics = stats;- _isLoading = false;- });- }- } catch (e) {- if (mounted) {- setState(() {- _error = e.toString();- _isLoading = false;- });- }- }- }-- Color _getLoggerColor(int index, double percentage) {- if (percentage > 50) return Colors.red.shade400;- if (percentage > 20) return Colors.orange.shade400;- if (percentage > 10) return Colors.blue.shade400;- return Colors.green.shade400;- }-- @override- Widget build(BuildContext context) {- final theme = Theme.of(context);-- return Scaffold(- appBar: AppBar(title: const Text('Logger Analytics'), elevation: 0),- body: _isLoading- ? const Center(child: CircularProgressIndicator())- : _error != null- ? Center(- child: Column(- mainAxisAlignment: MainAxisAlignment.center,- children: [- Icon(- Icons.error_outline,- size: 48,- color: theme.colorScheme.error,- ),- const SizedBox(height: 16),- Text(- 'Failed to load statistics',- style: theme.textTheme.headlineSmall,- ),- const SizedBox(height: 8),- Text(- _error!,- style: theme.textTheme.bodyMedium?.copyWith(- color: theme.colorScheme.error,- ),- textAlign: TextAlign.center,- ),- const SizedBox(height: 16),- ElevatedButton.icon(- onPressed: _loadStatistics,- icon: const Icon(Icons.refresh),- label: const Text('Retry'),- ),- ],- ),- )- : _statistics.isEmpty- ? Center(- child: Column(- mainAxisAlignment: MainAxisAlignment.center,- children: [- Icon(- Icons.analytics_outlined,- size: 64,- color: theme.disabledColor,- ),- const SizedBox(height: 16),- Text(- 'No log data available',- style: theme.textTheme.headlineSmall?.copyWith(- color: theme.disabledColor,- ),- ),- ],- ),- )- : Column(- children: [- Container(- padding: const EdgeInsets.all(16),- child: Row(- children: [- Expanded(- child: _SummaryCard(- title: 'Total Logs',- value: _statistics- .fold(0, (sum, stat) => sum + stat.count)- .toString(),- icon: Icons.notes,- color: Colors.blue,- ),- ),- const SizedBox(width: 16),- Expanded(- child: _SummaryCard(- title: 'Loggers',- value: _statistics.length.toString(),- icon: Icons.category,- color: Colors.green,- ),- ),- ],- ),- ),-- Expanded(- child: RefreshIndicator(- onRefresh: _loadStatistics,- child: ListView.builder(- padding: const EdgeInsets.symmetric(horizontal: 16),- itemCount: _statistics.length,- itemBuilder: (context, index) {- final stat = _statistics[index];- final color = _getLoggerColor(index, stat.percentage);-- return Card(- margin: const EdgeInsets.only(bottom: 8),- child: InkWell(- onTap: () {- Navigator.pop(- context,- 'logger:${stat.loggerName}',- );- },- borderRadius: BorderRadius.circular(12),- child: Padding(- padding: const EdgeInsets.all(16),- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- Row(- mainAxisAlignment:- MainAxisAlignment.spaceBetween,- children: [- Expanded(- child: Text(- stat.loggerName,- style: theme.textTheme.titleMedium- ?.copyWith(- fontWeight: FontWeight.w500,- ),- overflow: TextOverflow.ellipsis,- ),- ),- Text(- stat.formattedPercentage,- style: theme.textTheme.titleMedium- ?.copyWith(- color: color,- fontWeight: FontWeight.bold,- ),- ),- ],- ),- const SizedBox(height: 8),- Row(- children: [- Expanded(- child: LinearProgressIndicator(- value: stat.percentage / 100,- backgroundColor: color.withValues(- alpha: 0.2,- ),- valueColor: AlwaysStoppedAnimation(- color,- ),- minHeight: 6,- ),- ),- const SizedBox(width: 12),- Text(- '${stat.count} logs',- style: theme.textTheme.bodyMedium- ?.copyWith(- color: theme- .colorScheme- .onSurfaceVariant,- fontWeight: FontWeight.w500,- ),- ),- ],- ),- ],- ),- ),- ),- );- },- ),- ),- ),- ],- ),- );- }-}--class _SummaryCard extends StatelessWidget {- final String title;- final String value;- final IconData icon;- final Color color;-- const _SummaryCard({- required this.title,- required this.value,- required this.icon,- required this.color,- });-- @override- Widget build(BuildContext context) {- final theme = Theme.of(context);-- return Container(- padding: const EdgeInsets.all(16),- decoration: BoxDecoration(- color: color.withValues(alpha: 0.1),- borderRadius: BorderRadius.circular(12),- border: Border.all(color: color.withValues(alpha: 0.3), width: 1),- ),- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- Row(- children: [- Icon(icon, color: color, size: 20),- const SizedBox(width: 8),- Text(- title,- style: theme.textTheme.bodyMedium?.copyWith(- color: color,- fontWeight: FontWeight.w500,- ),- ),- ],- ),- const SizedBox(height: 8),- Text(- value,- style: theme.textTheme.headlineMedium?.copyWith(- color: color,- fontWeight: FontWeight.bold,- ),- ),- ],- ),- );- }-}diff --git a/mobile/packages/log_viewer/lib/src/ui/timeline_widget.dart b/mobile/packages/log_viewer/lib/src/ui/timeline_widget.dartdeleted file mode 100644index a113f9e142..0000000000--- a/mobile/packages/log_viewer/lib/src/ui/timeline_widget.dart+++ /dev/null@@ -1,304 +0,0 @@-import 'package:flutter/material.dart';--class TimelineWidget extends StatefulWidget {- final DateTime startTime;- final DateTime endTime;- final DateTime currentStart;- final DateTime currentEnd;- final Function(DateTime start, DateTime end) onTimeRangeChanged;- final List<DateTime> logTimestamps;-- const TimelineWidget({- super.key,- required this.startTime,- required this.endTime,- required this.currentStart,- required this.currentEnd,- required this.onTimeRangeChanged,- this.logTimestamps = const [],- });-- @override- State<TimelineWidget> createState() => _TimelineWidgetState();-}--class _TimelineWidgetState extends State<TimelineWidget> {- late double _leftPosition;- late double _rightPosition;- bool _isDraggingLeft = false;- bool _isDraggingRight = false;-- @override- void initState() {- super.initState();- _updatePositions();- }-- @override- void didUpdateWidget(TimelineWidget oldWidget) {- super.didUpdateWidget(oldWidget);- if (oldWidget.currentStart != widget.currentStart ||- oldWidget.currentEnd != widget.currentEnd ||- oldWidget.startTime != widget.startTime ||- oldWidget.endTime != widget.endTime) {- _updatePositions();- }- }-- void _updatePositions() {- final totalDuration = widget.endTime- .difference(widget.startTime)- .inMilliseconds;- final startOffset = widget.currentStart- .difference(widget.startTime)- .inMilliseconds;- final endOffset = widget.currentEnd- .difference(widget.startTime)- .inMilliseconds;-- _leftPosition = startOffset / totalDuration;- _rightPosition = endOffset / totalDuration;- }-- void _onPanUpdate(DragUpdateDetails details, bool isLeft) {- final RenderBox renderBox = context.findRenderObject() as RenderBox;- final double width = renderBox.size.width - 40; // Account for handle width-- final Offset globalPosition = details.globalPosition;- final Offset localPosition = renderBox.globalToLocal(globalPosition);- final double localX =- localPosition.dx - 20; // Account for left handle width- final double position = (localX / width).clamp(0.0, 1.0);-- setState(() {- if (isLeft) {- _leftPosition = position.clamp(0.0, _rightPosition - 0.01);- } else {- _rightPosition = position.clamp(_leftPosition + 0.01, 1.0);- }- });-- final totalDuration = widget.endTime- .difference(widget.startTime)- .inMilliseconds;- final newStart = widget.startTime.add(- Duration(milliseconds: (_leftPosition * totalDuration).round()),- );- final newEnd = widget.startTime.add(- Duration(milliseconds: (_rightPosition * totalDuration).round()),- );-- widget.onTimeRangeChanged(newStart, newEnd);- }-- @override- Widget build(BuildContext context) {- final theme = Theme.of(context);-- return Container(- height: 120,- padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),- child: Column(- crossAxisAlignment: CrossAxisAlignment.start,- children: [- Text(- 'Timeline Filter',- style: theme.textTheme.titleSmall?.copyWith(- fontWeight: FontWeight.w600,- ),- ),- const SizedBox(height: 8),- Expanded(- child: LayoutBuilder(- builder: (context, constraints) {- return Stack(- children: [- Positioned(- left: 20,- right: 20,- top: 20,- bottom: 20,- child: Container(- decoration: BoxDecoration(- color: theme.colorScheme.surfaceContainerHighest,- borderRadius: BorderRadius.circular(4),- border: Border.all(- color: theme.colorScheme.outline.withValues(- alpha: 0.3,- ),- width: 1,- ),- ),- child: _buildLogDensityIndicator(- constraints.maxWidth - 40,- ),- ),- ),-- Positioned(- left: 20 + (_leftPosition * (constraints.maxWidth - 40)),- right:- constraints.maxWidth -- 20 -- (_rightPosition * (constraints.maxWidth - 40)),- top: 20,- bottom: 20,- child: Container(- decoration: BoxDecoration(- color: theme.colorScheme.primary.withValues(- alpha: 0.4,- ),- borderRadius: BorderRadius.circular(4),- border: Border.all(- color: theme.colorScheme.primary.withValues(- alpha: 0.7,- ),- width: 1,- ),- ),- ),- ),-- Positioned(- left: (_leftPosition * (constraints.maxWidth - 40)),- top: 12,- child: GestureDetector(- onPanUpdate: (details) => _onPanUpdate(details, true),- onPanStart: (_) =>- setState(() => _isDraggingLeft = true),- onPanEnd: (_) =>- setState(() => _isDraggingLeft = false),- child: Container(- width: 20,- height: 32,- decoration: BoxDecoration(- color: _isDraggingLeft- ? theme.colorScheme.primary- : theme.colorScheme.primary.withValues(- alpha: 0.8,- ),- borderRadius: BorderRadius.circular(4),- boxShadow: [- BoxShadow(- color: Colors.black.withValues(alpha: 0.2),- blurRadius: 4,- offset: const Offset(0, 2),- ),- ],- ),- child: Icon(- Icons.drag_indicator,- size: 12,- color: theme.colorScheme.onPrimary,- ),- ),- ),- ),-- Positioned(- left: (_rightPosition * (constraints.maxWidth - 40)),- top: 12,- child: GestureDetector(- onPanUpdate: (details) => _onPanUpdate(details, false),- onPanStart: (_) =>- setState(() => _isDraggingRight = true),- onPanEnd: (_) =>- setState(() => _isDraggingRight = false),- child: Container(- width: 20,- height: 32,- decoration: BoxDecoration(- color: _isDraggingRight- ? theme.colorScheme.primary- : theme.colorScheme.primary.withValues(- alpha: 0.8,- ),- borderRadius: BorderRadius.circular(4),- boxShadow: [- BoxShadow(- color: Colors.black.withValues(alpha: 0.2),- blurRadius: 4,- offset: const Offset(0, 2),- ),- ],- ),- child: Icon(- Icons.drag_indicator,- size: 12,- color: theme.colorScheme.onPrimary,- ),- ),- ),- ),- ],- );- },- ),- ),-- Row(- mainAxisAlignment: MainAxisAlignment.spaceBetween,- children: [- Text(- _formatTime(widget.currentStart),- style: theme.textTheme.bodySmall,- ),- Text(- _formatTime(widget.currentEnd),- style: theme.textTheme.bodySmall,- ),- ],- ),- ],- ),- );- }-- Widget _buildLogDensityIndicator(double width) {- if (widget.logTimestamps.isEmpty) return const SizedBox.shrink();-- final theme = Theme.of(context);- final totalDuration = widget.endTime- .difference(widget.startTime)- .inMilliseconds;- const bucketCount = 50;- final bucketDuration = totalDuration / bucketCount;- final buckets = List<int>.filled(bucketCount, 0);-- for (final timestamp in widget.logTimestamps) {- final offset = timestamp.difference(widget.startTime).inMilliseconds;- if (offset >= 0 && offset <= totalDuration) {- final bucketIndex = (offset / bucketDuration).floor().clamp(- 0,- bucketCount - 1,- );- buckets[bucketIndex]++;- }- }-- final maxCount = buckets.reduce((a, b) => a > b ? a : b);- if (maxCount == 0) return const SizedBox.shrink();-- return Row(- children: buckets.map((count) {- final intensity = count / maxCount;- return Expanded(- child: Container(- height: double.infinity,- margin: const EdgeInsets.symmetric(horizontal: 0.5),- decoration: BoxDecoration(- color: theme.colorScheme.primary.withValues(- alpha: intensity * 0.6,- ),- borderRadius: BorderRadius.circular(1),- ),- ),- );- }).toList(),- );- }-- String _formatTime(DateTime time) {- return '${time.hour.toString().padLeft(2, '0')}:${time.minute.toString().padLeft(2, '0')}:${time.second.toString().padLeft(2, '0')}';- }-}diff --git a/mobile/packages/log_viewer/pubspec.yaml b/mobile/packages/log_viewer/pubspec.yamldeleted file mode 100644index 58eadf5e49..0000000000--- a/mobile/packages/log_viewer/pubspec.yaml+++ /dev/null@@ -1,24 +0,0 @@-name: log_viewer-description: In-app log viewer with filtering capabilities for Ente apps--resolution: workspace-environment:- sdk: ">=3.10.0 <4.0.0"- flutter: ">=3.0.0"--dependencies:- collection: 1.19.1- flutter:- sdk: flutter- logging: 1.3.0- path: 1.9.1- path_provider: 2.1.5- share_plus: 12.0.0- sqflite: 2.4.2--dev_dependencies:- flutter_lints: 6.0.0- flutter_test:- sdk: flutter--flutter:diff --git a/mobile/pubspec.yaml b/mobile/pubspec.yamlindex e1c82ea422..b1c134bbf9 100644--- a/mobile/pubspec.yaml+++ b/mobile/pubspec.yaml@@ -34,7 +34,6 @@ workspace:- packages/legacy- packages/local_auth_linux- packages/lock_screen- - packages/log_viewer- packages/logging- packages/mail- packages/native_video_editor