Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob][i] Allow internal users to enable db logging

Neeraj1dbdb270b418
diff --git a/mobile/apps/photos/lib/core/error-reporting/super_logging.dart b/mobile/apps/photos/lib/core/error-reporting/super_logging.dart
index bbbe76570a..13cc1cace5 100644
--- a/mobile/apps/photos/lib/core/error-reporting/super_logging.dart
+++ b/mobile/apps/photos/lib/core/error-reporting/super_logging.dart
@@ -221,7 +221,7 @@ class SuperLogging {
// Initialize log viewer integration in debug mode
// Initialize log viewer in debug mode only
- if (kDebugMode) {
+ if (_preferences.getBool("enable_db_logging") ?? kDebugMode) {
try {
await LogViewer.initialize();
// Register LogViewer with SuperLogging to receive logs with process prefix
diff --git a/mobile/apps/photos/lib/ui/settings/debug/debug_section_widget.dart b/mobile/apps/photos/lib/ui/settings/debug/debug_section_widget.dart
index 3d523ad2ca..adb34315d2 100644
--- a/mobile/apps/photos/lib/ui/settings/debug/debug_section_widget.dart
+++ b/mobile/apps/photos/lib/ui/settings/debug/debug_section_widget.dart
@@ -23,6 +23,7 @@ class DebugSectionWidget extends StatefulWidget {
}
class _DebugSectionWidgetState extends State<DebugSectionWidget> {
+
@override
Widget build(BuildContext context) {
return ExpandableMenuItemWidget(
@@ -35,6 +36,27 @@ class _DebugSectionWidgetState extends State<DebugSectionWidget> {
Widget _getSectionOptions(BuildContext context) {
return Column(
children: [
+ sectionOptionSpacing,
+ MenuItemWidget(
+ captionedTextWidget: const CaptionedTextWidget(
+ title: "Enable database logging",
+ ),
+ pressedColor: getEnteColorScheme(context).fillFaint,
+ trailingWidget: ToggleSwitchWidget(
+ value: () => localSettings.enableDatabaseLogging,
+ onChanged: () async {
+ final newValue = !localSettings.enableDatabaseLogging;
+ await localSettings.setEnableDatabaseLogging(newValue);
+ setState(() {});
+ showShortToast(
+ context,
+ newValue
+ ? "Database logging enabled. Restart app."
+ : "Database logging disabled. Restart app.",
+ );
+ },
+ ),
+ ),
sectionOptionSpacing,
MenuItemWidget(
captionedTextWidget: const CaptionedTextWidget(
diff --git a/mobile/apps/photos/lib/ui/settings_page.dart b/mobile/apps/photos/lib/ui/settings_page.dart
index 04061007ea..545b51fcd6 100644
--- a/mobile/apps/photos/lib/ui/settings_page.dart
+++ b/mobile/apps/photos/lib/ui/settings_page.dart
@@ -36,6 +36,7 @@ class SettingsPage extends StatelessWidget {
const SettingsPage({super.key, required this.emailNotifier});
+
@override
Widget build(BuildContext context) {
Bus.instance.fire(OpenedSettingsEvent());
@@ -82,7 +83,7 @@ class SettingsPage extends StatelessWidget {
),
),
),
- if (kDebugMode)
+ if (localSettings.enableDatabaseLogging)
GestureDetector(
onTap: () {
Navigator.of(context).push(
diff --git a/mobile/apps/photos/lib/utils/local_settings.dart b/mobile/apps/photos/lib/utils/local_settings.dart
index d6bd933d53..13b541fbeb 100644
--- a/mobile/apps/photos/lib/utils/local_settings.dart
+++ b/mobile/apps/photos/lib/utils/local_settings.dart
@@ -1,3 +1,5 @@
+import 'package:flutter/foundation.dart';
+
import 'package:photos/core/constants.dart';
import 'package:photos/ui/viewer/gallery/component/group/type.dart';
import "package:photos/utils/ram_check_util.dart";
@@ -42,6 +44,7 @@ class LocalSettings {
static const kCollectionViewType = "collection_view_type";
static const kCollectionSortDirection = "collection_sort_direction";
static const kShowLocalIDOverThumbnails = "show_local_id_over_thumbnails";
+ static const kEnableDatabaseLogging = "enable_db_logging";
// Thumbnail queue configuration keys
static const kSmallQueueMaxConcurrent = "small_queue_max_concurrent";
@@ -234,6 +237,13 @@ 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);
+ }
+
// Thumbnail queue configuration - Small queue
int get smallQueueMaxConcurrent =>
_prefs.getInt(kSmallQueueMaxConcurrent) ?? 15;
diff --git a/mobile/apps/photos/scripts/internal_changes.txt b/mobile/apps/photos/scripts/internal_changes.txt
index 11f35430d5..3efc74a4a9 100644
--- a/mobile/apps/photos/scripts/internal_changes.txt
+++ b/mobile/apps/photos/scripts/internal_changes.txt
@@ -1 +1,2 @@
-- Neeraj: Potential fix for ios in-app payment
\ No newline at end of file
+- Neeraj: Potential fix for ios in-app payment
+- Neeraj: (i) Debug option to enable logViewer
\ No newline at end of file